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): copy table only has one row and col (#3234)

Ran Luo08034d096a09
diff --git a/packages/engine-render/src/components/docs/text-selection/convert-rect-range.ts b/packages/engine-render/src/components/docs/text-selection/convert-rect-range.ts
index e82e2a28f6..ed6b972821 100644
--- a/packages/engine-render/src/components/docs/text-selection/convert-rect-range.ts
+++ b/packages/engine-render/src/components/docs/text-selection/convert-rect-range.ts
@@ -21,7 +21,7 @@ import type { IDocumentOffsetConfig } from '../document';
import type { DocumentSkeleton } from '../layout/doc-skeleton';
import { Liquid } from '../liquid';
import { getTableIdAndSliceIndex } from '../layout/block/table';
-import { getPageFromPath, pushToPoints } from './convert-text-range';
+import { compareNodePositionLogic, getPageFromPath, pushToPoints } from './convert-text-range';
// The anchor and focus need to be in the same table,
// and cannot be in the same cell, start node must be the first glyph in the cell,
@@ -74,6 +74,10 @@ export function isInSameTableCell(anchorNodePosition: INodePosition, focusNodePo
// Return true if a is before b.
export function compareNodePositionInTable(a: INodePosition, b: INodePosition): boolean {
+ if (isInSameTableCell(a, b)) {
+ return compareNodePositionLogic(a, b);
+ }
+
const { path: aPath } = a;
const { path: bPath } = b;