@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
51 lines • 1.96 kB
JavaScript
import { keymap } from '../../prosemirror';
import * as keymaps from '../../keymaps';
import pluginKey from './plugin-key';
export function keymapPlugin(schema) {
var list = {};
keymaps.bindKeymapWithCommand(keymaps.moveUp.common, function (state, dispatch) {
var mentionsPlugin = pluginKey.getState(state);
if (!mentionsPlugin.queryActive) {
return false;
}
return mentionsPlugin.onSelectPrevious();
}, list);
keymaps.bindKeymapWithCommand(keymaps.moveDown.common, function (state, dispatch) {
var mentionsPlugin = pluginKey.getState(state);
if (!mentionsPlugin.queryActive) {
return false;
}
return mentionsPlugin.onSelectNext();
}, list);
keymaps.bindKeymapWithCommand(keymaps.enter.common, function (state, dispatch) {
var mentionsPlugin = pluginKey.getState(state);
if (!mentionsPlugin.queryActive) {
return false;
}
return mentionsPlugin.onSelectCurrent();
}, list);
keymaps.bindKeymapWithCommand(keymaps.tab.common, function (state, dispatch) {
var mentionsPlugin = pluginKey.getState(state);
if (!mentionsPlugin.queryActive) {
return false;
}
return mentionsPlugin.onSelectCurrent();
}, list);
keymaps.bindKeymapWithCommand(keymaps.escape.common, function (state, dispatch) {
var mentionsPlugin = pluginKey.getState(state);
if (!mentionsPlugin.queryActive) {
return false;
}
return mentionsPlugin.dismiss();
}, list);
keymaps.bindKeymapWithCommand(keymaps.space.common, function (state, dispatch) {
var mentionsPlugin = pluginKey.getState(state);
if (!mentionsPlugin.queryActive) {
return false;
}
return mentionsPlugin.trySelectCurrent();
}, list);
return keymap(list);
}
export default keymapPlugin;
//# sourceMappingURL=keymap.js.map