@atlaskit/editor-plugin-selection-extension 9.0.1 → 9.0.3

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 (42) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/pm-plugins/utils/index.js +58 -4
  3. package/dist/cjs/selectionExtensionPlugin.js +10 -0
  4. package/dist/cjs/types/index.js +7 -6
  5. package/dist/cjs/ui/menu/SelectionExtensionDropdownItem.js +20 -0
  6. package/dist/cjs/ui/menu/SelectionExtensionDropdownMenu.js +37 -0
  7. package/dist/cjs/ui/menu/SelectionExtensionMenuItems.js +30 -0
  8. package/dist/cjs/ui/utils/menu-items.js +15 -0
  9. package/dist/cjs/ui/utils/registerBlockMenuItems.js +5 -3
  10. package/dist/es2019/pm-plugins/utils/index.js +60 -2
  11. package/dist/es2019/selectionExtensionPlugin.js +11 -1
  12. package/dist/es2019/types/index.js +7 -6
  13. package/dist/es2019/ui/menu/SelectionExtensionDropdownItem.js +13 -0
  14. package/dist/es2019/ui/menu/SelectionExtensionDropdownMenu.js +28 -0
  15. package/dist/es2019/ui/menu/SelectionExtensionMenuItems.js +24 -0
  16. package/dist/es2019/ui/utils/menu-items.js +9 -0
  17. package/dist/es2019/ui/utils/registerBlockMenuItems.js +5 -3
  18. package/dist/esm/pm-plugins/utils/index.js +56 -2
  19. package/dist/esm/selectionExtensionPlugin.js +11 -1
  20. package/dist/esm/types/index.js +7 -6
  21. package/dist/esm/ui/menu/SelectionExtensionDropdownItem.js +12 -0
  22. package/dist/esm/ui/menu/SelectionExtensionDropdownMenu.js +28 -0
  23. package/dist/esm/ui/menu/SelectionExtensionMenuItems.js +23 -0
  24. package/dist/esm/ui/utils/menu-items.js +9 -0
  25. package/dist/esm/ui/utils/registerBlockMenuItems.js +5 -3
  26. package/dist/types/pm-plugins/utils/index.d.ts +16 -0
  27. package/dist/types/selectionExtensionPluginType.d.ts +3 -1
  28. package/dist/types/types/index.d.ts +13 -11
  29. package/dist/types/ui/menu/SelectionExtensionDropdownItem.d.ts +7 -0
  30. package/dist/types/ui/menu/SelectionExtensionDropdownMenu.d.ts +6 -0
  31. package/dist/types/ui/menu/SelectionExtensionMenuItems.d.ts +7 -0
  32. package/dist/types/ui/toolbar-components/ToolbarMenu.d.ts +1 -1
  33. package/dist/types/ui/utils/menu-items.d.ts +8 -0
  34. package/dist/types-ts4.5/pm-plugins/utils/index.d.ts +16 -0
  35. package/dist/types-ts4.5/selectionExtensionPluginType.d.ts +3 -1
  36. package/dist/types-ts4.5/types/index.d.ts +13 -11
  37. package/dist/types-ts4.5/ui/menu/SelectionExtensionDropdownItem.d.ts +7 -0
  38. package/dist/types-ts4.5/ui/menu/SelectionExtensionDropdownMenu.d.ts +6 -0
  39. package/dist/types-ts4.5/ui/menu/SelectionExtensionMenuItems.d.ts +7 -0
  40. package/dist/types-ts4.5/ui/toolbar-components/ToolbarMenu.d.ts +1 -1
  41. package/dist/types-ts4.5/ui/utils/menu-items.d.ts +8 -0
  42. package/package.json +8 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-selection-extension
2
2
 
