@atlaskit/editor-plugin-text-color 11.0.11 → 11.0.12

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,14 @@
1
1
  # @atlaskit/editor-plugin-text-color
2
2
 
3
+ ## 11.0.12
4
+
5
+ ### Patch Changes
6
+
7
+ - [`94d24f07a0482`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/94d24f07a0482) -
8
+ [ux] [EDITOR-7451] keep color palette open after applying text or highlight changes or clearing
9
+ the text color
10
+ - Updated dependencies
11
+
3
12
  ## 11.0.11
4
13
 
5
14
  ### Patch Changes
@@ -17,6 +17,7 @@ var _toolbar = require("@atlaskit/editor-common/toolbar");
17
17
  var _uiColor = require("@atlaskit/editor-common/ui-color");
18
18
  var _editorToolbar = require("@atlaskit/editor-toolbar");
19
19
  var _compiled = require("@atlaskit/primitives/compiled");
20
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
20
21
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
21
22
  var styles = {
22
23
  removeColorButton: "_2rko12b0 _195gv77o _189ee4h9 _1dqonqa1 _1h6d1l7x _19pk12x7"
@@ -51,7 +52,9 @@ var RemoveColorMenuItem = exports.RemoveColorMenuItem = function RemoveColorMenu
51
52
  });
52
53
  return tr;
53
54
  });
54
- closeMenu === null || closeMenu === void 0 || closeMenu(event);
55
+ if (!(0, _expValEquals.expValEquals)('platform_editor_lovability_text_bg_color', 'isEnabled', true)) {
56
+ closeMenu === null || closeMenu === void 0 || closeMenu(event);
57
+ }
55
58
  };
56
59
  return /*#__PURE__*/React.createElement("div", {
57
60
  className: (0, _runtime.ax)([styles.removeColorButton])
@@ -86,8 +86,25 @@ var TextColorHighlightMenu = exports.TextColorHighlightMenu = function TextColor
86
86
  });
87
87
  }
88
88
  }, [api === null || api === void 0 || (_api$textColor2 = api.textColor) === null || _api$textColor2 === void 0 ? void 0 : _api$textColor2.commands, api === null || api === void 0 ? void 0 : api.core.actions]);
89
+
90
+ // use isPaletteOpenRef to "close" the palette on unmount, and not on state changes
91
+ var isPaletteOpenRef = (0, _react.useRef)(isPaletteOpen);
92
+ isPaletteOpenRef.current = isPaletteOpen;
93
+ (0, _react.useEffect)(function () {
94
+ return function () {
95
+ if ((0, _expValEquals.expValEquals)('platform_editor_lovability_text_bg_color', 'isEnabled', true)) {
96
+ if (isPaletteOpenRef.current) {
97
+ setIsPaletteOpen(false);
98
+ }
99
+ }
100
+ };
101
+ // eslint-disable-next-line react-hooks/exhaustive-deps
102
+ }, []);
89
103
  (0, _react.useEffect)(function () {
90
104
  return function () {
105
+ if ((0, _expValEquals.expValEquals)('platform_editor_lovability_text_bg_color', 'isEnabled', true)) {
106
+ return;
107
+ }
91
108
  if (isPaletteOpen) {
92
109
  setIsPaletteOpen(false);
93
110
  }
@@ -19,6 +19,7 @@ var _editorPalette = require("@atlaskit/editor-palette");
19
19
  var _editorToolbar = require("@atlaskit/editor-toolbar");
20
20
  var _heading = _interopRequireDefault(require("@atlaskit/heading"));
21
21
  var _compiled = require("@atlaskit/primitives/compiled");
22
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
22
23
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
23
24
  var styles = {
24
25
  container: "_zulp12x7"
@@ -48,7 +49,9 @@ function TextColorMenuItem(_ref) {
48
49
  }
49
50
  if (api !== null && api !== void 0 && (_api$textColor = api.textColor) !== null && _api$textColor !== void 0 && (_api$textColor = _api$textColor.actions) !== null && _api$textColor !== void 0 && _api$textColor.changeColor) {
50
51
  api.textColor.actions.changeColor(color, (0, _toolbar.getInputMethodFromParentKeys)(parents))(editorView.state, editorView.dispatch);
51
- closeMenu === null || closeMenu === void 0 || closeMenu(event);
52
+ if (!(0, _expValEquals.expValEquals)('platform_editor_lovability_text_bg_color', 'isEnabled', true)) {
53
+ closeMenu === null || closeMenu === void 0 || closeMenu(event);
54
+ }
52
55
  }
53
56
  }, [editorView === null || editorView === void 0 ? void 0 : editorView.state, editorView === null || editorView === void 0 ? void 0 : editorView.dispatch, api === null || api === void 0 ? void 0 : api.textColor.actions, parents, closeMenu]);
54
57
  var _useIntl = (0, _reactIntl.useIntl)(),
@@ -9,6 +9,7 @@ import { getInputMethodFromParentKeys } from '@atlaskit/editor-common/toolbar';
9
9
  import { REMOVE_HIGHLIGHT_COLOR } from '@atlaskit/editor-common/ui-color';
10
10
  import { useToolbarDropdownMenu } from '@atlaskit/editor-toolbar';
11
11
  import { Text } from '@atlaskit/primitives/compiled';
12
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
12
13
  const styles = {
13
14
  removeColorButton: "_2rko12b0 _195gv77o _189ee4h9 _1dqonqa1 _1h6d1l7x _19pk12x7"
14
15
  };
@@ -45,7 +46,9 @@ export const RemoveColorMenuItem = ({
45
46
  });
46
47
  return tr;
47
48
  });
