UNPKG

@atlaskit/editor-plugin-date

Version:

Date plugin for @atlaskit/editor-core

47 lines (46 loc) 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; exports.keymapPlugin = keymapPlugin; var _keymaps = require("@atlaskit/editor-common/keymaps"); var _state = require("@atlaskit/editor-prosemirror/state"); var _actions = require("./actions"); var _main = require("./main"); function keymapPlugin() { var list = {}; (0, _keymaps.bindKeymapWithCommand)( // Ignored via go/ees005 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion _keymaps.enter.common, function (state, dispatch) { var datePlugin = (0, _main.getPluginState)(state); var isDateNode = state.selection instanceof _state.NodeSelection ? state.selection.node.type === state.schema.nodes.date : false; if (!isDateNode) { return false; } if (!datePlugin.showDatePickerAt) { (0, _actions.openDatePicker)()(state, dispatch); return true; } (0, _actions.closeDatePicker)()(state, dispatch); return true; }, list); (0, _keymaps.bindKeymapWithCommand)( // Ignored via go/ees005 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion _keymaps.tab.common, function (state, dispatch) { var datePlugin = (0, _main.getPluginState)(state); var isDateNode = state.selection instanceof _state.NodeSelection ? state.selection.node.type === state.schema.nodes.date : false; if (!isDateNode) { return false; } if (datePlugin.showDatePickerAt) { (0, _actions.focusDateInput)()(state, dispatch); return true; } return false; }, list); return (0, _keymaps.keymap)(list); } var _default = exports.default = keymapPlugin;