@atlaskit/editor-plugin-block-menu 6.0.48 → 6.1.1

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/editor-commands/transform-node-utils/wrapStep.js +1 -1
  3. package/dist/cjs/editor-commands/transformNode.js +1 -9
  4. package/dist/cjs/pm-plugins/experiences/block-menu-experiences.js +12 -10
  5. package/dist/cjs/pm-plugins/experiences/experience-check-utils.js +3 -2
  6. package/dist/cjs/pm-plugins/main.js +1 -1
  7. package/dist/cjs/pm-plugins/utils/shouldSuppressKeyboardEvent.js +1 -1
  8. package/dist/cjs/ui/block-menu-components.js +6 -3
  9. package/dist/cjs/ui/block-menu-renderer/fallbacks.js +7 -1
  10. package/dist/cjs/ui/block-menu.js +2 -1
  11. package/dist/cjs/ui/copy-link.js +13 -2
  12. package/dist/cjs/ui/delete-button.js +8 -1
  13. package/dist/cjs/ui/flag.js +8 -1
  14. package/dist/cjs/ui/format-menu-nested.js +10 -2
  15. package/dist/cjs/ui/move-down.js +8 -1
  16. package/dist/cjs/ui/move-up.js +8 -1
  17. package/dist/cjs/ui/suggested-items-menu-section.js +10 -1
  18. package/dist/cjs/ui/utils/checkHasPreviousSectionContent.js +66 -0
  19. package/dist/cjs/ui/utils/fixBlockMenuPositionAndScroll.js +2 -1
  20. package/dist/es2019/editor-commands/transform-node-utils/wrapStep.js +1 -1
  21. package/dist/es2019/editor-commands/transformNode.js +1 -9
  22. package/dist/es2019/pm-plugins/experiences/block-menu-experiences.js +15 -11
  23. package/dist/es2019/pm-plugins/experiences/experience-check-utils.js +3 -2
  24. package/dist/es2019/pm-plugins/main.js +1 -1
  25. package/dist/es2019/pm-plugins/utils/shouldSuppressKeyboardEvent.js +1 -1
  26. package/dist/es2019/ui/block-menu-components.js +6 -3
  27. package/dist/es2019/ui/block-menu-renderer/fallbacks.js +7 -1
  28. package/dist/es2019/ui/block-menu.js +2 -1
  29. package/dist/es2019/ui/copy-link.js +13 -2
  30. package/dist/es2019/ui/delete-button.js +8 -1
  31. package/dist/es2019/ui/flag.js +8 -1
  32. package/dist/es2019/ui/format-menu-nested.js +10 -2
  33. package/dist/es2019/ui/move-down.js +8 -1
  34. package/dist/es2019/ui/move-up.js +8 -1
  35. package/dist/es2019/ui/suggested-items-menu-section.js +10 -1
  36. package/dist/es2019/ui/utils/checkHasPreviousSectionContent.js +59 -0
  37. package/dist/es2019/ui/utils/fixBlockMenuPositionAndScroll.js +2 -1
  38. package/dist/esm/editor-commands/transform-node-utils/wrapStep.js +1 -1
  39. package/dist/esm/editor-commands/transformNode.js +1 -9
  40. package/dist/esm/pm-plugins/experiences/block-menu-experiences.js +15 -13
  41. package/dist/esm/pm-plugins/experiences/experience-check-utils.js +3 -2
  42. package/dist/esm/pm-plugins/main.js +1 -1
  43. package/dist/esm/pm-plugins/utils/shouldSuppressKeyboardEvent.js +1 -1
  44. package/dist/esm/ui/block-menu-components.js +6 -3
  45. package/dist/esm/ui/block-menu-renderer/fallbacks.js +7 -1
  46. package/dist/esm/ui/block-menu.js +2 -1
  47. package/dist/esm/ui/copy-link.js +13 -2
  48. package/dist/esm/ui/delete-button.js +8 -1
  49. package/dist/esm/ui/flag.js +8 -1
  50. package/dist/esm/ui/format-menu-nested.js +10 -2
  51. package/dist/esm/ui/move-down.js +8 -1
  52. package/dist/esm/ui/move-up.js +8 -1
  53. package/dist/esm/ui/suggested-items-menu-section.js +10 -1
  54. package/dist/esm/ui/utils/checkHasPreviousSectionContent.js +61 -0
  55. package/dist/esm/ui/utils/fixBlockMenuPositionAndScroll.js +2 -1
  56. package/dist/types/pm-plugins/utils/shouldSuppressKeyboardEvent.d.ts +1 -1
  57. package/dist/types/ui/utils/checkHasPreviousSectionContent.d.ts +26 -0
  58. package/dist/types-ts4.5/pm-plugins/utils/shouldSuppressKeyboardEvent.d.ts +1 -1
  59. package/dist/types-ts4.5/ui/utils/checkHasPreviousSectionContent.d.ts +26 -0
  60. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/editor-plugin-block-menu
2
2
 
