@atlaskit/editor-plugin-block-controls
Version:
Block controls plugin for @atlaskit/editor-core
44 lines (43 loc) • 2.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.boundKeydownHandler = void 0;
var _keymaps = require("@atlaskit/editor-common/keymaps");
var _types = require("@atlaskit/editor-common/types");
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
var _moveNode = require("../editor-commands/move-node");
var _showDragHandle = require("../editor-commands/show-drag-handle");
function keymapList(api, formatMessage) {
var keymapList = {};
if (api) {
(0, _keymaps.bindKeymapWithCommand)(
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
_keymaps.showElementDragHandle.common, function (state, dispatch, view) {
(0, _showDragHandle.showDragHandleAtSelection)(api)(state, dispatch, view);
//we always want to handle this shortcut to prevent default browser special char insert when option + alphabetical key is used
return true;
}, keymapList);
(0, _keymaps.bindKeymapWithCommand)(
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
_keymaps.dragToMoveUp.common, (0, _moveNode.moveNodeViaShortcut)(api, _types.DIRECTION.UP, formatMessage), keymapList);
(0, _keymaps.bindKeymapWithCommand)(
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
_keymaps.dragToMoveDown.common, (0, _moveNode.moveNodeViaShortcut)(api, _types.DIRECTION.DOWN, formatMessage), keymapList);
(0, _keymaps.bindKeymapWithCommand)(
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
_keymaps.dragToMoveLeft.common, (0, _moveNode.moveNodeViaShortcut)(api, _types.DIRECTION.LEFT, formatMessage), keymapList);
(0, _keymaps.bindKeymapWithCommand)(
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
_keymaps.dragToMoveRight.common, (0, _moveNode.moveNodeViaShortcut)(api, _types.DIRECTION.RIGHT, formatMessage), keymapList);
}
return keymapList;
}
var boundKeydownHandler = exports.boundKeydownHandler = function boundKeydownHandler(api, formatMessage) {
return (0, _keymap.keydownHandler)(keymapList(api, formatMessage));
};