diff --git a/common/util/parse.ts b/common/util/parse.ts index 0bbd5cd9..bc5dc4d2 100644 --- a/common/util/parse.ts +++ b/common/util/parse.ts @@ -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, diff --git a/functions/src/create-market.ts b/functions/src/create-market.ts index 300d91f2..098080ea 100644 --- a/functions/src/create-market.ts +++ b/functions/src/create-market.ts @@ -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(