3
+ ## 6.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`57f499d6937db`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/57f499d6937db) -
8
+ Extract ExperienceCheckPopupMutation logic to be reusable for block menu experience tracking
9
+ - [`7ea2e225c0abb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7ea2e225c0abb) -
10
+ [ux] Minor styling, wording changes for block menu and sync blocks
11
+ - Updated dependencies
12
+
13
+ ## 6.1.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [`042eb4751bd4d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/042eb4751bd4d) -
18
+ [ux] Cleanup fg: platform_editor_table_transform_selection_fix
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+
3
24
  ## 6.0.48
4
25
 
5
26
  ### Patch Changes
@@ -12,7 +12,7 @@ var _utils2 = require("./utils");
12
12
  * Wraps nodes into the target container type.
13
13
  * When wrapping into expand, any expand children are converted to nestedExpand
14
14
  * since expand cannot be a direct child of expand.
15
- *
15
+ *
16
16
  * Preserves breakout marks when both source and target nodes support resizing
17
17
  * (codeBlock, expand, layoutSection).
18
18
  */
@@ -98,21 +98,13 @@ var transformNode = exports.transformNode = function transformNode(api) {
98
98
  } else {
99
99
  tr.replaceWith(sliceStart, $to.pos, content);
100
100
  }
101
-
102
- // [FEATURE FLAG: platform_editor_table_transform_selection_fix]
103
- // Fixes table cell selection not being preserved after transform to expand/layout.
104
- // When a table with CellSelection is transformed, we need to re-select the wrapper node.
105
- // To clean up: remove the if-else block and keep only the flag-on behavior.
106
- if (preservedSelection instanceof _editorTables.CellSelection && (0, _platformFeatureFlags.fg)('platform_editor_table_transform_selection_fix')) {
101
+ if (preservedSelection instanceof _editorTables.CellSelection) {
107
102
  var insertedNode = tr.doc.nodeAt($from.pos);
108
103
  var isSelectable = insertedNode && _state.NodeSelection.isSelectable(insertedNode);
109
104
  if (isSelectable) {
110
105
  var _api$blockControls3;
111
106
  var nodeSelection = _state.NodeSelection.create(tr.doc, $from.pos);
112
107
  tr.setSelection(nodeSelection);
113
-
114
- // Update preserved selection to match the new NodeSelection
115
- // This prevents appendTransaction from restoring the old table selection positions
116
108
  api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.startPreservingSelection()({
117
109
  tr: tr
118
110
  });
@@ -33,21 +33,23 @@ var getBlockMenuExperiencesPlugin = exports.getBlockMenuExperiencesPlugin = func
33
33
  }
34
34
  return popupTargetEl;
35
35
  };
36
+ var getEditorDom = function getEditorDom() {
37
+ var _editorView2;
38
+ if (((_editorView2 = editorView) === null || _editorView2 === void 0 ? void 0 : _editorView2.dom) instanceof HTMLElement) {
39
+ return editorView.dom;
40
+ }
41
+ return null;
42
+ };
36
43
  var blockMenuOpenExperience = new _experiences.Experience(_experiences.EXPERIENCE_ID.MENU_OPEN, {
37
44
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.BLOCK_MENU,
38
45
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
39
46
  checks: [new _experiences.ExperienceCheckTimeout({
40
47
  durationMs: TIMEOUT_DURATION
41
- }), new _experiences.ExperienceCheckDomMutation({
42
- onDomMutation: _experienceCheckUtils.handleMenuOpenDomMutation,
43
- observeConfig: function observeConfig() {
44
- return {
45
- target: getPopupsTarget(),
46
- options: {
47
- childList: true
48
- }
49
- };
50
- }
48
+ }), new _experiences.ExperienceCheckPopupMutation({
49
+ nestedElementQuery: "[data-testid=\"".concat(_blockMenu.BLOCK_MENU_TEST_ID, "\"]"),
50
+ getTarget: getPopupsTarget,
51
+ getEditorDom: getEditorDom,
52
+ type: 'editorContent'
51
53
  })]
52
54
  });
53
55
  var actionObserveConfig = function actionObserveConfig() {
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.isDragHandleElement = exports.isBlockMenuVisible = exports.handleTransformDomMutation = exports.handleMoveDomMutation = exports.handleMenuOpenDomMutation = exports.handleDeleteDomMutation = exports.getParentDOMAtSelection = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _blockMenu = require("@atlaskit/editor-common/block-menu");
9
10
  var _experiences = require("@atlaskit/editor-common/experiences");
10
11
  var _editorTables = require("@atlaskit/editor-tables");
11
12
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
@@ -31,7 +32,7 @@ var isBlockMenuVisible = exports.isBlockMenuVisible = function isBlockMenuVisibl
31
32
  if (!popupsTarget) {
32
33
  return false;
33
34
  }
34
- return (0, _experiences.popupWithNestedElement)(popupsTarget, '[data-testid="editor-block-menu"]') !== null;
35
+ return (0, _experiences.popupWithNestedElement)(popupsTarget, "[data-testid=\"".concat(_blockMenu.BLOCK_MENU_TEST_ID, "\"]")) !== null;
35
36
  };
36
37
 
37
38
  /**
@@ -71,7 +72,7 @@ var isBlockMenuAddedInMutation = function isBlockMenuAddedInMutation(_ref) {
71
72
  return type === 'childList' && (0, _toConsumableArray2.default)(addedNodes).some(isBlockMenuWithinNode);
72
73
  };
73
74
  var isBlockMenuWithinNode = function isBlockMenuWithinNode(node) {
74
- return (0, _experiences.popupWithNestedElement)(node, '[data-testid="editor-block-menu"]') !== null;
75
+ return (0, _experiences.popupWithNestedElement)(node, "[data-testid=\"".concat(_blockMenu.BLOCK_MENU_TEST_ID, "\"]")) !== null;
75
76
  };
76
77
 
77
78
  /**
@@ -36,7 +36,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
36
36
  }
37
37
 
38
38
  // Block further handling of key events when block menu is open
39
- // Except for backspace/delete/copy/cut/paste/undo/redo/copy-link-to-block which should be handled by the selection preservation plugin
39
+ // Except for backspace/delete/copy/cut/paste/undo/redo/copy-link-to-selection which should be handled by the selection preservation plugin
40
40
  return (0, _shouldSuppressKeyboardEvent.shouldSuppressKeyboardEvent)(event);
41
41
  }
42
42
  }
@@ -12,7 +12,7 @@ exports.shouldSuppressKeyboardEvent = void 0;
12
12
  * - Backspace/Delete: Allow deleting selected content
13
13
  * - Copy/Cut/Paste: Allow clipboard operations (Cmd/Ctrl+C, Cmd/Ctrl+X, Cmd/Ctrl+V)
14
14
  * - Undo/Redo: Allow undo/redo operations (Cmd/Ctrl+Z, Cmd/Ctrl+Y)
15
- * - Copy Link to Block: Allow the keyboard shortcut (Cmd/Ctrl+Alt+A)
15
+ * - Copy Link to Selection: Allow the keyboard shortcut (Cmd/Ctrl+Alt+A)
16
16
  *
17
17
  * @param event - The keyboard event to check
18
18
  * @returns true if the event should be suppressed, false if it should be allowed
@@ -22,6 +22,7 @@ var _moveDown = require("./move-down");
22
22
  var _moveUp = require("./move-up");
23
23
  var _suggestedItemsMenuSection = require("./suggested-items-menu-section");
24
24
  var _suggestedMenuItems = require("./suggested-menu-items");
25
+ var _checkHasPreviousSectionContent = require("./utils/checkHasPreviousSectionContent");
25
26
  var _createMenuItemsMap = require("./utils/createMenuItemsMap");
26
27
  var _getSuggestedItemsFromSelection = require("./utils/getSuggestedItemsFromSelection");
27
28
  var MIN_NUMBER_OF_AVAILABLE_NATIVE_TRANSFORMS = 7;
@@ -142,7 +143,8 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
142
143
  },
143
144
  children = _ref3.children;
144
145
  return /*#__PURE__*/_react.default.createElement(_MenuSection.MenuSection, {
145
- title: _messages.blockMenuMessages.create
146
+ title: _messages.blockMenuMessages.create,
147
+ hasSeparator: (0, _checkHasPreviousSectionContent.hasContentBeforeCreate)(api)
146
148
  }, children);
147
149
  }
