Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(docs-ui): cursor valished at paragraph beginning (#4147)

Ran Luoae027eb98f49
diff --git a/packages/docs-ui/src/services/selection/selection-utils.ts b/packages/docs-ui/src/services/selection/selection-utils.ts
index c2bee5ff9f..4216ef8c9a 100644
--- a/packages/docs-ui/src/services/selection/selection-utils.ts
+++ b/packages/docs-ui/src/services/selection/selection-utils.ts
@@ -197,6 +197,8 @@ export function getRangeListFromSelection(
for (const section of viewModel.getChildren()) {
for (const paragraph of section.children) {
const { startIndex, endIndex, children } = paragraph;
+ const paragraphIndex = section.children.indexOf(paragraph);
+ const nextParagraph = section.children[paragraphIndex + 1];
const table = children[0];
let endInTable = false;
@@ -254,7 +256,7 @@ export function getRangeListFromSelection(
if ((end >= startIndex && end <= endIndex + 1) || endInTable) {
// TO fix https://github.com/dream-num/univer-pro/issues/3437.
- if (end === endIndex + 1 && !endInTable) {
+ if (end === endIndex + 1 && !endInTable && nextParagraph && nextParagraph.children.length) {
end = endIndex;
endInTable = true;
}