@atlaskit/editor-plugin-text-color 5.2.0 → 5.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-text-color
2
2
 
3
+ ## 5.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`66414cddf2784`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/66414cddf2784) -
8
+ Add new platform_editor_toolbar_aifc_fix_editor_view experiment, replace destructured objects with
9
+ direct property access
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 5.2.0
4
16
 
5
17
  ### Minor Changes
@@ -40,6 +40,7 @@ function TextColorMenuItem(_ref) {
40
40
  palette = _useSharedPluginState.palette;
41
41
  var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
42
42
  editorView = _useEditorToolbar.editorView;
43
+ // Warning! Do not destructure editorView, it will become stale
43
44
  var _ref2 = editorView !== null && editorView !== void 0 ? editorView : {
44
45
  state: null,
45
46
  dispatch: null
@@ -49,15 +50,26 @@ function TextColorMenuItem(_ref) {
49
50
  var context = (0, _editorToolbar.useToolbarDropdownMenu)();
50
51
  var closeMenu = context === null || context === void 0 ? void 0 : context.closeMenu;
51
52
  var handleTextColorChange = (0, _react.useCallback)(function (color) {
52
- var _api$textColor;
53
- if (!state || !dispatch) {
54
- return;
53
+ if ((0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true)) {
54
+ var _api$textColor;
55
+ if (!(editorView !== null && editorView !== void 0 && editorView.state) || !(editorView !== null && editorView !== void 0 && editorView.dispatch)) {
56
+ return;
57
+ }
58
+ 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) {
59
+ api.textColor.actions.changeColor(color, (0, _toolbar.getInputMethodFromParentKeys)(parents))(editorView.state, editorView.dispatch);
60
+ closeMenu === null || closeMenu === void 0 || closeMenu();
61
+ }
62
+ } else {
63
+ var _api$textColor2;
64
+ if (!state || !dispatch) {
65
+ return;
66
+ }
67
+ if (api !== null && api !== void 0 && (_api$textColor2 = api.textColor) !== null && _api$textColor2 !== void 0 && (_api$textColor2 = _api$textColor2.actions) !== null && _api$textColor2 !== void 0 && _api$textColor2.changeColor) {
68
+ api.textColor.actions.changeColor(color, (0, _toolbar.getInputMethodFromParentKeys)(parents))(state, dispatch);
69
+ closeMenu === null || closeMenu === void 0 || closeMenu();
70
+ }
55
71
  }
56
- 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) {
57
- api.textColor.actions.changeColor(color, (0, _toolbar.getInputMethodFromParentKeys)(parents))(state, dispatch);
58
- closeMenu === null || closeMenu === void 0 || closeMenu();
59
- }
60
- }, [api, state, dispatch, closeMenu, parents]);
72
+ }, [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, state, dispatch]);
61
73
  var _useIntl = (0, _reactIntlNext.useIntl)(),
62
74
  formatMessage = _useIntl.formatMessage;