148
150
  }, {
@@ -159,7 +161,8 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
159
161
  },
160
162
  children = _ref4.children;
161
163
  return /*#__PURE__*/_react.default.createElement(_MenuSection.MenuSection, {
162
- title: _messages.blockMenuMessages.structure
164
+ title: _messages.blockMenuMessages.structure,
165
+ hasSeparator: (0, _checkHasPreviousSectionContent.hasContentBeforeStructure)(api)
163
166
  }, children);
164
167
  }
165
168
  }, {
@@ -177,7 +180,7 @@ var getTurnIntoMenuComponents = function getTurnIntoMenuComponents(api) {
177
180
  children = _ref5.children;
178
181
  return /*#__PURE__*/_react.default.createElement(_MenuSection.MenuSection, {
179
182
  title: _messages.blockMenuMessages.headings,
180
- hasSeparator: true
183
+ hasSeparator: (0, _checkHasPreviousSectionContent.hasContentBeforeHeadings)(api)
181
184
  }, children);
182
185
  }
183
186
  }, {
@@ -10,14 +10,20 @@ var _reactIntlNext = require("react-intl-next");
10
10
  var _messages = require("@atlaskit/editor-common/messages");
11
11
  var _editorToolbar = require("@atlaskit/editor-toolbar");
12
12
  var _chevronRight = _interopRequireDefault(require("@atlaskit/icon/core/chevron-right"));
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var FallbackNestedMenu = function FallbackNestedMenu(_ref) {
14
15
  var children = _ref.children;
15
16
  var _useIntl = (0, _reactIntlNext.useIntl)(),
16
17
  formatMessage = _useIntl.formatMessage;
18
+ // [FEATURE FLAG: platform_editor_block_menu_v2_patch_3]
19
+ // Adds size="small" to icons for better visual consistency in block menu.
20
+ // To clean up: remove conditional, keep only size="small" version.
21
+ var iconSize = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_v2_patch_3') ? 'small' : undefined;
17
22
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarNestedDropdownMenu, {
18
23
  elemBefore: undefined,
19
24
  elemAfter: /*#__PURE__*/_react.default.createElement(_chevronRight.default, {
20
- label: ""
25
+ label: "",
26
+ size: iconSize
21
27
  }),
22
28
  text: formatMessage(_messages.blockMenuMessages.fallbackNestedMenu),
23
29
  enableMaxHeight: true,
@@ -14,6 +14,7 @@ var _react = _interopRequireWildcard(require("react"));
14
14
  var _reactIntlNext = require("react-intl-next");
15
15
  var _css = require("@atlaskit/css");
16
16
  var _analytics = require("@atlaskit/editor-common/analytics");
17
+ var _blockMenu = require("@atlaskit/editor-common/block-menu");
17
18
  var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
18
19
  var _hooks = require("@atlaskit/editor-common/hooks");
19
20
  var _styles = require("@atlaskit/editor-common/styles");
@@ -100,7 +101,7 @@ var BlockMenuContent = function BlockMenuContent(_ref2) {
100
101
  return target.closest('[data-toolbar-nested-dropdown-menu]') !== null;
101
102
  };
102
103
  return /*#__PURE__*/_react.default.createElement(_compiled.Box, {
103
- testId: "editor-block-menu",
104
+ testId: _blockMenu.BLOCK_MENU_TEST_ID,
104
105
  role: (0, _expValEquals.expValEquals)('platform_editor_enghealth_a11y_jan_fixes', 'isEnabled', true) ? 'menu' : undefined,
105
106
  ref: ref,
106
107
  xcss: (0, _css.cx)(styles.base, (0, _platformFeatureFlags.fg)('platform_editor_block_menu_v2_patch_2') && styles.maxWidthStyles, (0, _experiments.editorExperiment)('platform_synced_block', true) && styles.emptyMenuSectionStyles)
@@ -88,15 +88,26 @@ var CopyLinkDropdownItemContent = function CopyLinkDropdownItemContent(_ref) {
88
88
  if (!(0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid')) {
89
89
  return null;
90
90
  }
91
+
92
+ // [FEATURE FLAG: platform_editor_block_menu_v2_patch_3]
93
+ // Conditionally display message based on feature flag
94
+ // To clean up: remove the conditional and use only copyLinkToBlock message
95
+ var message = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_v2_patch_3') ? _messages.blockMenuMessages.copyLinkToBlock : _messages.blockMenuMessages.copyLinkToBlockOld;
96
+
97
+ // [FEATURE FLAG: platform_editor_block_menu_v2_patch_3]
98
+ // Adds size="small" to icons for better visual consistency in block menu.
99
+ // To clean up: remove conditional, keep only size="small" version.
100
+ var iconSize = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_v2_patch_3') ? 'small' : undefined;
91
101
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
92
102
  onClick: handleClick,
93
103
  elemBefore: /*#__PURE__*/_react.default.createElement(_link.default, {
94
- label: ""
104
+ label: "",
105
+ size: iconSize
95
106
  }),
96
107
  elemAfter: shortcut ? /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarKeyboardShortcutHint, {
97
108
  shortcut: shortcut
98
109
  }) : undefined,
99
110
  ariaKeyshortcuts: shortcut
100
- }, formatMessage(_messages.blockMenuMessages.copyLinkToBlock));
111
+ }, formatMessage(message));
101
112
  };
102
113
  var CopyLinkDropdownItem = exports.CopyLinkDropdownItem = (0, _reactIntlNext.injectIntl)(CopyLinkDropdownItemContent);
@@ -14,6 +14,7 @@ var _messages = require("@atlaskit/editor-common/messages");
14
14
  var _selection = require("@atlaskit/editor-common/selection");
15
15
  var _editorToolbar = require("@atlaskit/editor-toolbar");
16
16
  var _delete = _interopRequireDefault(require("@atlaskit/icon/core/delete"));
17
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
18
  var _box = require("@atlaskit/primitives/box");
18
19
  var _text = _interopRequireDefault(require("@atlaskit/primitives/text"));
19
20
  var _consts = require("./consts");
@@ -96,6 +97,11 @@ var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
96
97
  onRemoveHoverDecoration();
97
98
  };