3
+ ## 9.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`5a3efdfff9617`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5a3efdfff9617) -
8
+ EDITOR-3911 Fix selection extension plugin to use preserved selection for block menu actions
9
+ - Updated dependencies
10
+
11
+ ## 9.0.2
12
+
13
+ ### Patch Changes
14
+
15
+ - [`609229c9d51fd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/609229c9d51fd) -
16
+ EDITOR-2772 Implement new rendering of block menu selection extensions
17
+ - Updated dependencies
18
+
3
19
  ## 9.0.1
4
20
 
5
21
  ### Patch Changes
@@ -4,10 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.getFragmentInfoFromSelection = void 0;
7
+ exports.getFragmentInfoFromSelectionNew = exports.getFragmentInfoFromSelection = void 0;
8
8
  exports.getSelectionAdfInfo = getSelectionAdfInfo;
9
9
  exports.getSelectionAdfInfoNew = getSelectionAdfInfoNew;
10
- exports.getSelectionTextInfo = void 0;
10
+ exports.getSelectionTextInfoNew = exports.getSelectionTextInfo = void 0;
11
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
12
  var _monitoring = require("@atlaskit/editor-common/monitoring");
13
13
  var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
@@ -51,10 +51,15 @@ var getSelectionInfoFromCellSelection = function getSelectionInfoFromCellSelecti
51
51
  nodePos: nodePos
52
52
  };
53
53
  };
54
+
55
+ /**
56
+ * @private
57
+ * @deprecated use getFragmentInfoFromSelectionNew instead
58
+ */
54
59
  var getSelectionTextInfo = exports.getSelectionTextInfo = function getSelectionTextInfo(view, api) {
55
- var _api$userPreferences, _api$selectionToolbar, _api$editorViewMode;
60
+ var _api$userPreferences, _api$editorViewMode;
56
61
  var currentSelection = view.state.selection;
57
- var toolbarDocking = (0, _platformFeatureFlags.fg)('platform_editor_use_preferences_plugin') ? api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.preferences) === null || _api$userPreferences === void 0 ? void 0 : _api$userPreferences.toolbarDockingPosition : api === null || api === void 0 || (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.currentState()) === null || _api$selectionToolbar === void 0 ? void 0 : _api$selectionToolbar.toolbarDocking;
62
+ var toolbarDocking = api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.preferences) === null || _api$userPreferences === void 0 ? void 0 : _api$userPreferences.toolbarDockingPosition;
58
63
  var isEditMode = Boolean((api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'edit');
59
64
  var shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode;
60
65
  var from = currentSelection.from,
@@ -71,6 +76,30 @@ var getSelectionTextInfo = exports.getSelectionTextInfo = function getSelectionT
71
76
  coords: coords
72
77
  };
73
78
  };
79
+ var getSelectionTextInfoNew = exports.getSelectionTextInfoNew = function getSelectionTextInfoNew(selection, view, api) {
80
+ var _api$userPreferences2, _api$selectionToolbar, _api$editorViewMode2;
81
+ var toolbarDocking = (0, _platformFeatureFlags.fg)('platform_editor_use_preferences_plugin') ? api === null || api === void 0 || (_api$userPreferences2 = api.userPreferences) === null || _api$userPreferences2 === void 0 || (_api$userPreferences2 = _api$userPreferences2.sharedState.currentState()) === null || _api$userPreferences2 === void 0 || (_api$userPreferences2 = _api$userPreferences2.preferences) === null || _api$userPreferences2 === void 0 ? void 0 : _api$userPreferences2.toolbarDockingPosition : api === null || api === void 0 || (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.currentState()) === null || _api$selectionToolbar === void 0 ? void 0 : _api$selectionToolbar.toolbarDocking;
82
+ var isEditMode = Boolean((api === null || api === void 0 || (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 || (_api$editorViewMode2 = _api$editorViewMode2.sharedState.currentState()) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.mode) === 'edit');
83
+ var shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode;
84
+ var from = selection.from,
85
+ to = selection.to;
86
+ var text = view.state.doc.textBetween(from, to, '\n');
87
+ var coords = (0, _getBoundingBoxFromSelection.getBoundingBoxFromSelection)(view, from, to, {
88
+ top: shouldOffsetToolbarHeight ? _editorSharedStyles.akEditorFullPageToolbarHeight : 0,
89
+ bottom: shouldOffsetToolbarHeight ? _editorSharedStyles.akEditorFullPageToolbarHeight : 0
90
+ });
91
+ return {
92
+ text: text,
93
+ from: from,
94
+ to: to,
95
+ coords: coords
96
+ };
97
+ };
98
+
99
+ /**
100
+ * @private
101
+ * @deprecated use getFragmentInfoFromSelectionNew instead
102
+ */
74
103
  var getFragmentInfoFromSelection = exports.getFragmentInfoFromSelection = function getFragmentInfoFromSelection(state) {
75
104
  var schema = state.schema,
76
105
  selection = state.selection;
@@ -93,6 +122,31 @@ var getFragmentInfoFromSelection = exports.getFragmentInfoFromSelection = functi
93
122
  selectedNodeAdf: selectedNodeAdf
94
123
  };
95
124
  };
125
+ var getFragmentInfoFromSelectionNew = exports.getFragmentInfoFromSelectionNew = function getFragmentInfoFromSelectionNew(selection) {
126
+ var schema = selection.$from.doc.type.schema;
127
+ var slice = selection.content();
128
+ var newDoc;
129
+ try {
130
+ var doc = schema.node('doc', null, [schema.node('paragraph', null, [])]);
131
+ var transform = new _transform.Transform(doc);
132
+ newDoc = transform.replaceRange(0, 2, slice).doc;
133
+ } catch (error) {
134
+ newDoc = schema.nodes.doc.createChecked({}, _model.Fragment.empty);
135
+ (0, _monitoring.logException)(error, {
136
+ location: 'editor-plugin-selection-extension'
137
+ });
138
+ }
139
+ var serializer = new _editorJsonTransformer.JSONTransformer();
140
+ var selectedNodeAdf = serializer.encodeNode(newDoc);
141
+ return {
142
+ selectedNodeAdf: selectedNodeAdf
143
+ };
144
+ };
145
+
146
+ /**
147
+ * @private
148
+ * @deprecated use getSelectionAdfInfoNew instead
149
+ */
96
150
  function getSelectionAdfInfo(state) {
97
151
  var selection = state.selection;
98
152
  var selectionInfo = {
@@ -112,6 +112,11 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
112
112
  return null;
113
113
  }
114
114
  var state = editorViewRef.current.state;
115
+ if ((0, _expValEquals.expValEquals)('platform_editor_block_menu', 'isEnabled', true)) {
116
+ var _api$blockControls;
117
+ var selection = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.preservedSelection) || state.selection;
118
+ return (0, _utils.getSelectionAdfInfoNew)(selection);
119
+ }
115
120
  var _getSelectionAdfInfo = (0, _utils.getSelectionAdfInfo)(state),
116
121
  selectionRanges = _getSelectionAdfInfo.selectionRanges,
117
122
  selectedNodeAdf = _getSelectionAdfInfo.selectedNodeAdf;
@@ -125,6 +130,11 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
125
130
  return null;
126
131
  }
127
132
  var state = editorViewRef.current.state;
133
+ if ((0, _expValEquals.expValEquals)('platform_editor_block_menu', 'isEnabled', true)) {
134
+ var _api$blockControls2;
135
+ var selection = (api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.sharedState.currentState()) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.preservedSelection) || state.selection;
136
+ return (0, _utils.getFragmentInfoFromSelectionNew)(selection);
137
+ }
128
138
  var _getFragmentInfoFromS = (0, _utils.getFragmentInfoFromSelection)(state),
129
139
  selectedNodeAdf = _getFragmentInfoFromS.selectedNodeAdf;
130
140
  return {
@@ -22,16 +22,17 @@ var SelectionExtensionActionTypes = exports.SelectionExtensionActionTypes = /*#_
22
22
  * Common fields applicable to all extension menu items
23
23
  */
24
24
  /**
25
- * Fields for a leaf menu item (i.e., an item that does not have nested menu items)
25
+ * Fields for a dropdown item (i.e., an item that does not have further nested menu items)
26
26
  */
27
27
  /**
28
- * Fields for a dropdown menu item (i.e., an item that has nested menu items)
28
+ * Fields for a nested dropdown menu (i.e., an menu item that has further nested menu items)
29
29
  */
30
30
  /**
31
- * A type which marks all fields from ExtensionMenuItemDropdownMenuConfiguration and ExtensionMenuItemLeafConfiguration
32
- * as never, ensuring that only one of the two can be present at a time to avoid misconfigurations
31
+ * This type represents either a dropdown item or a dropdown menu, but not both.
32
+ *
33
+ * We mark all fields of the other type as `never` to enforce this exclusivity.
33
34
  */
34
35
  /**
35
- * We intentionally only support leaf menu items nested within dropdown menu items so that there will
36
- * be at max two levels of nesting from extension menu items.
36
+ * We intentionally only support dropdown items nested within dropdown menus, i.e. no menus nested
37
+ * within menus – so there will be at max two levels of nesting from extension menu items
37
38
  */
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.SelectionExtensionDropdownItem = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _editorToolbar = require("@atlaskit/editor-toolbar");
10
+ 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); }
11
+ var SelectionExtensionDropdownItem = exports.SelectionExtensionDropdownItem = function SelectionExtensionDropdownItem(_ref) {
12
+ var dropdownItem = _ref.dropdownItem;
13
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
14
+ elemBefore: dropdownItem.icon ? /*#__PURE__*/(0, _react.createElement)(dropdownItem.icon, {
15
+ label: ''
16
+ }) : undefined,
17
+ onClick: dropdownItem.onClick,
18
+ isDisabled: dropdownItem.isDisabled
19
+ }, dropdownItem.label);
20
+ };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.SelectionExtensionNestedDropdownMenu = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _editorToolbar = require("@atlaskit/editor-toolbar");
11
+ var _chevronRight = _interopRequireDefault(require("@atlaskit/icon/core/chevron-right"));
12
+ var _SelectionExtensionDropdownItem = require("./SelectionExtensionDropdownItem");
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); }
14
+ var ChildItems = function ChildItems(_ref) {
15
+ var nestedDropdownMenu = _ref.nestedDropdownMenu;
16
+ var childItems = nestedDropdownMenu.getMenuItems();
17
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, childItems.map(function (dropdownItem) {
18
+ return /*#__PURE__*/_react.default.createElement(_SelectionExtensionDropdownItem.SelectionExtensionDropdownItem, {
19
+ key: dropdownItem.label,
20
+ dropdownItem: dropdownItem
21
+ });
22
+ }));
23
+ };
24
+ var SelectionExtensionNestedDropdownMenu = exports.SelectionExtensionNestedDropdownMenu = function SelectionExtensionNestedDropdownMenu(_ref2) {
25
+ var nestedDropdownMenu = _ref2.nestedDropdownMenu;
26
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarNestedDropdownMenu, {
27
+ text: nestedDropdownMenu.label,
28
+ elemBefore: nestedDropdownMenu.icon ? /*#__PURE__*/(0, _react.createElement)(nestedDropdownMenu.icon, {
29
+ label: ''
30
+ }) : undefined,
31
+ elemAfter: /*#__PURE__*/_react.default.createElement(_chevronRight.default, {
32
+ label: 'nested menu'
33
+ })
34
+ }, /*#__PURE__*/_react.default.createElement(ChildItems, {
35
+ nestedDropdownMenu: nestedDropdownMenu
36
+ }));
37
+ };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.SelectionExtensionMenuItems = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _menuItems = require("../utils/menu-items");
10
+ var _SelectionExtensionDropdownItem = require("./SelectionExtensionDropdownItem");
11
+ var _SelectionExtensionDropdownMenu = require("./SelectionExtensionDropdownMenu");
12
+ var SelectionExtensionMenuItems = exports.SelectionExtensionMenuItems = function SelectionExtensionMenuItems(_ref) {
13
+ var getMenuItems = _ref.getMenuItems;
14
+ var extensionMenuItems = getMenuItems();
15
+ if (!(extensionMenuItems !== null && extensionMenuItems !== void 0 && extensionMenuItems.length)) {
16
+ return null;
17
+ }
18
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, extensionMenuItems.map(function (item) {
19
+ if ((0, _menuItems.isNestedDropdownMenuConfiguration)(item)) {
20
+ return /*#__PURE__*/_react.default.createElement(_SelectionExtensionDropdownMenu.SelectionExtensionNestedDropdownMenu, {
21
+ key: item.label,
22
+ nestedDropdownMenu: item
23
+ });
24
+ }
25
+ return /*#__PURE__*/_react.default.createElement(_SelectionExtensionDropdownItem.SelectionExtensionDropdownItem, {
26
+ key: item.label,
27
+ dropdownItem: item
28
+ });
29
+ }));
30
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isNestedDropdownMenuConfiguration = void 0;
7
+ /**
8
+ * Type guard to check if the given configuration is for a dropdown menu.
9
+ *
10
+ * @param item - The menu item configuration to check, either menu item or dropdown menu
11
+ * @returns True if the item configuration is for a dropdown menu, false otherwise
12
+ */
13
+ var isNestedDropdownMenuConfiguration = exports.isNestedDropdownMenuConfiguration = function isNestedDropdownMenuConfiguration(item) {
14
+ return 'getMenuItems' in item && typeof item.getMenuItems === 'function';
15
+ };
@@ -7,8 +7,9 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.registerBlockMenuItems = registerBlockMenuItems;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _blockMenu = require("@atlaskit/editor-common/block-menu");
10
+ var _SelectionExtensionMenuItems = require("../menu/SelectionExtensionMenuItems");
10
11
  function registerBlockMenuItems(extensionList, api) {
11
- extensionList.forEach(function (_ref, index) {
12
+ extensionList.forEach(function (_ref) {
12
13
  var _api$blockMenu;
13
14
  var source = _ref.source,
14
15
  key = _ref.key,
@@ -25,8 +26,9 @@ function registerBlockMenuItems(extensionList, api) {
25
26
  rank: _blockMenu.TRANSFORM_MENU_ITEM_RANK[_blockMenu.TRANSFORM_CREATE_MENU_SECTION.key]
26
27
  },
27
28
  component: function component() {
28
- // EDITOR-2772 implementation of rendering in next PR
29
- return /*#__PURE__*/_react.default.createElement("div", null, "Placeholder");
29
+ return /*#__PURE__*/_react.default.createElement(_SelectionExtensionMenuItems.SelectionExtensionMenuItems, {
30
+ getMenuItems: blockMenu.getMenuItems
31
+ });
30
32
  }
31
33
  }]);
32
34
  });
@@ -40,12 +40,17 @@ const getSelectionInfoFromCellSelection = selection => {
40
40
  nodePos
41
41
  };
42
42
  };
43
+
44
+ /**
45
+ * @private
46
+ * @deprecated use getFragmentInfoFromSelectionNew instead
47
+ */
43
48
  export const getSelectionTextInfo = (view, api) => {
44
- var _api$userPreferences, _api$userPreferences$, _api$userPreferences$2, _api$selectionToolbar, _api$selectionToolbar2, _api$selectionToolbar3, _api$editorViewMode, _api$editorViewMode$s;
49
+ var _api$userPreferences, _api$userPreferences$, _api$userPreferences$2, _api$editorViewMode, _api$editorViewMode$s;
45
50
  const {
46
51
  selection: currentSelection
47
52
  } = view.state;
48
- const toolbarDocking = fg('platform_editor_use_preferences_plugin') ? api === null || api === void 0 ? void 0 : (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 ? void 0 : (_api$userPreferences$ = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences$ === void 0 ? void 0 : (_api$userPreferences$2 = _api$userPreferences$.preferences) === null || _api$userPreferences$2 === void 0 ? void 0 : _api$userPreferences$2.toolbarDockingPosition : api === null || api === void 0 ? void 0 : (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 ? void 0 : (_api$selectionToolbar2 = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar2 === void 0 ? void 0 : (_api$selectionToolbar3 = _api$selectionToolbar2.currentState()) === null || _api$selectionToolbar3 === void 0 ? void 0 : _api$selectionToolbar3.toolbarDocking;
53
+ const toolbarDocking = api === null || api === void 0 ? void 0 : (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 ? void 0 : (_api$userPreferences$ = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences$ === void 0 ? void 0 : (_api$userPreferences$2 = _api$userPreferences$.preferences) === null || _api$userPreferences$2 === void 0 ? void 0 : _api$userPreferences$2.toolbarDockingPosition;
49
54
  const isEditMode = Boolean((api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'edit');
50
55
  const shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode;
51
56
  const {
@@ -64,6 +69,32 @@ export const getSelectionTextInfo = (view, api) => {
64
69
  coords
65
70
  };
66
71
  };
72
+ export const getSelectionTextInfoNew = (selection, view, api) => {
73
+ var _api$userPreferences2, _api$userPreferences3, _api$userPreferences4, _api$selectionToolbar, _api$selectionToolbar2, _api$selectionToolbar3, _api$editorViewMode2, _api$editorViewMode2$;
74
+ const toolbarDocking = fg('platform_editor_use_preferences_plugin') ? api === null || api === void 0 ? void 0 : (_api$userPreferences2 = api.userPreferences) === null || _api$userPreferences2 === void 0 ? void 0 : (_api$userPreferences3 = _api$userPreferences2.sharedState.currentState()) === null || _api$userPreferences3 === void 0 ? void 0 : (_api$userPreferences4 = _api$userPreferences3.preferences) === null || _api$userPreferences4 === void 0 ? void 0 : _api$userPreferences4.toolbarDockingPosition : api === null || api === void 0 ? void 0 : (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 ? void 0 : (_api$selectionToolbar2 = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar2 === void 0 ? void 0 : (_api$selectionToolbar3 = _api$selectionToolbar2.currentState()) === null || _api$selectionToolbar3 === void 0 ? void 0 : _api$selectionToolbar3.toolbarDocking;
75
+ const isEditMode = Boolean((api === null || api === void 0 ? void 0 : (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 ? void 0 : (_api$editorViewMode2$ = _api$editorViewMode2.sharedState.currentState()) === null || _api$editorViewMode2$ === void 0 ? void 0 : _api$editorViewMode2$.mode) === 'edit');
76
+ const shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode;
77
+ const {
78
+ from,
79
+ to
80
+ } = selection;
81
+ const text = view.state.doc.textBetween(from, to, '\n');
82
+ const coords = getBoundingBoxFromSelection(view, from, to, {
83
+ top: shouldOffsetToolbarHeight ? akEditorFullPageToolbarHeight : 0,
84
+ bottom: shouldOffsetToolbarHeight ? akEditorFullPageToolbarHeight : 0
85
+ });
86
+ return {
87
+ text,
88
+ from,
89
+ to,
90
+ coords
91
+ };
92
+ };
93
+
94
+ /**
95
+ * @private
96
+ * @deprecated use getFragmentInfoFromSelectionNew instead
97
+ */
67
98
  export const getFragmentInfoFromSelection = state => {
68
99
  const {
69
100
  schema,
@@ -90,6 +121,33 @@ export const getFragmentInfoFromSelection = state => {
90
121
  selectedNodeAdf
91
122
  };
92
123
  };
124
+ export const getFragmentInfoFromSelectionNew = selection => {
125
+ const {
126
+ schema
127
+ } = selection.$from.doc.type;
128
+ const slice = selection.content();
129
+ let newDoc;
130
+ try {
131
+ const doc = schema.node('doc', null, [schema.node('paragraph', null, [])]);
132
+ const transform = new Transform(doc);
133
+ newDoc = transform.replaceRange(0, 2, slice).doc;
134
+ } catch (error) {
135
+ newDoc = schema.nodes.doc.createChecked({}, Fragment.empty);
136
+ logException(error, {
137
+ location: 'editor-plugin-selection-extension'
138
+ });
139
+ }
140
+ const serializer = new JSONTransformer();
141
+ const selectedNodeAdf = serializer.encodeNode(newDoc);
142
+ return {
143
+ selectedNodeAdf
144
+ };
145
+ };
146
+
147
+ /**
148
+ * @private
149
+ * @deprecated use getSelectionAdfInfoNew instead
150
+ */
93
151
  export function getSelectionAdfInfo(state) {
94
152
  const selection = state.selection;
95
153
  let selectionInfo = {
@@ -8,7 +8,7 @@ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equ
8
8
  import { insertAdfAtEndOfDoc } from './pm-plugins/actions/insertAdfAtEndOfDoc';
9
9
  import { replaceWithAdf } from './pm-plugins/actions/replaceWithAdf';
10
10
  import { createPlugin, selectionExtensionPluginKey } from './pm-plugins/main';
11
- import { getFragmentInfoFromSelection, getSelectionAdfInfo, getSelectionTextInfo } from './pm-plugins/utils';
11
+ import { getFragmentInfoFromSelection, getFragmentInfoFromSelectionNew, getSelectionAdfInfo, getSelectionAdfInfoNew, getSelectionTextInfo } from './pm-plugins/utils';
12
12
  import { SelectionExtensionActionTypes } from './types';
13
13
  import { SelectionExtensionComponentWrapper } from './ui/extension/SelectionExtensionComponentWrapper';
14
14
  import { getMenuItemExtensions, getToolbarItemExtensions } from './ui/extensions';
@@ -103,6 +103,11 @@ export const selectionExtensionPlugin = ({
103
103
  const {
104
104
  state
105
105
  } = editorViewRef.current;
106
+ if (expValEquals('platform_editor_block_menu', 'isEnabled', true)) {
107
+ var _api$blockControls, _api$blockControls$sh;
108
+ const selection = (api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : (_api$blockControls$sh = _api$blockControls.sharedState.currentState()) === null || _api$blockControls$sh === void 0 ? void 0 : _api$blockControls$sh.preservedSelection) || state.selection;
109
+ return getSelectionAdfInfoNew(selection);
110
+ }
106
111
  const {
107
112
  selectionRanges,
108
113
  selectedNodeAdf
@@ -119,6 +124,11 @@ export const selectionExtensionPlugin = ({
119
124
  const {
120
125
  state
121
126
  } = editorViewRef.current;
127
+ if (expValEquals('platform_editor_block_menu', 'isEnabled', true)) {
128
+ var _api$blockControls2, _api$blockControls2$s;
129
+ const selection = (api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$s = _api$blockControls2.sharedState.currentState()) === null || _api$blockControls2$s === void 0 ? void 0 : _api$blockControls2$s.preservedSelection) || state.selection;
130
+ return getFragmentInfoFromSelectionNew(selection);
131
+ }
122
132
  const {
123
133
  selectedNodeAdf
124
134
  } = getFragmentInfoFromSelection(state);
@@ -20,19 +20,20 @@ export let SelectionExtensionActionTypes = /*#__PURE__*/function (SelectionExten
20
20
  */
21
21
 
22
22
  /**
23
- * Fields for a leaf menu item (i.e., an item that does not have nested menu items)
23
+ * Fields for a dropdown item (i.e., an item that does not have further nested menu items)
24
24
  */
25
25
 
26
26
  /**
27
- * Fields for a dropdown menu item (i.e., an item that has nested menu items)
27
+ * Fields for a nested dropdown menu (i.e., an menu item that has further nested menu items)
28
28
  */
29
29
 
30
30
  /**
31
- * A type which marks all fields from ExtensionMenuItemDropdownMenuConfiguration and ExtensionMenuItemLeafConfiguration
32
- * as never, ensuring that only one of the two can be present at a time to avoid misconfigurations
31
+ * This type represents either a dropdown item or a dropdown menu, but not both.
32
+ *
33
+ * We mark all fields of the other type as `never` to enforce this exclusivity.
33
34
  */
34
35
 
35
36
  /**
36
- * We intentionally only support leaf menu items nested within dropdown menu items so that there will
37
- * be at max two levels of nesting from extension menu items.
37
+ * We intentionally only support dropdown items nested within dropdown menus, i.e. no menus nested
38
+ * within menus – so there will be at max two levels of nesting from extension menu items
38
39
  */
@@ -0,0 +1,13 @@
1
+ import React, { createElement } from 'react';
2
+ import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
3
+ export const SelectionExtensionDropdownItem = ({
4
+ dropdownItem
5
+ }) => {
6
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
7
+ elemBefore: dropdownItem.icon ? /*#__PURE__*/createElement(dropdownItem.icon, {
8
+ label: ''
9
+ }) : undefined,
10
+ onClick: dropdownItem.onClick,
11
+ isDisabled: dropdownItem.isDisabled
12
+ }, dropdownItem.label);
13
+ };
@@ -0,0 +1,28 @@
1
+ import React, { createElement } from 'react';
2
+ import { ToolbarNestedDropdownMenu } from '@atlaskit/editor-toolbar';
3
+ import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
4
+ import { SelectionExtensionDropdownItem } from './SelectionExtensionDropdownItem';
5
+ const ChildItems = ({
6
+ nestedDropdownMenu
7
+ }) => {
8
+ const childItems = nestedDropdownMenu.getMenuItems();
9
+ return /*#__PURE__*/React.createElement(React.Fragment, null, childItems.map(dropdownItem => /*#__PURE__*/React.createElement(SelectionExtensionDropdownItem, {
10
+ key: dropdownItem.label,
11
+ dropdownItem: dropdownItem
12
+ })));
13
+ };
14
+ export const SelectionExtensionNestedDropdownMenu = ({
15
+ nestedDropdownMenu
16
+ }) => {
17
+ return /*#__PURE__*/React.createElement(ToolbarNestedDropdownMenu, {
18
+ text: nestedDropdownMenu.label,
19
+ elemBefore: nestedDropdownMenu.icon ? /*#__PURE__*/createElement(nestedDropdownMenu.icon, {
20
+ label: ''
21
+ }) : undefined,
22
+ elemAfter: /*#__PURE__*/React.createElement(ChevronRightIcon, {
23
+ label: 'nested menu'
24
+ })
25
+ }, /*#__PURE__*/React.createElement(ChildItems, {
26
+ nestedDropdownMenu: nestedDropdownMenu
27
+ }));
28
+ };
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { isNestedDropdownMenuConfiguration } from '../utils/menu-items';
3
+ import { SelectionExtensionDropdownItem } from './SelectionExtensionDropdownItem';
4
+ import { SelectionExtensionNestedDropdownMenu } from './SelectionExtensionDropdownMenu';
5
+ export const SelectionExtensionMenuItems = ({
6
+ getMenuItems
7
+ }) => {
8
+ const extensionMenuItems = getMenuItems();
9
+ if (!(extensionMenuItems !== null && extensionMenuItems !== void 0 && extensionMenuItems.length)) {
10
+ return null;
11
+ }
12
+ return /*#__PURE__*/React.createElement(React.Fragment, null, extensionMenuItems.map(item => {
13
+ if (isNestedDropdownMenuConfiguration(item)) {
14
+ return /*#__PURE__*/React.createElement(SelectionExtensionNestedDropdownMenu, {
15
+ key: item.label,
16
+ nestedDropdownMenu: item
17
+ });
18
+ }
19
+ return /*#__PURE__*/React.createElement(SelectionExtensionDropdownItem, {
20
+ key: item.label,
21
+ dropdownItem: item
22
+ });
23
+ }));
24
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Type guard to check if the given configuration is for a dropdown menu.
3
+ *
4
+ * @param item - The menu item configuration to check, either menu item or dropdown menu
5
+ * @returns True if the item configuration is for a dropdown menu, false otherwise
6
+ */
7
+ export const isNestedDropdownMenuConfiguration = item => {
8
+ return 'getMenuItems' in item && typeof item.getMenuItems === 'function';
9
+ };
@@ -1,11 +1,12 @@
1
1
  import React from 'react';
2
2
  import { TRANSFORM_CREATE_MENU_SECTION, TRANSFORM_MENU_ITEM_RANK } from '@atlaskit/editor-common/block-menu';
3
+ import { SelectionExtensionMenuItems } from '../menu/SelectionExtensionMenuItems';
3
4
  export function registerBlockMenuItems(extensionList, api) {
4
5
  extensionList.forEach(({
5
6
  source,
6
7
  key,
7
8
  blockMenu
8
- }, index) => {
9
+ }) => {
9
10
  var _api$blockMenu;
10
11
  if (source !== 'first-party' || !blockMenu) {
11
12
  return;
@@ -19,8 +20,9 @@ export function registerBlockMenuItems(extensionList, api) {
19
20
  rank: TRANSFORM_MENU_ITEM_RANK[TRANSFORM_CREATE_MENU_SECTION.key]
20
21
  },
21
22
  component: () => {
22
- // EDITOR-2772 implementation of rendering in next PR
23
- return /*#__PURE__*/React.createElement("div", null, "Placeholder");
23
+ return /*#__PURE__*/React.createElement(SelectionExtensionMenuItems, {
24
+ getMenuItems: blockMenu.getMenuItems
25
+ });
24
26
  }
25
27
  }]);
26
28
  });
@@ -41,10 +41,15 @@ var getSelectionInfoFromCellSelection = function getSelectionInfoFromCellSelecti
41
41
  nodePos: nodePos
42
42
  };
43
43
  };
44
+
45
+ /**
46
+ * @private
47
+ * @deprecated use getFragmentInfoFromSelectionNew instead
48
+ */
44
49
  export var getSelectionTextInfo = function getSelectionTextInfo(view, api) {
45
- var _api$userPreferences, _api$selectionToolbar, _api$editorViewMode;
50
+ var _api$userPreferences, _api$editorViewMode;
46
51
  var currentSelection = view.state.selection;
47
- var toolbarDocking = fg('platform_editor_use_preferences_plugin') ? api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.preferences) === null || _api$userPreferences === void 0 ? void 0 : _api$userPreferences.toolbarDockingPosition : api === null || api === void 0 || (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.currentState()) === null || _api$selectionToolbar === void 0 ? void 0 : _api$selectionToolbar.toolbarDocking;
52
+ var toolbarDocking = api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.preferences) === null || _api$userPreferences === void 0 ? void 0 : _api$userPreferences.toolbarDockingPosition;
48
53
  var isEditMode = Boolean((api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'edit');
49
54
  var shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode;
50
55
  var from = currentSelection.from,
@@ -61,6 +66,30 @@ export var getSelectionTextInfo = function getSelectionTextInfo(view, api) {
61
66
  coords: coords
62
67
  };
63
68
  };
69
+ export var getSelectionTextInfoNew = function getSelectionTextInfoNew(selection, view, api) {
70
+ var _api$userPreferences2, _api$selectionToolbar, _api$editorViewMode2;
71
+ var toolbarDocking = fg('platform_editor_use_preferences_plugin') ? api === null || api === void 0 || (_api$userPreferences2 = api.userPreferences) === null || _api$userPreferences2 === void 0 || (_api$userPreferences2 = _api$userPreferences2.sharedState.currentState()) === null || _api$userPreferences2 === void 0 || (_api$userPreferences2 = _api$userPreferences2.preferences) === null || _api$userPreferences2 === void 0 ? void 0 : _api$userPreferences2.toolbarDockingPosition : api === null || api === void 0 || (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.currentState()) === null || _api$selectionToolbar === void 0 ? void 0 : _api$selectionToolbar.toolbarDocking;
72
+ var isEditMode = Boolean((api === null || api === void 0 || (_api$editorViewMode2 = api.editorViewMode) === null || _api$editorViewMode2 === void 0 || (_api$editorViewMode2 = _api$editorViewMode2.sharedState.currentState()) === null || _api$editorViewMode2 === void 0 ? void 0 : _api$editorViewMode2.mode) === 'edit');
73
+ var shouldOffsetToolbarHeight = toolbarDocking === 'top' && isEditMode;
74
+ var from = selection.from,
75
+ to = selection.to;
76
+ var text = view.state.doc.textBetween(from, to, '\n');
77
+ var coords = getBoundingBoxFromSelection(view, from, to, {
78
+ top: shouldOffsetToolbarHeight ? akEditorFullPageToolbarHeight : 0,
79
+ bottom: shouldOffsetToolbarHeight ? akEditorFullPageToolbarHeight : 0
80
+ });
81
+ return {
82
+ text: text,
83
+ from: from,
84
+ to: to,
85
+ coords: coords
86
+ };
87
+ };
88
+
89
+ /**
90
+ * @private
91
+ * @deprecated use getFragmentInfoFromSelectionNew instead
92
+ */
64
93
  export var getFragmentInfoFromSelection = function getFragmentInfoFromSelection(state) {
65
94
  var schema = state.schema,
66
95
  selection = state.selection;
@@ -83,6 +112,31 @@ export var getFragmentInfoFromSelection = function getFragmentInfoFromSelection(
83
112
  selectedNodeAdf: selectedNodeAdf
84
113
  };
85
114
  };
115
+ export var getFragmentInfoFromSelectionNew = function getFragmentInfoFromSelectionNew(selection) {
116
+ var schema = selection.$from.doc.type.schema;
117
+ var slice = selection.content();
118
+ var newDoc;
119
+ try {
120
+ var doc = schema.node('doc', null, [schema.node('paragraph', null, [])]);
121
+ var transform = new Transform(doc);
122
+ newDoc = transform.replaceRange(0, 2, slice).doc;
123
+ } catch (error) {
124
+ newDoc = schema.nodes.doc.createChecked({}, Fragment.empty);
125
+ logException(error, {
126
+ location: 'editor-plugin-selection-extension'
127
+ });
128
+ }
129
+ var serializer = new JSONTransformer();
130
+ var selectedNodeAdf = serializer.encodeNode(newDoc);
131
+ return {
132
+ selectedNodeAdf: selectedNodeAdf
133
+ };
134
+ };
135
+
136
+ /**
137
+ * @private
138
+ * @deprecated use getSelectionAdfInfoNew instead
139
+ */
86
140
  export function getSelectionAdfInfo(state) {
87
141
  var selection = state.selection;
88
142
  var selectionInfo = {
@@ -9,7 +9,7 @@ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equ
9
9
  import { insertAdfAtEndOfDoc as _insertAdfAtEndOfDoc } from './pm-plugins/actions/insertAdfAtEndOfDoc';
10
10
  import { replaceWithAdf as _replaceWithAdf } from './pm-plugins/actions/replaceWithAdf';
11
11
  import { createPlugin, selectionExtensionPluginKey } from './pm-plugins/main';
12
- import { getFragmentInfoFromSelection, getSelectionAdfInfo, getSelectionTextInfo } from './pm-plugins/utils';
12
+ import { getFragmentInfoFromSelection, getFragmentInfoFromSelectionNew, getSelectionAdfInfo, getSelectionAdfInfoNew, getSelectionTextInfo } from './pm-plugins/utils';
13
13
  import { SelectionExtensionActionTypes } from './types';
14
14
  import { SelectionExtensionComponentWrapper } from './ui/extension/SelectionExtensionComponentWrapper';
15
15
  import { getMenuItemExtensions, getToolbarItemExtensions } from './ui/extensions';
@@ -105,6 +105,11 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
105
105
  return null;
106
106
  }
107
107
  var state = editorViewRef.current.state;
108
+ if (expValEquals('platform_editor_block_menu', 'isEnabled', true)) {
109
+ var _api$blockControls;
110
+ var selection = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || (_api$blockControls = _api$blockControls.sharedState.currentState()) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.preservedSelection) || state.selection;
111
+ return getSelectionAdfInfoNew(selection);
112
+ }
108
113
  var _getSelectionAdfInfo = getSelectionAdfInfo(state),
109
114
  selectionRanges = _getSelectionAdfInfo.selectionRanges,
110
115
  selectedNodeAdf = _getSelectionAdfInfo.selectedNodeAdf;
@@ -118,6 +123,11 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
118
123
  return null;
119
124
  }
120
125
  var state = editorViewRef.current.state;
126
+ if (expValEquals('platform_editor_block_menu', 'isEnabled', true)) {
127
+ var _api$blockControls2;
128
+ var selection = (api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.sharedState.currentState()) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.preservedSelection) || state.selection;
129
+ return getFragmentInfoFromSelectionNew(selection);
130
+ }
121
131
  var _getFragmentInfoFromS = getFragmentInfoFromSelection(state),
122
132
  selectedNodeAdf = _getFragmentInfoFromS.selectedNodeAdf;
123
133
  return {
@@ -20,19 +20,20 @@ export var SelectionExtensionActionTypes = /*#__PURE__*/function (SelectionExten
20
20
  */
21
21
 
22
22
  /**
23
- * Fields for a leaf menu item (i.e., an item that does not have nested menu items)
23
+ * Fields for a dropdown item (i.e., an item that does not have further nested menu items)
24
24
  */
25
25
 
26
26
  /**
27
- * Fields for a dropdown menu item (i.e., an item that has nested menu items)
27
+ * Fields for a nested dropdown menu (i.e., an menu item that has further nested menu items)
28
28
  */
29
29
 
30
30
  /**
31
- * A type which marks all fields from ExtensionMenuItemDropdownMenuConfiguration and ExtensionMenuItemLeafConfiguration
32
- * as never, ensuring that only one of the two can be present at a time to avoid misconfigurations
31
+ * This type represents either a dropdown item or a dropdown menu, but not both.
32
+ *
33
+ * We mark all fields of the other type as `never` to enforce this exclusivity.
33
34
  */
34
35
 
35
36
  /**
36
- * We intentionally only support leaf menu items nested within dropdown menu items so that there will
37
- * be at max two levels of nesting from extension menu items.
37
+ * We intentionally only support dropdown items nested within dropdown menus, i.e. no menus nested
38
+ * within menus – so there will be at max two levels of nesting from extension menu items
38
39
  */
@@ -0,0 +1,12 @@
1
+ import React, { createElement } from 'react';
2
+ import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
3
+ export var SelectionExtensionDropdownItem = function SelectionExtensionDropdownItem(_ref) {
4
+ var dropdownItem = _ref.dropdownItem;
5
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
6
+ elemBefore: dropdownItem.icon ? /*#__PURE__*/createElement(dropdownItem.icon, {
7
+ label: ''
8
+ }) : undefined,
9
+ onClick: dropdownItem.onClick,
10
+ isDisabled: dropdownItem.isDisabled
11
+ }, dropdownItem.label);
12
+ };
@@ -0,0 +1,28 @@
1
+ import React, { createElement } from 'react';
2
+ import { ToolbarNestedDropdownMenu } from '@atlaskit/editor-toolbar';
3
+ import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
4
+ import { SelectionExtensionDropdownItem } from './SelectionExtensionDropdownItem';
5
+ var ChildItems = function ChildItems(_ref) {
6
+ var nestedDropdownMenu = _ref.nestedDropdownMenu;
7
+ var childItems = nestedDropdownMenu.getMenuItems();
8
+ return /*#__PURE__*/React.createElement(React.Fragment, null, childItems.map(function (dropdownItem) {
9
+ return /*#__PURE__*/React.createElement(SelectionExtensionDropdownItem, {
10
+ key: dropdownItem.label,
11
+ dropdownItem: dropdownItem
12
+ });
13
+ }));
14
+ };
15
+ export var SelectionExtensionNestedDropdownMenu = function SelectionExtensionNestedDropdownMenu(_ref2) {
16
+ var nestedDropdownMenu = _ref2.nestedDropdownMenu;
17
+ return /*#__PURE__*/React.createElement(ToolbarNestedDropdownMenu, {
18
+ text: nestedDropdownMenu.label,
19
+ elemBefore: nestedDropdownMenu.icon ? /*#__PURE__*/createElement(nestedDropdownMenu.icon, {
20
+ label: ''
21
+ }) : undefined,
22
+ elemAfter: /*#__PURE__*/React.createElement(ChevronRightIcon, {
23
+ label: 'nested menu'
24
+ })
25
+ }, /*#__PURE__*/React.createElement(ChildItems, {
26
+ nestedDropdownMenu: nestedDropdownMenu
27
+ }));
28
+ };
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { isNestedDropdownMenuConfiguration } from '../utils/menu-items';
3
+ import { SelectionExtensionDropdownItem } from './SelectionExtensionDropdownItem';
4
+ import { SelectionExtensionNestedDropdownMenu } from './SelectionExtensionDropdownMenu';
5
+ export var SelectionExtensionMenuItems = function SelectionExtensionMenuItems(_ref) {
6
+ var getMenuItems = _ref.getMenuItems;
7
+ var extensionMenuItems = getMenuItems();
8
+ if (!(extensionMenuItems !== null && extensionMenuItems !== void 0 && extensionMenuItems.length)) {
9
+ return null;
10
+ }
11
+ return /*#__PURE__*/React.createElement(React.Fragment, null, extensionMenuItems.map(function (item) {
12
+ if (isNestedDropdownMenuConfiguration(item)) {
13
+ return /*#__PURE__*/React.createElement(SelectionExtensionNestedDropdownMenu, {
14
+ key: item.label,
15
+ nestedDropdownMenu: item
16
+ });
17
+ }
18
+ return /*#__PURE__*/React.createElement(SelectionExtensionDropdownItem, {
19
+ key: item.label,
20
+ dropdownItem: item
21
+ });
22
+ }));
23
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Type guard to check if the given configuration is for a dropdown menu.
3
+ *
4
+ * @param item - The menu item configuration to check, either menu item or dropdown menu
5
+ * @returns True if the item configuration is for a dropdown menu, false otherwise
6
+ */
7
+ export var isNestedDropdownMenuConfiguration = function isNestedDropdownMenuConfiguration(item) {
8
+ return 'getMenuItems' in item && typeof item.getMenuItems === 'function';
9
+ };
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TRANSFORM_CREATE_MENU_SECTION, TRANSFORM_MENU_ITEM_RANK } from '@atlaskit/editor-common/block-menu';
3
+ import { SelectionExtensionMenuItems } from '../menu/SelectionExtensionMenuItems';
3
4
  export function registerBlockMenuItems(extensionList, api) {
4
- extensionList.forEach(function (_ref, index) {
5
+ extensionList.forEach(function (_ref) {
5
6
  var _api$blockMenu;
6
7
  var source = _ref.source,
7
8
  key = _ref.key,
@@ -18,8 +19,9 @@ export function registerBlockMenuItems(extensionList, api) {
18
19
  rank: TRANSFORM_MENU_ITEM_RANK[TRANSFORM_CREATE_MENU_SECTION.key]
19
20
  },
20
21
  component: function component() {
21
- // EDITOR-2772 implementation of rendering in next PR
22
- return /*#__PURE__*/React.createElement("div", null, "Placeholder");
22
+ return /*#__PURE__*/React.createElement(SelectionExtensionMenuItems, {
23
+ getMenuItems: blockMenu.getMenuItems
24
+ });
23
25
  }
24
26
  }]);
25
27
  });
@@ -12,10 +12,26 @@ type SelectionInfo = {
12
12
  selectedNodeAdf: ADFEntity;
13
13
  selectionRanges?: SelectionRange[];
14
14
  };
15
+ /**
16
+ * @private
17
+ * @deprecated use getFragmentInfoFromSelectionNew instead
18
+ */
15
19
  export declare const getSelectionTextInfo: (view: EditorView, api?: ExtractInjectionAPI<SelectionExtensionPlugin>) => SelectionExtensionSelectionInfo;
20
+ export declare const getSelectionTextInfoNew: (selection: Selection, view: EditorView, api?: ExtractInjectionAPI<SelectionExtensionPlugin>) => SelectionExtensionSelectionInfo;
21
+ /**
22
+ * @private
23
+ * @deprecated use getFragmentInfoFromSelectionNew instead
24
+ */
16
25
  export declare const getFragmentInfoFromSelection: (state: EditorState) => {
17
26
  selectedNodeAdf: ADFEntity;
18
27
  };
28
+ export declare const getFragmentInfoFromSelectionNew: (selection: Selection) => {
29
+ selectedNodeAdf: ADFEntity;
30
+ };
31
+ /**
32
+ * @private
33
+ * @deprecated use getSelectionAdfInfoNew instead
34
+ */
19
35
  export declare function getSelectionAdfInfo(state: EditorState): SelectionInfo;
20
36
  export declare function getSelectionAdfInfoNew(selection: Selection): SelectionInfo;
21
37
  export {};
@@ -1,6 +1,7 @@
1
1
  import { type ADFEntity } from '@atlaskit/adf-utils/types';
2
2
  import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
+ import type { BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
4
5
  import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
5
6
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
6
7
  import type { EditorViewModeEffectsPlugin } from '@atlaskit/editor-plugin-editor-viewmode-effects';
@@ -10,7 +11,7 @@ import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-t
10
11
  import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
11
12
  import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
12
13
  import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
13
- import type { SelectionAdfResult, InsertAdfAtEndOfDocResult, ReplaceWithAdfResult, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, ExtensionMenuItemConfiguration } from './types';
14
+ import type { ExtensionMenuItemConfiguration, InsertAdfAtEndOfDocResult, ReplaceWithAdfResult, SelectionAdfResult, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
14
15
  export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
15
16
  actions: {
16
17
  getDocumentFromSelection: () => {
@@ -35,6 +36,7 @@ export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
35
36
  OptionalPlugin<UserPreferencesPlugin>,
36
37
  OptionalPlugin<UserIntentPlugin>,
37
38
  OptionalPlugin<SelectionPlugin>,
39
+ OptionalPlugin<BlockControlsPlugin>,
38
40
  OptionalPlugin<BlockMenuPlugin>,
39
41
  OptionalPlugin<ToolbarPlugin>,
40
42
  SelectionToolbarPlugin
@@ -156,9 +156,9 @@ type ExtensionMenuItemBaseConfiguration = {
156
156
  isDisabled?: boolean;
157
157
  };
158
158
  /**
159
- * Fields for a leaf menu item (i.e., an item that does not have nested menu items)
159
+ * Fields for a dropdown item (i.e., an item that does not have further nested menu items)
160
160
  */
161
- type ExtensionMenuItemLeafConfiguration = {
161
+ type ExtensionDropdownItemFields = {
162
162
  /**
163
163
  * Optional content component to render when this menu item is selected
164
164
  *
@@ -174,23 +174,25 @@ type ExtensionMenuItemLeafConfiguration = {
174
174
  onClick?: () => void;
175
175
  };
176
176
  /**
177
- * Fields for a dropdown menu item (i.e., an item that has nested menu items)
177
+ * Fields for a nested dropdown menu (i.e., an menu item that has further nested menu items)
178
178
  */
179
- type ExtensionMenuItemDropdownMenuConfiguration = {
179
+ type ExtensionNestedDropdownMenuFields = {
180
180
  getMenuItems: GetNestedMenuItemsFn;
181
181
  };
182
+ export type ExtensionDropdownItemConfiguration = ExtensionMenuItemBaseConfiguration & AllNever<ExtensionNestedDropdownMenuFields> & ExtensionDropdownItemFields;
183
+ export type ExtensionNestedDropdownMenuConfiguration = ExtensionMenuItemBaseConfiguration & AllNever<ExtensionDropdownItemFields> & ExtensionNestedDropdownMenuFields;
182
184
  type AllNever<T> = {
183
185
  [K in keyof T]?: never;
184
186
  };
185
187
  /**
186
- * A type which marks all fields from ExtensionMenuItemDropdownMenuConfiguration and ExtensionMenuItemLeafConfiguration
187
- * as never, ensuring that only one of the two can be present at a time to avoid misconfigurations
188
+ * This type represents either a dropdown item or a dropdown menu, but not both.
189
+ *
190
+ * We mark all fields of the other type as `never` to enforce this exclusivity.
188
191
  */
189
- type ExtensionMenuItemUnsupportedConfiguration = AllNever<ExtensionMenuItemDropdownMenuConfiguration | ExtensionMenuItemLeafConfiguration>;
190
- export type ExtensionMenuItemConfiguration = ExtensionMenuItemBaseConfiguration & ExtensionMenuItemUnsupportedConfiguration & (ExtensionMenuItemLeafConfiguration | ExtensionMenuItemDropdownMenuConfiguration);
192
+ export type ExtensionMenuItemConfiguration = ExtensionDropdownItemConfiguration | ExtensionNestedDropdownMenuConfiguration;
191
193
  /**
192
- * We intentionally only support leaf menu items nested within dropdown menu items so that there will
193
- * be at max two levels of nesting from extension menu items.
194
+ * We intentionally only support dropdown items nested within dropdown menus, i.e. no menus nested
195
+ * within menus – so there will be at max two levels of nesting from extension menu items
194
196
  */
195
- type ExtensionMenuItemNestedConfiguration = ExtensionMenuItemBaseConfiguration & ExtensionMenuItemLeafConfiguration;
197
+ type ExtensionMenuItemNestedConfiguration = ExtensionDropdownItemConfiguration;
196
198
  export {};
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { ExtensionDropdownItemConfiguration } from '../../types';
3
+ type SelectionExtensionDropdownItemProps = {
4
+ dropdownItem: ExtensionDropdownItemConfiguration;
5
+ };
6
+ export declare const SelectionExtensionDropdownItem: ({ dropdownItem, }: SelectionExtensionDropdownItemProps) => React.JSX.Element;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { type ExtensionNestedDropdownMenuConfiguration } from '../../types';
3
+ export type SelectionExtensionNestedDropdownMenuProps = {
4
+ nestedDropdownMenu: ExtensionNestedDropdownMenuConfiguration;
5
+ };
6
+ export declare const SelectionExtensionNestedDropdownMenu: ({ nestedDropdownMenu, }: SelectionExtensionNestedDropdownMenuProps) => React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { ExtensionMenuItemConfiguration } from '../../types';
3
+ type SelectionExtensionMenuItemsProps = {
4
+ getMenuItems: () => ExtensionMenuItemConfiguration[];
5
+ };
6
+ export declare const SelectionExtensionMenuItems: ({ getMenuItems }: SelectionExtensionMenuItemsProps) => React.JSX.Element | null;
7
+ export {};
@@ -6,5 +6,5 @@ type ToolbarMenuProps = React.PropsWithChildren<{
6
6
  api: ExtractInjectionAPI<SelectionExtensionPlugin> | undefined;
7
7
  config: ExtensionToolbarItemConfiguration;
8
8
  }>;
9
- export declare const ToolbarMenu: ({ api, config, children }: ToolbarMenuProps) => React.JSX.Element | null;
9
+ export declare const ToolbarMenu: ({ api, config, children, }: ToolbarMenuProps) => React.JSX.Element | null;
10
10
  export {};
@@ -0,0 +1,8 @@
1
+ import type { ExtensionMenuItemConfiguration, ExtensionNestedDropdownMenuConfiguration } from '../../types';
2
+ /**
3
+ * Type guard to check if the given configuration is for a dropdown menu.
4
+ *
5
+ * @param item - The menu item configuration to check, either menu item or dropdown menu
6
+ * @returns True if the item configuration is for a dropdown menu, false otherwise
7
+ */
8
+ export declare const isNestedDropdownMenuConfiguration: (item: ExtensionMenuItemConfiguration) => item is ExtensionNestedDropdownMenuConfiguration;
@@ -12,10 +12,26 @@ type SelectionInfo = {
12
12
  selectedNodeAdf: ADFEntity;
13
13
  selectionRanges?: SelectionRange[];
14
14
  };
15
+ /**
16
+ * @private
17
+ * @deprecated use getFragmentInfoFromSelectionNew instead
18
+ */
15
19
  export declare const getSelectionTextInfo: (view: EditorView, api?: ExtractInjectionAPI<SelectionExtensionPlugin>) => SelectionExtensionSelectionInfo;
20
+ export declare const getSelectionTextInfoNew: (selection: Selection, view: EditorView, api?: ExtractInjectionAPI<SelectionExtensionPlugin>) => SelectionExtensionSelectionInfo;
21
+ /**
22
+ * @private
23
+ * @deprecated use getFragmentInfoFromSelectionNew instead
24
+ */
16
25
  export declare const getFragmentInfoFromSelection: (state: EditorState) => {
17
26
  selectedNodeAdf: ADFEntity;
18
27
  };
28
+ export declare const getFragmentInfoFromSelectionNew: (selection: Selection) => {
29
+ selectedNodeAdf: ADFEntity;
30
+ };
31
+ /**
32
+ * @private
33
+ * @deprecated use getSelectionAdfInfoNew instead
34
+ */
19
35
  export declare function getSelectionAdfInfo(state: EditorState): SelectionInfo;
20
36
  export declare function getSelectionAdfInfoNew(selection: Selection): SelectionInfo;
21
37
  export {};
@@ -1,6 +1,7 @@
1
1
  import { type ADFEntity } from '@atlaskit/adf-utils/types';
2
2
  import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
+ import type { BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
4
5
  import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
5
6
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
6
7
  import type { EditorViewModeEffectsPlugin } from '@atlaskit/editor-plugin-editor-viewmode-effects';
@@ -10,7 +11,7 @@ import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-t
10
11
  import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
11
12
  import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
12
13
  import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
13
- import type { SelectionAdfResult, InsertAdfAtEndOfDocResult, ReplaceWithAdfResult, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, ExtensionMenuItemConfiguration } from './types';
14
+ import type { ExtensionMenuItemConfiguration, InsertAdfAtEndOfDocResult, ReplaceWithAdfResult, SelectionAdfResult, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
14
15
  export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
15
16
  actions: {
16
17
  getDocumentFromSelection: () => {
@@ -35,6 +36,7 @@ export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
35
36
  OptionalPlugin<UserPreferencesPlugin>,
36
37
  OptionalPlugin<UserIntentPlugin>,
37
38
  OptionalPlugin<SelectionPlugin>,
39
+ OptionalPlugin<BlockControlsPlugin>,
38
40
  OptionalPlugin<BlockMenuPlugin>,
39
41
  OptionalPlugin<ToolbarPlugin>,
40
42
  SelectionToolbarPlugin
@@ -156,9 +156,9 @@ type ExtensionMenuItemBaseConfiguration = {
156
156
  isDisabled?: boolean;
157
157
  };
158
158
  /**
159
- * Fields for a leaf menu item (i.e., an item that does not have nested menu items)
159
+ * Fields for a dropdown item (i.e., an item that does not have further nested menu items)
160
160
  */
161
- type ExtensionMenuItemLeafConfiguration = {
161
+ type ExtensionDropdownItemFields = {
162
162
  /**
163
163
  * Optional content component to render when this menu item is selected
164
164
  *
@@ -174,23 +174,25 @@ type ExtensionMenuItemLeafConfiguration = {
174
174
  onClick?: () => void;
175
175
  };
176
176
  /**
177
- * Fields for a dropdown menu item (i.e., an item that has nested menu items)
177
+ * Fields for a nested dropdown menu (i.e., an menu item that has further nested menu items)
178
178
  */
179
- type ExtensionMenuItemDropdownMenuConfiguration = {
179
+ type ExtensionNestedDropdownMenuFields = {
180
180
  getMenuItems: GetNestedMenuItemsFn;
181
181
  };
182
+ export type ExtensionDropdownItemConfiguration = ExtensionMenuItemBaseConfiguration & AllNever<ExtensionNestedDropdownMenuFields> & ExtensionDropdownItemFields;
183
+ export type ExtensionNestedDropdownMenuConfiguration = ExtensionMenuItemBaseConfiguration & AllNever<ExtensionDropdownItemFields> & ExtensionNestedDropdownMenuFields;
182
184
  type AllNever<T> = {
183
185
  [K in keyof T]?: never;
184
186
  };
185
187
  /**
186
- * A type which marks all fields from ExtensionMenuItemDropdownMenuConfiguration and ExtensionMenuItemLeafConfiguration
187
- * as never, ensuring that only one of the two can be present at a time to avoid misconfigurations
188
+ * This type represents either a dropdown item or a dropdown menu, but not both.
189
+ *
190
+ * We mark all fields of the other type as `never` to enforce this exclusivity.
188
191
  */
189
- type ExtensionMenuItemUnsupportedConfiguration = AllNever<ExtensionMenuItemDropdownMenuConfiguration | ExtensionMenuItemLeafConfiguration>;
190
- export type ExtensionMenuItemConfiguration = ExtensionMenuItemBaseConfiguration & ExtensionMenuItemUnsupportedConfiguration & (ExtensionMenuItemLeafConfiguration | ExtensionMenuItemDropdownMenuConfiguration);
192
+ export type ExtensionMenuItemConfiguration = ExtensionDropdownItemConfiguration | ExtensionNestedDropdownMenuConfiguration;
191
193
  /**
192
- * We intentionally only support leaf menu items nested within dropdown menu items so that there will
193
- * be at max two levels of nesting from extension menu items.
194
+ * We intentionally only support dropdown items nested within dropdown menus, i.e. no menus nested
195
+ * within menus – so there will be at max two levels of nesting from extension menu items
194
196
  */
195
- type ExtensionMenuItemNestedConfiguration = ExtensionMenuItemBaseConfiguration & ExtensionMenuItemLeafConfiguration;
197
+ type ExtensionMenuItemNestedConfiguration = ExtensionDropdownItemConfiguration;
196
198
  export {};
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { ExtensionDropdownItemConfiguration } from '../../types';
3
+ type SelectionExtensionDropdownItemProps = {
4
+ dropdownItem: ExtensionDropdownItemConfiguration;
5
+ };
6
+ export declare const SelectionExtensionDropdownItem: ({ dropdownItem, }: SelectionExtensionDropdownItemProps) => React.JSX.Element;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { type ExtensionNestedDropdownMenuConfiguration } from '../../types';
3
+ export type SelectionExtensionNestedDropdownMenuProps = {
4
+ nestedDropdownMenu: ExtensionNestedDropdownMenuConfiguration;
5
+ };
6
+ export declare const SelectionExtensionNestedDropdownMenu: ({ nestedDropdownMenu, }: SelectionExtensionNestedDropdownMenuProps) => React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { ExtensionMenuItemConfiguration } from '../../types';
3
+ type SelectionExtensionMenuItemsProps = {
4
+ getMenuItems: () => ExtensionMenuItemConfiguration[];
5
+ };
6
+ export declare const SelectionExtensionMenuItems: ({ getMenuItems }: SelectionExtensionMenuItemsProps) => React.JSX.Element | null;
7
+ export {};
@@ -6,5 +6,5 @@ type ToolbarMenuProps = React.PropsWithChildren<{
6
6
  api: ExtractInjectionAPI<SelectionExtensionPlugin> | undefined;
7
7
  config: ExtensionToolbarItemConfiguration;
8
8
  }>;
9
- export declare const ToolbarMenu: ({ api, config, children }: ToolbarMenuProps) => React.JSX.Element | null;
9
+ export declare const ToolbarMenu: ({ api, config, children, }: ToolbarMenuProps) => React.JSX.Element | null;
10
10
  export {};
@@ -0,0 +1,8 @@
1
+ import type { ExtensionMenuItemConfiguration, ExtensionNestedDropdownMenuConfiguration } from '../../types';
2
+ /**
3
+ * Type guard to check if the given configuration is for a dropdown menu.
4
+ *
5
+ * @param item - The menu item configuration to check, either menu item or dropdown menu
6
+ * @returns True if the item configuration is for a dropdown menu, false otherwise
7
+ */
8
+ export declare const isNestedDropdownMenuConfiguration: (item: ExtensionMenuItemConfiguration) => item is ExtensionNestedDropdownMenuConfiguration;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection-extension",
3
- "version": "9.0.1",
3
+ "version": "9.0.3",
4
4
  "description": "editor-plugin-selection-extension plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,34 +35,35 @@
35
35
  "@atlaskit/adf-utils": "^19.26.0",
36
36
  "@atlaskit/editor-json-transformer": "^8.31.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^6.2.0",
38
- "@atlaskit/editor-plugin-block-menu": "^5.1.0",
38
+ "@atlaskit/editor-plugin-block-controls": "^7.14.0",
39
+ "@atlaskit/editor-plugin-block-menu": "^5.2.0",
39
40
  "@atlaskit/editor-plugin-editor-viewmode": "^8.0.0",
40
41
  "@atlaskit/editor-plugin-editor-viewmode-effects": "^6.1.0",
41
42
  "@atlaskit/editor-plugin-primary-toolbar": "^7.0.0",
42
43
  "@atlaskit/editor-plugin-selection-toolbar": "^7.1.0",
43
44
  "@atlaskit/editor-plugin-toolbar": "^3.4.0",
44
45
  "@atlaskit/editor-plugin-user-preferences": "^4.0.0",
45
- "@atlaskit/editor-prosemirror": "7.0.0",
46
+ "@atlaskit/editor-prosemirror": "^7.2.0",
46
47
  "@atlaskit/editor-shared-styles": "^3.10.0",
47
48
  "@atlaskit/editor-tables": "^2.9.0",
48
49
  "@atlaskit/editor-toolbar": "^0.18.0",
49
- "@atlaskit/icon": "^29.0.0",
50
+ "@atlaskit/icon": "^29.1.0",
50
51
  "@atlaskit/lozenge": "^13.1.0",
51
52
  "@atlaskit/platform-feature-flags": "^1.1.0",
52
53
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
53
54
  "@atlaskit/primitives": "^16.4.0",
54
- "@atlaskit/tmp-editor-statsig": "^15.0.0",
55
+ "@atlaskit/tmp-editor-statsig": "^15.10.0",
55
56
  "@babel/runtime": "^7.0.0",
56
57
  "lodash": "^4.17.21",
57
58
  "react-intl-next": "npm:react-intl@^5.18.1",
58
59
  "uuid": "^3.1.0"
59
60
  },
60
61
  "peerDependencies": {
61
- "@atlaskit/editor-common": "^110.40.0",
62
+ "@atlaskit/editor-common": "^110.42.0",
62
63
  "react": "^18.2.0"
63
64
  },
64
65
  "devDependencies": {
65
- "@testing-library/react": "^13.4.0",
66
+ "@testing-library/react": "^16.3.0",
66
67
  "react-dom": "^18.2.0",
67
68
  "wait-for-expect": "^1.2.0"
68
69
  },