@atlaskit/editor-plugin-highlight
Version:
Highlight plugin for @atlaskit/editor-core
38 lines • 1.67 kB
JavaScript
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
import { bindKeymapWithCommand, keymap, toggleHighlightPalette, applyYellowHighlight } from '@atlaskit/editor-common/keymaps';
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
import { highlightColorPalette } from '@atlaskit/editor-common/ui-color';
import { changeColor } from '../editor-commands/change-color';
import { togglePalette } from '../editor-commands/palette';
export 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) {
bindKeymapWithCommand(
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
toggleHighlightPalette.common,
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
togglePalette(api)({
inputMethod: 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 = highlightColorPalette.find(function (_ref2) {
var label = _ref2.label;
return label === 'Yellow';
});
if (color) {
bindKeymapWithCommand(
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
applyYellowHighlight.common, editorCommandToPMCommand(changeColor(analyticsApi)({
color: color.value,
inputMethod: INPUT_METHOD.SHORTCUT
})), list);
}
return keymap(list);
}