98
99
  }, [onRemoveHoverDecoration]);
100
+
101
+ // [FEATURE FLAG: platform_editor_block_menu_v2_patch_3]
102
+ // Adds size="small" to icons for better visual consistency in block menu.
103
+ // To clean up: remove conditional, keep only size="small" version.
104
+ var iconSize = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_v2_patch_3') ? 'small' : undefined;
99
105
  return /*#__PURE__*/_react.default.createElement(_box.Box, {
100
106
  onMouseEnter: onShowHoverDecoration,
101
107
  onMouseLeave: onRemoveHoverDecoration,
@@ -104,7 +110,8 @@ var DeleteDropdownItemContent = function DeleteDropdownItemContent(_ref) {
104
110
  }, /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
105
111
  elemBefore: /*#__PURE__*/_react.default.createElement(_delete.default, {
106
112
  color: "var(--ds-icon-danger, #C9372C)",
107
- label: ""
113
+ label: "",
114
+ size: iconSize
108
115
  }),
109
116
  onClick: onClick,
110
117
  testId: _blockMenu.BLOCK_MENU_ACTION_TEST_ID.DELETE
@@ -13,6 +13,7 @@ var _hooks = require("@atlaskit/editor-common/hooks");
13
13
  var _messages = require("@atlaskit/editor-common/messages");
14
14
  var _flag = _interopRequireWildcard(require("@atlaskit/flag"));
15
15
  var _checkCircle = _interopRequireDefault(require("@atlaskit/icon/core/check-circle"));
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
17
  var _blockMenuPluginType = require("../blockMenuPluginType");
17
18
  var _main = require("../pm-plugins/main");
18
19
  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); }
