diff --git a/src/bundle/types.ts b/src/bundle/types.ts index 25a7ba2e..0c538870 100644 --- a/src/bundle/types.ts +++ b/src/bundle/types.ts @@ -29,7 +29,7 @@ export type ParseInsertedUrlAsImage = (text: string) => {imageUrl: string; title export type WysiwygPlaceholderOptions = { value?: string | (() => string); /** Default – empty-doc */ - behavior?: 'empty-doc' | 'empty-row'; + behavior?: 'empty-doc' | 'empty-doc-row' | 'empty-row'; }; export type MarkdownEditorMdOptions = { diff --git a/src/bundle/wysiwyg-preset.ts b/src/bundle/wysiwyg-preset.ts index 4dad8a43..e5bd8f79 100644 --- a/src/bundle/wysiwyg-preset.ts +++ b/src/bundle/wysiwyg-preset.ts @@ -66,9 +66,14 @@ export const BundlePreset: ExtensionAuto = (builder, opts) paragraphPlaceholder: (node: Node, parent?: Node | null) => { const {value, behavior} = opts.placeholderOptions || {}; - const isRowEmpty = !node.text && parent?.type.name === BaseNode.Doc; - const isDocEmpty = isRowEmpty && parent.childCount === 1; - const showPlaceholder = behavior === 'empty-row' ? isRowEmpty : isDocEmpty; + const emptyList = { + 'empty-row': !node.text, + 'empty-doc-row': !node.text && parent?.type.name === BaseNode.Doc, + 'empty-doc': + !node.text && parent?.type.name === BaseNode.Doc && parent.childCount === 1, + }; + + const showPlaceholder = emptyList[behavior || 'empty-doc']; if (!showPlaceholder) return null;