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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(docs-ui): selection in table when across two pages (#4006)
Ran Luofe6c0b259294
diff --git a/packages/docs-ui/src/services/selection/convert-rect-range.ts b/packages/docs-ui/src/services/selection/convert-rect-range.tsindex 7ff23726e9..4ac5fb889a 100644--- a/packages/docs-ui/src/services/selection/convert-rect-range.ts+++ b/packages/docs-ui/src/services/selection/convert-rect-range.ts@@ -38,8 +38,8 @@ export function isValidRectRange(anchorNodePosition: INodePosition, focusNodePosconst rowIndex = anchorPath.indexOf('rows') + 1;const cellIndex = anchorPath.indexOf('cells') + 1;- const anchorTableId = getTableIdAndSliceIndex(anchorPath[tableIdIndex] as string).tableId;- const focusTableId = getTableIdAndSliceIndex(focusPath[tableIdIndex] as string).tableId;+ const { tableId: anchorTableId, sliceIndex: anchorSliceIndex } = getTableIdAndSliceIndex(anchorPath[tableIdIndex] as string);+ const { tableId: focusTableId, sliceIndex: focusSliceIndex } = getTableIdAndSliceIndex(focusPath[tableIdIndex] as string);if (anchorTableId !== focusTableId) {return false;@@ -50,7 +50,7 @@ export function isValidRectRange(anchorNodePosition: INodePosition, focusNodePosconst anchorCellIndex = anchorPath[cellIndex];const focusCellIndex = focusPath[cellIndex];- if (anchorRowIndex === focusRowIndex && anchorCellIndex === focusCellIndex) {+ if (anchorRowIndex === focusRowIndex && anchorCellIndex === focusCellIndex && anchorSliceIndex === focusSliceIndex) {return false;}diff --git a/packages/docs-ui/src/services/selection/doc-selection-render.service.ts b/packages/docs-ui/src/services/selection/doc-selection-render.service.tsindex 2929dee681..1a5341ccc8 100644--- a/packages/docs-ui/src/services/selection/doc-selection-render.service.ts+++ b/packages/docs-ui/src/services/selection/doc-selection-render.service.ts@@ -945,15 +945,16 @@ export class DocSelectionRenderService extends RxDisposable implements IRenderMo}private _moving(moveOffsetX: number, moveOffsetY: number) {+ const { _currentSegmentId: segmentId, _currentSegmentPage: segmentPage } = this;const focusNode = this._findNodeByCoord(moveOffsetX, moveOffsetY, {strict: true,- segmentId: this._currentSegmentId,- segmentPage: this._currentSegmentPage,+ segmentId,+ segmentPage,});const focusNodePosition = this._getNodePosition(focusNode);- if (!focusNodePosition || focusNode == null) {+ if (focusNodePosition == null || focusNode == null) {return;}@@ -972,23 +973,23 @@ export class DocSelectionRenderService extends RxDisposable implements IRenderMothis._removeAllCacheRanges();- const { _anchorNodePosition, _focusNodePosition, _selectionStyle, _currentSegmentId, _currentSegmentPage } = this;+ const { _anchorNodePosition, _selectionStyle } = this;const { scene, mainComponent } = this._context;const skeleton = this._docSkeletonManagerService.getSkeleton();- if (_anchorNodePosition == null || _focusNodePosition == null || mainComponent == null) {+ if (_anchorNodePosition == null || mainComponent == null) {return;}const ranges = getRangeListFromSelection(_anchorNodePosition,- _focusNodePosition,+ focusNodePosition,scene,mainComponent as Documents,skeleton,_selectionStyle,- _currentSegmentId,- _currentSegmentPage+ segmentId,+ segmentPage);if (ranges == null) {diff --git a/packages/docs-ui/src/services/selection/selection-utils.ts b/packages/docs-ui/src/services/selection/selection-utils.tsindex 29f46e49f9..b4260f18a8 100644--- a/packages/docs-ui/src/services/selection/selection-utils.ts+++ b/packages/docs-ui/src/services/selection/selection-utils.ts@@ -217,6 +217,7 @@ export function getRangeListFromSelection(textRanges.push(new TextRange(scene, document, skeleton, ap, fp, style, segmentId, segmentPage));}+start = tableEnd + 1;}