@@ -46,6 +47,11 @@ var Flag = exports.Flag = function Flag(_ref) {
46
47
  api === null || api === void 0 || api.core.actions.focus();
47
48
  };
48
49
  var FlagComponent = flagMap[showFlag].autoDismiss ? _flag.AutoDismissFlag : _flag.default;
50
+
51
+ // [FEATURE FLAG: platform_editor_block_menu_v2_patch_3]
52
+ // Adds size="small" to icons for better visual consistency in block menu.
53
+ // To clean up: remove conditional, keep only size="small" version.
54
+ var iconSize = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_v2_patch_3') ? 'small' : undefined;
49
55
  return /*#__PURE__*/_react.default.createElement(_flag.FlagGroup, null, /*#__PURE__*/_react.default.createElement(FlagComponent, {
50
56
  onDismissed: onDismissed,
51
57
  title: formatMessage(title),
@@ -53,7 +59,8 @@ var Flag = exports.Flag = function Flag(_ref) {
53
59
  testId: showFlag,
54
60
  icon: /*#__PURE__*/_react.default.createElement(_checkCircle.default, {
55
61
  label: "",
56
- color: "var(--ds-icon-success, #6A9A23)"
62
+ color: "var(--ds-icon-success, #6A9A23)",
63
+ size: iconSize
57
64
  })
58
65
  }));
59
66
  };
@@ -13,6 +13,7 @@ var _messages = require("@atlaskit/editor-common/messages");
13
13
  var _editorToolbar = require("@atlaskit/editor-toolbar");
14
14
  var _changes = _interopRequireDefault(require("@atlaskit/icon/core/changes"));
15
15
  var _chevronRight = _interopRequireDefault(require("@atlaskit/icon/core/chevron-right"));
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
17
  var _consts = require("./consts");
17
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); }
18
19
  var FormatMenuComponent = exports.FormatMenuComponent = function FormatMenuComponent(_ref) {
@@ -36,13 +37,20 @@ var FormatMenuComponent = exports.FormatMenuComponent = function FormatMenuCompo
36
37
  return tr;
37
38
  });
38
39
  }, [api]);
40
+
41
+ // [FEATURE FLAG: platform_editor_block_menu_v2_patch_3]
42
+ // Adds size="small" to icons for better visual consistency in block menu.
43
+ // To clean up: remove conditional, keep only size="small" version.
44
+ var iconSize = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_v2_patch_3') ? 'small' : undefined;
39
45
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarNestedDropdownMenu, {
40
46
  text: formatMessage(_messages.blockMenuMessages.turnInto),
41
47
  elemBefore: /*#__PURE__*/_react.default.createElement(_changes.default, {
42
- label: ""
48
+ label: "",
49
+ size: iconSize
43
50
  }),
44
51
  elemAfter: /*#__PURE__*/_react.default.createElement(_chevronRight.default, {
45
- label: ""
52
+ label: "",
53
+ size: iconSize
46
54
  }),
47
55
  enableMaxHeight: true,
48
56
  onClick: handleClick,
@@ -16,6 +16,7 @@ var _messages = require("@atlaskit/editor-common/messages");
16
16
  var _types = require("@atlaskit/editor-common/types");
17
17
  var _editorToolbar = require("@atlaskit/editor-toolbar");
18
18
  var _arrowDown = _interopRequireDefault(require("@atlaskit/icon/core/arrow-down"));
19
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
19
20
  var _blockMenuProvider = require("./block-menu-provider");
20
21
  var _consts = require("./consts");
21
22
  var _fixBlockMenuPositionAndScroll = require("./utils/fixBlockMenuPositionAndScroll");
@@ -67,11 +68,17 @@ var MoveDownDropdownItemContent = function MoveDownDropdownItemContent(_ref) {
67
68
  (0, _fixBlockMenuPositionAndScroll.fixBlockMenuPositionAndScroll)(newFirstNode);
68
69
  });
69
70
  };
71
+
72
+ // [FEATURE FLAG: platform_editor_block_menu_v2_patch_3]
73
+ // Adds size="small" to icons for better visual consistency in block menu.
74
+ // To clean up: remove conditional, keep only size="small" version.
75
+ var iconSize = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_v2_patch_3') ? 'small' : undefined;
70
76
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
71
77
  triggerRef: moveDownRef,
72
78
  onClick: handleClick,
