Skip to content

Commit

Permalink
fix: cursor position (#1363)
Browse files Browse the repository at this point in the history
* fix: cursor position error

* fix: cursor position error

* fix: cursor position error
  • Loading branch information
Jocs committed Feb 18, 2024
1 parent 33bc465 commit 34508a0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
15 changes: 12 additions & 3 deletions packages/docs/src/commands/mutations/core-editing.mutation.ts
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
});
}
Expand Down
1 change: 1 addition & 0 deletions packages/docs/src/controllers/doc-render.controller.ts
Expand Up @@ -146,6 +146,7 @@ export class DocRenderController extends RxDisposable {

if (excludeUnitList.includes(unitId)) {
currentRender.mainComponent?.makeDirty();

return;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/services/doc-skeleton-manager.service.ts
Expand Up @@ -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 = '';
Expand Down

0 comments on commit 34508a0

Please sign in to comment.