48
- closeMenu === null || closeMenu === void 0 ? void 0 : closeMenu(event);
49
+ if (!expValEquals('platform_editor_lovability_text_bg_color', 'isEnabled', true)) {
50
+ closeMenu === null || closeMenu === void 0 ? void 0 : closeMenu(event);
51
+ }
49
52
  };
50
53
  return /*#__PURE__*/React.createElement("div", {
51
54
  className: ax([styles.removeColorButton])
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useEffect } from 'react';
1
+ import React, { useCallback, useEffect, useRef } from 'react';
2
2
  import { useIntl } from 'react-intl';
3
3
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
4
  import { toggleHighlightPalette, ToolTipContent } from '@atlaskit/editor-common/keymaps';
@@ -81,8 +81,25 @@ export const TextColorHighlightMenu = ({
81
81
  });
82
82
  }
83
83
  }, [api === null || api === void 0 ? void 0 : (_api$textColor2 = api.textColor) === null || _api$textColor2 === void 0 ? void 0 : _api$textColor2.commands, api === null || api === void 0 ? void 0 : api.core.actions]);
84
+
85
+ // use isPaletteOpenRef to "close" the palette on unmount, and not on state changes
86
+ const isPaletteOpenRef = useRef(isPaletteOpen);
87
+ isPaletteOpenRef.current = isPaletteOpen;
84
88
  useEffect(() => {
85
89
  return () => {
90
+ if (expValEquals('platform_editor_lovability_text_bg_color', 'isEnabled', true)) {
91
+ if (isPaletteOpenRef.current) {
92
+ setIsPaletteOpen(false);
93
+ }
94
+ }
95
+ };
96
+ // eslint-disable-next-line react-hooks/exhaustive-deps
97
+ }, []);
98
+ useEffect(() => {
99
+ return () => {
100
+ if (expValEquals('platform_editor_lovability_text_bg_color', 'isEnabled', true)) {
101
+ return;
102
+ }
86
103
  if (isPaletteOpen) {
87
104
  setIsPaletteOpen(false);
88
105
  }
@@ -11,6 +11,7 @@ import { hexToEditorTextPaletteColor } from '@atlaskit/editor-palette';
11
11
  import { ColorPalette, useToolbarDropdownMenu } from '@atlaskit/editor-toolbar';
12
12
  import Heading from '@atlaskit/heading';
13
13
  import { Stack } from '@atlaskit/primitives/compiled';
14
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
14
15
  const styles = {
15
16
  container: "_zulp12x7"
16
17
  };
@@ -42,7 +43,9 @@ export function TextColorMenuItem({
42
43
  }
43
44
  if (api !== null && api !== void 0 && (_api$textColor = api.textColor) !== null && _api$textColor !== void 0 && (_api$textColor$action = _api$textColor.actions) !== null && _api$textColor$action !== void 0 && _api$textColor$action.changeColor) {
44
45
  api.textColor.actions.changeColor(color, getInputMethodFromParentKeys(parents))(editorView.state, editorView.dispatch);
45
- closeMenu === null || closeMenu === void 0 ? void 0 : closeMenu(event);
46
+ if (!expValEquals('platform_editor_lovability_text_bg_color', 'isEnabled', true)) {
47
+ closeMenu === null || closeMenu === void 0 ? void 0 : closeMenu(event);
48
+ }
46
49
  }
47
50
  }, [editorView === null || editorView === void 0 ? void 0 : editorView.state, editorView === null || editorView === void 0 ? void 0 : editorView.dispatch, api === null || api === void 0 ? void 0 : api.textColor.actions, parents, closeMenu]);
48
51
  const {
@@ -9,6 +9,7 @@ import { getInputMethodFromParentKeys } from '@atlaskit/editor-common/toolbar';
9
9
  import { REMOVE_HIGHLIGHT_COLOR } from '@atlaskit/editor-common/ui-color';
10
10
  import { useToolbarDropdownMenu } from '@atlaskit/editor-toolbar';
11
11
  import { Text } from '@atlaskit/primitives/compiled';
12
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
12
13
  var styles = {
13
14
  removeColorButton: "_2rko12b0 _195gv77o _189ee4h9 _1dqonqa1 _1h6d1l7x _19pk12x7"
14
15
  };
@@ -42,7 +43,9 @@ export var RemoveColorMenuItem = function RemoveColorMenuItem(_ref) {
42
43
  });
43
44
  return tr;
44
45
  });
