Skip to content

Commit 4d98e8b

Browse files
committed
fix: 修复换行编辑导致文本重叠
1 parent ca3bc6f commit 4d98e8b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/components/slide-renderer/EditableTextOverlay.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ interface TextSegment {
1515
styleKey: string
1616
}
1717

18+
const BLOCK_LINE_TAGS = new Set(['DIV', 'P', 'LI'])
19+
1820
const defaultRunTemplate: TextRun = {
1921
text: '',
2022
fontFamily: 'Arial',
@@ -66,6 +68,12 @@ function extractTextRunsFromLineNode(
6668
if (node.nodeType !== Node.ELEMENT_NODE) return
6769
const element = node as HTMLElement
6870
if (element.tagName === 'BR') {
71+
pushSegment('\n', activeStyleKey)
72+
return
73+
}
74+
75+
// contentEditable 在换行编辑后可能出现嵌套块级节点,跳过它们可避免跨行文本重复采集
76+
if (element !== lineNode && BLOCK_LINE_TAGS.has(element.tagName)) {
6977
return
7078
}
7179

0 commit comments

Comments
 (0)