Skip to content

Commit

Permalink
fix(editor): preload the editor (#1662)
Browse files Browse the repository at this point in the history
* fix(editor): preload the editor

* fix(editor): zen editor lazy
  • Loading branch information
DR-Univer authored Mar 23, 2024
1 parent b47487a commit 09ceb16
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ enum InputPanelState {

const sheetEditorUnitIds = [DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY];

@OnLifecycle(LifecycleStages.Steady, PromptController)
@OnLifecycle(LifecycleStages.Rendered, PromptController)
export class PromptController extends Disposable {
private _formulaRefColors: string[] = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { IRenderManagerService } from '@univerjs/engine-render';
import { Inject } from '@wendellhu/redi';
import { takeUntil } from 'rxjs';

@OnLifecycle(LifecycleStages.Steady, EditingController)
@OnLifecycle(LifecycleStages.Rendered, EditingController)
export class EditingController extends RxDisposable {
constructor(
@IUniverInstanceService private readonly _currentUniverService: IUniverInstanceService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ enum CursorChange {
StartEditor,
CursorChange,
}

@OnLifecycle(LifecycleStages.Steady, EndEditController)
@OnLifecycle(LifecycleStages.Rendered, EndEditController)
export class EndEditController extends Disposable {
private _cursorChangeObservers: Nullable<Observer<IPointerEvent | IMouseEvent>>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ interface ICanvasOffset {
top: number;
}

@OnLifecycle(LifecycleStages.Steady, StartEditController)
@OnLifecycle(LifecycleStages.Rendered, StartEditController)
export class StartEditController extends Disposable {
private _editorVisiblePrevious = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type { Nullable } from '@univerjs/core';
import type { IDisposable } from '@wendellhu/redi';
import { createIdentifier } from '@wendellhu/redi';
import type { Observable } from 'rxjs';
import { BehaviorSubject } from 'rxjs';
import { BehaviorSubject, Subject } from 'rxjs';

export interface IFormulaEditorManagerService {
position$: Observable<Nullable<DOMRect>>;
Expand All @@ -42,10 +42,10 @@ export class FormulaEditorManagerService implements IDisposable {
private readonly _focus$ = new BehaviorSubject<boolean>(this._focus);
readonly focus$ = this._focus$.asObservable();

private readonly _fxBtnClick$ = new BehaviorSubject<boolean>(false);
private readonly _fxBtnClick$ = new Subject<boolean>();
readonly fxBtnClick$ = this._fxBtnClick$.asObservable();

private readonly _foldBtnStatus$ = new BehaviorSubject<boolean>(false);
private readonly _foldBtnStatus$ = new Subject<boolean>();
readonly foldBtnStatus$ = this._foldBtnStatus$.asObservable();

dispose(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class ZenEditorController extends RxDisposable {

this._commandExecutedListener();

this._createZenEditorInstance();
// this._createZenEditorInstance();
}

private _createZenEditorInstance() {
Expand Down Expand Up @@ -142,7 +142,14 @@ export class ZenEditorController extends RxDisposable {
});
}

private _zenEditorInitialState = false;

private _handleOpenZenEditor() {
if (!this._zenEditorInitialState) {
this._createZenEditorInstance();
this._zenEditorInitialState = true;
}

this._zenZoneService.open();

// Need to clear undo/redo service when open zen mode.
Expand Down

0 comments on commit 09ceb16

Please sign in to comment.