UNPKG

@atlaskit/editor-plugin-highlight

Version:

Highlight plugin for @atlaskit/editor-core

44 lines (43 loc) 1.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.keymapPlugin = keymapPlugin; var _analytics = require("@atlaskit/editor-common/analytics"); var _keymaps = require("@atlaskit/editor-common/keymaps"); var _preset = require("@atlaskit/editor-common/preset"); var _uiColor = require("@atlaskit/editor-common/ui-color"); var _changeColor = require("../editor-commands/change-color"); var _palette = require("../editor-commands/palette"); function keymapPlugin(_ref) { var _api$analytics; var api = _ref.api; var list = {}; var isToolbarAIFCEnabled = Boolean(api === null || api === void 0 ? void 0 : api.toolbar); if (!isToolbarAIFCEnabled) { (0, _keymaps.bindKeymapWithCommand)( // Ignored via go/ees005 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion _keymaps.toggleHighlightPalette.common, // Ignored via go/ees005 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion (0, _palette.togglePalette)(api)({ inputMethod: _analytics.INPUT_METHOD.SHORTCUT }), list); } var analyticsApi = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions; var color = _uiColor.highlightColorPalette.find(function (_ref2) { var label = _ref2.label; return label === 'Yellow'; }); if (color) { (0, _keymaps.bindKeymapWithCommand)( // Ignored via go/ees005 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion _keymaps.applyYellowHighlight.common, (0, _preset.editorCommandToPMCommand)((0, _changeColor.changeColor)(analyticsApi)({ color: color.value, inputMethod: _analytics.INPUT_METHOD.SHORTCUT })), list); } return (0, _keymaps.keymap)(list); }