@atlaskit/editor-plugin-highlight 1.9.0 → 1.10.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/editor-plugin-highlight
2
2
 
3
+ ## 1.10.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 1.10.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#114903](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/114903)
14
+ [`8f2977cd60ba0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8f2977cd60ba0) -
15
+ [ux] [ED-23063] Adds optional floating toolbar button for text highlighting to the selection
16
+ toolbar (disabled by default)
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 1.9.0
4
23
 
5
24
  ### Minor Changes
@@ -10,11 +10,13 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
10
  var _commands = require("./commands");
11
11
  var _keymap = require("./pm-plugins/keymap");
12
12
  var _main = require("./pm-plugins/main");
13
+ var _FloatingToolbarHighlightColor = require("./ui/FloatingToolbarHighlightColor");
13
14
  var _PrimaryToolbarHighlightColor = require("./ui/PrimaryToolbarHighlightColor");
14
15
  var _ToolbarHighlightColor = require("./ui/ToolbarHighlightColor");
15
16
  var highlightPlugin = exports.highlightPlugin = function highlightPlugin(_ref) {
16
17
  var _api$analytics;
17
- var api = _ref.api;
18
+ var api = _ref.api,
19
+ options = _ref.config;
18
20
  var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
19
21
  var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
20
22
  var popupsMountPoint = _ref2.popupsMountPoint,
@@ -76,6 +78,28 @@ var highlightPlugin = exports.highlightPlugin = function highlightPlugin(_ref) {
76
78
  component: primaryToolbarComponent
77
79
  }));
78
80
  },
81
+ pluginsOptions: {
82
+ selectionToolbar: function selectionToolbar() {
83
+ if (!(options !== null && options !== void 0 && options.textHighlightingFloatingToolbarExperiment) || !(0, _platformFeatureFlags.getBooleanFF)('platform.editor.enable-selection-toolbar_ucdwd')) {
84
+ return;
85
+ }
86
+ var toolbarCustom = {
87
+ type: 'custom',
88
+ render: function render(_view, _idx, dispatchAnalyticsEvent) {
89
+ return /*#__PURE__*/_react.default.createElement(_FloatingToolbarHighlightColor.FloatingToolbarHighlightColorWithIntl, {
90
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
91
+ pluginInjectionApi: api
92
+ });
93
+ },
94
+ fallback: []
95
+ };
96
+ return {
97
+ rank: -9,
98
+ isToolbarAbove: true,
99
+ items: [toolbarCustom]
100
+ };
101
+ }
102
+ },
79
103
  primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
80
104
  };
81
105
  };
@@ -21,13 +21,10 @@ var _PaletteDropdown = require("./shared/PaletteDropdown");
21
21
  var _useDropdownEvents2 = require("./shared/useDropdownEvents");
22
22
  /** @jsx jsx */
23
23
 
24
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
25
+
24
26
  var FloatingToolbarHighlightColor = function FloatingToolbarHighlightColor(_ref) {
25
- var popupsMountPoint = _ref.popupsMountPoint,
26
- popupsBoundariesElement = _ref.popupsBoundariesElement,
27
- popupsScrollableElement = _ref.popupsScrollableElement,
28
- isToolbarReducedSpacing = _ref.isToolbarReducedSpacing,
29
- disabled = _ref.disabled,
30
- pluginInjectionApi = _ref.pluginInjectionApi,
27
+ var pluginInjectionApi = _ref.pluginInjectionApi,
31
28
  formatMessage = _ref.intl.formatMessage;
32
29
  var toolbarItemRef = (0, _react.useRef)(null);
33
30
  var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['highlight']),
@@ -61,15 +58,12 @@ var FloatingToolbarHighlightColor = function FloatingToolbarHighlightColor(_ref)
61
58
  return (0, _react2.jsx)(_primitives.Flex, {
62
59
  alignItems: "center"
63
60
  }, (0, _react2.jsx)(_PaletteDropdown.PaletteDropdown, {
64
- popupsMountPoint: popupsMountPoint,
65
- popupsBoundariesElement: popupsBoundariesElement,
66
- popupsScrollableElement: popupsScrollableElement,
67
61
  isOpen: isDropdownOpen && !highlightState.disabled,
68
62
  activeColor: highlightState.activeColor,
69
63
  trigger: (0, _react2.jsx)(_uiMenu.ToolbarButton, {
70
64
  buttonId: _uiMenu.TOOLBAR_BUTTON.BACKGROUND_COLOR,
71
- spacing: isToolbarReducedSpacing ? 'none' : 'default',
72
- disabled: disabled || highlightState.disabled,
65
+ spacing: 'default',
66
+ disabled: highlightState.disabled,
73
67
  selected: isDropdownOpen,
74
68
  "aria-label": toolbarButtonLabel,
75
69
  "aria-expanded": isDropdownOpen,
@@ -86,7 +80,7 @@ var FloatingToolbarHighlightColor = function FloatingToolbarHighlightColor(_ref)
86
80
  }, (0, _react2.jsx)(_chevronDown.default, {
87
81
  label: ""
88
82
  })))
89
- }),
83
+ }, formatMessage(_messages.highlightMessages.highlightFloatingToolbar)),
90
84
  onColorChange: function onColorChange(color) {
91
85
  return handleColorChange(color);
92
86
  },
@@ -3,10 +3,12 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
3
3
  import { changeColor } from './commands';
4
4
  import { keymapPlugin } from './pm-plugins/keymap';
5
5
  import { createPlugin, highlightPluginKey } from './pm-plugins/main';
6
+ import { FloatingToolbarHighlightColorWithIntl as FloatingToolbarHighlightColor } from './ui/FloatingToolbarHighlightColor';
6
7
  import { PrimaryToolbarHighlightColorWithIntl as PrimaryToolbarHighlightColor } from './ui/PrimaryToolbarHighlightColor';
7
8
  import { ToolbarHighlightColorWithIntl as ToolbarHighlightColor } from './ui/ToolbarHighlightColor';
8
9
  export const highlightPlugin = ({
9
- api
10
+ api,
11
+ config: options
10
12
  }) => {
11
13
  var _api$analytics;
12
14
  const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
@@ -63,6 +65,26 @@ export const highlightPlugin = ({
63
65
  component: primaryToolbarComponent
64
66
  }));
65
67
  },
68
+ pluginsOptions: {
69
+ selectionToolbar() {
70
+ if (!(options !== null && options !== void 0 && options.textHighlightingFloatingToolbarExperiment) || !getBooleanFF('platform.editor.enable-selection-toolbar_ucdwd')) {
71
+ return;
72
+ }
73
+ const toolbarCustom = {
74
+ type: 'custom',
75
+ render: (_view, _idx, dispatchAnalyticsEvent) => /*#__PURE__*/React.createElement(FloatingToolbarHighlightColor, {
76
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
77
+ pluginInjectionApi: api
78
+ }),
79
+ fallback: []
80
+ };
81
+ return {
82
+ rank: -9,
83
+ isToolbarAbove: true,
84
+ items: [toolbarCustom]
85
+ };
86
+ }
87
+ },
66
88
  primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
67
89
  };
68
90
  };
@@ -1,5 +1,7 @@
1
1
  /** @jsx jsx */
2
2
  import { useRef, useState } from 'react';
3
+
4
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
3
5
  import { jsx } from '@emotion/react';
4
6
  import { injectIntl } from 'react-intl-next';
5
7
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
@@ -13,11 +15,6 @@ import { EditorHighlightIcon } from './shared/EditorHighlightIcon';
13
15
  import { PaletteDropdown } from './shared/PaletteDropdown';
14
16
  import { useDropdownEvents } from './shared/useDropdownEvents';
15
17
  const FloatingToolbarHighlightColor = ({
16
- popupsMountPoint,
17
- popupsBoundariesElement,
18
- popupsScrollableElement,
19
- isToolbarReducedSpacing,
20
- disabled,
21
18
  pluginInjectionApi,
22
19
  intl: {
23
20
  formatMessage
@@ -54,15 +51,12 @@ const FloatingToolbarHighlightColor = ({
54
51
  return jsx(Flex, {
55
52
  alignItems: "center"
56
53
  }, jsx(PaletteDropdown, {
57
- popupsMountPoint: popupsMountPoint,
58
- popupsBoundariesElement: popupsBoundariesElement,
59
- popupsScrollableElement: popupsScrollableElement,
60
54
  isOpen: isDropdownOpen && !highlightState.disabled,
61
55
  activeColor: highlightState.activeColor,
62
56
  trigger: jsx(ToolbarButton, {
63
57
  buttonId: TOOLBAR_BUTTON.BACKGROUND_COLOR,
64
- spacing: isToolbarReducedSpacing ? 'none' : 'default',
65
- disabled: disabled || highlightState.disabled,
58
+ spacing: 'default',
59
+ disabled: highlightState.disabled,
66
60
  selected: isDropdownOpen,
67
61
  "aria-label": toolbarButtonLabel,
68
62
  "aria-expanded": isDropdownOpen,
@@ -79,7 +73,7 @@ const FloatingToolbarHighlightColor = ({
79
73
  }, jsx(ExpandIcon, {
80
74
  label: ""
81
75
  })))
82
- }),
76
+ }, formatMessage(messages.highlightFloatingToolbar)),
83
77
  onColorChange: color => handleColorChange(color),
84
78
  isOpenedByKeyboard: isOpenedByKeyboard,
85
79
  handleClickOutside: handleClickOutside,
@@ -3,11 +3,13 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
3
3
  import { changeColor } from './commands';
4
4
  import { keymapPlugin } from './pm-plugins/keymap';
5
5
  import { createPlugin, highlightPluginKey } from './pm-plugins/main';
6
+ import { FloatingToolbarHighlightColorWithIntl as FloatingToolbarHighlightColor } from './ui/FloatingToolbarHighlightColor';
6
7
  import { PrimaryToolbarHighlightColorWithIntl as PrimaryToolbarHighlightColor } from './ui/PrimaryToolbarHighlightColor';
7
8
  import { ToolbarHighlightColorWithIntl as ToolbarHighlightColor } from './ui/ToolbarHighlightColor';
8
9
  export var highlightPlugin = function highlightPlugin(_ref) {
9
10
  var _api$analytics;
10
- var api = _ref.api;
11
+ var api = _ref.api,
12
+ options = _ref.config;
11
13
  var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
12
14
  var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
13
15
  var popupsMountPoint = _ref2.popupsMountPoint,
@@ -69,6 +71,28 @@ export var highlightPlugin = function highlightPlugin(_ref) {
69
71
  component: primaryToolbarComponent
70
72
  }));
71
73
  },
74
+ pluginsOptions: {
75
+ selectionToolbar: function selectionToolbar() {
76
+ if (!(options !== null && options !== void 0 && options.textHighlightingFloatingToolbarExperiment) || !getBooleanFF('platform.editor.enable-selection-toolbar_ucdwd')) {
77
+ return;
78
+ }
79
+ var toolbarCustom = {
80
+ type: 'custom',
81
+ render: function render(_view, _idx, dispatchAnalyticsEvent) {
82
+ return /*#__PURE__*/React.createElement(FloatingToolbarHighlightColor, {
83
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
84
+ pluginInjectionApi: api
85
+ });
86
+ },
87
+ fallback: []
88
+ };
89
+ return {
90
+ rank: -9,
91
+ isToolbarAbove: true,
92
+ items: [toolbarCustom]
93
+ };
94
+ }
95
+ },
72
96
  primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
73
97
  };
74
98
  };
@@ -1,6 +1,8 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  /** @jsx jsx */
3
3
  import { 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';
@@ -14,12 +16,7 @@ import { EditorHighlightIcon } from './shared/EditorHighlightIcon';
14
16
  import { PaletteDropdown } from './shared/PaletteDropdown';
15
17
  import { useDropdownEvents } from './shared/useDropdownEvents';
16
18
  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,
19
+ var pluginInjectionApi = _ref.pluginInjectionApi,
23
20
  formatMessage = _ref.intl.formatMessage;
24
21
  var toolbarItemRef = useRef(null);
25
22
  var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['highlight']),
@@ -53,15 +50,12 @@ var FloatingToolbarHighlightColor = function FloatingToolbarHighlightColor(_ref)
53
50
  return jsx(Flex, {
54
51
  alignItems: "center"
55
52
  }, jsx(PaletteDropdown, {
56
- popupsMountPoint: popupsMountPoint,
57
- popupsBoundariesElement: popupsBoundariesElement,
58
- popupsScrollableElement: popupsScrollableElement,
59
53
  isOpen: isDropdownOpen && !highlightState.disabled,
60
54
  activeColor: highlightState.activeColor,
61
55
  trigger: jsx(ToolbarButton, {
62
56
  buttonId: TOOLBAR_BUTTON.BACKGROUND_COLOR,
63
- spacing: isToolbarReducedSpacing ? 'none' : 'default',
64
- disabled: disabled || highlightState.disabled,
57
+ spacing: 'default',
58
+ disabled: highlightState.disabled,
65
59
  selected: isDropdownOpen,
66
60
  "aria-label": toolbarButtonLabel,
67
61
  "aria-expanded": isDropdownOpen,
@@ -78,7 +72,7 @@ var FloatingToolbarHighlightColor = function FloatingToolbarHighlightColor(_ref)
78
72
  }, jsx(ExpandIcon, {
79
73
  label: ""
80
74
  })))
81
- }),
75
+ }, formatMessage(messages.highlightFloatingToolbar)),
82
76
  onColorChange: function onColorChange(color) {
83
77
  return handleColorChange(color);
84
78
  },
@@ -4,7 +4,11 @@ import type { BackgroundColorPlugin } from '@atlaskit/editor-plugin-background-c
4
4
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
5
5
  import type { TextFormattingPlugin } from '@atlaskit/editor-plugin-text-formatting';
6
6
  import type { HighlightPluginState } from './pm-plugins/main';
7
+ export type HighlightPluginOptions = {
8
+ textHighlightingFloatingToolbarExperiment?: boolean;
9
+ };
7
10
  export type HighlightPlugin = NextEditorPlugin<'highlight', {
11
+ pluginConfiguration?: HighlightPluginOptions;
8
12
  dependencies: [
9
13
  BackgroundColorPlugin,
10
14
  OptionalPlugin<AnalyticsPlugin>,
@@ -4,20 +4,10 @@ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
4
4
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
5
  import type { HighlightPlugin } from '../plugin';
6
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
7
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
13
8
  pluginInjectionApi: ExtractInjectionAPI<HighlightPlugin> | undefined;
14
9
  } & WrappedComponentProps>> & {
15
10
  WrappedComponent: import("react").ComponentType<{
16
- popupsMountPoint?: HTMLElement | undefined;
17
- popupsBoundariesElement?: HTMLElement | undefined;
18
- popupsScrollableElement?: HTMLElement | undefined;
19
- disabled: boolean;
20
- isToolbarReducedSpacing: boolean;
21
11
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
22
12
  pluginInjectionApi: ExtractInjectionAPI<HighlightPlugin> | undefined;
23
13
  } & WrappedComponentProps>;
@@ -4,7 +4,11 @@ import type { BackgroundColorPlugin } from '@atlaskit/editor-plugin-background-c
4
4
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
5
5
  import type { TextFormattingPlugin } from '@atlaskit/editor-plugin-text-formatting';
6
6
  import type { HighlightPluginState } from './pm-plugins/main';
7
+ export type HighlightPluginOptions = {
8
+ textHighlightingFloatingToolbarExperiment?: boolean;
9
+ };
7
10
  export type HighlightPlugin = NextEditorPlugin<'highlight', {
11
+ pluginConfiguration?: HighlightPluginOptions;
8
12
  dependencies: [
9
13
  BackgroundColorPlugin,
10
14
  OptionalPlugin<AnalyticsPlugin>,
@@ -4,20 +4,10 @@ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
4
4
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
5
  import type { HighlightPlugin } from '../plugin';
6
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
7
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
13
8
  pluginInjectionApi: ExtractInjectionAPI<HighlightPlugin> | undefined;
14
9
  } & WrappedComponentProps>> & {
15
10
  WrappedComponent: import("react").ComponentType<{
16
- popupsMountPoint?: HTMLElement | undefined;
17
- popupsBoundariesElement?: HTMLElement | undefined;
18
- popupsScrollableElement?: HTMLElement | undefined;
19
- disabled: boolean;
20
- isToolbarReducedSpacing: boolean;
21
11
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
22
12
  pluginInjectionApi: ExtractInjectionAPI<HighlightPlugin> | undefined;
23
13
  } & WrappedComponentProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-highlight",
3
- "version": "1.9.0",
3
+ "version": "1.10.1",
4
4
  "description": "Highlight plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -38,18 +38,18 @@
38
38
  ".": "./src/index.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@atlaskit/editor-common": "^82.9.0",
41
+ "@atlaskit/editor-common": "^83.0.0",
42
42
  "@atlaskit/editor-palette": "1.6.0",
43
- "@atlaskit/editor-plugin-analytics": "^1.2.0",
44
- "@atlaskit/editor-plugin-background-color": "^1.1.0",
43
+ "@atlaskit/editor-plugin-analytics": "^1.3.0",
44
+ "@atlaskit/editor-plugin-background-color": "^1.2.0",
45
45
  "@atlaskit/editor-plugin-primary-toolbar": "^1.1.0",
46
- "@atlaskit/editor-plugin-text-formatting": "^1.7.0",
46
+ "@atlaskit/editor-plugin-text-formatting": "^1.8.0",
47
47
  "@atlaskit/editor-prosemirror": "4.0.1",
48
48
  "@atlaskit/editor-shared-styles": "^2.12.0",
49
49
  "@atlaskit/editor-tables": "^2.7.4",
50
- "@atlaskit/icon": "^22.4.0",
50
+ "@atlaskit/icon": "^22.5.0",
51
51
  "@atlaskit/platform-feature-flags": "^0.2.0",
52
- "@atlaskit/primitives": "^8.0.0",
52
+ "@atlaskit/primitives": "^9.0.0",
53
53
  "@babel/runtime": "^7.0.0",
54
54
  "@emotion/react": "^11.7.1"
55
55
  },
@@ -58,7 +58,7 @@
58
58
  "react-intl-next": "npm:react-intl@^5.18.1"
59
59
  },
60
60
  "devDependencies": {
61
- "@atlaskit/tokens": "^1.51.0",
61
+ "@atlaskit/tokens": "^1.53.0",
62
62
  "typescript": "~5.4.2"
63
63
  },
64
64
  "techstack": {
@@ -110,6 +110,9 @@
110
110
  },
111
111
  "platform.editor.refactor-highlight-toolbar_mo0pj": {
112
112
  "type": "boolean"
113
+ },
114
+ "platform.editor.enable-selection-toolbar_ucdwd": {
115
+ "type": "boolean"
113
116
  }
114
117
  }
115
118
  }