Revert "Make parse.richTextToString
more efficient (#848)"
This reverts commit cb143117e5
.
This commit is contained in:
parent
cb143117e5
commit
483838c1b2
|
@ -13,7 +13,6 @@
|
||||||
"@tiptap/extension-link": "2.0.0-beta.43",
|
"@tiptap/extension-link": "2.0.0-beta.43",
|
||||||
"@tiptap/extension-mention": "2.0.0-beta.102",
|
"@tiptap/extension-mention": "2.0.0-beta.102",
|
||||||
"@tiptap/starter-kit": "2.0.0-beta.191",
|
"@tiptap/starter-kit": "2.0.0-beta.191",
|
||||||
"prosemirror-model": "1.18.1",
|
|
||||||
"lodash": "4.17.21"
|
"lodash": "4.17.21"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
import { MAX_TAG_LENGTH } from '../contract'
|
import { MAX_TAG_LENGTH } from '../contract'
|
||||||
import {
|
import { generateText, JSONContent } from '@tiptap/core'
|
||||||
getText,
|
|
||||||
getTextSerializersFromSchema,
|
|
||||||
getSchema,
|
|
||||||
JSONContent,
|
|
||||||
} from '@tiptap/core'
|
|
||||||
import { Node as ProseMirrorNode } from 'prosemirror-model'
|
|
||||||
|
|
||||||
// Tiptap starter extensions
|
// Tiptap starter extensions
|
||||||
import { Blockquote } from '@tiptap/extension-blockquote'
|
import { Blockquote } from '@tiptap/extension-blockquote'
|
||||||
import { Bold } from '@tiptap/extension-bold'
|
import { Bold } from '@tiptap/extension-bold'
|
||||||
|
@ -104,6 +97,7 @@ export const exhibitExts = [
|
||||||
Paragraph,
|
Paragraph,
|
||||||
Strike,
|
Strike,
|
||||||
Text,
|
Text,
|
||||||
|
|
||||||
Image,
|
Image,
|
||||||
Link,
|
Link,
|
||||||
Mention,
|
Mention,
|
||||||
|
@ -111,15 +105,6 @@ export const exhibitExts = [
|
||||||
TiptapTweet,
|
TiptapTweet,
|
||||||
]
|
]
|
||||||
|
|
||||||
const exhibitSchema = getSchema(exhibitExts)
|
|
||||||
|
|
||||||
export function richTextToString(text?: JSONContent) {
|
export function richTextToString(text?: JSONContent) {
|
||||||
if (!text) {
|
return !text ? '' : generateText(text, exhibitExts)
|
||||||
return ''
|
|
||||||
}
|
|
||||||
const contentNode = ProseMirrorNode.fromJSON(exhibitSchema, text)
|
|
||||||
return getText(contentNode, {
|
|
||||||
blockSeparator: '\n\n',
|
|
||||||
textSerializers: getTextSerializersFromSchema(exhibitSchema),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user