Extract utility method

This commit is contained in:
Marshall Polaris 2022-09-22 21:44:48 -07:00
parent d04304bdac
commit d309a4f31b
2 changed files with 14 additions and 9 deletions

View File

@ -79,6 +79,18 @@ export function parseMentions(data: JSONContent): string[] {
return uniq(mentions)
}
export const plainTextToProseMirror = (text: string): JSONContent => {
return {
type: 'doc',
content: [
{
type: 'paragraph',
content: [{ type: 'text', text }],
},
],
}
}
// can't just do [StarterKit, Image...] because it doesn't work with cjs imports
export const exhibitExts = [
Blockquote,

View File

@ -29,6 +29,7 @@ import {
} from '../../common/antes'
import { Answer, getNoneAnswer } from '../../common/answer'
import { getNewContract } from '../../common/new-contract'
import { plainTextToProseMirror } from '../../common/util/parse'
import { NUMERIC_BUCKET_COUNT } from '../../common/numeric-constants'
import { User } from '../../common/user'
import { Group, GroupLink, MAX_ID_LENGTH } from '../../common/group'
@ -187,15 +188,7 @@ export const createmarket = newEndpoint({}, async (req, auth) => {
// convert string descriptions into JSONContent
const newDescription =
typeof description === 'string'
? {
type: 'doc',
content: [
{
type: 'paragraph',
content: [{ type: 'text', text: description }],
},
],
}
? plainTextToProseMirror(description)
: description ?? {}
const contract = getNewContract(