@atlaskit/editor-plugin-highlight 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/plugin.js +11 -3
  3. package/dist/cjs/ui/FloatingToolbarHighlightColor.js +98 -0
  4. package/dist/cjs/ui/PrimaryToolbarHighlightColor.js +107 -0
  5. package/dist/cjs/ui/ToolbarHighlightColor.js +3 -1
  6. package/dist/cjs/ui/shared/PaletteDropdown.js +61 -0
  7. package/dist/cjs/ui/shared/useDropdownEvents.js +55 -0
  8. package/dist/es2019/plugin.js +11 -3
  9. package/dist/es2019/ui/FloatingToolbarHighlightColor.js +89 -0
  10. package/dist/es2019/ui/PrimaryToolbarHighlightColor.js +104 -0
  11. package/dist/es2019/ui/ToolbarHighlightColor.js +3 -1
  12. package/dist/es2019/ui/shared/PaletteDropdown.js +57 -0
  13. package/dist/es2019/ui/shared/useDropdownEvents.js +46 -0
  14. package/dist/esm/plugin.js +11 -3
  15. package/dist/esm/ui/FloatingToolbarHighlightColor.js +90 -0
  16. package/dist/esm/ui/PrimaryToolbarHighlightColor.js +99 -0
  17. package/dist/esm/ui/ToolbarHighlightColor.js +3 -1
  18. package/dist/esm/ui/shared/PaletteDropdown.js +54 -0
  19. package/dist/esm/ui/shared/useDropdownEvents.js +48 -0
  20. package/dist/types/ui/FloatingToolbarHighlightColor.d.ts +24 -0
  21. package/dist/types/ui/PrimaryToolbarHighlightColor.d.ts +24 -0
  22. package/dist/types/ui/shared/PaletteDropdown.d.ts +14 -0
  23. package/dist/types/ui/shared/useDropdownEvents.d.ts +19 -0
  24. package/dist/types-ts4.5/ui/FloatingToolbarHighlightColor.d.ts +24 -0
  25. package/dist/types-ts4.5/ui/PrimaryToolbarHighlightColor.d.ts +24 -0
  26. package/dist/types-ts4.5/ui/shared/PaletteDropdown.d.ts +14 -0
  27. package/dist/types-ts4.5/ui/shared/useDropdownEvents.d.ts +19 -0
  28. package/package.json +46 -17
  29. /package/dist/cjs/ui/{EditorHighlightIcon.js → shared/EditorHighlightIcon.js} +0 -0
  30. /package/dist/es2019/ui/{EditorHighlightIcon.js → shared/EditorHighlightIcon.js} +0 -0
  31. /package/dist/esm/ui/{EditorHighlightIcon.js → shared/EditorHighlightIcon.js} +0 -0
  32. /package/dist/types/ui/{EditorHighlightIcon.d.ts → shared/EditorHighlightIcon.d.ts} +0 -0
  33. /package/dist/types-ts4.5/ui/{EditorHighlightIcon.d.ts → shared/EditorHighlightIcon.d.ts} +0 -0
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import { ColorPalette, getSelectedRowAndColumnFromPalette, highlightColorPalette, highlightColorPaletteWithTokenBorders } from '@atlaskit/editor-common/ui-color';
3
+ import { ArrowKeyNavigationType, DropdownContainer as Dropdown } from '@atlaskit/editor-common/ui-menu';
4
+ import { hexToEditorTextBackgroundPaletteColor } from '@atlaskit/editor-palette';
5
+ import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
6
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
+ export const PaletteDropdown = props => {
8
+ const {
9
+ popupsMountPoint,
10
+ popupsBoundariesElement,
11
+ popupsScrollableElement,
12
+ isOpen,
13
+ activeColor,
14
+ trigger,
15
+ onColorChange,
16
+ isOpenedByKeyboard,
17
+ handleClickOutside,
18
+ handleEscapeKeydown
19
+ } = props;
20
+
21
+ // pixels, used to determine where to horizontally position the dropdown when space is limited
22
+ // this should reflect the width of the dropdown when fully populated with colors, including translations due to layering
23
+ const fitWidth = 242;
24
+ const palette = getBooleanFF('platform.editor.dynamic-palette-borders') ? highlightColorPaletteWithTokenBorders : highlightColorPalette;
25
+ const {
26
+ selectedRowIndex,
27
+ selectedColumnIndex
28
+ } = getSelectedRowAndColumnFromPalette(palette, activeColor);
29
+ return /*#__PURE__*/React.createElement(Dropdown, {
30
+ mountTo: popupsMountPoint,
31
+ boundariesElement: popupsBoundariesElement,
32
+ scrollableElement: popupsScrollableElement,
33
+ isOpen: isOpen,
34
+ handleClickOutside: handleClickOutside,
35
+ handleEscapeKeydown: handleEscapeKeydown,
36
+ zIndex: akEditorMenuZIndex,
37
+ fitWidth: fitWidth,
38
+ closeOnTab: true,
39
+ arrowKeyNavigationProviderOptions: {
40
+ type: ArrowKeyNavigationType.COLOR,
41
+ selectedRowIndex,
42
+ selectedColumnIndex,
43
+ isOpenedByKeyboard,
44
+ isPopupPositioned: true
45
+ },
46
+ trigger: trigger
47
+ }, /*#__PURE__*/React.createElement("div", {
48
+ "data-testid": "highlight-color-palette"
49
+ }, /*#__PURE__*/React.createElement(ColorPalette, {
50
+ onClick: onColorChange,
51
+ selectedColor: activeColor,
52
+ paletteOptions: {
53
+ palette,
54
+ hexToPaletteColor: hexToEditorTextBackgroundPaletteColor
55
+ }
56
+ })));
57
+ };
@@ -0,0 +1,46 @@
1
+ import { useState } from 'react';
2
+ import { changeColor } from '../../commands';
3
+ export const useDropdownEvents = args => {
4
+ const {
5
+ toolbarItemRef,
6
+ setIsDropdownOpen,
7
+ isDropdownOpen,
8
+ pluginInjectionApi
9
+ } = args;
10
+ const [isOpenedByKeyboard, setIsOpenedByKeyboard] = useState(false);
11
+ return {
12
+ handleClick: () => {
13
+ setIsOpenedByKeyboard(false);
14
+ setIsDropdownOpen(!isDropdownOpen);
15
+ },
16
+ handleKeyDown: event => {
17
+ if (event.key === 'Enter' || event.key === ' ') {
18
+ event.preventDefault();
19
+ setIsOpenedByKeyboard(true);
20
+ setIsDropdownOpen(!isDropdownOpen);
21
+ }
22
+ },
23
+ handleClickOutside: () => {
24
+ if (isDropdownOpen) {
25
+ setIsDropdownOpen(false);
26
+ setIsOpenedByKeyboard(false);
27
+ }
28
+ },
29
+ handleEscapeKeydown: () => {
30
+ if (isDropdownOpen) {
31
+ var _toolbarItemRef$curre;
32
+ setIsDropdownOpen(false);
33
+ setIsOpenedByKeyboard(false);
34
+ toolbarItemRef === null || toolbarItemRef === void 0 ? void 0 : (_toolbarItemRef$curre = toolbarItemRef.current) === null || _toolbarItemRef$curre === void 0 ? void 0 : _toolbarItemRef$curre.focus();
35
+ }
36
+ },
37
+ handleColorChange: color => {
38
+ var _pluginInjectionApi$c, _pluginInjectionApi$a;
39
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.core) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.execute(changeColor(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)({
40
+ color
41
+ }));
42
+ setIsDropdownOpen(false);
43
+ },
44
+ isOpenedByKeyboard
45
+ };
46
+ };
@@ -1,7 +1,9 @@
1
1
  import React from 'react';