73
79
  elemBefore: /*#__PURE__*/_react.default.createElement(_arrowDown.default, {
74
- label: ""
80
+ label: "",
81
+ size: iconSize
75
82
  }),
76
83
  isDisabled: !canMoveDown,
77
84
  testId: _blockMenu.BLOCK_MENU_ACTION_TEST_ID.MOVE_DOWN
@@ -16,6 +16,7 @@ var _messages = require("@atlaskit/editor-common/messages");
16
16
  var _types = require("@atlaskit/editor-common/types");
17
17
  var _editorToolbar = require("@atlaskit/editor-toolbar");
18
18
  var _arrowUp = _interopRequireDefault(require("@atlaskit/icon/core/arrow-up"));
19
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
19
20
  var _blockMenuProvider = require("./block-menu-provider");
20
21
  var _consts = require("./consts");
21
22
  var _fixBlockMenuPositionAndScroll = require("./utils/fixBlockMenuPositionAndScroll");
@@ -65,11 +66,17 @@ var MoveUpDropdownItemContent = function MoveUpDropdownItemContent(_ref) {
65
66
  (0, _fixBlockMenuPositionAndScroll.fixBlockMenuPositionAndScroll)(newFirstNode);
66
67
  });
67
68
  };
69
+
70
+ // [FEATURE FLAG: platform_editor_block_menu_v2_patch_3]
71
+ // Adds size="small" to icons for better visual consistency in block menu.
72
+ // To clean up: remove conditional, keep only size="small" version.
73
+ var iconSize = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_v2_patch_3') ? 'small' : undefined;
68
74
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
69
75
  triggerRef: moveUpRef,
70
76
  onClick: handleClick,
71
77
  elemBefore: /*#__PURE__*/_react.default.createElement(_arrowUp.default, {
72
- label: ""
78
+ label: "",
79
+ size: iconSize
73
80
  }),
74
81
  isDisabled: !canMoveUp,
75
82
  testId: _blockMenu.BLOCK_MENU_ACTION_TEST_ID.MOVE_UP
@@ -9,7 +9,9 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _reactIntlNext = require("react-intl-next");
10
10
  var _messages = require("@atlaskit/editor-common/messages");
11
11
  var _editorToolbar = require("@atlaskit/editor-toolbar");
12
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
13
  var _useSuggestedItems = require("./hooks/useSuggestedItems");
