From 14981ef077def28f82ba93002ccbbf7d089c2dbc Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Fri, 12 Sep 2025 02:15:06 +0200 Subject: [PATCH] Fix --- web/components/editor/utils.ts | 4 ++++ web/components/widgets/editor.tsx | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/web/components/editor/utils.ts b/web/components/editor/utils.ts index 809b0245..426e57fd 100644 --- a/web/components/editor/utils.ts +++ b/web/components/editor/utils.ts @@ -65,6 +65,10 @@ export function getField(extension: AnyExtension, field: string) { * We can't use prosemirror node views (this is what tiptap `generateHTML` does) because it uses document which is on the client. */ export const generateReact = (doc: JSONContent, extensions: Extensions) => { + if (!doc) { + return null + } + const extensionsIncludingStarterKit = extensions.flatMap( (e) => getField(e, 'addExtensions')?.() ?? e ) diff --git a/web/components/widgets/editor.tsx b/web/components/widgets/editor.tsx index 0929704f..cbe27b2e 100644 --- a/web/components/widgets/editor.tsx +++ b/web/components/widgets/editor.tsx @@ -215,8 +215,6 @@ function RichContent(props: { }) { const { className, content, size = 'md' } = props - if (!content) return null - const jsxContent = useMemo(() => { try { return generateReact(content, [ @@ -236,6 +234,8 @@ function RichContent(props: { } }, [content, size]) + if (!content) return null + return (