@atlaskit/editor-plugin-table
Version:
Table plugin for the @atlaskit/editor
28 lines (24 loc) • 1.92 kB
JavaScript
import { bindKeymapArrayWithCommand, bindKeymapWithCommand, moveLeft, moveRight, selectColumn, selectRow, selectTable, shiftArrowUp } from '@atlaskit/editor-common/keymaps';
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
import { arrowLeftFromTable, arrowRightFromTable, modASelectTable, selectColumns, selectRows, shiftArrowUpFromTable } from './commands/selection';
export function tableSelectionKeymapPlugin(pluginInjectionApi, getIntl) {
var _pluginInjectionApi$a;
const list = {};
const editorSelectionAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.selection;
const ariaNotifyPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.accessibilityUtils) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.ariaNotify;
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
bindKeymapWithCommand(moveRight.common, arrowRightFromTable(editorSelectionAPI)(), list);
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
bindKeymapWithCommand(moveLeft.common, arrowLeftFromTable(editorSelectionAPI)(), list);
bindKeymapArrayWithCommand(selectColumn, selectColumns(editorSelectionAPI, ariaNotifyPlugin, getIntl)(true), list);
bindKeymapArrayWithCommand(selectRow, selectRows(editorSelectionAPI, ariaNotifyPlugin, getIntl)(true), list);
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
bindKeymapWithCommand(shiftArrowUp.common, shiftArrowUpFromTable(editorSelectionAPI)(), list);
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
bindKeymapWithCommand(selectTable.common, modASelectTable(editorSelectionAPI)(), list);
return keymap(list);
}