@atlaskit/editor-plugin-block-menu 3.2.6 → 3.2.7

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,13 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 3.2.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`0ef848d2118aa`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0ef848d2118aa) -
8
+ Grey out `Turn Into` option on block menu where it is not supported
9
+ - Updated dependencies
10
+
3
11
  ## 3.2.6
4
12
 
5
13
  ### Patch Changes
@@ -61,7 +61,9 @@ var getFormatMenuComponents = function getFormatMenuComponents(api) {
61
61
  children: null
62
62
  },
63
63
  children = _ref.children;
64
- return /*#__PURE__*/_react.default.createElement(_formatMenuNested.FormatMenuComponent, null, children);
64
+ return /*#__PURE__*/_react.default.createElement(_formatMenuNested.FormatMenuComponent, {
65
+ api: api
66
+ }, children);
65
67
  }
66
68
  }, {
67
69
  type: 'block-menu-section',
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.FormatMenuComponent = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
+ var _react = _interopRequireWildcard(require("react"));
9
10
  var _reactIntlNext = require("react-intl-next");
10
11
  var _blockMenu = require("@atlaskit/editor-common/block-menu");
11
12
  var _messages = require("@atlaskit/editor-common/messages");
@@ -13,11 +14,17 @@ var _editorToolbar = require("@atlaskit/editor-toolbar");
13
14
  var _changes = _interopRequireDefault(require("@atlaskit/icon/core/changes"));
14
15
  var _chevronRight = _interopRequireDefault(require("@atlaskit/icon/core/chevron-right"));
15
16
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
+ var _checkIsFormatMenuHidden = require("./utils/checkIsFormatMenuHidden");
18
+ 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); }
16
19
  var FormatMenuComponent = exports.FormatMenuComponent = function FormatMenuComponent(_ref) {
17
- var children = _ref.children;
20
+ var api = _ref.api,
21
+ children = _ref.children;
18
22
  var _useIntl = (0, _reactIntlNext.useIntl)(),
19
23
  formatMessage = _useIntl.formatMessage;
20
24
  var text = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_patch_1') ? formatMessage(_messages.blockMenuMessages.turnInto) : formatMessage(_blockMenu.messages.turnInto);
25
+ var isDisabled = (0, _react.useMemo)(function () {
26
+ return (0, _platformFeatureFlags.fg)('platform_editor_block_menu_for_disabled_nodes') ? (0, _checkIsFormatMenuHidden.checkIsFormatMenuHidden)(api) : false;
27
+ }, [api]);
21
28
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarNestedDropdownMenu, {
22
29
  text: text,
23
30
  elemBefore: /*#__PURE__*/_react.default.createElement(_changes.default, {
@@ -26,6 +33,7 @@ var FormatMenuComponent = exports.FormatMenuComponent = function FormatMenuCompo
26
33
  elemAfter: /*#__PURE__*/_react.default.createElement(_chevronRight.default, {
27
34
  label: ""
28
35
  }),
29
- enableMaxHeight: true
36
+ enableMaxHeight: true,
37
+ isDisabled: isDisabled
30
38
  }, children);
31
39
  };
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.FormatMenuSection = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _editorToolbar = require("@atlaskit/editor-toolbar");
10
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
11
  var _checkIsFormatMenuHidden = require("./utils/checkIsFormatMenuHidden");
11
12
  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); }
