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): arrow in table when table across two pages (#3692)

Ran Luo9e98122aa13b
diff --git a/packages/docs-ui/src/basics/table.ts b/packages/docs-ui/src/basics/table.ts
index 5517ed88d9..fb5d41c343 100644
--- a/packages/docs-ui/src/basics/table.ts
+++ b/packages/docs-ui/src/basics/table.ts
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-import { DocumentSkeletonPageType, getLastLine, lineIterator } from '@univerjs/engine-render';
import type { Nullable } from '@univerjs/core';
import type { IDocumentSkeletonCached, IDocumentSkeletonLine, IDocumentSkeletonPage, IDocumentSkeletonRow, IDocumentSkeletonTable } from '@univerjs/engine-render';
+import { DocumentSkeletonPageType, getLastLine, lineIterator } from '@univerjs/engine-render';
export function firstLineInTable(table: IDocumentSkeletonTable) {
const firstRow = table.rows[0];
@@ -84,18 +84,37 @@ export function findBellowCell(cell: IDocumentSkeletonPage) {
const row = cell.parent as IDocumentSkeletonRow;
const table = row?.parent as IDocumentSkeletonTable;
+ const tableId = table?.tableId;
+
if (row == null || table == null) {
return;
}
+ const col = row.cells.indexOf(cell);
+
const bellowRow = table.rows[table.rows.indexOf(row) + 1];
if (bellowRow == null) {
+ if (tableId.indexOf('#-#')) {
+ const [id, index] = tableId.split('#-#');
+ const pages = (table.parent?.parent as IDocumentSkeletonCached)?.pages;
+ const nextTableId = `${id}#-#${Number.parseInt(index) + 1}`;
+
+ if (pages) {
+ for (const page of pages) {
+ const { skeTables } = page;
+ if (skeTables.has(nextTableId)) {
+ const nextTable = skeTables.get(nextTableId);
+ if (nextTable?.rows.length) {
+ return nextTable.rows[0].cells[col];
+ }
+ }
+ }
+ }
+ }
return;
}
- const col = row.cells.indexOf(cell);
-
return bellowRow.cells[col];
}
@@ -109,12 +128,28 @@ export function findAboveCell(cell: IDocumentSkeletonPage) {
const aboveRow = table.rows[table.rows.indexOf(row) - 1];
+ const col = row.cells.indexOf(cell);
+
if (aboveRow == null) {
+ if (table.tableId.indexOf('#-#')) {
+ const [id, index] = table.tableId.split('#-#');
+ const pages = (table.parent?.parent as IDocumentSkeletonCached)?.pages;
+ const nextTableId = `${id}#-#${Number.parseInt(index) - 1}`;
+ if (pages) {
+ for (const page of pages) {
+ const { skeTables } = page;
+ if (skeTables.has(nextTableId)) {
+ const nextTable = skeTables.get(nextTableId);
+ if (nextTable?.rows.length) {
+ return nextTable.rows[nextTable.rows.length - 1].cells[col];
+ }
+ }
+ }
+ }
+ }
return;
}
- const col = row.cells.indexOf(cell);
-
return aboveRow.cells[col];
}
diff --git a/packages/docs-ui/src/controllers/config.schema.ts b/packages/docs-ui/src/controllers/config.schema.ts
index e446683162..0ccff699d5 100644
--- a/packages/docs-ui/src/controllers/config.schema.ts
+++ b/packages/docs-ui/src/controllers/config.schema.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import type { MenuConfig } from '@univerjs/ui';
import type { DependencyOverride } from '@univerjs/core';
+import type { MenuConfig } from '@univerjs/ui';
import type { ILayout } from '../basics';
import { DefaultDocContainerConfig, DefaultToolbarConfig } from '../basics';
diff --git a/packages/docs-ui/src/controllers/doc-header-footer.controller.ts b/packages/docs-ui/src/controllers/doc-header-footer.controller.ts
index 34fad14855..1650aa1b60 100644
--- a/packages/docs-ui/src/controllers/doc-header-footer.controller.ts
+++ b/packages/docs-ui/src/controllers/doc-header-footer.controller.ts
@@ -14,14 +14,14 @@
* limitations under the License.
*/
+import type { DocumentDataModel } from '@univerjs/core';
+import type { Documents, DocumentViewModel, IMouseEvent, IPageRenderConfig, IPathProps, IPointerEvent, IRenderContext, IRenderModule, RenderComponentType } from '@univerjs/engine-render';
+import type { Nullable } from 'vitest';
import { BooleanNumber, Disposable, DocumentFlavor, ICommandService, Inject, IUniverInstanceService, LocaleService, toDisposable, Tools } from '@univerjs/core';
+
import { DocSkeletonManagerService } from '@univerjs/docs';
import { DocumentEditArea, IRenderManagerService, PageLayoutType, Path, Rect, Vector2 } from '@univerjs/engine-render';
import { ComponentManager } from '@univerjs/ui';
-
-import type { DocumentDataModel } from '@univerjs/core';
-import type { Documents, DocumentViewModel, IMouseEvent, IPageRenderConfig, IPathProps, IPointerEvent, IRenderContext, IRenderModule, RenderComponentType } from '@univerjs/engine-render';
-import type { Nullable } from 'vitest';
import { neoGetDocObject } from '../basics/component-tools';
import { CoreHeaderFooterCommand } from '../commands/commands/doc-header-footer.command';
import { IEditorService } from '../services/editor/editor-manager.service';