From cabae7a91eba3094dc120d003ae6bdd443e1cdc1 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 9 Jul 2025 19:56:29 -0400 Subject: [PATCH] fix: Empty placeholder shows up when no text but image in paragraph (#9593) --- app/editor/extensions/BlockMenu.tsx | 1 + shared/editor/nodes/Doc.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/editor/extensions/BlockMenu.tsx b/app/editor/extensions/BlockMenu.tsx index ead19219f2..57dd372ed4 100644 --- a/app/editor/extensions/BlockMenu.tsx +++ b/app/editor/extensions/BlockMenu.tsx @@ -80,6 +80,7 @@ export default class BlockMenuExtension extends Suggestion { $start.depth === 1 && state.selection.$from.pos === $start.pos + node.content.size && !!textContent && + node.childCount === 0 && node.textContent === "", text: this.options.dictionary.newLineEmpty, }, diff --git a/shared/editor/nodes/Doc.ts b/shared/editor/nodes/Doc.ts index b8c06552fd..cf8b669b29 100644 --- a/shared/editor/nodes/Doc.ts +++ b/shared/editor/nodes/Doc.ts @@ -18,11 +18,12 @@ export default class Doc extends Node { return [ new PlaceholderPlugin([ { - condition: ({ $start, parent, state, textContent }) => + condition: ({ $start, parent, node, state, textContent }) => textContent === "" && !isNull(parent) && parent.type === state.doc.type && parent.childCount === 1 && + node.childCount === 0 && $start.index($start.depth - 1) === 0, text: this.options.placeholder, },