12
13
  var FormatMenuSection = exports.FormatMenuSection = function FormatMenuSection(_ref) {
@@ -15,7 +16,9 @@ var FormatMenuSection = exports.FormatMenuSection = function FormatMenuSection(_
15
16
  var isFormatMenuHidden = (0, _react.useCallback)(function () {
16
17
  return (0, _checkIsFormatMenuHidden.checkIsFormatMenuHidden)(api);
17
18
  }, [api]);
18
- if (isFormatMenuHidden()) {
19
+
20
+ // When platform_editor_block_menu_for_disabled_nodes feature flag is OFF, use the original behavior (hide the menu)
21
+ if (isFormatMenuHidden() && !(0, _platformFeatureFlags.fg)('platform_editor_block_menu_for_disabled_nodes')) {
19
22
  return null;
20
23
  }
21
24
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, null, children);
@@ -49,7 +49,9 @@ const getFormatMenuComponents = api => {
49
49
  } = {
50
50
  children: null
51
51
  }) => {
52
- return /*#__PURE__*/React.createElement(FormatMenuComponent, null, children);
52
+ return /*#__PURE__*/React.createElement(FormatMenuComponent, {
53
+ api: api
54
+ }, children);
53
55
  }
54
56
  }, {
55
57
  type: 'block-menu-section',
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { messages } from '@atlaskit/editor-common/block-menu';
4
4
  import { blockMenuMessages } from '@atlaskit/editor-common/messages';
@@ -6,13 +6,18 @@ import { ToolbarNestedDropdownMenu } from '@atlaskit/editor-toolbar';
6
6
  import ChangesIcon from '@atlaskit/icon/core/changes';
7
7
  import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
+ import { checkIsFormatMenuHidden } from './utils/checkIsFormatMenuHidden';
9
10
  export const FormatMenuComponent = ({
11
+ api,
10
12
  children
11
13
  }) => {
12
14
  const {
13
15
  formatMessage
14
16
  } = useIntl();
15
17
  const text = fg('platform_editor_block_menu_patch_1') ? formatMessage(blockMenuMessages.turnInto) : formatMessage(messages.turnInto);
18
+ const isDisabled = useMemo(() => {
19
+ return fg('platform_editor_block_menu_for_disabled_nodes') ? checkIsFormatMenuHidden(api) : false;
20
+ }, [api]);
16
21
  return /*#__PURE__*/React.createElement(ToolbarNestedDropdownMenu, {
17
22
  text: text,
18
23
  elemBefore: /*#__PURE__*/React.createElement(ChangesIcon, {
@@ -21,6 +26,7 @@ export const FormatMenuComponent = ({
21
26
  elemAfter: /*#__PURE__*/React.createElement(ChevronRightIcon, {
22
27
  label: ""
23
28
  }),
24
- enableMaxHeight: true
29
+ enableMaxHeight: true,
30
+ isDisabled: isDisabled
25
31
  }, children);
26
32
  };
@@ -1,5 +1,6 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { checkIsFormatMenuHidden } from './utils/checkIsFormatMenuHidden';
4
5
  export const FormatMenuSection = ({
5
6
  children,
@@ -8,7 +9,9 @@ export const FormatMenuSection = ({
8
9
  const isFormatMenuHidden = useCallback(() => {
9
10
  return checkIsFormatMenuHidden(api);
10
11
  }, [api]);
11
- if (isFormatMenuHidden()) {
12
+
13
+ // When platform_editor_block_menu_for_disabled_nodes feature flag is OFF, use the original behavior (hide the menu)
14
+ if (isFormatMenuHidden() && !fg('platform_editor_block_menu_for_disabled_nodes')) {
12
15
  return null;
13
16
  }
14
17
  return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, children);
@@ -54,7 +54,9 @@ var getFormatMenuComponents = function getFormatMenuComponents(api) {
54
54
  children: null
55
55
  },
56
56
  children = _ref.children;
57
- return /*#__PURE__*/React.createElement(FormatMenuComponent, null, children);
57
+ return /*#__PURE__*/React.createElement(FormatMenuComponent, {
58
+ api: api
59
+ }, children);
58
60
  }
59
61
  }, {
60
62
  type: 'block-menu-section',
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { messages } from '@atlaskit/editor-common/block-menu';
4
4
  import { blockMenuMessages } from '@atlaskit/editor-common/messages';
@@ -6,11 +6,16 @@ import { ToolbarNestedDropdownMenu } from '@atlaskit/editor-toolbar';
6
6
  import ChangesIcon from '@atlaskit/icon/core/changes';
7
7
  import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
+ import { checkIsFormatMenuHidden } from './utils/checkIsFormatMenuHidden';
9
10
  export var FormatMenuComponent = function FormatMenuComponent(_ref) {
10
- var children = _ref.children;
11
+ var api = _ref.api,
12
+ children = _ref.children;
11
13
  var _useIntl = useIntl(),
12
14
  formatMessage = _useIntl.formatMessage;
13
15
  var text = fg('platform_editor_block_menu_patch_1') ? formatMessage(blockMenuMessages.turnInto) : formatMessage(messages.turnInto);
16
+ var isDisabled = useMemo(function () {
17
+ return fg('platform_editor_block_menu_for_disabled_nodes') ? checkIsFormatMenuHidden(api) : false;
18
+ }, [api]);
14
19
  return /*#__PURE__*/React.createElement(ToolbarNestedDropdownMenu, {
15
20
  text: text,
16
21
  elemBefore: /*#__PURE__*/React.createElement(ChangesIcon, {
@@ -19,6 +24,7 @@ export var FormatMenuComponent = function FormatMenuComponent(_ref) {
19
24
  elemAfter: /*#__PURE__*/React.createElement(ChevronRightIcon, {
20
25
  label: ""
21
26
  }),
22
- enableMaxHeight: true
27
+ enableMaxHeight: true,
28
+ isDisabled: isDisabled
23
29
  }, children);
24
30
  };
@@ -1,5 +1,6 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { checkIsFormatMenuHidden } from './utils/checkIsFormatMenuHidden';
4
5
  export var FormatMenuSection = function FormatMenuSection(_ref) {
5
6
  var children = _ref.children,
@@ -7,7 +8,9 @@ export var FormatMenuSection = function FormatMenuSection(_ref) {
7
8
  var isFormatMenuHidden = useCallback(function () {
8
9
  return checkIsFormatMenuHidden(api);
9
10
  }, [api]);
10
- if (isFormatMenuHidden()) {
11
+
12
+ // When platform_editor_block_menu_for_disabled_nodes feature flag is OFF, use the original behavior (hide the menu)
13
+ if (isFormatMenuHidden() && !fg('platform_editor_block_menu_for_disabled_nodes')) {
11
14
  return null;
12
15
  }
13
16
  return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, children);
@@ -1,4 +1,7 @@
1
1
  import React from 'react';
2
- export declare const FormatMenuComponent: ({ children }: {
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { BlockMenuPlugin } from '../blockMenuPluginType';
4
+ export declare const FormatMenuComponent: ({ api, children, }: {
5
+ api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
3
6
  children: React.ReactNode;
4
7
  }) => React.JSX.Element;
@@ -1,4 +1,7 @@
1
1
  import React from 'react';
2
- export declare const FormatMenuComponent: ({ children }: {
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { BlockMenuPlugin } from '../blockMenuPluginType';
4
+ export declare const FormatMenuComponent: ({ api, children, }: {
5
+ api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
3
6
  children: React.ReactNode;
4
7
  }) => React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "3.2.6",
3
+ "version": "3.2.7",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -99,6 +99,9 @@
99
99
  },
100
100
  "platform_editor_block_menu_patch_1": {
101
101
  "type": "boolean"
102
+ },
103
+ "platform_editor_block_menu_for_disabled_nodes": {
104
+ "type": "boolean"
102
105
  }
103
106
  }
104
107
  }