45
- closeMenu === null || closeMenu === void 0 || closeMenu(event);
46
+ if (!expValEquals('platform_editor_lovability_text_bg_color', 'isEnabled', true)) {
47
+ closeMenu === null || closeMenu === void 0 || closeMenu(event);
48
+ }
46
49
  };
47
50
  return /*#__PURE__*/React.createElement("div", {
48
51
  className: ax([styles.removeColorButton])
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useEffect } from 'react';
1
+ import React, { useCallback, useEffect, useRef } from 'react';
2
2
  import { useIntl } from 'react-intl';
3
3
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
4
  import { toggleHighlightPalette, ToolTipContent } from '@atlaskit/editor-common/keymaps';
@@ -78,8 +78,25 @@ export var TextColorHighlightMenu = function TextColorHighlightMenu(_ref) {
78
78
  });
79
79
  }
80
80
  }, [api === null || api === void 0 || (_api$textColor2 = api.textColor) === null || _api$textColor2 === void 0 ? void 0 : _api$textColor2.commands, api === null || api === void 0 ? void 0 : api.core.actions]);
81
+
82
+ // use isPaletteOpenRef to "close" the palette on unmount, and not on state changes
83
+ var isPaletteOpenRef = useRef(isPaletteOpen);
84
+ isPaletteOpenRef.current = isPaletteOpen;
81
85
  useEffect(function () {
82
86
  return function () {
87
+ if (expValEquals('platform_editor_lovability_text_bg_color', 'isEnabled', true)) {
88
+ if (isPaletteOpenRef.current) {
89
+ setIsPaletteOpen(false);
90
+ }
91
+ }
92
+ };
93
+ // eslint-disable-next-line react-hooks/exhaustive-deps
94
+ }, []);
95
+ useEffect(function () {
96
+ return function () {
97
+ if (expValEquals('platform_editor_lovability_text_bg_color', 'isEnabled', true)) {
98
+ return;
99
+ }
83
100
  if (isPaletteOpen) {
84
101
  setIsPaletteOpen(false);
85
102
  }
@@ -11,6 +11,7 @@ import { hexToEditorTextPaletteColor } from '@atlaskit/editor-palette';
11
11
  import { ColorPalette, useToolbarDropdownMenu } from '@atlaskit/editor-toolbar';
12
12
  import Heading from '@atlaskit/heading';
13
13
  import { Stack } from '@atlaskit/primitives/compiled';
14
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
14
15
  var styles = {
15
16
  container: "_zulp12x7"
16
17
  };
@@ -39,7 +40,9 @@ export function TextColorMenuItem(_ref) {
39
40
  }
40
41
  if (api !== null && api !== void 0 && (_api$textColor = api.textColor) !== null && _api$textColor !== void 0 && (_api$textColor = _api$textColor.actions) !== null && _api$textColor !== void 0 && _api$textColor.changeColor) {
41
42
  api.textColor.actions.changeColor(color, getInputMethodFromParentKeys(parents))(editorView.state, editorView.dispatch);
42
- closeMenu === null || closeMenu === void 0 || closeMenu(event);
43
+ if (!expValEquals('platform_editor_lovability_text_bg_color', 'isEnabled', true)) {
44
+ closeMenu === null || closeMenu === void 0 || closeMenu(event);
45
+ }
43
46
  }
44
47
  }, [editorView === null || editorView === void 0 ? void 0 : editorView.state, editorView === null || editorView === void 0 ? void 0 : editorView.dispatch, api === null || api === void 0 ? void 0 : api.textColor.actions, parents, closeMenu]);
45
48
  var _useIntl = useIntl(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-text-color",
3
- "version": "11.0.11",
3
+ "version": "11.0.12",
4
4
  "description": "Text color plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,7 +29,7 @@
29
29
  ],
30
30
  "atlaskit:src": "src/index.ts",
31
31
  "dependencies": {
32
- "@atlaskit/adf-schema": "^53.0.0",
32
+ "@atlaskit/adf-schema": "^54.0.0",
33
33
  "@atlaskit/button": "^23.11.0",
34
34
  "@atlaskit/css": "^0.19.0",
35
35
  "@atlaskit/editor-palette": "^2.2.0",
@@ -48,13 +48,13 @@
48
48
  "@atlaskit/platform-feature-flags": "^1.1.0",
49
49
  "@atlaskit/platform-feature-flags-react": "^0.5.0",
50
50
  "@atlaskit/primitives": "^19.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^98.0.0",
51
+ "@atlaskit/tmp-editor-statsig": "^99.0.0",
52
52
  "@atlaskit/tokens": "^13.3.0",
53
53
  "@babel/runtime": "^7.0.0",
54
54
  "@emotion/react": "^11.7.1"
55
55
  },
56
56
  "peerDependencies": {
57
- "@atlaskit/editor-common": "^115.12.0",
57
+ "@atlaskit/editor-common": "^115.13.0",
58
58
  "react": "^18.2.0",
59
59
  "react-dom": "^18.2.0",
60
60
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"