Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cursor position #1363

Merged
merged 3 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions packages/docs/src/commands/mutations/core-editing.mutation.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export class DocRenderController extends RxDisposable {

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

return;
}

Expand Down
Original file line number Diff line number Diff line change
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
Loading