UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

54 lines 2.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var prosemirror_1 = require("../../prosemirror"); var keymaps = require("../../keymaps"); var plugin_key_1 = require("./plugin-key"); function keymapPlugin(schema) { var list = {}; keymaps.bindKeymapWithCommand(keymaps.moveUp.common, function (state, dispatch) { var mentionsPlugin = plugin_key_1.default.getState(state); if (!mentionsPlugin.queryActive) { return false; } return mentionsPlugin.onSelectPrevious(); }, list); keymaps.bindKeymapWithCommand(keymaps.moveDown.common, function (state, dispatch) { var mentionsPlugin = plugin_key_1.default.getState(state); if (!mentionsPlugin.queryActive) { return false; } return mentionsPlugin.onSelectNext(); }, list); keymaps.bindKeymapWithCommand(keymaps.enter.common, function (state, dispatch) { var mentionsPlugin = plugin_key_1.default.getState(state); if (!mentionsPlugin.queryActive) { return false; } return mentionsPlugin.onSelectCurrent(); }, list); keymaps.bindKeymapWithCommand(keymaps.tab.common, function (state, dispatch) { var mentionsPlugin = plugin_key_1.default.getState(state); if (!mentionsPlugin.queryActive) { return false; } return mentionsPlugin.onSelectCurrent(); }, list); keymaps.bindKeymapWithCommand(keymaps.escape.common, function (state, dispatch) { var mentionsPlugin = plugin_key_1.default.getState(state); if (!mentionsPlugin.queryActive) { return false; } return mentionsPlugin.dismiss(); }, list); keymaps.bindKeymapWithCommand(keymaps.space.common, function (state, dispatch) { var mentionsPlugin = plugin_key_1.default.getState(state); if (!mentionsPlugin.queryActive) { return false; } return mentionsPlugin.trySelectCurrent(); }, list); return prosemirror_1.keymap(list); } exports.keymapPlugin = keymapPlugin; exports.default = keymapPlugin; //# sourceMappingURL=keymap.js.map