UNPKG

@atlaskit/editor-plugin-highlight

Version:

Highlight plugin for @atlaskit/editor-core

40 lines 1.95 kB
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics'; import { applyYellowHighlight, bindKeymapWithCommand, keymap, toggleHighlightPalette } from '@atlaskit/editor-common/keymaps'; import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset'; import { highlightColorPalette, highlightColorPaletteNew } from '@atlaskit/editor-common/ui-color'; import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure'; 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 highlightPalette = expValEqualsNoExposure('platform_editor_lovability_text_bg_color', 'isEnabled', true) ? highlightColorPaletteNew : highlightColorPalette; var color = highlightPalette.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); }