@atlaskit/editor-plugin-block-menu 6.1.0 → 6.1.2

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 (57) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/editor-commands/transform-node-utils/wrapStep.js +1 -1
  3. package/dist/cjs/pm-plugins/experiences/block-menu-experiences.js +12 -10
  4. package/dist/cjs/pm-plugins/experiences/experience-check-utils.js +3 -2
  5. package/dist/cjs/pm-plugins/main.js +1 -1
  6. package/dist/cjs/pm-plugins/utils/shouldSuppressKeyboardEvent.js +1 -1
  7. package/dist/cjs/ui/block-menu-components.js +6 -3
  8. package/dist/cjs/ui/block-menu-renderer/fallbacks.js +7 -1
  9. package/dist/cjs/ui/block-menu.js +2 -1
  10. package/dist/cjs/ui/copy-link.js +13 -2
  11. package/dist/cjs/ui/delete-button.js +8 -1
  12. package/dist/cjs/ui/flag.js +8 -1
  13. package/dist/cjs/ui/format-menu-nested.js +10 -2
  14. package/dist/cjs/ui/move-down.js +8 -1
  15. package/dist/cjs/ui/move-up.js +8 -1
  16. package/dist/cjs/ui/suggested-items-menu-section.js +10 -1
  17. package/dist/cjs/ui/utils/checkHasPreviousSectionContent.js +66 -0
  18. package/dist/cjs/ui/utils/fixBlockMenuPositionAndScroll.js +2 -1
  19. package/dist/es2019/editor-commands/transform-node-utils/wrapStep.js +1 -1
  20. package/dist/es2019/pm-plugins/experiences/block-menu-experiences.js +15 -11
  21. package/dist/es2019/pm-plugins/experiences/experience-check-utils.js +3 -2
  22. package/dist/es2019/pm-plugins/main.js +1 -1
  23. package/dist/es2019/pm-plugins/utils/shouldSuppressKeyboardEvent.js +1 -1
  24. package/dist/es2019/ui/block-menu-components.js +6 -3
  25. package/dist/es2019/ui/block-menu-renderer/fallbacks.js +7 -1
  26. package/dist/es2019/ui/block-menu.js +2 -1
  27. package/dist/es2019/ui/copy-link.js +13 -2
  28. package/dist/es2019/ui/delete-button.js +8 -1
  29. package/dist/es2019/ui/flag.js +8 -1
  30. package/dist/es2019/ui/format-menu-nested.js +10 -2
  31. package/dist/es2019/ui/move-down.js +8 -1
  32. package/dist/es2019/ui/move-up.js +8 -1
  33. package/dist/es2019/ui/suggested-items-menu-section.js +10 -1
  34. package/dist/es2019/ui/utils/checkHasPreviousSectionContent.js +59 -0
  35. package/dist/es2019/ui/utils/fixBlockMenuPositionAndScroll.js +2 -1
  36. package/dist/esm/editor-commands/transform-node-utils/wrapStep.js +1 -1
  37. package/dist/esm/pm-plugins/experiences/block-menu-experiences.js +15 -13
  38. package/dist/esm/pm-plugins/experiences/experience-check-utils.js +3 -2
  39. package/dist/esm/pm-plugins/main.js +1 -1
  40. package/dist/esm/pm-plugins/utils/shouldSuppressKeyboardEvent.js +1 -1
  41. package/dist/esm/ui/block-menu-components.js +6 -3
  42. package/dist/esm/ui/block-menu-renderer/fallbacks.js +7 -1
  43. package/dist/esm/ui/block-menu.js +2 -1
  44. package/dist/esm/ui/copy-link.js +13 -2
  45. package/dist/esm/ui/delete-button.js +8 -1
  46. package/dist/esm/ui/flag.js +8 -1
  47. package/dist/esm/ui/format-menu-nested.js +10 -2
  48. package/dist/esm/ui/move-down.js +8 -1
  49. package/dist/esm/ui/move-up.js +8 -1
  50. package/dist/esm/ui/suggested-items-menu-section.js +10 -1
  51. package/dist/esm/ui/utils/checkHasPreviousSectionContent.js +61 -0
  52. package/dist/esm/ui/utils/fixBlockMenuPositionAndScroll.js +2 -1
  53. package/dist/types/pm-plugins/utils/shouldSuppressKeyboardEvent.d.ts +1 -1
  54. package/dist/types/ui/utils/checkHasPreviousSectionContent.d.ts +26 -0
  55. package/dist/types-ts4.5/pm-plugins/utils/shouldSuppressKeyboardEvent.d.ts +1 -1
  56. package/dist/types-ts4.5/ui/utils/checkHasPreviousSectionContent.d.ts +26 -0
  57. package/package.json +8 -5