14
+ var _checkHasPreviousSectionContent = require("./utils/checkHasPreviousSectionContent");
13
15
  var SuggestedItemsMenuSection = exports.SuggestedItemsMenuSection = /*#__PURE__*/_react.default.memo(function (_ref) {
14
16
  var api = _ref.api,
15
17
  children = _ref.children;
@@ -19,7 +21,14 @@ var SuggestedItemsMenuSection = exports.SuggestedItemsMenuSection = /*#__PURE__*
19
21
  if (suggestedItems.length === 0) {
20
22
  return null;
21
23
  }
24
+
25
+ // [FEATURE FLAG: platform_editor_block_menu_v2_patch_3]
26
+ // Conditionally show separator based on whether there's content after this section.
27
+ // Old behavior: always show separator (true).
28
+ // To clean up: remove conditional, keep only the hasCreateSectionContent || hasStructureSectionContent logic.
29
+ var hasSeparator = (0, _platformFeatureFlags.fg)('platform_editor_block_menu_v2_patch_3') ? (0, _checkHasPreviousSectionContent.hasCreateSectionContent)(api) || (0, _checkHasPreviousSectionContent.hasStructureSectionContent)(api) : true;
22
30
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
23
- title: formatMessage(_messages.blockMenuMessages.suggested)
31
+ title: formatMessage(_messages.blockMenuMessages.suggested),
32
+ hasSeparator: hasSeparator
24
33
  }, children);
25
34
  });
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hasSuggestedSectionContent = exports.hasStructureSectionContent = exports.hasCreateSectionContent = exports.hasContentBeforeStructure = exports.hasContentBeforeHeadings = exports.hasContentBeforeCreate = void 0;
7
+ var _blockMenu = require("@atlaskit/editor-common/block-menu");
8
+ var _utils = require("../block-menu-renderer/utils");
9
+ /**
10
+ * Checks if a section has any visible content (items that will render)
11
+ */
12
+ var hasSectionContent = function hasSectionContent(sectionKey, api) {
13
+ var _api$blockMenu;
14
+ var blockMenuComponents = api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.getBlockMenuComponents();
15
+ if (!blockMenuComponents) {
16
+ return false;
17
+ }
18
+ var childrenMap = (0, _utils.buildChildrenMap)(blockMenuComponents);
19
+ var sectionMapKey = (0, _utils.getChildrenMapKey)(sectionKey, 'block-menu-section');
20
+ var sectionChildren = childrenMap.get(sectionMapKey) || [];
21
+ return sectionChildren.some(function (child) {
22
+ return (0, _utils.willComponentRender)(child, childrenMap);
23
+ });
24
+ };
25
+
26
+ /**
27
+ * Checks if the Suggested section has any visible content
28
+ */
29
+ var hasSuggestedSectionContent = exports.hasSuggestedSectionContent = function hasSuggestedSectionContent(api) {
30
+ return hasSectionContent(_blockMenu.TRANSFORM_SUGGESTED_MENU_SECTION.key, api);
31
+ };
32
+
33
+ /**
34
+ * Checks if the Create section has any visible content
35
+ */
36
+ var hasCreateSectionContent = exports.hasCreateSectionContent = function hasCreateSectionContent(api) {
37
+ return hasSectionContent(_blockMenu.TRANSFORM_CREATE_MENU_SECTION.key, api);
38
+ };
39
+
40
+ /**
41
+ * Checks if the Structure section has any visible content
42
+ */
43
+ var hasStructureSectionContent = exports.hasStructureSectionContent = function hasStructureSectionContent(api) {
44
+ return hasSectionContent(_blockMenu.TRANSFORM_STRUCTURE_MENU_SECTION.key, api);
45
+ };
46
+
47
+ /**
48
+ * Checks if there's any content before the Create section (i.e., Suggested section has content)
49
+ */
50
+ var hasContentBeforeCreate = exports.hasContentBeforeCreate = function hasContentBeforeCreate(api) {
51
+ return hasSuggestedSectionContent(api);
52
+ };
53
+
54
+ /**
55
+ * Checks if there's any content before the Structure section (i.e., Create or Suggested sections have content)
56
+ */
57
+ var hasContentBeforeStructure = exports.hasContentBeforeStructure = function hasContentBeforeStructure(api) {
58
+ return hasCreateSectionContent(api) || hasSuggestedSectionContent(api);
59
+ };
60
+
61
+ /**
62
+ * Checks if there's any content before the Headings section (i.e., Structure, Create, or Suggested sections have content)
63
+ */
64
+ var hasContentBeforeHeadings = exports.hasContentBeforeHeadings = function hasContentBeforeHeadings(api) {
65
+ return hasStructureSectionContent(api) || hasCreateSectionContent(api) || hasSuggestedSectionContent(api);
66
+ };
@@ -5,12 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.fixBlockMenuPositionAndScroll = void 0;
7
7
  var _browserApis = require("@atlaskit/browser-apis");
8
+ var _blockMenu = require("@atlaskit/editor-common/block-menu");
8
9
  var fixBlockMenuPositionAndScroll = exports.fixBlockMenuPositionAndScroll = function fixBlockMenuPositionAndScroll(firstSelectedNode) {
9
10
  var doc = (0, _browserApis.getDocument)();
10
11
  if (!doc) {
11
12
  return;
12
13
  }
13
- var blockMenuEl = doc.querySelector('[data-testid="editor-block-menu"]');
14
+ var blockMenuEl = doc.querySelector("[data-testid=\"".concat(_blockMenu.BLOCK_MENU_TEST_ID, "\"]"));
14
15
  if (!(blockMenuEl !== null && blockMenuEl !== void 0 && blockMenuEl.parentElement)) {
15
16
  return;
16
17
  }
@@ -7,7 +7,7 @@ import { convertExpandToNestedExpand } from './utils';
7
7
  * Wraps nodes into the target container type.
8
8
  * When wrapping into expand, any expand children are converted to nestedExpand
9
9
  * since expand cannot be a direct child of expand.
10
- *
10
+ *
11
11
  * Preserves breakout marks when both source and target nodes support resizing
12
12
  * (codeBlock, expand, layoutSection).
13
13
  */
@@ -92,21 +92,13 @@ export const transformNode = api => (targetType, metadata) => ({
92
92
  } else {
93
93
  tr.replaceWith(sliceStart, $to.pos, content);
94
94
  }
95
-
96
- // [FEATURE FLAG: platform_editor_table_transform_selection_fix]
97
- // Fixes table cell selection not being preserved after transform to expand/layout.
98
- // When a table with CellSelection is transformed, we need to re-select the wrapper node.
99
- // To clean up: remove the if-else block and keep only the flag-on behavior.
100
- if (preservedSelection instanceof CellSelection && fg('platform_editor_table_transform_selection_fix')) {
95
+ if (preservedSelection instanceof CellSelection) {
101
96
  const insertedNode = tr.doc.nodeAt($from.pos);
102
97
  const isSelectable = insertedNode && NodeSelection.isSelectable(insertedNode);
103
98
  if (isSelectable) {
104
99
  var _api$blockControls3;
105
100
  const nodeSelection = NodeSelection.create(tr.doc, $from.pos);
106
101
  tr.setSelection(nodeSelection);
107
-
108
- // Update preserved selection to match the new NodeSelection
109
- // This prevents appendTransaction from restoring the old table selection positions
110
102
  api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.startPreservingSelection()({
111
103
  tr
112
104
  });
@@ -1,10 +1,10 @@
1
1
  import { bind } from 'bind-event-listener';
2
2
  import { ACTION, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
3
- import { BLOCK_MENU_ACTION_TEST_ID } from '@atlaskit/editor-common/block-menu';
4
- import { Experience, EXPERIENCE_ID, ExperienceCheckDomMutation, ExperienceCheckTimeout, getPopupContainerFromEditorView } from '@atlaskit/editor-common/experiences';
3
+ import { BLOCK_MENU_ACTION_TEST_ID, BLOCK_MENU_TEST_ID } from '@atlaskit/editor-common/block-menu';
4
+ import { Experience, EXPERIENCE_ID, ExperienceCheckDomMutation, ExperienceCheckPopupMutation, ExperienceCheckTimeout, getPopupContainerFromEditorView } from '@atlaskit/editor-common/experiences';
5
5
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
6
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
- import { getParentDOMAtSelection, handleDeleteDomMutation, handleMenuOpenDomMutation, handleMoveDomMutation, handleTransformDomMutation, isBlockMenuVisible, isDragHandleElement } from './experience-check-utils';
7
+ import { getParentDOMAtSelection, handleDeleteDomMutation, handleMoveDomMutation, handleTransformDomMutation, isBlockMenuVisible, isDragHandleElement } from './experience-check-utils';
8
8
  const TIMEOUT_DURATION = 1000;
9
9
  const pluginKey = new PluginKey('blockMenuExperiences');
10
10
  const START_METHOD = {
@@ -28,19 +28,23 @@ export const getBlockMenuExperiencesPlugin = ({
28
28
  }
29
29
  return popupTargetEl;
30
30
  };
31
+ const getEditorDom = () => {
32
+ var _editorView2;
33
+ if (((_editorView2 = editorView) === null || _editorView2 === void 0 ? void 0 : _editorView2.dom) instanceof HTMLElement) {
34
+ return editorView.dom;
35
+ }
36
+ return null;
37
+ };
31
38
  const blockMenuOpenExperience = new Experience(EXPERIENCE_ID.MENU_OPEN, {
32
39
  actionSubjectId: ACTION_SUBJECT_ID.BLOCK_MENU,
33
40
  dispatchAnalyticsEvent,
34
41
  checks: [new ExperienceCheckTimeout({
35
42
  durationMs: TIMEOUT_DURATION
36
- }), new ExperienceCheckDomMutation({
37
- onDomMutation: handleMenuOpenDomMutation,
38
- observeConfig: () => ({
39
- target: getPopupsTarget(),
40
- options: {
41
- childList: true
42
- }
43
- })
43
+ }), new ExperienceCheckPopupMutation({
44
+ nestedElementQuery: `[data-testid="${BLOCK_MENU_TEST_ID}"]`,
45
+ getTarget: getPopupsTarget,
46
+ getEditorDom,
47
+ type: 'editorContent'
44
48
  })]
45
49
  });
46
50
  const actionObserveConfig = () => ({
@@ -1,3 +1,4 @@
1
+ import { BLOCK_MENU_TEST_ID } from '@atlaskit/editor-common/block-menu';
1
2
  import { popupWithNestedElement } from '@atlaskit/editor-common/experiences';
2
3
  import { CellSelection } from '@atlaskit/editor-tables';
3
4
 
@@ -21,7 +22,7 @@ export const isBlockMenuVisible = popupsTarget => {
21
22
  if (!popupsTarget) {
22
23
  return false;
23
24
  }
24
- return popupWithNestedElement(popupsTarget, '[data-testid="editor-block-menu"]') !== null;
25
+ return popupWithNestedElement(popupsTarget, `[data-testid="${BLOCK_MENU_TEST_ID}"]`) !== null;
25
26
  };
26
27
 
27
28
  /**
@@ -64,7 +65,7 @@ const isBlockMenuAddedInMutation = ({
64
65
  return type === 'childList' && [...addedNodes].some(isBlockMenuWithinNode);
65
66
  };
66
67
  const isBlockMenuWithinNode = node => {
67
- return popupWithNestedElement(node, '[data-testid="editor-block-menu"]') !== null;
68
+ return popupWithNestedElement(node, `[data-testid="${BLOCK_MENU_TEST_ID}"]`) !== null;
68
69
  };
69
70
 
70
71
  /**
@@ -30,7 +30,7 @@ export const createPlugin = api => {
30
30
  }
31
31
 
32
32
  // Block further handling of key events when block menu is open
33
- // Except for backspace/delete/copy/cut/paste/undo/redo/copy-link-to-block which should be handled by the selection preservation plugin
33
+ // Except for backspace/delete/copy/cut/paste/undo/redo/copy-link-to-selection which should be handled by the selection preservation plugin
34
34
  return shouldSuppressKeyboardEvent(event);
35
35
  }
36
36
  }
@@ -6,7 +6,7 @@
6
6
  * - Backspace/Delete: Allow deleting selected content
7
7
  * - Copy/Cut/Paste: Allow clipboard operations (Cmd/Ctrl+C, Cmd/Ctrl+X, Cmd/Ctrl+V)
8
8
  * - Undo/Redo: Allow undo/redo operations (Cmd/Ctrl+Z, Cmd/Ctrl+Y)
9
- * - Copy Link to Block: Allow the keyboard shortcut (Cmd/Ctrl+Alt+A)
9
+ * - Copy Link to Selection: Allow the keyboard shortcut (Cmd/Ctrl+Alt+A)
10
10
  *
11
11
  * @param event - The keyboard event to check
12
12
  * @returns true if the event should be suppressed, false if it should be allowed