@atlaskit/editor-plugin-block-controls 4.1.11 → 4.2.0

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 (52) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/blockControlsPlugin.js +29 -13
  3. package/dist/cjs/editor-commands/move-node-with-block-menu.js +44 -0
  4. package/dist/cjs/editor-commands/move-node.js +16 -15
  5. package/dist/cjs/editor-commands/show-drag-handle.js +5 -1
  6. package/dist/cjs/editor-commands/utils/move-node-utils.js +91 -0
  7. package/dist/cjs/pm-plugins/decorations-drop-target.js +6 -2
  8. package/dist/cjs/pm-plugins/decorations-quick-insert-button.js +3 -1
  9. package/dist/cjs/pm-plugins/keymap.js +5 -5
  10. package/dist/cjs/pm-plugins/main.js +46 -27
  11. package/dist/cjs/pm-plugins/utils/consts.js +1 -8
  12. package/dist/cjs/pm-plugins/utils/getNestedNodePosition.js +6 -4
  13. package/dist/cjs/ui/block-menu-items.js +3 -3
  14. package/dist/es2019/blockControlsPlugin.js +31 -13
  15. package/dist/es2019/editor-commands/move-node-with-block-menu.js +39 -0
  16. package/dist/es2019/editor-commands/move-node.js +13 -12
  17. package/dist/es2019/editor-commands/show-drag-handle.js +5 -1
  18. package/dist/es2019/editor-commands/utils/move-node-utils.js +88 -0
  19. package/dist/es2019/pm-plugins/decorations-drop-target.js +6 -2
  20. package/dist/es2019/pm-plugins/decorations-quick-insert-button.js +3 -1
  21. package/dist/es2019/pm-plugins/keymap.js +1 -1
  22. package/dist/es2019/pm-plugins/main.js +46 -29
  23. package/dist/es2019/pm-plugins/utils/consts.js +0 -7
  24. package/dist/es2019/pm-plugins/utils/getNestedNodePosition.js +7 -6
  25. package/dist/es2019/ui/block-menu-items.js +1 -1
  26. package/dist/esm/blockControlsPlugin.js +29 -13
  27. package/dist/esm/editor-commands/move-node-with-block-menu.js +38 -0
  28. package/dist/esm/editor-commands/move-node.js +13 -12
  29. package/dist/esm/editor-commands/show-drag-handle.js +5 -1
  30. package/dist/esm/editor-commands/utils/move-node-utils.js +85 -0
  31. package/dist/esm/pm-plugins/decorations-drop-target.js +6 -2
  32. package/dist/esm/pm-plugins/decorations-quick-insert-button.js +3 -1
  33. package/dist/esm/pm-plugins/keymap.js +1 -1
  34. package/dist/esm/pm-plugins/main.js +46 -27
  35. package/dist/esm/pm-plugins/utils/consts.js +0 -7
  36. package/dist/esm/pm-plugins/utils/getNestedNodePosition.js +6 -4
  37. package/dist/esm/ui/block-menu-items.js +1 -1
  38. package/dist/types/blockControlsPluginType.d.ts +11 -2
  39. package/dist/types/editor-commands/move-node-with-block-menu.d.ts +4 -0
  40. package/dist/types/editor-commands/move-node.d.ts +1 -1
  41. package/dist/types/editor-commands/utils/move-node-utils.d.ts +23 -0
  42. package/dist/types/pm-plugins/main.d.ts +27 -2
  43. package/dist/types/pm-plugins/utils/consts.d.ts +0 -6
  44. package/dist/types/pm-plugins/utils/getNestedNodePosition.d.ts +7 -2
  45. package/dist/types-ts4.5/blockControlsPluginType.d.ts +11 -2
  46. package/dist/types-ts4.5/editor-commands/move-node-with-block-menu.d.ts +4 -0
  47. package/dist/types-ts4.5/editor-commands/move-node.d.ts +1 -1
  48. package/dist/types-ts4.5/editor-commands/utils/move-node-utils.d.ts +23 -0
  49. package/dist/types-ts4.5/pm-plugins/main.d.ts +27 -2
  50. package/dist/types-ts4.5/pm-plugins/utils/consts.d.ts +0 -6
  51. package/dist/types-ts4.5/pm-plugins/utils/getNestedNodePosition.d.ts +7 -2
  52. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 4.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`353075175e7ff`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/353075175e7ff) -