@@ -8,6 +8,7 @@ import { blockMenuMessages as messages } from '@atlaskit/editor-common/messages'
8
8
  import { DIRECTION } from '@atlaskit/editor-common/types';
9
9
  import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
10
10
  import ArrowDownIcon from '@atlaskit/icon/core/arrow-down';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import { useBlockMenu } from './block-menu-provider';
12
13
  import { BLOCK_MENU_ITEM_NAME } from './consts';
13
14
  import { fixBlockMenuPositionAndScroll } from './utils/fixBlockMenuPositionAndScroll';
@@ -58,11 +59,17 @@ var MoveDownDropdownItemContent = function MoveDownDropdownItemContent(_ref) {
58
59
  fixBlockMenuPositionAndScroll(newFirstNode);
59
60
  });
60
61
  };
62
+
63
+ // [FEATURE FLAG: platform_editor_block_menu_v2_patch_3]
64
+ // Adds size="small" to icons for better visual consistency in block menu.
65
+ // To clean up: remove conditional, keep only size="small" version.
66
+ var iconSize = fg('platform_editor_block_menu_v2_patch_3') ? 'small' : undefined;
61
67
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
62
68
  triggerRef: moveDownRef,
63
69
  onClick: handleClick,
64
70
  elemBefore: /*#__PURE__*/React.createElement(ArrowDownIcon, {
65
- label: ""
71
+ label: "",
72
+ size: iconSize
66
73
  }),
67
74
  isDisabled: !canMoveDown,
68
75
  testId: BLOCK_MENU_ACTION_TEST_ID.MOVE_DOWN
@@ -8,6 +8,7 @@ import { blockMenuMessages as messages } from '@atlaskit/editor-common/messages'
8
8
  import { DIRECTION } from '@atlaskit/editor-common/types';
9
9
  import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
10
10
  import ArrowUpIcon from '@atlaskit/icon/core/arrow-up';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import { useBlockMenu } from './block-menu-provider';
12
13
  import { BLOCK_MENU_ITEM_NAME } from './consts';
13
14
  import { fixBlockMenuPositionAndScroll } from './utils/fixBlockMenuPositionAndScroll';
@@ -56,11 +57,17 @@ var MoveUpDropdownItemContent = function MoveUpDropdownItemContent(_ref) {
56
57
  fixBlockMenuPositionAndScroll(newFirstNode);
57
58
  });
58
59
  };
60
+
61
+ // [FEATURE FLAG: platform_editor_block_menu_v2_patch_3]
62
+ // Adds size="small" to icons for better visual consistency in block menu.
63
+ // To clean up: remove conditional, keep only size="small" version.
64
+ var iconSize = fg('platform_editor_block_menu_v2_patch_3') ? 'small' : undefined;
59
65
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
60
66
  triggerRef: moveUpRef,
61
67
  onClick: handleClick,
62
68
  elemBefore: /*#__PURE__*/React.createElement(ArrowUpIcon, {
63
- label: ""
69
+ label: "",
70
+ size: iconSize
64
71
  }),
65
72
  isDisabled: !canMoveUp,
66
73
  testId: BLOCK_MENU_ACTION_TEST_ID.MOVE_UP
@@ -2,7 +2,9 @@ import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { blockMenuMessages } from '@atlaskit/editor-common/messages';
4
4
  import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { useSuggestedItems } from './hooks/useSuggestedItems';
7
+ import { hasCreateSectionContent, hasStructureSectionContent } from './utils/checkHasPreviousSectionContent';
6
8
  export var SuggestedItemsMenuSection = /*#__PURE__*/React.memo(function (_ref) {
7
9
  var api = _ref.api,
8
10
  children = _ref.children;
@@ -12,7 +14,14 @@ export var SuggestedItemsMenuSection = /*#__PURE__*/React.memo(function (_ref) {
12
14
  if (suggestedItems.length === 0) {
13
15
  return null;
14
16
  }
17
+
18
+ // [FEATURE FLAG: platform_editor_block_menu_v2_patch_3]
19
+ // Conditionally show separator based on whether there's content after this section.
20
+ // Old behavior: always show separator (true).
21
+ // To clean up: remove conditional, keep only the hasCreateSectionContent || hasStructureSectionContent logic.
22
+ var hasSeparator = fg('platform_editor_block_menu_v2_patch_3') ? hasCreateSectionContent(api) || hasStructureSectionContent(api) : true;
15
23
  return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
16
- title: formatMessage(blockMenuMessages.suggested)
24
+ title: formatMessage(blockMenuMessages.suggested),
25
+ hasSeparator: hasSeparator
17
26
  }, children);
18
27
  });
