From ffa6304c1a19ed88297f3b11a86ef591d6aa5c86 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 | 4 ---- src/tests/markdown.spec.js | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/nodes/BulletList.ts b/src/nodes/BulletList.ts index 1a328dc2289..9d56294de5f 100644 --- a/src/nodes/BulletList.ts +++ b/src/nodes/BulletList.ts @@ -12,10 +12,6 @@ import { listInputRule, toggleListCommand } from '../commands/index.ts' * 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 dd3e7bc7046..2f5bb9e5011 100644 --- a/src/tests/markdown.spec.js +++ b/src/tests/markdown.spec.js @@ -44,6 +44,21 @@ 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)', ({ editor }) => { + const source = '- foo\n - bar\n- baz' + editor.commands.setContent(markdownit.render(source)) + // Walk the doc: no hardBreak node should exist in outer list item's paragraph + let hasHardBreak = false + editor.state.doc.descendants((node) => { + if (node.type.name === 'hardBreak') { + hasHardBreak = true + } + }) + expect(hasHardBreak).toBe(false) }) test('ol', ({ markdownThroughEditor }) => { expect(markdownThroughEditor('1. foo\n2. bar')).toBe('1. foo\n2. bar')