@atlaskit/editor-plugin-block-menu 7.0.11 → 7.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,11 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 7.0.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
3
9
  ## 7.0.11
4
10
 
5
11
  ### Patch Changes
@@ -24,6 +24,7 @@ var _moveUp = require("./move-up");
24
24
  var _suggestedItemsMenuSection = require("./suggested-items-menu-section");
25
25
  var _suggestedMenuItems = require("./suggested-menu-items");
26
26
  var _checkHasPreviousSectionContent = require("./utils/checkHasPreviousSectionContent");
27
+ var _checkIsFormatMenuHidden = require("./utils/checkIsFormatMenuHidden");
27
28
  var _createMenuItemsMap = require("./utils/createMenuItemsMap");
28
29
  var _getSuggestedItemsFromSelection = require("./utils/getSuggestedItemsFromSelection");
29
30
  var MIN_NUMBER_OF_AVAILABLE_NATIVE_TRANSFORMS = 7;
@@ -86,7 +87,10 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
86
87
  return /*#__PURE__*/_react.default.createElement(_formatMenuNested.FormatMenuComponent, {
87
88
  api: api
88
89
  }, children);
89
- }
90
+ },
91
+ isHidden: (0, _platformFeatureFlags.fg)('platform_editor_block_menu_divider_patch') ? function () {
92
+ return (0, _checkIsFormatMenuHidden.checkIsFormatMenuHidden)(api);
93
+ } : undefined
90
94
  }, {
91
95
  type: 'block-menu-section',
92
96
  key: _blockMenu.TRANSFORM_SUGGESTED_MENU_SECTION.key,
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.CopySection = 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 _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
11
12
  var _checkIsFormatMenuHidden = require("./utils/checkIsFormatMenuHidden");
12
13
  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,7 +17,8 @@ var CopySection = exports.CopySection = function CopySection(_ref) {
16
17
  var isFormatMenuHidden = (0, _react.useCallback)(function () {
17
18
  return (0, _checkIsFormatMenuHidden.checkIsFormatMenuHidden)(api);
18
19
  }, [api]);
20
+ var hasSeparator = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_divider_patch') ? true : (0, _experiments.editorExperiment)('platform_synced_block', true) ? true : !isFormatMenuHidden();
19
21
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
20
- hasSeparator: (0, _experiments.editorExperiment)('platform_synced_block', true) ? true : !isFormatMenuHidden()
22
+ hasSeparator: hasSeparator
21
23
  }, children);
22
24
  };
@@ -5,12 +5,18 @@ 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 getIsFormatMenuHidden = function getIsFormatMenuHidden(selection, schema) {
9
10
  var nodes = schema.nodes;
10
11
  if (!nodes) {
11
12
  return false;
12
13
  }
13
- var disabledOnNodes = [nodes.syncBlock, nodes.bodiedSyncBlock, nodes.rule];
14
+
15
+ // When platform_editor_block_menu_divider_patch is enabled, the "Copy synced block"
16
+ // item is placed inside TRANSFORM_MENU_SECTION, so we must not hide the section for
17
+ // syncBlock/bodiedSyncBlock nodes — the "Turn into" nested item has its own isHidden
18
+ // guard that will still hide it for those node types.
19
+ var disabledOnNodes = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_divider_patch') ? [nodes.rule] : [nodes.syncBlock, nodes.bodiedSyncBlock, nodes.rule];
14
20
  var disabledNode = (0, _utils.findSelectedNodeOfType)(disabledOnNodes)(selection);
15
21
  return !!disabledNode;
16
22
  };
@@ -16,6 +16,7 @@ import { MoveUpDropdownItem } from './move-up';
16
16
  import { SuggestedItemsMenuSection } from './suggested-items-menu-section';
17
17
  import { SuggestedMenuItems } from './suggested-menu-items';
18
18
  import { hasContentBeforeCreate, hasContentBeforeStructure, hasContentBeforeHeadings } from './utils/checkHasPreviousSectionContent';
19
+ import { checkIsFormatMenuHidden } from './utils/checkIsFormatMenuHidden';
19
20
  import { createMenuItemsMap } from './utils/createMenuItemsMap';