@@ -0,0 +1,61 @@
1
+ import { TRANSFORM_SUGGESTED_MENU_SECTION, TRANSFORM_CREATE_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION } from '@atlaskit/editor-common/block-menu';
2
+ import { buildChildrenMap, getChildrenMapKey, willComponentRender } from '../block-menu-renderer/utils';
3
+
4
+ /**
5
+ * Checks if a section has any visible content (items that will render)
6
+ */
7
+ var hasSectionContent = function hasSectionContent(sectionKey, api) {
8
+ var _api$blockMenu;
9
+ var blockMenuComponents = api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.getBlockMenuComponents();
10
+ if (!blockMenuComponents) {
11
+ return false;
12
+ }
13
+ var childrenMap = buildChildrenMap(blockMenuComponents);
14
+ var sectionMapKey = getChildrenMapKey(sectionKey, 'block-menu-section');
15
+ var sectionChildren = childrenMap.get(sectionMapKey) || [];
16
+ return sectionChildren.some(function (child) {
17
+ return willComponentRender(child, childrenMap);
18
+ });
19
+ };
20
+
21
+ /**
22
+ * Checks if the Suggested section has any visible content
23
+ */
24
+ export var hasSuggestedSectionContent = function hasSuggestedSectionContent(api) {
25
+ return hasSectionContent(TRANSFORM_SUGGESTED_MENU_SECTION.key, api);
26
+ };
27
+
28
+ /**
29
+ * Checks if the Create section has any visible content
30
+ */
31
+ export var hasCreateSectionContent = function hasCreateSectionContent(api) {
32
+ return hasSectionContent(TRANSFORM_CREATE_MENU_SECTION.key, api);
33
+ };
34
+
35
+ /**
36
+ * Checks if the Structure section has any visible content
37
+ */
38
+ export var hasStructureSectionContent = function hasStructureSectionContent(api) {
39
+ return hasSectionContent(TRANSFORM_STRUCTURE_MENU_SECTION.key, api);
40
+ };
41
+
42
+ /**
43
+ * Checks if there's any content before the Create section (i.e., Suggested section has content)
44
+ */
45
+ export var hasContentBeforeCreate = function hasContentBeforeCreate(api) {
46
+ return hasSuggestedSectionContent(api);
47
+ };
48
+
49
+ /**
50
+ * Checks if there's any content before the Structure section (i.e., Create or Suggested sections have content)
51
+ */
52
+ export var hasContentBeforeStructure = function hasContentBeforeStructure(api) {
53
+ return hasCreateSectionContent(api) || hasSuggestedSectionContent(api);
54
+ };
55
+
56
+ /**
57
+ * Checks if there's any content before the Headings section (i.e., Structure, Create, or Suggested sections have content)
58
+ */
59
+ export var hasContentBeforeHeadings = function hasContentBeforeHeadings(api) {
60
+ return hasStructureSectionContent(api) || hasCreateSectionContent(api) || hasSuggestedSectionContent(api);
61
+ };
@@ -1,10 +1,11 @@
1
1
  import { getDocument } from '@atlaskit/browser-apis';
