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: cursor position (#1363)
Ran Luo34508a0ecfcf
diff --git a/packages/docs/src/commands/mutations/core-editing.mutation.ts b/packages/docs/src/commands/mutations/core-editing.mutation.tsindex 7ab83bdadb..4fb68aa3f4 100644--- a/packages/docs/src/commands/mutations/core-editing.mutation.ts+++ b/packages/docs/src/commands/mutations/core-editing.mutation.ts@@ -46,7 +46,16 @@ export const RichTextEditingMutation: IMutation<IRichTextEditingMutationParams,type: CommandType.MUTATION,handler: (accessor, params) => {- const { unitId, actions, textRanges, prevTextRanges, trigger, noNeedSetTextRange, noHistory, isCompositionEnd } = params;+ const {+ unitId,+ actions,+ textRanges,+ prevTextRanges,+ trigger,+ noHistory,+ isCompositionEnd,+ noNeedSetTextRange,+ } = params;const univerInstanceService = accessor.get(IUniverInstanceService);const documentDataModel = univerInstanceService.getUniverDocInstance(unitId);@@ -81,9 +90,9 @@ export const RichTextEditingMutation: IMutation<IRichTextEditingMutationParams,segmentViewModel.reset(segmentDocumentDataModel);// Step 3: Update cursor & selection.+ // make sure update cursor & selection after doc skeleton is calculated.if (!noNeedSetTextRange && textRanges) {- // Update selection in the next frame.- requestAnimationFrame(() => {+ queueMicrotask(() => {textSelectionManagerService.replaceTextRanges(textRanges);});}diff --git a/packages/docs/src/controllers/doc-render.controller.ts b/packages/docs/src/controllers/doc-render.controller.tsindex ac530ac66b..17634d2bb7 100644--- a/packages/docs/src/controllers/doc-render.controller.ts+++ b/packages/docs/src/controllers/doc-render.controller.ts@@ -146,6 +146,7 @@ export class DocRenderController extends RxDisposable {if (excludeUnitList.includes(unitId)) {currentRender.mainComponent?.makeDirty();+return;}diff --git a/packages/docs/src/services/doc-skeleton-manager.service.ts b/packages/docs/src/services/doc-skeleton-manager.service.tsindex cbd822d8c0..2273753b32 100644--- a/packages/docs/src/services/doc-skeleton-manager.service.ts+++ b/packages/docs/src/services/doc-skeleton-manager.service.ts@@ -31,7 +31,7 @@ export interface IDocSkeletonManagerParam {}/**- * This service is for worksheet build sheet skeleton.+ * This service is for document build and manage doc skeletons.*/export class DocSkeletonManagerService extends RxDisposable {private _currentSkeletonUnitId: string = '';