From 5fb02688bf2ee66cb5ec64452c1304f57f7e190a Mon Sep 17 00:00:00 2001 From: Jonas Date: Sun, 12 Jul 2026 17:24:15 +0200 Subject: [PATCH] fix(BulletList): remove `preserveWhitespace: true` parseHTML override This fixes a regression with prosemirror-model 1.25.4 which changed DOM parsing so that newlines in whitespace-preserved text nodes are converted into a hard break instead of being collapsed to spaces. The `preserveWhitespace: true` setting never really had an effect: The newline in `* first\n second` already was converted to a space in a full Markdown - editor - Markdown round-trip before the regression. Also add several regression tests. Fixes: #8775 Signed-off-by: Jonas --- src/nodes/BulletList.ts | 6 ------ src/tests/markdown.spec.js | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/nodes/BulletList.ts b/src/nodes/BulletList.ts index 11118abb9d5..1ab7b07f4ce 100644 --- a/src/nodes/BulletList.ts +++ b/src/nodes/BulletList.ts @@ -12,12 +12,6 @@ import { listInputRule, toggleListCommand } from '../commands' * Only there we know the user is not trying to create a task list. */ const BulletList = TiptapBulletList.extend({ - parseHTML() { - return this.parent?.()?.map((rule) => - Object.assign(rule, { preserveWhitespace: true }), - ) - }, - addAttributes() { return { ...this.parent?.(), diff --git a/src/tests/markdown.spec.js b/src/tests/markdown.spec.js index 70ef5f72b78..30ffeb9bddc 100644 --- a/src/tests/markdown.spec.js +++ b/src/tests/markdown.spec.js @@ -52,6 +52,26 @@ describe('Markdown though editor', () => { expect(markdownThroughEditor('- foo\n- bar')).toBe('- foo\n- bar') expect(markdownThroughEditor('- foo\n\n- bar')).toBe('- foo\n- bar') expect(markdownThroughEditor('- foo\n\n\n- bar')).toBe('- foo\n- bar') + expect(markdownThroughEditor('- foo\n - bar')).toBe('- foo\n - bar') + expect(markdownThroughEditor('- foo\n - bar\n- baz')).toBe( + '- foo\n - bar\n- baz', + ) + expect(markdownThroughEditor('- foo \n bar \n baz')).toBe( + '- foo \n bar \n baz', + ) + }) + test('ul - no suprious linebreak in nested lists (#8775)', () => { + const source = '- foo\n - bar\n- baz' + const tiptap = createRichEditor() + tiptap.commands.setContent(markdownit.render(source)) + // Walk the doc: no hardBreak node should exist in outer list item's paragraph + let hasHardBreak = false + tiptap.state.doc.descendants((node) => { + if (node.type.name === 'hardBreak') { + hasHardBreak = true + } + }) + expect(hasHardBreak).toBe(false) }) test('ol', () => { expect(markdownThroughEditor('1. foo\n2. bar')).toBe('1. foo\n2. bar')