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
feat: set the initial cursor at the begining of document (#2447)
Ran Luoa812d2e60b12
diff --git a/packages/docs-ui/src/controllers/text-selection.controller.ts b/packages/docs-ui/src/controllers/text-selection.controller.tsindex e609e22ea4..27d1f95492 100644--- a/packages/docs-ui/src/controllers/text-selection.controller.ts+++ b/packages/docs-ui/src/controllers/text-selection.controller.ts@@ -238,6 +238,17 @@ export class TextSelectionController extends Disposable {unitId,subUnitId: '',});++ // The initial cursor is set at the beginning of the document,+ // and can be set to the previous cursor position in the future.+ if (!this._editorService.isEditor(unitId)) {+ this._textSelectionManagerService.replaceTextRanges([+ {+ startOffset: 0,+ endOffset: 0,+ },+ ], false);+ }}));}diff --git a/packages/docs/src/controllers/move-cursor.controller.ts b/packages/docs/src/controllers/move-cursor.controller.tsindex 6c73c4ee63..6fa5bdc6ec 100644--- a/packages/docs/src/controllers/move-cursor.controller.ts+++ b/packages/docs/src/controllers/move-cursor.controller.ts@@ -90,6 +90,7 @@ export class MoveCursorController extends Disposable {);}+ // eslint-disable-next-line max-lines-per-function, complexityprivate _handleShiftMoveSelection(direction: Direction) {const activeRange = this._textSelectionManagerService.getActiveRange();const allRanges = this._textSelectionManagerService.getSelections()!;