Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
/**
* 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 { KeyCode, MetaKeys } from '@univerjs/ui';
import { EnterCommand } from '../commands/commands/auto-format.command';
import { BreakLineCommand } from '../commands/commands/break-line.command';
import { DeleteLeftCommand, DeleteRightCommand } from '../commands/commands/doc-delete.command';
import { CloseHeaderFooterCommand } from '../commands/commands/doc-header-footer.command';
import { whenDocAndEditorFocused, whenDocAndEditorFocusedWithBreakLine, whenTextEditorFocused } from './utils';
export const BreakLineShortcut: IShortcutItem = {
id: EnterCommand.id,
preconditions: whenDocAndEditorFocusedWithBreakLine,
binding: KeyCode.ENTER,
};
export const SoftBreakLineShortcut: IShortcutItem = {
id: BreakLineCommand.id,
preconditions: whenDocAndEditorFocusedWithBreakLine,
binding: KeyCode.ENTER | MetaKeys.SHIFT,
};
export const DeleteLeftShortcut: IShortcutItem = {
id: DeleteLeftCommand.id,
preconditions: whenDocAndEditorFocused,
binding: KeyCode.BACKSPACE,
};
export const DeleteRightShortcut: IShortcutItem = {
id: DeleteRightCommand.id,
preconditions: whenDocAndEditorFocused,
binding: KeyCode.DELETE,
};
export const CloseHeaderFooterShortcut: IShortcutItem = {
id: CloseHeaderFooterCommand.id,
preconditions: whenDocAndEditorFocused,
binding: KeyCode.ESC,
};
export const DeleteWordLeftShortcut: IShortcutItem = {
id: DeleteLeftCommand.id,
preconditions: whenTextEditorFocused,
binding: KeyCode.BACKSPACE | MetaKeys.CTRL_COMMAND,
mac: KeyCode.BACKSPACE | MetaKeys.ALT,
staticParameters: { granularity: 'word' },
};
export const DeleteWordRightShortcut: IShortcutItem = {
id: DeleteRightCommand.id,
preconditions: whenTextEditorFocused,
mac: KeyCode.DELETE | MetaKeys.ALT,
staticParameters: { granularity: 'word' },
};
export const DeleteLineStartShortcut: IShortcutItem = {
id: DeleteLeftCommand.id,
preconditions: whenTextEditorFocused,
mac: KeyCode.BACKSPACE | MetaKeys.CTRL_COMMAND,
staticParameters: { granularity: 'line' },
};
export const DeleteLineEndShortcut: IShortcutItem = {
id: DeleteRightCommand.id,
preconditions: whenTextEditorFocused,
binding: KeyCode.DELETE | MetaKeys.CTRL_COMMAND,
mac: KeyCode.DELETE | MetaKeys.MAC_CTRL,
staticParameters: { granularity: 'line' },
};