Skip to content

Commit

Permalink
fix(editor): short key error (#1679)
Browse files Browse the repository at this point in the history
* fix(editor): short key error

* fix(editor): type error
  • Loading branch information
DR-Univer committed Mar 23, 2024
1 parent 09ceb16 commit 7afaff0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/core/src/services/context/context.ts
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
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
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)
);
}
4 changes: 3 additions & 1 deletion packages/sheets-ui/src/controllers/shortcuts/utils.ts
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
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

0 comments on commit 7afaff0

Please sign in to comment.