2
+ import { BLOCK_MENU_TEST_ID } from '@atlaskit/editor-common/block-menu';
2
3
  export var fixBlockMenuPositionAndScroll = function fixBlockMenuPositionAndScroll(firstSelectedNode) {
3
4
  var doc = getDocument();
4
5
  if (!doc) {
5
6
  return;
6
7
  }
7
- var blockMenuEl = doc.querySelector('[data-testid="editor-block-menu"]');
8
+ var blockMenuEl = doc.querySelector("[data-testid=\"".concat(BLOCK_MENU_TEST_ID, "\"]"));
8
9
  if (!(blockMenuEl !== null && blockMenuEl !== void 0 && blockMenuEl.parentElement)) {
9
10
  return;
10
11
  }
@@ -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
@@ -0,0 +1,26 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { BlockMenuPlugin } from '../../blockMenuPluginType';
3
+ /**
4
+ * Checks if the Suggested section has any visible content
5
+ */
6
+ export declare const hasSuggestedSectionContent: (api: ExtractInjectionAPI<BlockMenuPlugin> | undefined) => boolean;
7
+ /**
8
+ * Checks if the Create section has any visible content
9
+ */
10
+ export declare const hasCreateSectionContent: (api: ExtractInjectionAPI<BlockMenuPlugin> | undefined) => boolean;
11
+ /**
12
+ * Checks if the Structure section has any visible content
13
+ */
14
+ export declare const hasStructureSectionContent: (api: ExtractInjectionAPI<BlockMenuPlugin> | undefined) => boolean;
15
+ /**
16
+ * Checks if there's any content before the Create section (i.e., Suggested section has content)
17
+ */
18
+ export declare const hasContentBeforeCreate: (api: ExtractInjectionAPI<BlockMenuPlugin> | undefined) => boolean;
19
+ /**
20
+ * Checks if there's any content before the Structure section (i.e., Create or Suggested sections have content)
21
+ */
22
+ export declare const hasContentBeforeStructure: (api: ExtractInjectionAPI<BlockMenuPlugin> | undefined) => boolean;
23
+ /**
24
+ * Checks if there's any content before the Headings section (i.e., Structure, Create, or Suggested sections have content)
25
+ */
26
+ export declare const hasContentBeforeHeadings: (api: ExtractInjectionAPI<BlockMenuPlugin> | undefined) => boolean;
@@ -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
@@ -0,0 +1,26 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { BlockMenuPlugin } from '../../blockMenuPluginType';
3
+ /**
4
+ * Checks if the Suggested section has any visible content
5
+ */
6
+ export declare const hasSuggestedSectionContent: (api: ExtractInjectionAPI<BlockMenuPlugin> | undefined) => boolean;
7
+ /**
8
+ * Checks if the Create section has any visible content
9
+ */
10
+ export declare const hasCreateSectionContent: (api: ExtractInjectionAPI<BlockMenuPlugin> | undefined) => boolean;
11
+ /**
12
+ * Checks if the Structure section has any visible content
13
+ */
14
+ export declare const hasStructureSectionContent: (api: ExtractInjectionAPI<BlockMenuPlugin> | undefined) => boolean;
15
+ /**
16
+ * Checks if there's any content before the Create section (i.e., Suggested section has content)
17
+ */
18
+ export declare const hasContentBeforeCreate: (api: ExtractInjectionAPI<BlockMenuPlugin> | undefined) => boolean;
19
+ /**
20
+ * Checks if there's any content before the Structure section (i.e., Create or Suggested sections have content)
21
+ */
22
+ export declare const hasContentBeforeStructure: (api: ExtractInjectionAPI<BlockMenuPlugin> | undefined) => boolean;
23
+ /**
24
+ * Checks if there's any content before the Headings section (i.e., Structure, Create, or Suggested sections have content)
25
+ */
26
+ export declare const hasContentBeforeHeadings: (api: ExtractInjectionAPI<BlockMenuPlugin> | undefined) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-menu",
3
- "version": "6.1.0",
3
+ "version": "6.1.2",
4
4
  "description": "BlockMenu plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,7 @@
32
32
  "@atlaskit/css": "^0.19.0",
33
33
  "@atlaskit/dropdown-menu": "^16.4.0",
34
34
  "@atlaskit/editor-plugin-analytics": "^7.0.0",
35
- "@atlaskit/editor-plugin-block-controls": "^8.5.0",
35
+ "@atlaskit/editor-plugin-block-controls": "^8.6.0",
36
36
  "@atlaskit/editor-plugin-decorations": "^7.0.0",
37
37
  "@atlaskit/editor-plugin-selection": "^7.0.0",
38
38
  "@atlaskit/editor-plugin-user-intent": "^5.0.0",
@@ -41,18 +41,18 @@
41
41
  "@atlaskit/editor-tables": "^2.9.0",
42
42
  "@atlaskit/editor-toolbar": "^0.19.0",
43
43
  "@atlaskit/flag": "^17.8.0",
44
- "@atlaskit/icon": "^31.0.0",
44
+ "@atlaskit/icon": "^32.0.0",
45
45
  "@atlaskit/platform-feature-flags": "^1.1.0",
46
46
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
47
47
  "@atlaskit/primitives": "^18.0.0",
48
48
  "@atlaskit/prosemirror-history": "^0.2.0",
49
- "@atlaskit/tmp-editor-statsig": "^29.4.0",
49
+ "@atlaskit/tmp-editor-statsig": "^29.6.0",
50
50
  "@atlaskit/tokens": "^11.0.0",
51
51
  "@babel/runtime": "^7.0.0",
52
52
  "bind-event-listener": "^3.0.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "@atlaskit/editor-common": "^111.19.0",
55
+ "@atlaskit/editor-common": "^111.20.0",
56
56
  "react": "^18.2.0",
57
57
  "react-intl-next": "npm:react-intl@^5.18.1"
58
58
  },
@@ -102,6 +102,9 @@
102
102
  "platform_editor_block_menu_v2_patch_2": {
103
103
  "type": "boolean"
104
104
  },
105
+ "platform_editor_block_menu_v2_patch_3": {
106
+ "type": "boolean"
107
+ },
105
108
  "platform_editor_preserve_breakout_on_transform": {
106
109
  "type": "boolean"
107
110
  }