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: selection before table (#4134)
Ran Luo744a203f977b
diff --git a/examples/src/docs/main.ts b/examples/src/docs/main.tsindex 0f36562fb2..07d69e555b 100644--- a/examples/src/docs/main.ts+++ b/examples/src/docs/main.ts@@ -25,7 +25,7 @@ import { UniverDocsThreadCommentUIPlugin } from '@univerjs/docs-thread-comment-uimport { UniverDocsUIPlugin } from '@univerjs/docs-ui';import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';import { UniverRenderEnginePlugin } from '@univerjs/engine-render';-import { DEFAULT_DOCUMENT_DATA_CN } from '@univerjs/mockdata';+import { DEFAULT_DOCUMENT_DATA_SIMPLE } from '@univerjs/mockdata';import { UniverUIPlugin } from '@univerjs/ui';import { enUS, faIR, ruRU, zhCN } from '../locales';@@ -69,7 +69,7 @@ univer.registerPlugin(UniverDocsHyperLinkUIPlugin);univer.registerPlugin(UniverDocsMentionUIPlugin);if (!IS_E2E) {- univer.createUnit(UniverInstanceType.UNIVER_DOC, DEFAULT_DOCUMENT_DATA_CN);+ univer.createUnit(UniverInstanceType.UNIVER_DOC, DEFAULT_DOCUMENT_DATA_SIMPLE);}// use for console testdiff --git a/packages/docs-ui/src/services/selection/selection-utils.ts b/packages/docs-ui/src/services/selection/selection-utils.tsindex 137a6d3619..c2bee5ff9f 100644--- a/packages/docs-ui/src/services/selection/selection-utils.ts+++ b/packages/docs-ui/src/services/selection/selection-utils.ts@@ -252,7 +252,13 @@ export function getRangeListFromSelection(}}- if ((end >= startIndex && end <= endIndex) || endInTable) {+ if ((end >= startIndex && end <= endIndex + 1) || endInTable) {+ // TO fix https://github.com/dream-num/univer-pro/issues/3437.+ if (end === endIndex + 1 && !endInTable) {+ end = endIndex;+ endInTable = true;+ }+const sp = skeleton.findNodePositionByCharIndex(start, true, segmentId, segmentPage);const ep = skeleton.findNodePositionByCharIndex(end, !endInTable, segmentId, segmentPage);const ap = direction === RANGE_DIRECTION.FORWARD ? sp : ep;