From c88126dec5368865dc74e460d6c8091bf5e993aa Mon Sep 17 00:00:00 2001 From: YuanShiJiLoong <2450829984@qq.com> Date: Tue, 24 Feb 2026 22:02:16 +0900 Subject: [PATCH] fix: split by double newlines for paragraphs, removing excessive blank lines --- app/components/Editor.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/components/Editor.js b/app/components/Editor.js index 50c45ed..1e9782b 100644 --- a/app/components/Editor.js +++ b/app/components/Editor.js @@ -160,11 +160,10 @@ const Editor = forwardRef(function Editor({ content, onUpdate, editable = true, useImperativeHandle(ref, () => ({ insertText: (text) => { if (!editor) return; - // 合并连续空行(3+ → 1 空行),然后按行拆分,每行包装为

- const cleaned = text.replace(/\n{3,}/g, '\n\n'); - const lines = cleaned.split('\n'); - const html = lines - .map(line => `

${line || '
'}

`) + // 按双换行分段(markdown 标准段落分隔),过滤空段 + const paragraphs = text.split(/\n\s*\n/).filter(p => p.trim()); + const html = paragraphs + .map(p => `

${p.replace(/\n/g, ' ').trim()}

`) .join(''); editor.chain().focus().insertContent(html).run(); },