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(editor): short key error #1679

Merged
merged 2 commits into from
Mar 23, 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
3 changes: 2 additions & 1 deletion packages/core/src/services/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ export const FOCUSING_FORMULA_EDITOR = 'FOCUSING_FORMULA_EDITOR';

export const FOCUSING_UNIVER_EDITOR = 'FOCUSING_UNIVER_EDITOR';

export const FOCUSING_UNIVER_EDITOR_SINGLE_MODE = 'FOCUSING_UNIVER_EDITOR_SINGLE_MODE';
export const FOCUSING_EDITOR_STANDALONE = 'FOCUSING_EDITOR_INPUT_FORMULA';
export const FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE = 'FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE';
4 changes: 2 additions & 2 deletions packages/docs-ui/src/shortcuts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*/

import type { IContextService } from '@univerjs/core';
import { FOCUSING_DOC, FOCUSING_UNIVER_EDITOR, FOCUSING_UNIVER_EDITOR_SINGLE_MODE } from '@univerjs/core';
import { FOCUSING_DOC, FOCUSING_UNIVER_EDITOR, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE } from '@univerjs/core';

export function whenDocAndEditorFocused(contextService: IContextService): boolean {
return contextService.getContextValue(FOCUSING_DOC) && contextService.getContextValue(FOCUSING_UNIVER_EDITOR);
}

export function whenDocAndEditorFocusedWithBreakLine(contextService: IContextService): boolean {
return contextService.getContextValue(FOCUSING_DOC) && contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && !contextService.getContextValue(FOCUSING_UNIVER_EDITOR_SINGLE_MODE);
return contextService.getContextValue(FOCUSING_DOC) && contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && !contextService.getContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE);
}
4 changes: 2 additions & 2 deletions packages/sheets-formula/src/controllers/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*/

import type { IContextService } from '@univerjs/core';
import { FOCUSING_DOC, FOCUSING_UNIVER_EDITOR, FOCUSING_UNIVER_EDITOR_SINGLE_MODE } from '@univerjs/core';
import { FOCUSING_DOC, FOCUSING_UNIVER_EDITOR, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE } from '@univerjs/core';

export function whenEditorStandalone(contextService: IContextService) {
return (
contextService.getContextValue(FOCUSING_DOC) &&
contextService.getContextValue(FOCUSING_UNIVER_EDITOR) &&
contextService.getContextValue(FOCUSING_UNIVER_EDITOR_SINGLE_MODE)
contextService.getContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE)
);
}
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
4 changes: 3 additions & 1 deletion packages/sheets-ui/src/controllers/shortcuts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type { IContextService } from '@univerjs/core';
import {
EDITOR_ACTIVATED,
FOCUSING_EDITOR_INPUT_FORMULA,
FOCUSING_EDITOR_STANDALONE,
FOCUSING_FORMULA_EDITOR,
FOCUSING_SHEET,
FOCUSING_UNIVER_EDITOR,
Expand Down Expand Up @@ -93,6 +94,7 @@ export function whenEditorDidNotInputFormulaActivated(contextService: IContextSe
contextService.getContextValue(FOCUSING_SHEET) &&
contextService.getContextValue(FOCUSING_UNIVER_EDITOR) &&
contextService.getContextValue(EDITOR_ACTIVATED) &&
!contextService.getContextValue(FOCUSING_EDITOR_INPUT_FORMULA)
!contextService.getContextValue(FOCUSING_EDITOR_INPUT_FORMULA) &&
!contextService.getContextValue(FOCUSING_EDITOR_STANDALONE)
);
}
10 changes: 8 additions & 2 deletions packages/ui/src/services/editor/editor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import type { DocumentDataModel, IDocumentBody, IDocumentData, IDocumentStyle, IPosition, Nullable } from '@univerjs/core';
import { DEFAULT_EMPTY_DOCUMENT_VALUE, Disposable, FOCUSING_EDITOR_INPUT_FORMULA, FOCUSING_UNIVER_EDITOR_SINGLE_MODE, HorizontalAlign, IContextService, IUniverInstanceService, toDisposable, VerticalAlign } from '@univerjs/core';
import { DEFAULT_EMPTY_DOCUMENT_VALUE, Disposable, EDITOR_ACTIVATED, FOCUSING_EDITOR_INPUT_FORMULA, FOCUSING_EDITOR_STANDALONE, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, HorizontalAlign, IContextService, IUniverInstanceService, toDisposable, VerticalAlign } from '@univerjs/core';
import type { IDisposable } from '@wendellhu/redi';
import { createIdentifier, Inject } from '@wendellhu/redi';
import type { Observable } from 'rxjs';
Expand Down Expand Up @@ -383,6 +383,9 @@ export class EditorService extends Disposable implements IEditorService, IDispos
return;
}

this._contextService.setContextValue(EDITOR_ACTIVATED, false);
this._contextService.setContextValue(FOCUSING_EDITOR_STANDALONE, false);

this.changeSpreadsheetFocusState(false);

this.blur();
Expand All @@ -404,7 +407,10 @@ export class EditorService extends Disposable implements IEditorService, IDispos

editor.setFocus(true);

this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR_SINGLE_MODE, editor.isSingle());
this._contextService.setContextValue(EDITOR_ACTIVATED, true);
this._contextService.setContextValue(FOCUSING_EDITOR_STANDALONE, true);

this._contextService.setContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, editor.isSingle());

if (!this._spreadsheetFocusState) {
this.singleSelection(editor.isSingleChoice());
Expand Down
Loading