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: can not select text when the last page ends with table (#2954)

Ran Luod5d3b39b2e58
diff --git a/packages/engine-render/src/components/docs/layout/tools.ts b/packages/engine-render/src/components/docs/layout/tools.ts
index 7d1ed9ae11..efcf347df4 100644
--- a/packages/engine-render/src/components/docs/layout/tools.ts
+++ b/packages/engine-render/src/components/docs/layout/tools.ts
@@ -447,6 +447,13 @@ export function updateBlockIndex(pages: IDocumentSkeletonPage[], start: number =
preSectionStartIndex = section.ed;
}
+ // Some tables may across pages, so we need to calculate the page's end index by the tables.
+ for (const table of skeTables.values()) {
+ const { ed } = table;
+
+ preSectionStartIndex = Math.max(preSectionStartIndex, ed);
+ }
+
page.st = pageStartIndex + 1;
page.ed = preSectionStartIndex >= page.st ? preSectionStartIndex : page.st;
page.height = contentHeight;