20
21
  import { getSuggestedItemsFromSelection } from './utils/getSuggestedItemsFromSelection';
21
22
  const MIN_NUMBER_OF_AVAILABLE_NATIVE_TRANSFORMS = 7;
@@ -72,7 +73,8 @@ const getTurnIntoMenuComponents = api => {
72
73
  return /*#__PURE__*/React.createElement(FormatMenuComponent, {
73
74
  api: api
74
75
  }, children);
75
- }
76
+ },
77
+ isHidden: fg('platform_editor_block_menu_divider_patch') ? () => checkIsFormatMenuHidden(api) : undefined
76
78
  }, {
77
79
  type: 'block-menu-section',
78
80
  key: TRANSFORM_SUGGESTED_MENU_SECTION.key,
@@ -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 { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
5
  import { checkIsFormatMenuHidden } from './utils/checkIsFormatMenuHidden';
5
6
  export const CopySection = ({
@@ -9,7 +10,8 @@ export const CopySection = ({
9
10
  const isFormatMenuHidden = useCallback(() => {
10
11
  return checkIsFormatMenuHidden(api);
11
12
  }, [api]);
13
+ const hasSeparator = fg('platform_editor_block_menu_divider_patch') ? true : editorExperiment('platform_synced_block', true) ? true : !isFormatMenuHidden();
12
14
  return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
13
- hasSeparator: editorExperiment('platform_synced_block', true) ? true : !isFormatMenuHidden()
15
+ hasSeparator: hasSeparator
14
16
  }, children);
15
17
  };
@@ -1,10 +1,16 @@
1
1
  import { findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  const getIsFormatMenuHidden = (selection, schema) => {
3
4
  const nodes = schema.nodes;
4
5
  if (!nodes) {
5
6
  return false;
6
7
  }
7
- const disabledOnNodes = [nodes.syncBlock, nodes.bodiedSyncBlock, nodes.rule];
8
+
9
+ // When platform_editor_block_menu_divider_patch is enabled, the "Copy synced block"
10
+ // item is placed inside TRANSFORM_MENU_SECTION, so we must not hide the section for
11
+ // syncBlock/bodiedSyncBlock nodes — the "Turn into" nested item has its own isHidden
12
+ // guard that will still hide it for those node types.
13
+ const disabledOnNodes = fg('platform_editor_block_menu_divider_patch') ? [nodes.rule] : [nodes.syncBlock, nodes.bodiedSyncBlock, nodes.rule];
8
14
  const disabledNode = findSelectedNodeOfType(disabledOnNodes)(selection);
9
15
  return !!disabledNode;
10
16
  };
@@ -17,6 +17,7 @@ import { MoveUpDropdownItem } from './move-up';
17
17
  import { SuggestedItemsMenuSection } from './suggested-items-menu-section';
18
18
  import { SuggestedMenuItems } from './suggested-menu-items';
19
19
  import { hasContentBeforeCreate, hasContentBeforeStructure, hasContentBeforeHeadings } from './utils/checkHasPreviousSectionContent';
20
+ import { checkIsFormatMenuHidden } from './utils/checkIsFormatMenuHidden';
20
21
  import { createMenuItemsMap } from './utils/createMenuItemsMap';
21
22
  import { getSuggestedItemsFromSelection } from './utils/getSuggestedItemsFromSelection';
22
23
  var MIN_NUMBER_OF_AVAILABLE_NATIVE_TRANSFORMS = 7;
@@ -79,7 +80,10 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
79
80
  return /*#__PURE__*/React.createElement(FormatMenuComponent, {
80
81
  api: api
81
82
  }, children);
82
- }
83
+ },
84
+ isHidden: fg('platform_editor_block_menu_divider_patch') ? function () {
85
+ return checkIsFormatMenuHidden(api);
86
+ } : undefined
83
87
  }, {
84
88
  type: 'block-menu-section',
85
89
  key: TRANSFORM_SUGGESTED_MENU_SECTION.key,
@@ -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 { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
5
  import { checkIsFormatMenuHidden } from './utils/checkIsFormatMenuHidden';
5
6
  export var CopySection = function CopySection(_ref) {
@@ -8,7 +9,8 @@ export var CopySection = function CopySection(_ref) {
8
9
  var isFormatMenuHidden = useCallback(function () {
9
10
  return checkIsFormatMenuHidden(api);
10
11
  }, [api]);
12
+ var hasSeparator = fg('platform_editor_block_menu_divider_patch') ? true : editorExperiment('platform_synced_block', true) ? true : !isFormatMenuHidden();
11
13
  return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
12
- hasSeparator: editorExperiment('platform_synced_block', true) ? true : !isFormatMenuHidden()
14
+ hasSeparator: hasSeparator
13
15
  }, children);
14
16
  };
@@ -1,10 +1,16 @@
1
1
  import { findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  var getIsFormatMenuHidden = function getIsFormatMenuHidden(selection, schema) {
3
4
  var nodes = schema.nodes;
4
5
  if (!nodes) {
5
6
  return false;
6
7
  }
7
- var disabledOnNodes = [nodes.syncBlock, nodes.bodiedSyncBlock, nodes.rule];
8
+
9
+ // When platform_editor_block_menu_divider_patch is enabled, the "Copy synced block"
10
+ // item is placed inside TRANSFORM_MENU_SECTION, so we must not hide the section for
11
+ // syncBlock/bodiedSyncBlock nodes — the "Turn into" nested item has its own isHidden
12
+ // guard that will still hide it for those node types.
13
+ var disabledOnNodes = fg('platform_editor_block_menu_divider_patch') ? [nodes.rule] : [nodes.syncBlock, nodes.bodiedSyncBlock, nodes.rule];
8
14
  var disabledNode = findSelectedNodeOfType(disabledOnNodes)(selection);
9
15
  return !!disabledNode;
10
16
  };
@@ -95,6 +95,7 @@ export type BlockMenuNestedSectionComponent = (props: {
95
95
  export type BlockMenuItemComponent = () => React.ReactNode;
96
96
  export type RegisterBlockMenuNested = BlockMenuNested & {
97
97
  component?: BlockMenuNestedComponent;
98
+ isHidden?: () => boolean;
98
99
  parent: Parent<BlockMenuSection>;
99
100
  };
100
101
  export type RegisterBlockMenuSection = BlockMenuSection & {
@@ -2,6 +2,6 @@ import React from 'react';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { BlockMenuPlugin } from '../blockMenuPluginType';
4
4
  export declare const CopySection: ({ api, children, }: {
5
- api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
5
+ api?: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
6
6
  children: React.ReactNode;
7
7
  }) => React.JSX.Element;
@@ -95,6 +95,7 @@ export type BlockMenuNestedSectionComponent = (props: {
95
95
  export type BlockMenuItemComponent = () => React.ReactNode;
96
96
  export type RegisterBlockMenuNested = BlockMenuNested & {
97
97
  component?: BlockMenuNestedComponent;
98
+ isHidden?: () => boolean;
98
99
  parent: Parent<BlockMenuSection>;
99
100
  };
100
101
  export type RegisterBlockMenuSection = BlockMenuSection & {
@@ -2,6 +2,6 @@ import React from 'react';
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { BlockMenuPlugin } from '../blockMenuPluginType';
4
4
  export declare const CopySection: ({ api, children, }: {
5
- api: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
5
+ api?: ExtractInjectionAPI<BlockMenuPlugin> | undefined;
6
6
  children: React.ReactNode;
7
7
  }) => React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "7.0.11",
3
+ "version": "7.0.12",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -44,7 +44,7 @@
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
45
  "@atlaskit/primitives": "^18.0.0",
46
46
  "@atlaskit/prosemirror-history": "^0.2.0",
47
- "@atlaskit/tmp-editor-statsig": "^42.0.0",
47
+ "@atlaskit/tmp-editor-statsig": "^43.0.0",
48
48
  "@atlaskit/tokens": "^11.1.0",
49
49
  "@babel/runtime": "^7.0.0",
50
50
  "bind-event-listener": "^3.0.0"
@@ -102,6 +102,9 @@
102
102
  },
103
103
  "platform_editor_block_menu_v2_patch_3": {
104
104
  "type": "boolean"
105
+ },
106
+ "platform_editor_block_menu_divider_patch": {
107
+ "type": "boolean"
105
108
  }
106
109
  }
107
110
  }