From a718dc98b42a70113bff2a0b5b95cef0add8b3e2 Mon Sep 17 00:00:00 2001 From: YuanShiJiLoong <2450829984@qq.com> Date: Tue, 24 Feb 2026 22:28:49 +0900 Subject: [PATCH] fix: use br for line breaks within blocks, p only for blank-line-separated sections --- app/components/Editor.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/components/Editor.js b/app/components/Editor.js index 78387db..ddf4630 100644 --- a/app/components/Editor.js +++ b/app/components/Editor.js @@ -160,14 +160,17 @@ const Editor = forwardRef(function Editor({ content, onUpdate, editable = true, useImperativeHandle(ref, () => ({ insertText: (text) => { if (!editor) return; - // 每个非空行视为一个段落(中文小说标准格式),跳过空行 - const lines = text - .replace(/\r\n/g, '\n') - .replace(/\r/g, '\n') - .split('\n') - .map(line => line.trim()) - .filter(line => line.length > 0); - const html = lines.map(line => `
${line}
`).join(''); + // 规范化换行 + const normalized = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n').trim(); + // 按空行(双换行)分段,段内用${lines.join('
')}