2
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
2
3
  import { changeColor } from './commands';
3
4
  import { keymapPlugin } from './pm-plugins/keymap';
4
5
  import { createPlugin, highlightPluginKey } from './pm-plugins/main';
6
+ import { PrimaryToolbarHighlightColorWithIntl as PrimaryToolbarHighlightColor } from './ui/PrimaryToolbarHighlightColor';
5
7
  import { ToolbarHighlightColorWithIntl as ToolbarHighlightColor } from './ui/ToolbarHighlightColor';
6
8
  export var highlightPlugin = function highlightPlugin(_ref) {
7
9
  var _api$analytics;
@@ -13,15 +15,21 @@ export var highlightPlugin = function highlightPlugin(_ref) {
13
15
  popupsScrollableElement = _ref2.popupsScrollableElement,
14
16
  disabled = _ref2.disabled,
15
17
  isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing,
16
- dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
17
18
  editorView = _ref2.editorView;
18
- return /*#__PURE__*/React.createElement(ToolbarHighlightColor, {
19
+ return getBooleanFF('platform.editor.refactor-highlight-toolbar_mo0pj') ? /*#__PURE__*/React.createElement(PrimaryToolbarHighlightColor, {
20
+ popupsMountPoint: popupsMountPoint,
21
+ popupsBoundariesElement: popupsBoundariesElement,
22
+ popupsScrollableElement: popupsScrollableElement,
23
+ disabled: disabled,
24
+ isToolbarReducedSpacing: isToolbarReducedSpacing,
25
+ pluginInjectionApi: api,
26
+ editorView: editorView
27
+ }) : /*#__PURE__*/React.createElement(ToolbarHighlightColor, {
19
28
  popupsMountPoint: popupsMountPoint,
20
29
  popupsBoundariesElement: popupsBoundariesElement,
21
30
  popupsScrollableElement: popupsScrollableElement,
22
31
  disabled: disabled,
23
32
  isToolbarReducedSpacing: isToolbarReducedSpacing,
24
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
25
33
  pluginInjectionApi: api,
26
34
  editorView: editorView
27
35
  });
@@ -0,0 +1,90 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ /** @jsx jsx */
3
+ import { useRef, useState } from 'react';
4
+ import { jsx } from '@emotion/react';
5
+ import { injectIntl } from 'react-intl-next';
6
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
+ import { highlightMessages as messages } from '@atlaskit/editor-common/messages';
8
+ import { expandIconWrapperStyle } from '@atlaskit/editor-common/styles';
9
+ import { TOOLBAR_BUTTON, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
10
+ import { hexToEditorTextBackgroundPaletteColor } from '@atlaskit/editor-palette';
11
+ import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
12
+ import { Flex } from '@atlaskit/primitives';
13
+ import { EditorHighlightIcon } from './shared/EditorHighlightIcon';
14
+ import { PaletteDropdown } from './shared/PaletteDropdown';
15
+ import { useDropdownEvents } from './shared/useDropdownEvents';
16
+ var FloatingToolbarHighlightColor = function FloatingToolbarHighlightColor(_ref) {
17
+ var popupsMountPoint = _ref.popupsMountPoint,
18
+ popupsBoundariesElement = _ref.popupsBoundariesElement,
19
+ popupsScrollableElement = _ref.popupsScrollableElement,
20
+ isToolbarReducedSpacing = _ref.isToolbarReducedSpacing,
21
+ disabled = _ref.disabled,
22
+ pluginInjectionApi = _ref.pluginInjectionApi,
23
+ formatMessage = _ref.intl.formatMessage;
24
+ var toolbarItemRef = useRef(null);
25
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['highlight']),
26
+ highlightState = _useSharedPluginState.highlightState;
27
+ var _useState = useState(false),
28
+ _useState2 = _slicedToArray(_useState, 2),
29
+ isDropdownOpen = _useState2[0],
30
+ setIsDropdownOpen = _useState2[1];
31
+ var _useDropdownEvents = useDropdownEvents({
32
+ toolbarItemRef: toolbarItemRef,
33
+ setIsDropdownOpen: setIsDropdownOpen,
34
+ isDropdownOpen: isDropdownOpen,
35
+ pluginInjectionApi: pluginInjectionApi
36
+ }),
37
+ handleClick = _useDropdownEvents.handleClick,
38
+ handleKeyDown = _useDropdownEvents.handleKeyDown,
39
+ handleClickOutside = _useDropdownEvents.handleClickOutside,
40
+ handleEscapeKeydown = _useDropdownEvents.handleEscapeKeydown,
41
+ handleColorChange = _useDropdownEvents.handleColorChange,
42
+ isOpenedByKeyboard = _useDropdownEvents.isOpenedByKeyboard;
43
+
44
+ // Don't render the toolbar option while the plugin is initialising
45
+ if (!highlightState) {
46
+ return null;
47
+ }
48
+ var toolbarButtonLabel = formatMessage(messages.highlight);
49
+
50
+ // Get the design token for the active color (if it exists) to modify the toolbar
51
+ // icon, but show the nice rainbow if none is selected
52
+ var activeColorToken = highlightState.activeColor === null ? null : hexToEditorTextBackgroundPaletteColor(highlightState.activeColor);
53
+ return jsx(Flex, {
54
+ alignItems: "center"
55
+ }, jsx(PaletteDropdown, {
56
+ popupsMountPoint: popupsMountPoint,
57
+ popupsBoundariesElement: popupsBoundariesElement,
58
+ popupsScrollableElement: popupsScrollableElement,
59
+ isOpen: isDropdownOpen && !highlightState.disabled,
60
+ activeColor: highlightState.activeColor,
61
+ trigger: jsx(ToolbarButton, {
62
+ buttonId: TOOLBAR_BUTTON.BACKGROUND_COLOR,
63
+ spacing: isToolbarReducedSpacing ? 'none' : 'default',
64
+ disabled: disabled || highlightState.disabled,
65
+ selected: isDropdownOpen,
66
+ "aria-label": toolbarButtonLabel,
67
+ "aria-expanded": isDropdownOpen,
68
+ "aria-haspopup": true,
69
+ title: toolbarButtonLabel,
70
+ onClick: handleClick,
71
+ onKeyDown: handleKeyDown,
72
+ ref: toolbarItemRef,
73
+ iconBefore: jsx(Flex, null, jsx(EditorHighlightIcon, {
74
+ selectedColor: activeColorToken,
75
+ disabled: highlightState.disabled
76
+ }), jsx("span", {
77
+ css: expandIconWrapperStyle
78
+ }, jsx(ExpandIcon, {
79
+ label: ""
80
+ })))
81
+ }),
82
+ onColorChange: function onColorChange(color) {
83
+ return handleColorChange(color);
84
+ },
85
+ isOpenedByKeyboard: isOpenedByKeyboard,
86
+ handleClickOutside: handleClickOutside,
87
+ handleEscapeKeydown: handleEscapeKeydown
88
+ }));
89
+ };
90
+ export var FloatingToolbarHighlightColorWithIntl = injectIntl(FloatingToolbarHighlightColor);
@@ -0,0 +1,99 @@
1
+ /** @jsx jsx */
2
+ import { useRef } from 'react';
3
+
4
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
5
+ import { jsx } from '@emotion/react';
6
+ import { injectIntl } from 'react-intl-next';
7
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
8
+ import { getAriaKeyshortcuts, toggleHighlightPalette, tooltip } from '@atlaskit/editor-common/keymaps';
9
+ import { highlightMessages as messages } from '@atlaskit/editor-common/messages';
10
+ import { expandIconWrapperStyle } from '@atlaskit/editor-common/styles';
11
+ import { TOOLBAR_BUTTON, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
12
+ import { hexToEditorTextBackgroundPaletteColor } from '@atlaskit/editor-palette';
13
+ import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
14
+ import { Flex } from '@atlaskit/primitives';
15
+ import { setPalette } from '../commands';
16
+ import { EditorHighlightIcon } from './shared/EditorHighlightIcon';
17
+ import { PaletteDropdown } from './shared/PaletteDropdown';
18
+ import { useDropdownEvents } from './shared/useDropdownEvents';
19
+ var PrimaryToolbarHighlightColor = function PrimaryToolbarHighlightColor(_ref) {
20
+ var popupsMountPoint = _ref.popupsMountPoint,
21
+ popupsBoundariesElement = _ref.popupsBoundariesElement,
22
+ popupsScrollableElement = _ref.popupsScrollableElement,
23
+ isToolbarReducedSpacing = _ref.isToolbarReducedSpacing,
24
+ disabled = _ref.disabled,
25
+ pluginInjectionApi = _ref.pluginInjectionApi,
26
+ formatMessage = _ref.intl.formatMessage,
27
+ editorView = _ref.editorView;
28
+ var toolbarItemRef = useRef(null);
29
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['highlight']),
30
+ highlightState = _useSharedPluginState.highlightState;
31
+ var setDropdownOpen = function setDropdownOpen(isOpen) {
32
+ if (!(highlightState !== null && highlightState !== void 0 && highlightState.disabled)) {
33
+ var state = editorView.state,
34
+ dispatch = editorView.dispatch;
35
+ setPalette(pluginInjectionApi, isOpen)(state, dispatch);
36
+ }
37
+ };
38
+ var isDropdownOpen = !!(highlightState !== null && highlightState !== void 0 && highlightState.isPaletteOpen);
39
+ var _useDropdownEvents = useDropdownEvents({
40
+ toolbarItemRef: toolbarItemRef,
41
+ setIsDropdownOpen: setDropdownOpen,
42
+ isDropdownOpen: isDropdownOpen,
43
+ pluginInjectionApi: pluginInjectionApi
44
+ }),
45
+ handleClick = _useDropdownEvents.handleClick,
46
+ handleKeyDown = _useDropdownEvents.handleKeyDown,
47
+ handleClickOutside = _useDropdownEvents.handleClickOutside,
48
+ handleEscapeKeydown = _useDropdownEvents.handleEscapeKeydown,
49
+ handleColorChange = _useDropdownEvents.handleColorChange,
50
+ isOpenedByKeyboard = _useDropdownEvents.isOpenedByKeyboard;
51
+
52
+ // Don't render the toolbar option while the plugin is initialising
53
+ if (!highlightState) {
54
+ return null;
55
+ }
56
+ var toolbarButtonLabel = formatMessage(messages.highlight);
57
+
58
+ // Get the design token for the active color (if it exists) to modify the toolbar
59
+ // icon, but show the nice rainbow if none is selected
60
+ var activeColorToken = highlightState.activeColor === null ? null : hexToEditorTextBackgroundPaletteColor(highlightState.activeColor);
61
+ return jsx(Flex, {
62
+ alignItems: "center"
63
+ }, jsx(PaletteDropdown, {
64
+ popupsMountPoint: popupsMountPoint,
65
+ popupsBoundariesElement: popupsBoundariesElement,
66
+ popupsScrollableElement: popupsScrollableElement,
67
+ isOpen: isDropdownOpen && !highlightState.disabled,
68
+ activeColor: highlightState.activeColor,
69
+ trigger: jsx(ToolbarButton, {
70
+ buttonId: TOOLBAR_BUTTON.BACKGROUND_COLOR,
71
+ spacing: isToolbarReducedSpacing ? 'none' : 'default',
72
+ disabled: disabled || highlightState.disabled,
73
+ selected: isDropdownOpen,
74
+ "aria-label": tooltip(toggleHighlightPalette, toolbarButtonLabel),
75
+ "aria-keyshortcuts": getAriaKeyshortcuts(toggleHighlightPalette),
76
+ "aria-expanded": isDropdownOpen,
77
+ "aria-haspopup": true,
78
+ title: tooltip(toggleHighlightPalette, toolbarButtonLabel),
79
+ onClick: handleClick,
80
+ onKeyDown: handleKeyDown,
81
+ ref: toolbarItemRef,
82
+ iconBefore: jsx(Flex, null, jsx(EditorHighlightIcon, {
83
+ selectedColor: activeColorToken,
84
+ disabled: highlightState.disabled
85
+ }), jsx("span", {
86
+ css: expandIconWrapperStyle
87
+ }, jsx(ExpandIcon, {
88
+ label: ""
89
+ })))
90
+ }),
91
+ onColorChange: function onColorChange(color) {
92
+ return handleColorChange(color);
93
+ },
94
+ isOpenedByKeyboard: isOpenedByKeyboard,
95
+ handleClickOutside: handleClickOutside,
96
+ handleEscapeKeydown: handleEscapeKeydown
97
+ }));
98
+ };
99
+ export var PrimaryToolbarHighlightColorWithIntl = injectIntl(PrimaryToolbarHighlightColor);
@@ -1,6 +1,8 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  /** @jsx jsx */
3
3
  import React, { useRef, useState } from 'react';
4
+
5
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
4
6
  import { jsx } from '@emotion/react';
5
7
  import { injectIntl } from 'react-intl-next';
6
8
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
@@ -15,7 +17,7 @@ import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
15
17
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
16
18
  import { Flex } from '@atlaskit/primitives';
17
19
  import { changeColor, setPalette } from '../commands';
18
- import { EditorHighlightIcon } from './EditorHighlightIcon';
20
+ import { EditorHighlightIcon } from './shared/EditorHighlightIcon';
19
21
  var ToolbarHighlightColor = function ToolbarHighlightColor(_ref) {
20
22
  var popupsMountPoint = _ref.popupsMountPoint,
21
23
  popupsBoundariesElement = _ref.popupsBoundariesElement,
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import { ColorPalette, getSelectedRowAndColumnFromPalette, highlightColorPalette, highlightColorPaletteWithTokenBorders } from '@atlaskit/editor-common/ui-color';
3
+ import { ArrowKeyNavigationType, DropdownContainer as Dropdown } from '@atlaskit/editor-common/ui-menu';
4
+ import { hexToEditorTextBackgroundPaletteColor } from '@atlaskit/editor-palette';
5
+ import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
6
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
+ export var PaletteDropdown = function PaletteDropdown(props) {
8
+ var popupsMountPoint = props.popupsMountPoint,
9
+ popupsBoundariesElement = props.popupsBoundariesElement,
10
+ popupsScrollableElement = props.popupsScrollableElement,
11
+ isOpen = props.isOpen,
12
+ activeColor = props.activeColor,
13
+ trigger = props.trigger,
14
+ onColorChange = props.onColorChange,
15
+ isOpenedByKeyboard = props.isOpenedByKeyboard,
16
+ handleClickOutside = props.handleClickOutside,
17
+ handleEscapeKeydown = props.handleEscapeKeydown;
18
+
19
+ // pixels, used to determine where to horizontally position the dropdown when space is limited
20
+ // this should reflect the width of the dropdown when fully populated with colors, including translations due to layering
21
+ var fitWidth = 242;
22
+ var palette = getBooleanFF('platform.editor.dynamic-palette-borders') ? highlightColorPaletteWithTokenBorders : highlightColorPalette;
23
+ var _getSelectedRowAndCol = getSelectedRowAndColumnFromPalette(palette, activeColor),
24
+ selectedRowIndex = _getSelectedRowAndCol.selectedRowIndex,
25
+ selectedColumnIndex = _getSelectedRowAndCol.selectedColumnIndex;
26
+ return /*#__PURE__*/React.createElement(Dropdown, {
27
+ mountTo: popupsMountPoint,
28
+ boundariesElement: popupsBoundariesElement,
29
+ scrollableElement: popupsScrollableElement,
30
+ isOpen: isOpen,
31
+ handleClickOutside: handleClickOutside,
32
+ handleEscapeKeydown: handleEscapeKeydown,
33
+ zIndex: akEditorMenuZIndex,
34
+ fitWidth: fitWidth,
35
+ closeOnTab: true,
36
+ arrowKeyNavigationProviderOptions: {
37
+ type: ArrowKeyNavigationType.COLOR,
38
+ selectedRowIndex: selectedRowIndex,
39
+ selectedColumnIndex: selectedColumnIndex,
40
+ isOpenedByKeyboard: isOpenedByKeyboard,
41
+ isPopupPositioned: true
42
+ },
43
+ trigger: trigger
44
+ }, /*#__PURE__*/React.createElement("div", {
45
+ "data-testid": "highlight-color-palette"
46
+ }, /*#__PURE__*/React.createElement(ColorPalette, {
47
+ onClick: onColorChange,
48
+ selectedColor: activeColor,
49
+ paletteOptions: {
50
+ palette: palette,
51
+ hexToPaletteColor: hexToEditorTextBackgroundPaletteColor
52
+ }
53
+ })));
54
+ };
@@ -0,0 +1,48 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import { useState } from 'react';
3
+ import { changeColor } from '../../commands';
4
+ export var useDropdownEvents = function useDropdownEvents(args) {
5
+ var toolbarItemRef = args.toolbarItemRef,
6
+ setIsDropdownOpen = args.setIsDropdownOpen,
7
+ isDropdownOpen = args.isDropdownOpen,
8
+ pluginInjectionApi = args.pluginInjectionApi;
9
+ var _useState = useState(false),
10
+ _useState2 = _slicedToArray(_useState, 2),
11
+ isOpenedByKeyboard = _useState2[0],
12
+ setIsOpenedByKeyboard = _useState2[1];
13
+ return {
14
+ handleClick: function handleClick() {
15
+ setIsOpenedByKeyboard(false);
16
+ setIsDropdownOpen(!isDropdownOpen);
17
+ },
18
+ handleKeyDown: function handleKeyDown(event) {
19
+ if (event.key === 'Enter' || event.key === ' ') {
20
+ event.preventDefault();
21
+ setIsOpenedByKeyboard(true);
22
+ setIsDropdownOpen(!isDropdownOpen);
23
+ }
24
+ },
25
+ handleClickOutside: function handleClickOutside() {
26
+ if (isDropdownOpen) {
27
+ setIsDropdownOpen(false);
28
+ setIsOpenedByKeyboard(false);
29
+ }
30
+ },
31
+ handleEscapeKeydown: function handleEscapeKeydown() {
32
+ if (isDropdownOpen) {
33
+ var _toolbarItemRef$curre;
34
+ setIsDropdownOpen(false);
35
+ setIsOpenedByKeyboard(false);
36
+ toolbarItemRef === null || toolbarItemRef === void 0 || (_toolbarItemRef$curre = toolbarItemRef.current) === null || _toolbarItemRef$curre === void 0 || _toolbarItemRef$curre.focus();
37
+ }
38
+ },
39
+ handleColorChange: function handleColorChange(color) {
40
+ var _pluginInjectionApi$c, _pluginInjectionApi$a;
41
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.core) === null || _pluginInjectionApi$c === void 0 || _pluginInjectionApi$c.actions.execute(changeColor(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)({
42
+ color: color
43
+ }));
44
+ setIsDropdownOpen(false);
45
+ },
46
+ isOpenedByKeyboard: isOpenedByKeyboard
47
+ };
48
+ };
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ import type { WrappedComponentProps } from 'react-intl-next';
3
+ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
4
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
+ import type { HighlightPlugin } from '../plugin';
6
+ export declare const FloatingToolbarHighlightColorWithIntl: import("react").FC<import("react-intl-next").WithIntlProps<{
7
+ popupsMountPoint?: HTMLElement | undefined;
8
+ popupsBoundariesElement?: HTMLElement | undefined;
9
+ popupsScrollableElement?: HTMLElement | undefined;
10
+ disabled: boolean;
11
+ isToolbarReducedSpacing: boolean;
12
+ dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
13
+ pluginInjectionApi: ExtractInjectionAPI<HighlightPlugin> | undefined;
14
+ } & WrappedComponentProps>> & {
15
+ WrappedComponent: import("react").ComponentType<{
16
+ popupsMountPoint?: HTMLElement | undefined;
17
+ popupsBoundariesElement?: HTMLElement | undefined;
18
+ popupsScrollableElement?: HTMLElement | undefined;
19
+ disabled: boolean;
20
+ isToolbarReducedSpacing: boolean;
21
+ dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
22
+ pluginInjectionApi: ExtractInjectionAPI<HighlightPlugin> | undefined;
23
+ } & WrappedComponentProps>;
24
+ };
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ import type { WrappedComponentProps } from 'react-intl-next';
3
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
+ import { type EditorView } from '@atlaskit/editor-prosemirror/view';
5
+ import type { HighlightPlugin } from '../plugin';
6
+ export declare const PrimaryToolbarHighlightColorWithIntl: import("react").FC<import("react-intl-next").WithIntlProps<{
7
+ popupsMountPoint?: HTMLElement | undefined;
8
+ popupsBoundariesElement?: HTMLElement | undefined;
9
+ popupsScrollableElement?: HTMLElement | undefined;
10
+ disabled: boolean;
11
+ isToolbarReducedSpacing: boolean;
12
+ pluginInjectionApi: ExtractInjectionAPI<HighlightPlugin> | undefined;
13
+ editorView: EditorView;
14
+ } & WrappedComponentProps>> & {
15
+ WrappedComponent: import("react").ComponentType<{
16
+ popupsMountPoint?: HTMLElement | undefined;
17
+ popupsBoundariesElement?: HTMLElement | undefined;
18
+ popupsScrollableElement?: HTMLElement | undefined;
19
+ disabled: boolean;
20
+ isToolbarReducedSpacing: boolean;
21
+ pluginInjectionApi: ExtractInjectionAPI<HighlightPlugin> | undefined;
22
+ editorView: EditorView;
23
+ } & WrappedComponentProps>;
24
+ };
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { type WithOutsideClickProps } from '@atlaskit/editor-common/ui';
3
+ type PaletteDropdownProps = {
4
+ popupsMountPoint?: HTMLElement;
5
+ popupsBoundariesElement?: HTMLElement;
6
+ popupsScrollableElement?: HTMLElement;
7
+ isOpen: boolean;
8
+ activeColor: string | null;
9
+ trigger: React.ReactElement;
10
+ onColorChange: (color: string) => void;
11
+ isOpenedByKeyboard: boolean;
12
+ } & WithOutsideClickProps;
13
+ export declare const PaletteDropdown: (props: PaletteDropdownProps) => JSX.Element;
14
+ export {};
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import { type ToolbarButtonRef } from '@atlaskit/editor-common/ui-menu';
4
+ import type { HighlightPlugin } from '../../plugin';
5
+ type UseDropdownEventArgs = {
6
+ setIsDropdownOpen: (isOpen: boolean) => void;
7
+ isDropdownOpen: boolean;
8
+ pluginInjectionApi: ExtractInjectionAPI<HighlightPlugin> | undefined;
9
+ toolbarItemRef: React.RefObject<ToolbarButtonRef>;
10
+ };
11
+ export declare const useDropdownEvents: (args: UseDropdownEventArgs) => {
12
+ handleClick: () => void;
13
+ handleKeyDown: (event: React.KeyboardEvent) => void;
14
+ handleClickOutside: () => void;
15
+ handleEscapeKeydown: () => void;
16
+ handleColorChange: (color: string) => void;
17
+ isOpenedByKeyboard: boolean;
18
+ };
19
+ export {};
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ import type { WrappedComponentProps } from 'react-intl-next';
3
+ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
4
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
+ import type { HighlightPlugin } from '../plugin';
6
+ export declare const FloatingToolbarHighlightColorWithIntl: import("react").FC<import("react-intl-next").WithIntlProps<{
7
+ popupsMountPoint?: HTMLElement | undefined;
8
+ popupsBoundariesElement?: HTMLElement | undefined;
9
+ popupsScrollableElement?: HTMLElement | undefined;
10
+ disabled: boolean;
11
+ isToolbarReducedSpacing: boolean;
12
+ dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
13
+ pluginInjectionApi: ExtractInjectionAPI<HighlightPlugin> | undefined;
14
+ } & WrappedComponentProps>> & {
15
+ WrappedComponent: import("react").ComponentType<{
16
+ popupsMountPoint?: HTMLElement | undefined;
17
+ popupsBoundariesElement?: HTMLElement | undefined;
18
+ popupsScrollableElement?: HTMLElement | undefined;
19
+ disabled: boolean;
20
+ isToolbarReducedSpacing: boolean;
21
+ dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
22
+ pluginInjectionApi: ExtractInjectionAPI<HighlightPlugin> | undefined;
23
+ } & WrappedComponentProps>;
24
+ };
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ import type { WrappedComponentProps } from 'react-intl-next';
3
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
+ import { type EditorView } from '@atlaskit/editor-prosemirror/view';
5
+ import type { HighlightPlugin } from '../plugin';
6
+ export declare const PrimaryToolbarHighlightColorWithIntl: import("react").FC<import("react-intl-next").WithIntlProps<{
7
+ popupsMountPoint?: HTMLElement | undefined;
8
+ popupsBoundariesElement?: HTMLElement | undefined;
9
+ popupsScrollableElement?: HTMLElement | undefined;
10
+ disabled: boolean;
11
+ isToolbarReducedSpacing: boolean;
12
+ pluginInjectionApi: ExtractInjectionAPI<HighlightPlugin> | undefined;
13
+ editorView: EditorView;
14
+ } & WrappedComponentProps>> & {
15
+ WrappedComponent: import("react").ComponentType<{
16
+ popupsMountPoint?: HTMLElement | undefined;
17
+ popupsBoundariesElement?: HTMLElement | undefined;
18
+ popupsScrollableElement?: HTMLElement | undefined;
19
+ disabled: boolean;
20
+ isToolbarReducedSpacing: boolean;
21
+ pluginInjectionApi: ExtractInjectionAPI<HighlightPlugin> | undefined;
22
+ editorView: EditorView;
23
+ } & WrappedComponentProps>;
24
+ };
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { type WithOutsideClickProps } from '@atlaskit/editor-common/ui';
3
+ type PaletteDropdownProps = {
4
+ popupsMountPoint?: HTMLElement;
5
+ popupsBoundariesElement?: HTMLElement;
6
+ popupsScrollableElement?: HTMLElement;
7
+ isOpen: boolean;
8
+ activeColor: string | null;
9
+ trigger: React.ReactElement;
10
+ onColorChange: (color: string) => void;
11
+ isOpenedByKeyboard: boolean;
12
+ } & WithOutsideClickProps;
13
+ export declare const PaletteDropdown: (props: PaletteDropdownProps) => JSX.Element;
14
+ export {};
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import { type ToolbarButtonRef } from '@atlaskit/editor-common/ui-menu';
4
+ import type { HighlightPlugin } from '../../plugin';
5
+ type UseDropdownEventArgs = {
6
+ setIsDropdownOpen: (isOpen: boolean) => void;
7
+ isDropdownOpen: boolean;
8
+ pluginInjectionApi: ExtractInjectionAPI<HighlightPlugin> | undefined;
9
+ toolbarItemRef: React.RefObject<ToolbarButtonRef>;
10
+ };
11
+ export declare const useDropdownEvents: (args: UseDropdownEventArgs) => {
12
+ handleClick: () => void;
13
+ handleKeyDown: (event: React.KeyboardEvent) => void;
14
+ handleClickOutside: () => void;
15
+ handleEscapeKeydown: () => void;
16
+ handleColorChange: (color: string) => void;
17
+ isOpenedByKeyboard: boolean;
18
+ };
19
+ export {};