@atlaskit/editor-plugin-block-menu 3.2.5 → 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,21 @@
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
+
11
+ ## 3.2.6
12
+
13
+ ### Patch Changes
14
+
15
+ - [`3c44ed6acd860`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3c44ed6acd860) -
16
+ Enable `Turn into` in block menu on all nested node under a feature gate
17
+ - Updated dependencies
18
+
3
19
  ## 3.2.5
4
20
 
5
21
  ### 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);
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.checkIsFormatMenuHidden = void 0;
7
7
  var _utils = require("@atlaskit/editor-prosemirror/utils");
8
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
9
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
9
10
  var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
10
11
  var _isNestedNode = require("./isNestedNode");
@@ -31,7 +32,7 @@ var getIsFormatMenuHidden = function getIsFormatMenuHidden(selection, schema, me
31
32
  }
32
33
  }
33
34
  var isNested = (0, _isNestedNode.isNestedNode)(selection, menuTriggerBy);
34
- return !content || isNested;
35
+ return !content || isNested && !(0, _platformFeatureFlags.fg)('platform_editor_block_menu_transform_nested_node');
35
36
  };
36
37
  var getIsFormatMenuHiddenEmptyLine = function getIsFormatMenuHiddenEmptyLine(selection, schema, menuTriggerBy) {
37
38
  var nodes = schema.nodes;
@@ -42,8 +43,8 @@ var getIsFormatMenuHiddenEmptyLine = function getIsFormatMenuHiddenEmptyLine(sel
42
43
  if (selection.empty || selection.content().size === 0) {
43
44
  // if empty selection, show format menu
44
45
  return false;
45
- } else if (isNested) {
46
- // if nested, always hide format menu
46
+ } else if (isNested && !(0, _platformFeatureFlags.fg)('platform_editor_block_menu_transform_nested_node')) {
47
+ // if nested, always hide format menu unless feature gate is enabled
47
48
  return true;
48
49
  } else {
49
50
  var content;
@@ -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);
@@ -1,4 +1,5 @@
1
1
  import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
4
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
4
5
  import { isNestedNode } from './isNestedNode';
@@ -25,7 +26,7 @@ const getIsFormatMenuHidden = (selection, schema, menuTriggerBy) => {
25
26
  }
26
27
  }
27
28
  const isNested = isNestedNode(selection, menuTriggerBy);
28
- return !content || isNested;
29
+ return !content || isNested && !fg('platform_editor_block_menu_transform_nested_node');
29
30
  };
30
31
  const getIsFormatMenuHiddenEmptyLine = (selection, schema, menuTriggerBy) => {
31
32
  const nodes = schema.nodes;
@@ -36,8 +37,8 @@ const getIsFormatMenuHiddenEmptyLine = (selection, schema, menuTriggerBy) => {
36
37
  if (selection.empty || selection.content().size === 0) {
37
38
  // if empty selection, show format menu
38
39
  return false;
39
- } else if (isNested) {
40
- // if nested, always hide format menu
40
+ } else if (isNested && !fg('platform_editor_block_menu_transform_nested_node')) {
41
+ // if nested, always hide format menu unless feature gate is enabled
41
42
  return true;
42
43
  } else {
43
44
  let content;
@@ -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,5 @@
1
1
  import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
4
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
4
5
  import { isNestedNode } from './isNestedNode';
@@ -25,7 +26,7 @@ var getIsFormatMenuHidden = function getIsFormatMenuHidden(selection, schema, me
25
26
  }
26
27
  }
27
28
  var isNested = isNestedNode(selection, menuTriggerBy);
28
- return !content || isNested;
29
+ return !content || isNested && !fg('platform_editor_block_menu_transform_nested_node');
29
30
  };
30
31
  var getIsFormatMenuHiddenEmptyLine = function getIsFormatMenuHiddenEmptyLine(selection, schema, menuTriggerBy) {
31
32
  var nodes = schema.nodes;
@@ -36,8 +37,8 @@ var getIsFormatMenuHiddenEmptyLine = function getIsFormatMenuHiddenEmptyLine(sel
36
37
  if (selection.empty || selection.content().size === 0) {
37
38
  // if empty selection, show format menu
38
39
  return false;
39
- } else if (isNested) {
40
- // if nested, always hide format menu
40
+ } else if (isNested && !fg('platform_editor_block_menu_transform_nested_node')) {
41
+ // if nested, always hide format menu unless feature gate is enabled
41
42
  return true;
42
43
  } else {
43
44
  var content;
@@ -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.5",
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",
@@ -38,7 +38,7 @@
38
38
  "@atlaskit/editor-shared-styles": "^3.6.0",
39
39
  "@atlaskit/editor-tables": "^2.9.0",
40
40
  "@atlaskit/editor-toolbar": "^0.9.0",
41
- "@atlaskit/icon": "^28.2.0",
41
+ "@atlaskit/icon": "^28.3.0",
42
42
  "@atlaskit/icon-lab": "^5.7.0",
43
43
  "@atlaskit/platform-feature-flags": "^1.1.0",
44
44
  "@atlaskit/primitives": "^14.15.0",
@@ -91,11 +91,17 @@
91
91
  "platform_editor_adf_with_localid": {
92
92
  "type": "boolean"
93
93
  },
94
+ "platform_editor_block_menu_transform_nested_node": {
95
+ "type": "boolean"
96
+ },
94
97
  "platform_editor_block_menu_selection_fix": {
95
98
  "type": "boolean"
96
99
  },
97
100
  "platform_editor_block_menu_patch_1": {
98
101
  "type": "boolean"
102
+ },
103
+ "platform_editor_block_menu_for_disabled_nodes": {
104
+ "type": "boolean"
99
105
  }
100
106
  }
101
107
  }