From 483838c1b2b3a85769928f092114e46ff8d24457 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Mon, 12 Sep 2022 19:06:37 -0500 Subject: [PATCH] Revert "Make `parse.richTextToString` more efficient (#848)" This reverts commit cb143117e51767f0648deb7755665f62319391a8. --- common/package.json | 1 - common/util/parse.ts | 21 +++------------------ 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/common/package.json b/common/package.json index c652cb69..52195398 100644 --- a/common/package.json +++ b/common/package.json @@ -13,7 +13,6 @@ "@tiptap/extension-link": "2.0.0-beta.43", "@tiptap/extension-mention": "2.0.0-beta.102", "@tiptap/starter-kit": "2.0.0-beta.191", - "prosemirror-model": "1.18.1", "lodash": "4.17.21" }, "devDependencies": { diff --git a/common/util/parse.ts b/common/util/parse.ts index 8efd88f6..0bbd5cd9 100644 --- a/common/util/parse.ts +++ b/common/util/parse.ts @@ -1,12 +1,5 @@ import { MAX_TAG_LENGTH } from '../contract' -import { - getText, - getTextSerializersFromSchema, - getSchema, - JSONContent, -} from '@tiptap/core' -import { Node as ProseMirrorNode } from 'prosemirror-model' - +import { generateText, JSONContent } from '@tiptap/core' // Tiptap starter extensions import { Blockquote } from '@tiptap/extension-blockquote' import { Bold } from '@tiptap/extension-bold' @@ -104,6 +97,7 @@ export const exhibitExts = [ Paragraph, Strike, Text, + Image, Link, Mention, @@ -111,15 +105,6 @@ export const exhibitExts = [ TiptapTweet, ] -const exhibitSchema = getSchema(exhibitExts) - export function richTextToString(text?: JSONContent) { - if (!text) { - return '' - } - const contentNode = ProseMirrorNode.fromJSON(exhibitSchema, text) - return getText(contentNode, { - blockSeparator: '\n\n', - textSerializers: getTextSerializersFromSchema(exhibitSchema), - }) + return !text ? '' : generateText(text, exhibitExts) }