From f3f802092949fcef3c23b07c5546202c8692c4ee Mon Sep 17 00:00:00 2001 From: 01zulfi <85733202+01zulfi@users.noreply.github.com> Date: Mon, 27 Oct 2025 14:03:34 +0500 Subject: [PATCH] editor: disable collapsible headings inside tables Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com> --- packages/editor/src/extensions/heading/heading.ts | 13 ++++++++----- packages/editor/styles/styles.css | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/packages/editor/src/extensions/heading/heading.ts b/packages/editor/src/extensions/heading/heading.ts index 465e8d471..1873f4be3 100644 --- a/packages/editor/src/extensions/heading/heading.ts +++ b/packages/editor/src/extensions/heading/heading.ts @@ -184,11 +184,14 @@ export const Heading = TiptapHeading.extend({ if (typeof pos !== "number") return; const resolvedPos = editor.state.doc.resolve(pos); - const calloutAncestor = findParentNodeClosestToPos( - resolvedPos, - (node) => node.type.name === "callout" - ); - if (calloutAncestor) return; + const forbiddenParents = ["callout", "table"]; + if ( + findParentNodeClosestToPos(resolvedPos, (node) => + forbiddenParents.includes(node.type.name) + ) + ) { + return; + } if ( isClickWithinBounds( diff --git a/packages/editor/styles/styles.css b/packages/editor/styles/styles.css index 214ce04da..301c52c0e 100644 --- a/packages/editor/styles/styles.css +++ b/packages/editor/styles/styles.css @@ -1010,6 +1010,21 @@ del.diffdel { display: none; } +.ProseMirror table h1::before, +.ProseMirror table h2::before, +.ProseMirror table h3::before, +.ProseMirror table h4::before, +.ProseMirror table h5::before, +.ProseMirror table h6::before, +.ProseMirror table h1::after, +.ProseMirror table h2::after, +.ProseMirror table h3::after, +.ProseMirror table h4::after, +.ProseMirror table h5::after, +.ProseMirror table h6::after { + display: none; +} + [data-hidden="true"] { display: none !important; }