63
75
  return /*#__PURE__*/_react.default.createElement(_compiled.Stack, {
@@ -34,6 +34,7 @@ export function TextColorMenuItem({
34
34
  const {
35
35
  editorView
36
36
  } = useEditorToolbar();
37
+ // Warning! Do not destructure editorView, it will become stale
37
38
  const {
38
39
  state,
39
40
  dispatch
@@ -44,15 +45,26 @@ export function TextColorMenuItem({
44
45
  const context = useToolbarDropdownMenu();
45
46
  const closeMenu = context === null || context === void 0 ? void 0 : context.closeMenu;
46
47
  const handleTextColorChange = useCallback(color => {
47
- var _api$textColor, _api$textColor$action;
48
- if (!state || !dispatch) {
49
- return;
48
+ if (expValEquals('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true)) {
49
+ var _api$textColor, _api$textColor$action;
50
+ if (!(editorView !== null && editorView !== void 0 && editorView.state) || !(editorView !== null && editorView !== void 0 && editorView.dispatch)) {
51
+ return;
52
+ }
53
+ 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) {
54
+ api.textColor.actions.changeColor(color, getInputMethodFromParentKeys(parents))(editorView.state, editorView.dispatch);
55
+ closeMenu === null || closeMenu === void 0 ? void 0 : closeMenu();
56
+ }
57
+ } else {
58
+ var _api$textColor2, _api$textColor2$actio;
59
+ if (!state || !dispatch) {
60
+ return;
61
+ }
62
+ if (api !== null && api !== void 0 && (_api$textColor2 = api.textColor) !== null && _api$textColor2 !== void 0 && (_api$textColor2$actio = _api$textColor2.actions) !== null && _api$textColor2$actio !== void 0 && _api$textColor2$actio.changeColor) {
63
+ api.textColor.actions.changeColor(color, getInputMethodFromParentKeys(parents))(state, dispatch);
64
+ closeMenu === null || closeMenu === void 0 ? void 0 : closeMenu();
65
+ }
50
66
  }
51
- 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) {
52
- api.textColor.actions.changeColor(color, getInputMethodFromParentKeys(parents))(state, dispatch);
53
- closeMenu === null || closeMenu === void 0 ? void 0 : closeMenu();
54
- }
55
- }, [api, state, dispatch, closeMenu, parents]);
67
+ }, [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, state, dispatch]);
56
68
  const {
57
69
  formatMessage
58
70
  } = useIntl();
@@ -31,6 +31,7 @@ export function TextColorMenuItem(_ref) {
31
31
  palette = _useSharedPluginState.palette;
32
32
  var _useEditorToolbar = useEditorToolbar(),
33
33
  editorView = _useEditorToolbar.editorView;
34
+ // Warning! Do not destructure editorView, it will become stale
34
35
  var _ref2 = editorView !== null && editorView !== void 0 ? editorView : {
35
36
  state: null,
36
37
  dispatch: null
@@ -40,15 +41,26 @@ export function TextColorMenuItem(_ref) {
40
41
  var context = useToolbarDropdownMenu();
41
42
  var closeMenu = context === null || context === void 0 ? void 0 : context.closeMenu;
42
43
  var handleTextColorChange = useCallback(function (color) {
43
- var _api$textColor;
44
- if (!state || !dispatch) {
45
- return;
44
+ if (expValEquals('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true)) {
45
+ var _api$textColor;
46
+ if (!(editorView !== null && editorView !== void 0 && editorView.state) || !(editorView !== null && editorView !== void 0 && editorView.dispatch)) {
47
+ return;
48
+ }
49
+ 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
+ api.textColor.actions.changeColor(color, getInputMethodFromParentKeys(parents))(editorView.state, editorView.dispatch);
51
+ closeMenu === null || closeMenu === void 0 || closeMenu();
52
+ }
53
+ } else {
54
+ var _api$textColor2;
55
+ if (!state || !dispatch) {
56
+ return;
57
+ }
58
+ if (api !== null && api !== void 0 && (_api$textColor2 = api.textColor) !== null && _api$textColor2 !== void 0 && (_api$textColor2 = _api$textColor2.actions) !== null && _api$textColor2 !== void 0 && _api$textColor2.changeColor) {
59
+ api.textColor.actions.changeColor(color, getInputMethodFromParentKeys(parents))(state, dispatch);
60
+ closeMenu === null || closeMenu === void 0 || closeMenu();
61
+ }
46
62
  }
47
- 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) {
48
- api.textColor.actions.changeColor(color, getInputMethodFromParentKeys(parents))(state, dispatch);
49
- closeMenu === null || closeMenu === void 0 || closeMenu();
50
- }
51
- }, [api, state, dispatch, closeMenu, parents]);
63
+ }, [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, state, dispatch]);
52
64
  var _useIntl = useIntl(),
53
65
  formatMessage = _useIntl.formatMessage;
54
66
  return /*#__PURE__*/React.createElement(Stack, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-text-color",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
4
4
  "description": "Text color plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -48,7 +48,7 @@
48
48
  "@atlaskit/platform-feature-flags": "^1.1.0",
49
49
  "@atlaskit/primitives": "^14.14.0",
50
50
  "@atlaskit/theme": "^21.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^12.14.0",
51
+ "@atlaskit/tmp-editor-statsig": "^12.15.0",
52
52
  "@atlaskit/tokens": "^6.3.0",
53
53
  "@babel/runtime": "^7.0.0",
54
54
  "@emotion/react": "^11.7.1"