8
+ [ux] ED-28584 Register move up and down options in block menu
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 4.1.12
15
+
16
+ ### Patch Changes
17
+
18
+ - [`20d3223b57972`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/20d3223b57972) -
19
+ Opted out of debounced portal provider
20
+ - [`e33be5daddd2b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e33be5daddd2b) -
21
+ ED-28892 Limited mode: adjust how we're triggering cleanup logic for block control plugin. Hook up
22
+ banner. Other misc setup.
23
+ - Updated dependencies
24
+
3
25
  ## 4.1.11
4
26
 
5
27
  ### Patch Changes
@@ -13,7 +13,9 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
13
  var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
14
14
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
15
15
  var _moveNode = require("./editor-commands/move-node");
16
+ var _moveNodeWithBlockMenu2 = require("./editor-commands/move-node-with-block-menu");
16
17
  var _moveToLayout = require("./editor-commands/move-to-layout");
18
+ var _moveNodeUtils = require("./editor-commands/utils/move-node-utils");
17
19
  var _firstNodeDecPlugin = require("./pm-plugins/first-node-dec-plugin");
18
20
  var _pmPlugin = require("./pm-plugins/interaction-tracking/pm-plugin");
19
21
  var _main = require("./pm-plugins/main");
@@ -89,12 +91,22 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
89
91
  }));
90
92
  return tr;
91
93
  }
94
+ var toggleMenuMeta = {
95
+ anchorName: options === null || options === void 0 ? void 0 : options.anchorName
96
+ };
97
+ var menuTriggerBy = 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.menuTriggerBy;
98
+ if (options !== null && options !== void 0 && options.anchorName) {
99
+ var _canMoveNodeUpOrDown = (0, _moveNodeUtils.canMoveNodeUpOrDown)(tr),
100
+ moveUp = _canMoveNodeUpOrDown.moveUp,
101
+ moveDown = _canMoveNodeUpOrDown.moveDown;
102
+ toggleMenuMeta = _objectSpread(_objectSpread({}, toggleMenuMeta), {}, {
103
+ moveUp: moveUp,
104
+ moveDown: moveDown
105
+ });
106
+ }
92
107
  tr.setMeta(_main.key, _objectSpread(_objectSpread({}, currMeta), {}, {
93
- toggleMenu: {
94
- anchorName: options === null || options === void 0 ? void 0 : options.anchorName
95
- }
108
+ toggleMenu: toggleMenuMeta
96
109
  }));
97
- var menuTriggerBy = 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.menuTriggerBy;
98
110
  if (menuTriggerBy === undefined || !!menuTriggerBy && menuTriggerBy === (options === null || options === void 0 ? void 0 : options.anchorName)) {
99
111
  var _api$userIntent;
100
112
  // Toggled from drag handle
@@ -197,25 +209,29 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
197
209
  isSelectedViaDragHandle: isSelectedViaDragHandle
198
210
  }));
199
211
  };
212
+ },
213
+ moveNodeWithBlockMenu: function moveNodeWithBlockMenu(direction) {
214
+ return (0, _moveNodeWithBlockMenu2.moveNodeWithBlockMenu)(api, direction);
200
215
  }
201
216
  },
202
217
  getSharedState: function getSharedState(editorState) {
203
- var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$activeN, _key$getState3, _key$getState$activeD, _key$getState4, _key$getState$isDragg, _key$getState5, _key$getState$isPMDra, _key$getState6, _key$getState$multiSe, _key$getState7, _key$getState$isShift, _key$getState8, _key$getState$lastDra, _key$getState9, _interactionTrackingP, _key$getState$isSelec, _key$getState0;
218
+ var _key$getState$isMenuO, _key$getState, _key$getState$menuTri, _key$getState2, _key$getState$blockMe, _key$getState3, _key$getState$activeN, _key$getState4, _key$getState$activeD, _key$getState5, _key$getState$isDragg, _key$getState6, _key$getState$isPMDra, _key$getState7, _key$getState$multiSe, _key$getState8, _key$getState$isShift, _key$getState9, _key$getState$lastDra, _key$getState0, _interactionTrackingP, _key$getState$isSelec, _key$getState1;
204
219
  if (!editorState) {
205
220
  return undefined;
206
221
  }
207
222
  var sharedState = {
208
223
  isMenuOpen: (_key$getState$isMenuO = (_key$getState = _main.key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.isMenuOpen) !== null && _key$getState$isMenuO !== void 0 ? _key$getState$isMenuO : false,
209
224
  menuTriggerBy: (_key$getState$menuTri = (_key$getState2 = _main.key.getState(editorState)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.menuTriggerBy) !== null && _key$getState$menuTri !== void 0 ? _key$getState$menuTri : undefined,
210
- activeNode: (_key$getState$activeN = (_key$getState3 = _main.key.getState(editorState)) === null || _key$getState3 === void 0 ? void 0 : _key$getState3.activeNode) !== null && _key$getState$activeN !== void 0 ? _key$getState$activeN : undefined,
211
- activeDropTargetNode: (_key$getState$activeD = (_key$getState4 = _main.key.getState(editorState)) === null || _key$getState4 === void 0 ? void 0 : _key$getState4.activeDropTargetNode) !== null && _key$getState$activeD !== void 0 ? _key$getState$activeD : undefined,
212
- isDragging: (_key$getState$isDragg = (_key$getState5 = _main.key.getState(editorState)) === null || _key$getState5 === void 0 ? void 0 : _key$getState5.isDragging) !== null && _key$getState$isDragg !== void 0 ? _key$getState$isDragg : false,
213
- isPMDragging: (_key$getState$isPMDra = (_key$getState6 = _main.key.getState(editorState)) === null || _key$getState6 === void 0 ? void 0 : _key$getState6.isPMDragging) !== null && _key$getState$isPMDra !== void 0 ? _key$getState$isPMDra : false,
214
- multiSelectDnD: (_key$getState$multiSe = (_key$getState7 = _main.key.getState(editorState)) === null || _key$getState7 === void 0 ? void 0 : _key$getState7.multiSelectDnD) !== null && _key$getState$multiSe !== void 0 ? _key$getState$multiSe : undefined,
215
- isShiftDown: (_key$getState$isShift = (_key$getState8 = _main.key.getState(editorState)) === null || _key$getState8 === void 0 ? void 0 : _key$getState8.isShiftDown) !== null && _key$getState$isShift !== void 0 ? _key$getState$isShift : undefined,
216
- lastDragCancelled: (_key$getState$lastDra = (_key$getState9 = _main.key.getState(editorState)) === null || _key$getState9 === void 0 ? void 0 : _key$getState9.lastDragCancelled) !== null && _key$getState$lastDra !== void 0 ? _key$getState$lastDra : false,
225
+ blockMenuOptions: (_key$getState$blockMe = (_key$getState3 = _main.key.getState(editorState)) === null || _key$getState3 === void 0 ? void 0 : _key$getState3.blockMenuOptions) !== null && _key$getState$blockMe !== void 0 ? _key$getState$blockMe : undefined,
226
+ activeNode: (_key$getState$activeN = (_key$getState4 = _main.key.getState(editorState)) === null || _key$getState4 === void 0 ? void 0 : _key$getState4.activeNode) !== null && _key$getState$activeN !== void 0 ? _key$getState$activeN : undefined,
227
+ activeDropTargetNode: (_key$getState$activeD = (_key$getState5 = _main.key.getState(editorState)) === null || _key$getState5 === void 0 ? void 0 : _key$getState5.activeDropTargetNode) !== null && _key$getState$activeD !== void 0 ? _key$getState$activeD : undefined,
228
+ isDragging: (_key$getState$isDragg = (_key$getState6 = _main.key.getState(editorState)) === null || _key$getState6 === void 0 ? void 0 : _key$getState6.isDragging) !== null && _key$getState$isDragg !== void 0 ? _key$getState$isDragg : false,
229
+ isPMDragging: (_key$getState$isPMDra = (_key$getState7 = _main.key.getState(editorState)) === null || _key$getState7 === void 0 ? void 0 : _key$getState7.isPMDragging) !== null && _key$getState$isPMDra !== void 0 ? _key$getState$isPMDra : false,
230
+ multiSelectDnD: (_key$getState$multiSe = (_key$getState8 = _main.key.getState(editorState)) === null || _key$getState8 === void 0 ? void 0 : _key$getState8.multiSelectDnD) !== null && _key$getState$multiSe !== void 0 ? _key$getState$multiSe : undefined,
231
+ isShiftDown: (_key$getState$isShift = (_key$getState9 = _main.key.getState(editorState)) === null || _key$getState9 === void 0 ? void 0 : _key$getState9.isShiftDown) !== null && _key$getState$isShift !== void 0 ? _key$getState$isShift : undefined,
232
+ lastDragCancelled: (_key$getState$lastDra = (_key$getState0 = _main.key.getState(editorState)) === null || _key$getState0 === void 0 ? void 0 : _key$getState0.lastDragCancelled) !== null && _key$getState$lastDra !== void 0 ? _key$getState$lastDra : false,
217
233
  isEditing: (_interactionTrackingP = _pmPlugin.interactionTrackingPluginKey.getState(editorState)) === null || _interactionTrackingP === void 0 ? void 0 : _interactionTrackingP.isEditing,
218
- isSelectedViaDragHandle: (_key$getState$isSelec = (_key$getState0 = _main.key.getState(editorState)) === null || _key$getState0 === void 0 ? void 0 : _key$getState0.isSelectedViaDragHandle) !== null && _key$getState$isSelec !== void 0 ? _key$getState$isSelec : false
234
+ isSelectedViaDragHandle: (_key$getState$isSelec = (_key$getState1 = _main.key.getState(editorState)) === null || _key$getState1 === void 0 ? void 0 : _key$getState1.isSelectedViaDragHandle) !== null && _key$getState$isSelec !== void 0 ? _key$getState$isSelec : false
219
235
  };
220
236
  if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
221
237
  var _interactionTrackingP2, _interactionTrackingP3;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.moveNodeWithBlockMenu = void 0;
7
+ var _analytics = require("@atlaskit/editor-common/analytics");
8
+ var _types = require("@atlaskit/editor-common/types");
9
+ var _moveNode = require("./move-node");
10
+ var _moveNodeUtils = require("./utils/move-node-utils");
11
+ var moveNodeWithBlockMenu = exports.moveNodeWithBlockMenu = function moveNodeWithBlockMenu(api, direction) {
12
+ return function (_ref) {
13
+ var tr = _ref.tr;
14
+ // Nodes like lists nest within themselves, we need to find the top most position
15
+ var currentNodePos = (0, _moveNodeUtils.getCurrentNodePosFromDragHandleSelection)({
16
+ selection: tr.selection,
17
+ schema: tr.doc.type.schema,
18
+ resolve: tr.doc.resolve.bind(tr.doc)
19
+ });
20
+ if (currentNodePos > -1) {
21
+ var $currentNodePos = tr.doc.resolve(currentNodePos);
22
+ var nodeAfterPos = $currentNodePos.posAtIndex($currentNodePos.index() + 1);
23
+ var moveToPos = direction === _types.DIRECTION.UP ? (0, _moveNodeUtils.getPosWhenMoveNodeUp)($currentNodePos, currentNodePos) : (0, _moveNodeUtils.getPosWhenMoveNodeDown)({
24
+ $currentNodePos: $currentNodePos,
25
+ nodeAfterPos: nodeAfterPos,
26
+ tr: tr
27
+ });
28
+
29
+ // only move the node if the destination is at the same depth, not support moving a nested node to a parent node
30
+ var shouldMoveNode = (0, _moveNodeUtils.getShouldMoveNode)({
31
+ currentNodePos: currentNodePos,
32
+ moveToPos: moveToPos,
33
+ tr: tr
34
+ });
35
+ if (shouldMoveNode) {
36
+ (0, _moveNode.moveNode)(api)(currentNodePos, moveToPos, _analytics.INPUT_METHOD.BLOCK_MENU)({
37
+ tr: tr
38
+ });
39
+ tr.scrollIntoView();
40
+ }
41
+ }
42
+ return tr;
43
+ };
44
+ };
@@ -11,6 +11,7 @@ var _expand = require("@atlaskit/editor-common/expand");
11
11
  var _messages = require("@atlaskit/editor-common/messages");
12
12
  var _selection = require("@atlaskit/editor-common/selection");
13
13
  var _transforms = require("@atlaskit/editor-common/transforms");
14
+ var _types = require("@atlaskit/editor-common/types");
14
15
  var _utils = require("@atlaskit/editor-common/utils");
15
16
  var _model = require("@atlaskit/editor-prosemirror/model");
16
17
  var _state = require("@atlaskit/editor-prosemirror/state");
@@ -20,13 +21,13 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
20
21
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
21
22
  var _main = require("../pm-plugins/main");
22
23
  var _analytics2 = require("../pm-plugins/utils/analytics");
23
- var _consts = require("../pm-plugins/utils/consts");
24
24
  var _getNestedNodePosition = require("../pm-plugins/utils/getNestedNodePosition");
25
25
  var _getSelection = require("../pm-plugins/utils/getSelection");
26
26
  var _removeFromSource = require("../pm-plugins/utils/remove-from-source");
27
27
  var _selection2 = require("../pm-plugins/utils/selection");
28
28
  var _updateSelection = require("../pm-plugins/utils/update-selection");
29
29
  var _validation = require("../pm-plugins/utils/validation");
30
+ var _moveNodeUtils = require("./utils/move-node-utils");
30
31
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
31
32
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
32
33
  /**
@@ -118,7 +119,11 @@ var getCurrentNodePos = function getCurrentNodePos(state) {
118
119
  // 3. the start of the selection is inside the node
119
120
  currentNodePos = selection.$from.before(1);
120
121
  if (selection.$from.depth > 0) {
121
- currentNodePos = (0, _getNestedNodePosition.getNestedNodePosition)(state);
122
+ currentNodePos = (0, _getNestedNodePosition.getNestedNodePosition)({
123
+ selection: selection,
124
+ schema: state.schema,
125
+ resolve: state.doc.resolve.bind(state.doc)
126
+ });
122
127
  }
123
128
  }
124
129
  return currentNodePos;
@@ -151,9 +156,8 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
151
156
  var nodeAfterPos = isMultiSelectEnabled && !getFocusedHandle(state) ? Math.max(expandedAnchor, expandedHead) : $currentNodePos.posAtIndex($currentNodePos.index() + 1);
152
157
  var isTopLevelNode = $currentNodePos.depth === 0;
153
158
  var moveToPos = -1;
154
- var nodeIndex = $currentNodePos.index();
155
159
  var isLayoutColumnSelected = selection instanceof _state.NodeSelection && selection.node.type.name === 'layoutColumn';
156
- if (direction === _consts.DIRECTION.LEFT) {
160
+ if (direction === _types.DIRECTION.LEFT) {
157
161
  if (isTopLevelNode && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
158
162
  var _api$core, _api$core2;
159
163
  var nodeBefore = $currentNodePos.nodeBefore;
@@ -197,7 +201,7 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
197
201
  var previousNode = grandParent ? grandParent.maybeChild(index - 1) : null;
198
202
  moveToPos = $currentNodePos.start() - ((previousNode === null || previousNode === void 0 ? void 0 : previousNode.nodeSize) || 1);
199
203
  }
200
- } else if (direction === _consts.DIRECTION.RIGHT) {
204
+ } else if (direction === _types.DIRECTION.RIGHT) {
201
205
  if (isTopLevelNode && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
202
206
  var _api$core4, _api$core5;
203
207
  var endOfDoc = $currentNodePos.end();
@@ -245,14 +249,11 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
245
249
  }
246
250
  moveToPos = $currentNodePos.after($currentNodePos.depth) + 1;
247
251
  }
248
- } else if (direction === _consts.DIRECTION.UP) {
252
+ } else if (direction === _types.DIRECTION.UP) {
249
253
  if (isLayoutColumnSelected) {
250
254
  moveToPos = $currentNodePos.start() - 1;
251
255
  } else {
252
- var _nodeBefore = $currentNodePos.depth > 1 && nodeIndex === 0 ? $currentNodePos.node($currentNodePos.depth) : $currentNodePos.nodeBefore;
253
- if (_nodeBefore) {
254
- moveToPos = currentNodePos - _nodeBefore.nodeSize;
255
- }
256
+ moveToPos = (0, _moveNodeUtils.getPosWhenMoveNodeUp)($currentNodePos, currentNodePos);
256
257
  }
257
258
  } else {
258
259
  var _endOfDoc = $currentNodePos.end();
@@ -262,11 +263,11 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
262
263
  if (isLayoutColumnSelected) {
263
264
  moveToPos = state.selection.$from.end() + 1;
264
265
  } else {
265
- var nodeAfter = state.doc.nodeAt(nodeAfterPos);
266
- if (nodeAfter) {
267
- // if not the last node, move to the end of the next node
268
- moveToPos = nodeAfterPos + nodeAfter.nodeSize;
269
- }
266
+ moveToPos = (0, _moveNodeUtils.getPosWhenMoveNodeDown)({
267
+ $currentNodePos: $currentNodePos,
268
+ nodeAfterPos: nodeAfterPos,
269
+ tr: state.tr
270
+ });
270
271
  }
271
272
  }
272
273
  var nodeType = (_state$doc$nodeAt = state.doc.nodeAt(currentNodePos)) === null || _state$doc$nodeAt === void 0 ? void 0 : _state$doc$nodeAt.type.name;
@@ -37,7 +37,11 @@ var findParentPosForHandle = function findParentPosForHandle(state) {
37
37
  }
38
38
 
39
39
  // else find closest parent node
40
- return (0, _getNestedNodePosition.getNestedNodePosition)(state);
40
+ return (0, _getNestedNodePosition.getNestedNodePosition)({
41
+ selection: state.selection,
42
+ schema: state.schema,
43
+ resolve: state.doc.resolve.bind(state.doc)
44
+ });
41
45
  };
42
46
  var findNextAnchorDecoration = function findNextAnchorDecoration(state) {
43
47
  var decorations = (0, _main.getDecorations)(state);
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getShouldMoveNode = exports.getPosWhenMoveNodeUp = exports.getPosWhenMoveNodeDown = exports.getCurrentNodePosFromDragHandleSelection = exports.canMoveNodeUpOrDown = void 0;
7
+ var _selection = require("@atlaskit/editor-common/selection");
8
+ var _utils = require("@atlaskit/editor-tables/utils");
9
+ var _getNestedNodePosition = require("../../pm-plugins/utils/getNestedNodePosition");
10
+ var getCurrentNodePosFromDragHandleSelection = exports.getCurrentNodePosFromDragHandleSelection = function getCurrentNodePosFromDragHandleSelection(_ref) {
11
+ var selection = _ref.selection,
12
+ schema = _ref.schema,
13
+ resolve = _ref.resolve;
14
+ var currentNodePos = -1;
15
+ if ((0, _utils.isTableSelected)(selection)) {
16
+ var _findTable$pos, _findTable;
17
+ // We only move table node if it's fully selected
18
+ // to avoid shortcut collision with table drag and drop
19
+ currentNodePos = (_findTable$pos = (_findTable = (0, _utils.findTable)(selection)) === null || _findTable === void 0 ? void 0 : _findTable.pos) !== null && _findTable$pos !== void 0 ? _findTable$pos : currentNodePos;
20
+ } else if (!(selection instanceof _selection.GapCursorSelection)) {
21
+ // 2. caret cursor is inside the node
22
+ // 3. the start of the selection is inside the node
23
+ currentNodePos = selection.$from.before(1);
24
+ if (selection.$from.depth > 0) {
25
+ currentNodePos = (0, _getNestedNodePosition.getNestedNodePosition)({
26
+ selection: selection,
27
+ schema: schema,
28
+ resolve: resolve
29
+ });
30
+ }
31
+ }
32
+ return currentNodePos;
33
+ };
34
+ var getPosWhenMoveNodeUp = exports.getPosWhenMoveNodeUp = function getPosWhenMoveNodeUp($currentNodePos, currentNodePos) {
35
+ var nodeIndex = $currentNodePos.index();
36
+ var nodeBefore = $currentNodePos.depth > 1 && nodeIndex === 0 ? $currentNodePos.node($currentNodePos.depth) : $currentNodePos.nodeBefore;
37
+ return nodeBefore ? currentNodePos - nodeBefore.nodeSize : -1;
38
+ };
39
+ var getPosWhenMoveNodeDown = exports.getPosWhenMoveNodeDown = function getPosWhenMoveNodeDown(_ref2) {
40
+ var $currentNodePos = _ref2.$currentNodePos,
41
+ nodeAfterPos = _ref2.nodeAfterPos,
42
+ tr = _ref2.tr;
43
+ var endOfDoc = $currentNodePos.end();
44
+ if (nodeAfterPos > endOfDoc) {
45
+ return -1;
46
+ }
47
+ var nodeAfter = tr.doc.nodeAt(nodeAfterPos);
48
+
49
+ // if not the last node, move to the end of the next node
50
+ return nodeAfter ? nodeAfterPos + nodeAfter.nodeSize : -1;
51
+ };
52
+ var getShouldMoveNode = exports.getShouldMoveNode = function getShouldMoveNode(_ref3) {
53
+ var currentNodePos = _ref3.currentNodePos,
54
+ moveToPos = _ref3.moveToPos,
55
+ tr = _ref3.tr;
56
+ // only move the node if the destination is at the same depth, not support moving a nested node to a parent node
57
+ return moveToPos > -1 && tr.doc.resolve(currentNodePos).depth === tr.doc.resolve(moveToPos).depth;
58
+ };
59
+ var canMoveNodeUpOrDown = exports.canMoveNodeUpOrDown = function canMoveNodeUpOrDown(tr) {
60
+ var currentNodePos = getCurrentNodePosFromDragHandleSelection({
61
+ selection: tr.selection,
62
+ schema: tr.doc.type.schema,
63
+ resolve: tr.doc.resolve.bind(tr.doc)
64
+ });
65
+ if (currentNodePos <= -1) {
66
+ return {
67
+ moveUp: false,
68
+ moveDown: false
69
+ };
70
+ }
71
+ var $currentNodePos = tr.doc.resolve(currentNodePos);
72
+ var nodeAfterPos = $currentNodePos.posAtIndex($currentNodePos.index() + 1);
73
+ var moveUpPos = getPosWhenMoveNodeUp($currentNodePos, currentNodePos);
74
+ var moveDownPos = getPosWhenMoveNodeDown({
75
+ $currentNodePos: $currentNodePos,
76
+ nodeAfterPos: nodeAfterPos,
77
+ tr: tr
78
+ });
79
+ return {
80
+ moveUp: getShouldMoveNode({
81
+ currentNodePos: currentNodePos,
82
+ moveToPos: moveUpPos,
83
+ tr: tr
84
+ }),
85
+ moveDown: getShouldMoveNode({
86
+ currentNodePos: currentNodePos,
87
+ moveToPos: moveDownPos,
88
+ tr: tr
89
+ })
90
+ };
91
+ };
@@ -109,7 +109,9 @@ var createDropTargetDecoration = exports.createDropTargetDecoration = function c
109
109
  anchorRectCache: anchorRectCache,
110
110
  isSameLayout: isSameLayout
111
111
  }));
112
- }, element, key);
112
+ }, element, key, undefined,
113
+ // @portal-render-immediately
114
+ true);
113
115
  return element;
114
116
  }, {
115
117
  type: _decorationsCommon.TYPE_DROP_TARGET_DEC,
@@ -140,7 +142,9 @@ var createLayoutDropTargetDecoration = exports.createLayoutDropTargetDecoration
140
142
  getPos: getPos,
141
143
  anchorRectCache: anchorRectCache
142
144
  }));
143
- }, element, key);
145
+ }, element, key, undefined,
146
+ // @portal-render-immediately
147
+ true);
144
148
  return element;
145
149
  }, {
146
150
  type: _decorationsCommon.TYPE_DROP_TARGET_DEC,
@@ -100,7 +100,9 @@ var quickInsertButtonDecoration = exports.quickInsertButtonDecoration = function
100
100
  rootNodeType: rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType,
101
101
  anchorRectCache: anchorRectCache
102
102
  });
103
- }, element, key);
103
+ }, element, key, undefined,
104
+ // @portal-render-immediately
105
+ true);
104
106
  return element;
105
107
  }, widgetSpec);
106
108
  };
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.boundKeydownHandler = void 0;
7
7
  var _keymaps = require("@atlaskit/editor-common/keymaps");
8
+ var _types = require("@atlaskit/editor-common/types");
8
9
  var _keymap = require("@atlaskit/editor-prosemirror/keymap");
9
10
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
11
  var _moveNode = require("../editor-commands/move-node");
11
12
  var _showDragHandle = require("../editor-commands/show-drag-handle");
12
- var _consts = require("./utils/consts");
13
13
  function keymapList(api, formatMessage) {
14
14
  var keymapList = {};
15
15
  if (api && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
@@ -24,19 +24,19 @@ function keymapList(api, formatMessage) {
24
24
  (0, _keymaps.bindKeymapWithCommand)(
25
25
  // Ignored via go/ees005
26
26
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
27
- _keymaps.dragToMoveUp.common, (0, _moveNode.moveNodeViaShortcut)(api, _consts.DIRECTION.UP, formatMessage), keymapList);
27
+ _keymaps.dragToMoveUp.common, (0, _moveNode.moveNodeViaShortcut)(api, _types.DIRECTION.UP, formatMessage), keymapList);
28
28
  (0, _keymaps.bindKeymapWithCommand)(
29
29
  // Ignored via go/ees005
30
30
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
31
- _keymaps.dragToMoveDown.common, (0, _moveNode.moveNodeViaShortcut)(api, _consts.DIRECTION.DOWN, formatMessage), keymapList);
31
+ _keymaps.dragToMoveDown.common, (0, _moveNode.moveNodeViaShortcut)(api, _types.DIRECTION.DOWN, formatMessage), keymapList);
32
32
  (0, _keymaps.bindKeymapWithCommand)(
33
33
  // Ignored via go/ees005
34
34
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
35
- _keymaps.dragToMoveLeft.common, (0, _moveNode.moveNodeViaShortcut)(api, _consts.DIRECTION.LEFT, formatMessage), keymapList);
35
+ _keymaps.dragToMoveLeft.common, (0, _moveNode.moveNodeViaShortcut)(api, _types.DIRECTION.LEFT, formatMessage), keymapList);
36
36
  (0, _keymaps.bindKeymapWithCommand)(
37
37
  // Ignored via go/ees005
38
38
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
39
- _keymaps.dragToMoveRight.common, (0, _moveNode.moveNodeViaShortcut)(api, _consts.DIRECTION.RIGHT, formatMessage), keymapList);
39
+ _keymaps.dragToMoveRight.common, (0, _moveNode.moveNodeViaShortcut)(api, _types.DIRECTION.RIGHT, formatMessage), keymapList);
40
40
  }
41
41
  return keymapList;
42
42
  }
@@ -76,7 +76,6 @@ var destroyFn = function destroyFn(api, editorView) {
76
76
  if ((0, _performanceMeasures.isMeasuring)(EDITOR_BLOCKS_DRAG_INIT)) {
77
77
  (0, _performanceMeasures.stopMeasure)(EDITOR_BLOCKS_DRAG_INIT, function (duration, startTime) {
78
78
  var _api$analytics;
79
- var state = editorView.state;
80
79
  api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
81
80
  action: _analytics.ACTION.BLOCKS_DRAG_INIT,
82
81
  actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
@@ -84,7 +83,7 @@ var destroyFn = function destroyFn(api, editorView) {
84
83
  attributes: {
85
84
  duration: duration,
86
85
  startTime: startTime,
87
- nodesCount: state.doc.nodeSize
86
+ nodesCount: editorView === null || editorView === void 0 ? void 0 : editorView.state.doc.nodeSize
88
87
  }
89
88
  });
90
89
  });
@@ -196,7 +195,7 @@ var destroyFn = function destroyFn(api, editorView) {
196
195
  dragInitializationDuration: dragInitializationDuration,
197
196
  dropProcessingDuration: duration,
198
197
  isCancelled: isCancelled,
199
- nodesCount: editorView.state.doc.nodeSize
198
+ nodesCount: editorView === null || editorView === void 0 ? void 0 : editorView.state.doc.nodeSize
200
199
  }
201
200
  });
202
201
  });
@@ -239,8 +238,8 @@ var getDecorationAtPos = function getDecorationAtPos(state, decorations, pos, to
239
238
  var nodeDecAtActivePos = nodeDecsAtActivePos.pop();
240
239
  return nodeDecAtActivePos;
241
240
  };
242
- var _apply = exports.apply = function apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) {
243
- var _meta$multiSelectDnD, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _meta$isDragging3, _meta$toggleMenu, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
241
+ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache, resizeObserverWidth, pragmaticCleanup) {
242
+ var _api$limitedMode, _meta$multiSelectDnD, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _meta$isDragging3, _meta$toggleMenu, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
244
243
  var activeNode = currentState.activeNode,
245
244
  decorations = currentState.decorations,
246
245
  isResizerResizing = currentState.isResizerResizing,
@@ -251,6 +250,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
251
250
  isDragging = currentState.isDragging,
252
251
  isMenuOpen = currentState.isMenuOpen,
253
252
  menuTriggerBy = currentState.menuTriggerBy,
253
+ blockMenuOptions = currentState.blockMenuOptions,
254
254
  isPMDragging = currentState.isPMDragging,
255
255
  isShiftDown = currentState.isShiftDown,
256
256
  lastDragCancelled = currentState.lastDragCancelled,
@@ -263,6 +263,18 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
263
263
  isAllText = _getTrMetadata.isAllText,
264
264
  isReplacedWithSameSize = _getTrMetadata.isReplacedWithSameSize;
265
265
  var meta = tr.getMeta(key);
266
+ var hasDocumentSizeBreachedThreshold = api === null || api === void 0 || (_api$limitedMode = api.limitedMode) === null || _api$limitedMode === void 0 || (_api$limitedMode = _api$limitedMode.sharedState.currentState()) === null || _api$limitedMode === void 0 || (_api$limitedMode = _api$limitedMode.limitedModePluginKey.getState(newState)) === null || _api$limitedMode === void 0 ? void 0 : _api$limitedMode.documentSizeBreachesThreshold;
267
+ if (hasDocumentSizeBreachedThreshold) {
268
+ /**
269
+ * INFO: This if statement is a duplicate of the logic in destroy(). When the threshold is breached and we enter limited mode, we want to trigger the cleanup logic in destroy().
270
+ */
271
+ var editorContentArea = document.querySelector('.fabric-editor-popup-scroll-parent');
272
+ if (editorContentArea && resizeObserverWidth) {
273
+ resizeObserverWidth.unobserve(editorContentArea);
274
+ }
275
+ pragmaticCleanup === null || pragmaticCleanup === void 0 || pragmaticCleanup();
276
+ return currentState;
277
+ }
266
278
 
267
279
  // When steps exist, remap existing decorations, activeNode and multi select positions
268
280
  if (tr.docChanged) {
@@ -529,6 +541,10 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
529
541
  isDragging: (_meta$isDragging3 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging3 !== void 0 ? _meta$isDragging3 : isDragging,
530
542
  isMenuOpen: isMenuOpenNew,
531
543
  menuTriggerBy: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') || (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) ? (meta === null || meta === void 0 || (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.anchorName) || menuTriggerBy : undefined,
544
+ blockMenuOptions: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) ? {
545
+ canMoveUp: (meta === null || meta === void 0 || (_meta$toggleMenu2 = meta.toggleMenu) === null || _meta$toggleMenu2 === void 0 ? void 0 : _meta$toggleMenu2.moveUp) !== undefined ? meta === null || meta === void 0 || (_meta$toggleMenu3 = meta.toggleMenu) === null || _meta$toggleMenu3 === void 0 ? void 0 : _meta$toggleMenu3.moveUp : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.canMoveUp,
546
+ canMoveDown: (meta === null || meta === void 0 || (_meta$toggleMenu4 = meta.toggleMenu) === null || _meta$toggleMenu4 === void 0 ? void 0 : _meta$toggleMenu4.moveDown) !== undefined ? meta === null || meta === void 0 || (_meta$toggleMenu5 = meta.toggleMenu) === null || _meta$toggleMenu5 === void 0 ? void 0 : _meta$toggleMenu5.moveDown : blockMenuOptions === null || blockMenuOptions === void 0 ? void 0 : blockMenuOptions.canMoveDown
547
+ } : undefined,
532
548
  editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : editorHeight,
533
549
  editorWidthLeft: (_meta$editorWidthLeft = meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== null && _meta$editorWidthLeft !== void 0 ? _meta$editorWidthLeft : editorWidthLeft,
534
550
  editorWidthRight: (_meta$editorWidthRigh = meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== null && _meta$editorWidthRigh !== void 0 ? _meta$editorWidthRigh : editorWidthRight,
@@ -557,6 +573,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
557
573
  if (!(0, _anchorUtils.isAnchorSupported)()) {
558
574
  anchorRectCache = new _anchorUtils.AnchorRectCache();
559
575
  }
576
+ var resizeObserverWidth;
577
+ var pragmaticCleanup = null;
560
578
  return new _safePlugin.SafePlugin({
561
579
  key: key,
562
580
  state: {
@@ -564,13 +582,13 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
564
582
  return initialState;
565
583
  },
566
584
  apply: function apply(tr, currentState, _, newState) {
567
- return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
585
+ return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache, resizeObserverWidth, pragmaticCleanup);
568
586
  }
569
587
  },
570
588
  props: {
571
589
  decorations: function decorations(state) {
572
- var _api$limitedMode, _api$editorDisabled, _key$getState2;
573
- if (api !== null && api !== void 0 && (_api$limitedMode = api.limitedMode) !== null && _api$limitedMode !== void 0 && (_api$limitedMode = _api$limitedMode.sharedState.currentState()) !== null && _api$limitedMode !== void 0 && _api$limitedMode.enabled) {
590
+ var _api$limitedMode2, _api$editorDisabled, _key$getState2;
591
+ if (api !== null && api !== void 0 && (_api$limitedMode2 = api.limitedMode) !== null && _api$limitedMode2 !== void 0 && (_api$limitedMode2 = _api$limitedMode2.sharedState.currentState()) !== null && _api$limitedMode2 !== void 0 && _api$limitedMode2.enabled) {
574
592
  return;
575
593
  }
576
594
  var isDisabled = api === null || api === void 0 || (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 || (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled === void 0 ? void 0 : _api$editorDisabled.editorDisabled;
@@ -629,8 +647,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
629
647
  return false;
630
648
  },
631
649
  dragenter: function dragenter(view, event) {
632
- var _api$limitedMode2;
633
- if (api !== null && api !== void 0 && (_api$limitedMode2 = api.limitedMode) !== null && _api$limitedMode2 !== void 0 && (_api$limitedMode2 = _api$limitedMode2.sharedState.currentState()) !== null && _api$limitedMode2 !== void 0 && _api$limitedMode2.enabled) {
650
+ var _api$limitedMode3;
651
+ if (api !== null && api !== void 0 && (_api$limitedMode3 = api.limitedMode) !== null && _api$limitedMode3 !== void 0 && (_api$limitedMode3 = _api$limitedMode3.sharedState.currentState()) !== null && _api$limitedMode3 !== void 0 && _api$limitedMode3.enabled) {
634
652
  return;
635
653
  }
636
654
  if (isHTMLElement(event.target) && (0, _expValEquals.expValEquals)('platform_editor_block_controls_perf_optimization', 'isEnabled', true)) {
@@ -663,8 +681,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
663
681
  }
664
682
  },
665
683
  dragstart: function dragstart(view) {
666
- var _api$limitedMode3, _anchorRectCache2;
667
- if (api !== null && api !== void 0 && (_api$limitedMode3 = api.limitedMode) !== null && _api$limitedMode3 !== void 0 && (_api$limitedMode3 = _api$limitedMode3.sharedState.currentState()) !== null && _api$limitedMode3 !== void 0 && _api$limitedMode3.enabled) {
684
+ var _api$limitedMode4, _anchorRectCache2;
685
+ if (api !== null && api !== void 0 && (_api$limitedMode4 = api.limitedMode) !== null && _api$limitedMode4 !== void 0 && (_api$limitedMode4 = _api$limitedMode4.sharedState.currentState()) !== null && _api$limitedMode4 !== void 0 && _api$limitedMode4.enabled) {
668
686
  return;
669
687
  }
670
688
  (0, _performanceMeasures.startMeasure)(EDITOR_BLOCKS_DRAG_INIT);
@@ -681,8 +699,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
681
699
  })));
682
700
  },
683
701
  dragend: function dragend(view) {
684
- var _api$limitedMode4, _key$getState3;
685
- if (api !== null && api !== void 0 && (_api$limitedMode4 = api.limitedMode) !== null && _api$limitedMode4 !== void 0 && (_api$limitedMode4 = _api$limitedMode4.sharedState.currentState()) !== null && _api$limitedMode4 !== void 0 && _api$limitedMode4.enabled) {
702
+ var _api$limitedMode5, _key$getState3;
703
+ if (api !== null && api !== void 0 && (_api$limitedMode5 = api.limitedMode) !== null && _api$limitedMode5 !== void 0 && (_api$limitedMode5 = _api$limitedMode5.sharedState.currentState()) !== null && _api$limitedMode5 !== void 0 && _api$limitedMode5.enabled) {
686
704
  return;
687
705
  }
688
706
  var state = view.state,
@@ -702,23 +720,23 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
702
720
  }
703
721
  },
704
722
  mouseover: function mouseover(view, event) {
705
- var _api$limitedMode5;
706
- if (api !== null && api !== void 0 && (_api$limitedMode5 = api.limitedMode) !== null && _api$limitedMode5 !== void 0 && (_api$limitedMode5 = _api$limitedMode5.sharedState.currentState()) !== null && _api$limitedMode5 !== void 0 && _api$limitedMode5.enabled) {
723
+ var _api$limitedMode6;
724
+ if (api !== null && api !== void 0 && (_api$limitedMode6 = api.limitedMode) !== null && _api$limitedMode6 !== void 0 && (_api$limitedMode6 = _api$limitedMode6.sharedState.currentState()) !== null && _api$limitedMode6 !== void 0 && _api$limitedMode6.enabled) {
707
725
  return;
708
726
  }
709
727
  (0, _handleMouseOver.handleMouseOver)(view, event, api);
710
728
  return false;
711
729
  },
712
730
  mousedown: function mousedown(view, event) {
713
- var _api$limitedMode6;
714
- if (api !== null && api !== void 0 && (_api$limitedMode6 = api.limitedMode) !== null && _api$limitedMode6 !== void 0 && (_api$limitedMode6 = _api$limitedMode6.sharedState.currentState()) !== null && _api$limitedMode6 !== void 0 && _api$limitedMode6.enabled) {
731
+ var _api$limitedMode7;
732
+ if (api !== null && api !== void 0 && (_api$limitedMode7 = api.limitedMode) !== null && _api$limitedMode7 !== void 0 && (_api$limitedMode7 = _api$limitedMode7.sharedState.currentState()) !== null && _api$limitedMode7 !== void 0 && _api$limitedMode7.enabled) {
715
733
  return;
716
734
  }
717
735
  return (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _handleMouseDown.handleMouseDown)(api)(view, event) : undefined;
718
736
  },
719
737
  keydown: function keydown(view, event) {
720
- var _api$limitedMode7;
721
- if (api !== null && api !== void 0 && (_api$limitedMode7 = api.limitedMode) !== null && _api$limitedMode7 !== void 0 && (_api$limitedMode7 = _api$limitedMode7.sharedState.currentState()) !== null && _api$limitedMode7 !== void 0 && _api$limitedMode7.enabled) {
738
+ var _api$limitedMode8;
739
+ if (api !== null && api !== void 0 && (_api$limitedMode8 = api.limitedMode) !== null && _api$limitedMode8 !== void 0 && (_api$limitedMode8 = _api$limitedMode8.sharedState.currentState()) !== null && _api$limitedMode8 !== void 0 && _api$limitedMode8.enabled) {
722
740
  return;
723
741
  }
724
742
  if (isMultiSelectEnabled) {
@@ -793,8 +811,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
793
811
  }
794
812
  },
795
813
  keyup: function keyup(view, event) {
796
- var _api$limitedMode8;
797
- if (api !== null && api !== void 0 && (_api$limitedMode8 = api.limitedMode) !== null && _api$limitedMode8 !== void 0 && (_api$limitedMode8 = _api$limitedMode8.sharedState.currentState()) !== null && _api$limitedMode8 !== void 0 && _api$limitedMode8.enabled) {
814
+ var _api$limitedMode9;
815
+ if (api !== null && api !== void 0 && (_api$limitedMode9 = api.limitedMode) !== null && _api$limitedMode9 !== void 0 && (_api$limitedMode9 = _api$limitedMode9.sharedState.currentState()) !== null && _api$limitedMode9 !== void 0 && _api$limitedMode9.enabled) {
798
816
  return;
799
817
  }
800
818
  if (!event.repeat && event.key === 'Shift') {
@@ -804,8 +822,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
804
822
  }
805
823
  },
806
824
  blur: function blur(view, event) {
807
- var _api$limitedMode9;
808
- if (api !== null && api !== void 0 && (_api$limitedMode9 = api.limitedMode) !== null && _api$limitedMode9 !== void 0 && (_api$limitedMode9 = _api$limitedMode9.sharedState.currentState()) !== null && _api$limitedMode9 !== void 0 && _api$limitedMode9.enabled) {
825
+ var _api$limitedMode0;
826
+ if (api !== null && api !== void 0 && (_api$limitedMode0 = api.limitedMode) !== null && _api$limitedMode0 !== void 0 && (_api$limitedMode0 = _api$limitedMode0.sharedState.currentState()) !== null && _api$limitedMode0 !== void 0 && _api$limitedMode0.enabled) {
809
827
  return;
810
828
  }
811
829
  if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
@@ -835,7 +853,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
835
853
  var editorContentArea = editorView.dom.closest('.fabric-editor-popup-scroll-parent');
836
854
 
837
855
  // Use ResizeObserver to observe resizer (scroll-parent typically grows when resizing) and editor width changes
838
- var resizeObserverWidth = new ResizeObserver((0, _rafSchd.default)(function (entries) {
856
+ resizeObserverWidth = new ResizeObserver((0, _rafSchd.default)(function (entries) {
839
857
  var pluginState = key.getState(editorView.state);
840
858
  if (!(pluginState !== null && pluginState !== void 0 && pluginState.isDragging)) {
841
859
  var isResizerResizing = !!dom.querySelector('.is-resizing');
@@ -864,13 +882,14 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
864
882
  }
865
883
 
866
884
  // Start pragmatic monitors
867
- var pragmaticCleanup = destroyFn(api, editorView);
885
+ pragmaticCleanup = destroyFn(api, editorView);
868
886
  return {
869
887
  destroy: function destroy() {
888
+ var _pragmaticCleanup;
870
889
  if (editorContentArea) {
871
890
  resizeObserverWidth.unobserve(editorContentArea);
872
891
  }
873
- pragmaticCleanup();
892
+ (_pragmaticCleanup = pragmaticCleanup) === null || _pragmaticCleanup === void 0 || _pragmaticCleanup();
874
893
  }
875
894
  };
876
895
  }