From 4bbadeb27c3e4b6d30cd5d34c9f2577bc006e4c0 Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Wed, 5 Oct 2022 14:08:51 -0600 Subject: [PATCH] Parse images and iframes from tiptap to string descriptions --- common/util/parse.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/util/parse.ts b/common/util/parse.ts index 0c50e07d..6cca448a 100644 --- a/common/util/parse.ts +++ b/common/util/parse.ts @@ -85,6 +85,15 @@ export function richTextToString(text?: JSONContent) { dfs(newText, (current) => { if (current.marks?.some((m) => m.type === TiptapSpoiler.name)) { current.text = '[spoiler]' + } else if (current.type === 'image') { + current.text = '[Image]' + // This is a hack, I've no idea how to change a tiptap extenstion's schema + current.type = 'text' + } else if (current.type === 'iframe') { + const src = current.attrs?.['src'] ? current.attrs['src'] : '' + current.text = '[Iframe]' + (src ? ` url:${src}` : '') + // This is a hack, I've no idea how to change a tiptap extenstion's schema + current.type = 'text' } }) return generateText(newText, exhibitExts)