Extract utility method
This commit is contained in:
parent
d04304bdac
commit
d309a4f31b
|
@ -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,
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue
Block a user