From 4653fe7427f4a9ec40700f6a86ff284d1d46088a Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Wed, 14 Aug 2024 21:11:43 +0800 Subject: [PATCH] fix: get range paragraph info boundary error #758 --- src/editor/core/range/RangeManager.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/editor/core/range/RangeManager.ts b/src/editor/core/range/RangeManager.ts index bba90f5..a377f24 100644 --- a/src/editor/core/range/RangeManager.ts +++ b/src/editor/core/range/RangeManager.ts @@ -171,8 +171,9 @@ export class RangeManager { } start-- } + const isCollapsed = startIndex === endIndex // 中间选择 - if (startIndex !== endIndex) { + if (!isCollapsed) { let middle = startIndex + 1 while (middle < endIndex) { const { pageNo, rowNo } = positionList[middle] @@ -189,6 +190,10 @@ export class RangeManager { } // 向下查找 let end = endIndex + // 闭合选区&&首字符为换行符时继续向下查找 + if (isCollapsed && elementList[startIndex].value === ZERO) { + end += 1 + } while (end < positionList.length) { const element = elementList[end] const nextElement = elementList[end + 1]