mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Add cut, copy, and paste to context menu
Summary: On supported browsers, the new context menu commands work exactly as they do via keyboard shortcuts. On unsupported browsers, an unavailable command modal is shown with a suggestion to use keyboard shortcuts instead. Test Plan: Browser tests. Reviewers: jarek Reviewed By: jarek Differential Revision: https://phab.getgrist.com/D3867
This commit is contained in:
27
app/client/ui/FieldContextMenu.ts
Normal file
27
app/client/ui/FieldContextMenu.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import {allCommands} from 'app/client/components/commands';
|
||||
import {makeT} from 'app/client/lib/localization';
|
||||
import {IRowContextMenu} from 'app/client/ui/RowContextMenu';
|
||||
import {menuDivider, menuItemCmd} from 'app/client/ui2018/menus';
|
||||
import {dom} from 'grainjs';
|
||||
|
||||
const t = makeT('FieldContextMenu');
|
||||
|
||||
export interface IFieldContextMenu {
|
||||
disableModify: boolean;
|
||||
isReadonly: boolean;
|
||||
}
|
||||
|
||||
export function FieldContextMenu(_rowOptions: IRowContextMenu, fieldOptions: IFieldContextMenu) {
|
||||
const {disableModify, isReadonly} = fieldOptions;
|
||||
const disableForReadonlyColumn = dom.cls('disabled', disableModify || isReadonly);
|
||||
return [
|
||||
menuItemCmd(allCommands.contextMenuCut, t('Cut'), disableForReadonlyColumn),
|
||||
menuItemCmd(allCommands.contextMenuCopy, t('Copy')),
|
||||
menuItemCmd(allCommands.contextMenuPaste, t('Paste'), disableForReadonlyColumn),
|
||||
menuDivider(),
|
||||
menuItemCmd(allCommands.clearCardFields, t('Clear field'), disableForReadonlyColumn),
|
||||
menuItemCmd(allCommands.hideCardFields, t('Hide field')),
|
||||
menuDivider(),
|
||||
menuItemCmd(allCommands.copyLink, t('Copy anchor link')),
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user