snapshot of https://github.com/dream-num/univer.git (dev, 2026-09-16; blobs > 131072B omitted)
Some checks failed
📦 Build / build (push) Has been cancelled
🧪 CI Test / test shard (1/4) (push) Has been cancelled
🧪 CI Test / test shard (2/4) (push) Has been cancelled
🧪 CI Test / test shard (3/4) (push) Has been cancelled
🧪 CI Test / test shard (4/4) (push) Has been cancelled
🧪 CI Test / test (push) Has been cancelled
🧪 CI Test / eslint (push) Has been cancelled
🧪 CI Test / typecheck (push) Has been cancelled
🔫 Sync to Pro / dispatch-sync (push) Has been cancelled
🔮 Sync Mirror / sync (push) Has been cancelled
Some checks failed
📦 Build / build (push) Has been cancelled
🧪 CI Test / test shard (1/4) (push) Has been cancelled
🧪 CI Test / test shard (2/4) (push) Has been cancelled
🧪 CI Test / test shard (3/4) (push) Has been cancelled
🧪 CI Test / test shard (4/4) (push) Has been cancelled
🧪 CI Test / test (push) Has been cancelled
🧪 CI Test / eslint (push) Has been cancelled
🧪 CI Test / typecheck (push) Has been cancelled
🔫 Sync to Pro / dispatch-sync (push) Has been cancelled
🔮 Sync Mirror / sync (push) Has been cancelled
This commit is contained in:
146
packages/slides-ui/src/controllers/shortcuts/editor.shortcuts.ts
Normal file
146
packages/slides-ui/src/controllers/shortcuts/editor.shortcuts.ts
Normal file
@@ -0,0 +1,146 @@
|
||||
/**
|
||||
* Copyright 2023-present DreamNum Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { IShortcutItem } from '@univerjs/ui';
|
||||
import { DeleteLeftCommand } from '@univerjs/docs-ui';
|
||||
import { DeviceInputEventType } from '@univerjs/engine-render';
|
||||
import { KeyCode, MetaKeys } from '@univerjs/ui';
|
||||
import { SetTextEditArrowOperation } from '../../commands/operations/text-edit.operation';
|
||||
import {
|
||||
whenEditorActivated,
|
||||
whenFormulaEditorFocused,
|
||||
} from './utils';
|
||||
|
||||
export const ARROW_SELECTION_KEYCODE_LIST = [
|
||||
KeyCode.ARROW_DOWN,
|
||||
KeyCode.ARROW_UP,
|
||||
KeyCode.ARROW_LEFT,
|
||||
KeyCode.ARROW_RIGHT,
|
||||
];
|
||||
|
||||
export const MOVE_SELECTION_KEYCODE_LIST = [KeyCode.ENTER, KeyCode.TAB, ...ARROW_SELECTION_KEYCODE_LIST];
|
||||
|
||||
export function generateArrowSelectionShortCutItem() {
|
||||
const shortcutList: IShortcutItem[] = [];
|
||||
|
||||
for (const keycode of ARROW_SELECTION_KEYCODE_LIST) {
|
||||
shortcutList.push({
|
||||
id: SetTextEditArrowOperation.id,
|
||||
binding: keycode,
|
||||
preconditions: (contextService) => whenEditorActivated(contextService),
|
||||
staticParameters: {
|
||||
visible: false,
|
||||
eventType: DeviceInputEventType.Keyboard,
|
||||
keycode,
|
||||
isShift: false,
|
||||
},
|
||||
});
|
||||
|
||||
shortcutList.push({
|
||||
id: SetTextEditArrowOperation.id,
|
||||
binding: keycode | MetaKeys.SHIFT,
|
||||
preconditions: (contextService) => whenEditorActivated(contextService),
|
||||
staticParameters: {
|
||||
visible: false,
|
||||
eventType: DeviceInputEventType.Keyboard,
|
||||
keycode,
|
||||
isShift: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return shortcutList;
|
||||
}
|
||||
|
||||
// export const StartEditWithF2Shortcut: IShortcutItem = {
|
||||
// id: SetCellEditVisibleWithF2Operation.id,
|
||||
// binding: KeyCode.F2,
|
||||
// description: 'shortcut.sheet.start-editing',
|
||||
// group: '4_sheet-edit',
|
||||
// preconditions: whenSheetEditorFocused,
|
||||
// staticParameters: {
|
||||
// visible: true,
|
||||
// eventType: DeviceInputEventType.Keyboard,
|
||||
// keycode: KeyCode.F2,
|
||||
// },
|
||||
// };
|
||||
|
||||
// export const EditorCursorEnterShortcut: IShortcutItem = {
|
||||
// id: SetCellEditVisibleOperation.id,
|
||||
// binding: KeyCode.ENTER,
|
||||
// description: 'shortcut.sheet.toggle-editing',
|
||||
// group: '4_sheet-edit',
|
||||
// preconditions: (contextService) => whenEditorDidNotInputFormulaActivated(contextService),
|
||||
// staticParameters: {
|
||||
// visible: false,
|
||||
// eventType: DeviceInputEventType.Keyboard,
|
||||
// keycode: KeyCode.ENTER,
|
||||
// },
|
||||
// };
|
||||
|
||||
// export const EditorCursorTabShortcut: IShortcutItem = {
|
||||
// id: SetCellEditVisibleOperation.id,
|
||||
// binding: KeyCode.TAB,
|
||||
// preconditions: (contextService) => whenEditorDidNotInputFormulaActivated(contextService),
|
||||
// staticParameters: {
|
||||
// visible: false,
|
||||
// eventType: DeviceInputEventType.Keyboard,
|
||||
// keycode: KeyCode.TAB,
|
||||
// },
|
||||
// };
|
||||
|
||||
// export const EditorCursorEscShortcut: IShortcutItem = {
|
||||
// id: SetCellEditVisibleOperation.id,
|
||||
// binding: KeyCode.ESC,
|
||||
// description: 'shortcut.sheet.abort-editing',
|
||||
// group: '4_sheet-edit',
|
||||
// preconditions: (contextService) => whenEditorDidNotInputFormulaActivated(contextService),
|
||||
// staticParameters: {
|
||||
// visible: false,
|
||||
// eventType: DeviceInputEventType.Keyboard,
|
||||
// keycode: KeyCode.ESC,
|
||||
// },
|
||||
// };
|
||||
|
||||
// export const EditorBreakLineShortcut: IShortcutItem = {
|
||||
// id: BreakLineCommand.id,
|
||||
// description: 'shortcut.sheet.break-line',
|
||||
// group: '4_sheet-edit',
|
||||
// preconditions: (contextService) => whenSheetEditorActivated(contextService),
|
||||
// binding: KeyCode.ENTER | MetaKeys.ALT,
|
||||
// };
|
||||
|
||||
export const EditorDeleteLeftShortcut: IShortcutItem = {
|
||||
id: DeleteLeftCommand.id,
|
||||
preconditions: (contextService) => {
|
||||
return whenEditorActivated(contextService) || whenFormulaEditorFocused(contextService);
|
||||
},
|
||||
binding: KeyCode.BACKSPACE,
|
||||
};
|
||||
|
||||
// export const EditorDeleteLeftShortcutInActive: IShortcutItem = {
|
||||
// id: SetCellEditVisibleOperation.id,
|
||||
// description: 'shortcut.sheet.delete-and-start-editing',
|
||||
// group: '4_sheet-edit',
|
||||
// preconditions: (contextService) =>
|
||||
// whenSheetEditorFocused(contextService) && !whenFormulaEditorFocused(contextService),
|
||||
// binding: KeyCode.BACKSPACE,
|
||||
// staticParameters: {
|
||||
// visible: true,
|
||||
// eventType: DeviceInputEventType.Keyboard,
|
||||
// keycode: KeyCode.BACKSPACE,
|
||||
// },
|
||||
// };
|
||||
Reference in New Issue
Block a user