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

refactor(docs-ui): refactor to RenderUnit #2539

Open
wants to merge 22 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: fix formula editor cannot be activated
  • Loading branch information
wzhudev committed Jun 18, 2024
commit c2d944b849ef18b0fc94c6ecc9fd08b25942178e
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import type { DocumentDataModel, ICommandInfo } from '@univerjs/core';
import { Disposable, ICommandService } from '@univerjs/core';
import { Disposable, ICommandService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import type { Documents, IMouseEvent, IPointerEvent, IRenderContext, IRenderModule, RenderComponentType } from '@univerjs/engine-render';
import { CURSOR_TYPE, ITextSelectionRenderManager } from '@univerjs/engine-render';
import { Inject } from '@wendellhu/redi';
Expand All @@ -29,11 +29,12 @@ export class DocTextSelectionRenderController extends Disposable implements IRen

constructor(
private readonly _context: IRenderContext<DocumentDataModel>,
@Inject(DocSkeletonManagerService) private readonly _docSkeletonManagerService: DocSkeletonManagerService,
@ICommandService private readonly _commandService: ICommandService,
@IEditorService private readonly _editorService: IEditorService,
@IUniverInstanceService private readonly _instanceSrv: IUniverInstanceService,
@ITextSelectionRenderManager private readonly _textSelectionRenderManager: ITextSelectionRenderManager,
@Inject(TextSelectionManagerService) private readonly _textSelectionManagerService: TextSelectionManagerService,
@IEditorService private readonly _editorService: IEditorService
@Inject(DocSkeletonManagerService) private readonly _docSkeletonManagerService: DocSkeletonManagerService,
@Inject(TextSelectionManagerService) private readonly _textSelectionManagerService: TextSelectionManagerService
) {
super();

Expand Down Expand Up @@ -79,9 +80,13 @@ export class DocTextSelectionRenderController extends Disposable implements IRen
return;
}

this._textSelectionRenderManager.eventTrigger(evt);
// FIXME:@Jocs: editor status should not be coupled with the instance service.
const currentDocInstance = this._instanceSrv.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);
if (currentDocInstance?.getUnitId() !== unitId) {
this._instanceSrv.setCurrentUnitForType(unitId);
}

const { offsetX, offsetY } = evt;
this._textSelectionRenderManager.eventTrigger(evt);

if (this._editorService.getEditor(unitId)) {
/**
Expand All @@ -93,6 +98,8 @@ export class DocTextSelectionRenderController extends Disposable implements IRen
* Translate the above text into English.
*/
this._setEditorFocus(unitId);
const { offsetX, offsetY } = evt;

setTimeout(() => {
this._setEditorFocus(unitId);
this._textSelectionRenderManager.setCursorManually(offsetX, offsetY);
Expand All @@ -117,8 +124,7 @@ export class DocTextSelectionRenderController extends Disposable implements IRen
return;
}
this._textSelectionRenderManager.handleTripleClick(evt);
})
);
}));
}

private _isEditorReadOnly(unitId: string) {
Expand All @@ -142,7 +148,7 @@ export class DocTextSelectionRenderController extends Disposable implements IRen
// // this._editorService.setOperationSheetSubUnitId(workbook.getActiveSheet().getSheetId());
// }

// this._editorService.focusStyle(unitId);
this._editorService.focusStyle(unitId);
}

private _commandExecutedListener() {
Expand Down