Skip to content

Commit

Permalink
fix(formula-editor): shortcut key priority
Browse files Browse the repository at this point in the history
  • Loading branch information
Gggpound committed Oct 26, 2024
1 parent f3d3e49 commit 1fc0456
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ import { CommandType, DisposableCollection, ICommandService, useDependency } fro
import { DeviceInputEventType } from '@univerjs/engine-render';
import { IShortcutService, KeyCode } from '@univerjs/ui';
import { useEffect } from 'react';
import { PROMPT_SELECTION_KEYCODE_ARROW_LIST } from '../../../controllers/shortcuts/prompt.shortcut';

export const useLeftAndRightArrow = (editor?: Editor) => {
export const useLeftAndRightArrow = (isNeed: boolean, editor?: Editor) => {
const commandService = useDependency(ICommandService);
const shortcutService = useDependency(IShortcutService);

useEffect(() => {
if (!editor) {
if (!editor || !isNeed) {
return;
}
const editorId = editor.getEditorId();
Expand Down Expand Up @@ -64,7 +63,7 @@ export const useLeftAndRightArrow = (editor?: Editor) => {
},
}));

PROMPT_SELECTION_KEYCODE_ARROW_LIST.map((keyCode) => {
[KeyCode.ARROW_LEFT, KeyCode.ARROW_RIGHT].map((keyCode) => {
return {
id: operationId,
binding: keyCode,
Expand All @@ -82,5 +81,5 @@ export const useLeftAndRightArrow = (editor?: Editor) => {
return () => {
d.dispose();
};
}, [editor]);
}, [editor, isNeed]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export function FormulaEditor(props: IFormulaEditorProps) {
useSheetHighlight(isFocus, unitId, subUnitId, refSelections);
useResize(editor);
useRefactorEffect(isFocus, unitId);
useLeftAndRightArrow(editor);
useLeftAndRightArrow(isFocus, editor);
useSheetSelectionChange(isFocus, unitId, subUnitId, sequenceNodes, isSupportAcrossSheet, editor, handleSelectionChange);
useBlur(editorId, isFocusSet);
const { searchList, searchText, handlerFormulaReplace, reset: resetFormulaSearch } = useFormulaSearch(sequenceNodes, editor);
Expand Down

0 comments on commit 1fc0456

Please sign in to comment.