@atlaskit/editor-plugin-block-controls 33.0.0 → 34.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 34.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - [`cabf3c7e59b8d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cabf3c7e59b8d) -
8
+ Remove internal uses of the always-true `areToolbarFlagsEnabled` helper and delete legacy toolbar
9
+ code that only rendered when it returned false (`ScrollButtons`, `LinkToolbarAppearance`,
10
+ `HyperlinkToolbarAppearance` and the media `LayoutGroup`).
11
+ - Updated dependencies
12
+
3
13
  ## 33.0.0
4
14
 
5
15
  ### Patch Changes
@@ -10,7 +10,6 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
  var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys");
12
12
  var _selection = require("@atlaskit/editor-common/selection");
13
- var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
14
13
  var _state = require("@atlaskit/editor-prosemirror/state");
15
14
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
16
15
  var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
@@ -177,7 +176,7 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
177
176
  // Not registered under the registry migration: the decoration puts an inline
178
177
  // `margin-top: 0` on the first document node, which fights features that render their own
179
178
  // content above it — a leading show-diff widget is left flush against the node below.
180
- if ((0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) && !registryBlockControlsEnabled) {
179
+ if (!registryBlockControlsEnabled) {
181
180
  pmPlugins.push({
182
181
  name: 'firstNodeDec',
183
182
  plugin: _firstNodeDecPlugin.firstNodeDecPlugin
@@ -466,7 +466,7 @@ var moveNode = exports.moveNode = function moveNode(api) {
466
466
  }
467
467
  var sliceSize = sliceTo - sliceFrom;
468
468
  if (inputMethod === _enums.INPUT_METHOD.DRAG_AND_DROP) {
469
- tr = (0, _getSelection.setCursorPositionAtMovedNode)(tr, mappedTo, api);
469
+ tr = (0, _getSelection.setCursorPositionAtMovedNode)(tr, mappedTo);
470
470
  } else if (preservedSelection) {
471
471
  var _currMeta = tr.getMeta(_main.key);
472
472
  var nodeMovedOffset = mappedTo - sliceFrom;
@@ -8,7 +8,6 @@ exports.handleMouseOver = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
10
10
  var _utils = require("@atlaskit/editor-common/selection/utils");
11
- var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
12
11
  var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
13
12
  var _fg = require("@atlaskit/platform-feature-flags/fg");
14
13
  var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
@@ -109,7 +108,6 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
109
108
  editorDisabled = _ref2.editorDisabled;
110
109
  var editorViewMode = 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;
111
110
  var isViewMode = editorViewMode === 'view';
112
- var toolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
113
111
 
114
112
  // EDITOR-7926: bail out while a diff is on screen (or a suggestion card is open) so hovering
115
113
  // doesn't dispatch showDragHandleAt and cause the drag handle to jitter over the diff.
@@ -253,47 +251,37 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
253
251
  var targetPos = view.state.doc.resolve(pos).pos;
254
252
  var rootAnchorName;
255
253
  var rootNodeType;
256
- var rootPos;
257
-
258
254
  // enables quick insert
259
- if (toolbarFlagsEnabled) {
260
- rootPos = view.state.doc.resolve(pos).before(1);
261
- if (targetPos !== rootPos) {
262
- var rootDOM = view.nodeDOM(rootPos);
263
- if (rootDOM instanceof HTMLElement) {
264
- var _ref4, _rootDOM$getAttribute, _rootDOM$getAttribute2;
265
- rootAnchorName = (_ref4 = (_rootDOM$getAttribute = rootDOM.getAttribute((0, _domAttrName.getAnchorAttrName)())) !== null && _rootDOM$getAttribute !== void 0 ? _rootDOM$getAttribute : rootDOM.getAttribute(_domAttrName.NODE_ANCHOR_ATTR_NAME)) !== null && _ref4 !== void 0 ? _ref4 : undefined;
266
- rootNodeType = isNativeAnchorSupported ? (0, _domAttrName.getTypeNameFromDom)(rootDOM) : // Fallback: breakout mark wrappers have no data-drag-handler-node-type;
267
- // use data-prosemirror-node-name instead.
268
- (_rootDOM$getAttribute2 = rootDOM.getAttribute('data-drag-handler-node-type')) !== null && _rootDOM$getAttribute2 !== void 0 ? _rootDOM$getAttribute2 : (0, _domAttrName.getTypeNameFromDom)(rootDOM);
269
- }
255
+ var rootPos = view.state.doc.resolve(pos).before(1);
256
+ if (targetPos !== rootPos) {
257
+ var rootDOM = view.nodeDOM(rootPos);
258
+ if (rootDOM instanceof HTMLElement) {
259
+ var _ref4, _rootDOM$getAttribute, _rootDOM$getAttribute2;
260
+ rootAnchorName = (_ref4 = (_rootDOM$getAttribute = rootDOM.getAttribute((0, _domAttrName.getAnchorAttrName)())) !== null && _rootDOM$getAttribute !== void 0 ? _rootDOM$getAttribute : rootDOM.getAttribute(_domAttrName.NODE_ANCHOR_ATTR_NAME)) !== null && _ref4 !== void 0 ? _ref4 : undefined;
261
+ rootNodeType = isNativeAnchorSupported ? (0, _domAttrName.getTypeNameFromDom)(rootDOM) : // Fallback: breakout mark wrappers have no data-drag-handler-node-type;
262
+ // use data-prosemirror-node-name instead.
263
+ (_rootDOM$getAttribute2 = rootDOM.getAttribute('data-drag-handler-node-type')) !== null && _rootDOM$getAttribute2 !== void 0 ? _rootDOM$getAttribute2 : (0, _domAttrName.getTypeNameFromDom)(rootDOM);
270
264
  }
271
265
  }
272
266
  var nodeType = isNativeAnchorSupported ? (0, _domAttrName.getTypeNameFromDom)(rootElement) : // Fallback for table nodes: tr has data-prosemirror-node-name but not data-drag-handler-node-type.
273
267
  (_rootElement$getAttri2 = rootElement.getAttribute('data-drag-handler-node-type')) !== null && _rootElement$getAttri2 !== void 0 ? _rootElement$getAttri2 : (0, _domAttrName.getTypeNameFromDom)(rootElement);
274
268
  if (nodeType) {
275
- var _api$userIntent2;
269
+ var _selectionPreservatio, _api$userIntent2;
276
270
  // enables quick insert
277
- if (toolbarFlagsEnabled) {
278
- var _selectionPreservatio;
279
- var preservedSelection = (_selectionPreservatio = _pluginKey.selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
280
- var selection = preservedSelection || view.state.selection;
281
- var isMultipleSelected = selection && (0, _utils.isMultiBlockSelection)(selection);
271
+ var preservedSelection = (_selectionPreservatio = _pluginKey.selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
272
+ var selection = preservedSelection || view.state.selection;
273
+ var isMultipleSelected = selection && (0, _utils.isMultiBlockSelection)(selection);
282
274
 
283
- // Only execute when selection is not a multi-selection, block menu is open, and menu is opened via keyboard
284
- // as when it is a multi-selection, the showDragHandleAt command interfere with selection
285
- // sometimes makes the multi-selection not continous after block menu is opened with keyboard
286
- if (!(isMultipleSelected && isMenuOpen && blockMenuOptions !== null && blockMenuOptions !== void 0 && blockMenuOptions.openedViaKeyboard)) {
287
- var _api$core, _api$blockControls3;
288
- api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(targetPos, anchorName, nodeType, undefined, rootPos !== null && rootPos !== void 0 ? rootPos : targetPos, rootAnchorName !== null && rootAnchorName !== void 0 ? rootAnchorName : anchorName, rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType));
289
- }
290
- } else {
291
- var _api$core2, _api$blockControls4;
292
- api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands.showDragHandleAt(targetPos, anchorName, nodeType));
275
+ // Only execute when selection is not a multi-selection, block menu is open, and menu is opened via keyboard
276
+ // as when it is a multi-selection, the showDragHandleAt command interfere with selection
277
+ // sometimes makes the multi-selection not continous after block menu is opened with keyboard
278
+ if (!(isMultipleSelected && isMenuOpen && blockMenuOptions !== null && blockMenuOptions !== void 0 && blockMenuOptions.openedViaKeyboard)) {
279
+ var _api$core, _api$blockControls3;
280
+ api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(targetPos, anchorName, nodeType, undefined, rootPos, rootAnchorName !== null && rootAnchorName !== void 0 ? rootAnchorName : anchorName, rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType));
293
281
  }
294
282
  if (isMenuOpen && originalAnchorName && (api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || (_api$userIntent2 = _api$userIntent2.sharedState.currentState()) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.currentUserIntent) === 'blockMenuOpen') {
295
- var _api$core3, _api$blockControls5;
296
- api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.toggleBlockMenu());
283
+ var _api$core2, _api$blockControls4;
284
+ api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands.toggleBlockMenu());
297
285
  }
298
286
  }
299
287
  }
@@ -14,7 +14,6 @@ var _browser = require("@atlaskit/editor-common/browser");
14
14
  var _nodeAnchorProvider = require("@atlaskit/editor-common/node-anchor-provider");
15
15
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
16
16
  var _dragHandle = require("@atlaskit/editor-common/styles/drag-handle");
17
- var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
18
17
  var _uiToolbar = require("@atlaskit/editor-common/ui-toolbar");
19
18
  var _utils = require("@atlaskit/editor-common/utils");
20
19
  var _state = require("@atlaskit/editor-prosemirror/state");
@@ -180,14 +179,14 @@ var getDecorationAtPos = function getDecorationAtPos(state, decorations, pos, to
180
179
  var nodeDecAtActivePos = nodeDecsAtActivePos.pop();
181
180
  return nodeDecAtActivePos;
182
181
  };
183
- var _apply = exports.apply = function apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry) {
184
- var _meta$multiSelectDnD, _api$editorViewMode, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _meta$toggleMenu, _meta$isDragging3, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$toggleMenu6, _meta$toggleMenu7, _meta$toggleMenu8, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$lastDragCancell;
185
- var rightSideControlsEnabled = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
186
- var quickInsertButtonEnabled = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : true;
187
- var anchorRectCache = arguments.length > 10 ? arguments[10] : undefined;
188
- var resizeObserverWidth = arguments.length > 11 ? arguments[11] : undefined;
189
- var pragmaticCleanup = arguments.length > 12 ? arguments[12] : undefined;
190
- var limitedModeTeardown = arguments.length > 13 ? arguments[13] : undefined;
182
+ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState, newState, nodeViewPortalProviderAPI, nodeDecorationRegistry) {
183
+ var _meta$multiSelectDnD, _api$editorViewMode, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _latestActiveNode11, _latestActiveNode12, _meta$toggleMenu, _meta$isDragging3, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$toggleMenu6, _meta$toggleMenu7, _meta$toggleMenu8, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$lastDragCancell;
184
+ var rightSideControlsEnabled = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
185
+ var quickInsertButtonEnabled = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : true;
186
+ var anchorRectCache = arguments.length > 9 ? arguments[9] : undefined;
187
+ var resizeObserverWidth = arguments.length > 10 ? arguments[10] : undefined;
188
+ var pragmaticCleanup = arguments.length > 11 ? arguments[11] : undefined;
189
+ var limitedModeTeardown = arguments.length > 12 ? arguments[12] : undefined;
191
190
  var activeNode = currentState.activeNode,
192
191
  decorations = currentState.decorations,
193
192
  isResizerResizing = currentState.isResizerResizing,
@@ -205,7 +204,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
205
204
  isPMDragging = currentState.isPMDragging,
206
205
  lastDragCancelled = currentState.lastDragCancelled;
207
206
  var isActiveNodeDeleted = false;
208
- var _getTrMetadata = (0, _transactions.getTrMetadata)(tr, flags),
207
+ var _getTrMetadata = (0, _transactions.getTrMetadata)(tr),
209
208
  from = _getTrMetadata.from,
210
209
  to = _getTrMetadata.to,
211
210
  numReplaceSteps = _getTrMetadata.numReplaceSteps,
@@ -304,62 +303,50 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
304
303
 
305
304
  // enables quick insert
306
305
  // don't remap activeNode if it's being dragged
307
- if (!flags.toolbarFlagsEnabled) {
308
- if (activeNode) {
309
- var mappedPos = tr.mapping.mapResult(activeNode.pos);
306
+ if (activeNode && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== true) {
307
+ var _mappedRootPos$pos, _mappedRootPos;
308
+ var mappedPos;
309
+ var browser = (0, _browser.getBrowserInfo)();
310
+ // In safari,
311
+ // sometimes the drag handle for the layout disppears after you click on the handle for a few times
312
+ // Which caused the drag handle onClick event not firing, then block menu wouldn't be opened
313
+ // This is caused by the mappedPos.deletedAfter sometimes returning true in webkit browsers even though the active node still exists
314
+ // This is likely a prosemirror and safari integration bug, but to unblock the issue, we are going to use mappedPos.deleted in safari for now
315
+ if (browser.webkit) {
316
+ mappedPos = tr.mapping.mapResult(activeNode.pos);
310
317
  isActiveNodeDeleted = mappedPos.deleted;
311
- activeNode = {
312
- pos: mappedPos.pos,
313
- anchorName: activeNode.anchorName,
314
- nodeType: activeNode.nodeType
315
- };
318
+ } else {
319
+ mappedPos = tr.mapping.mapResult(activeNode.pos, -1);
320
+ isActiveNodeDeleted = mappedPos.deletedAfter;
316
321
  }
317
- } else {
318
- if (activeNode && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== true) {
319
- var _mappedRootPos$pos, _mappedRootPos;
320
- var _mappedPos;
321
- var browser = (0, _browser.getBrowserInfo)();
322
- // In safari,
323
- // sometimes the drag handle for the layout disppears after you click on the handle for a few times
324
- // Which caused the drag handle onClick event not firing, then block menu wouldn't be opened
325
- // This is caused by the mappedPos.deletedAfter sometimes returning true in webkit browsers even though the active node still exists
326
- // This is likely a prosemirror and safari integration bug, but to unblock the issue, we are going to use mappedPos.deleted in safari for now
327
- if (browser.webkit) {
328
- _mappedPos = tr.mapping.mapResult(activeNode.pos);
329
- isActiveNodeDeleted = _mappedPos.deleted;
330
- } else {
331
- _mappedPos = tr.mapping.mapResult(activeNode.pos, -1);
332
- isActiveNodeDeleted = _mappedPos.deletedAfter;
333
- }
334
- // for editor controls, remap the rootPos as well
335
- var mappedRootPos;
336
- if (activeNode.rootPos !== undefined) {
337
- mappedRootPos = tr.mapping.mapResult(activeNode.rootPos, -1);
322
+ // for editor controls, remap the rootPos as well
323
+ var mappedRootPos;
324
+ if (activeNode.rootPos !== undefined) {
325
+ mappedRootPos = tr.mapping.mapResult(activeNode.rootPos, -1);
326
+ }
327
+ var mappedNodeType = activeNode.nodeType;
328
+ var mappedRootNodeType = activeNode.rootNodeType;
329
+ // Sparse mode does not redraw the old decorations. A block-type transaction may report
330
+ // a text range that excludes the active block position, so always refresh the already
331
+ // active node and root from the new document (for example, paragraph → heading-1).
332
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
333
+ var mappedNode = newState.doc.nodeAt(mappedPos.pos);
334
+ if (mappedNode !== null && mappedNode !== void 0 && mappedNode.isBlock) {
335
+ mappedNodeType = (0, _decorationsCommon.getNodeTypeWithLevel)(mappedNode);
338
336
  }
339
- var mappedNodeType = activeNode.nodeType;
340
- var mappedRootNodeType = activeNode.rootNodeType;
341
- // Sparse mode does not redraw the old decorations. A block-type transaction may report
342
- // a text range that excludes the active block position, so always refresh the already
343
- // active node and root from the new document (for example, paragraph → heading-1).
344
- if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration')) {
345
- var mappedNode = newState.doc.nodeAt(_mappedPos.pos);
346
- if (mappedNode !== null && mappedNode !== void 0 && mappedNode.isBlock) {
347
- mappedNodeType = (0, _decorationsCommon.getNodeTypeWithLevel)(mappedNode);
348
- }
349
- var mappedRootNode = mappedRootPos ? mappedRootPos.pos === _mappedPos.pos && mappedNode ? mappedNode : newState.doc.nodeAt(mappedRootPos.pos) : undefined;
350
- if (mappedRootNode !== null && mappedRootNode !== void 0 && mappedRootNode.isBlock) {
351
- mappedRootNodeType = (0, _decorationsCommon.getNodeTypeWithLevel)(mappedRootNode);
352
- }
337
+ var mappedRootNode = mappedRootPos ? mappedRootPos.pos === mappedPos.pos && mappedNode ? mappedNode : newState.doc.nodeAt(mappedRootPos.pos) : undefined;
338
+ if (mappedRootNode !== null && mappedRootNode !== void 0 && mappedRootNode.isBlock) {
339
+ mappedRootNodeType = (0, _decorationsCommon.getNodeTypeWithLevel)(mappedRootNode);
353
340
  }
354
- activeNode = {
355
- pos: _mappedPos.pos,
356
- anchorName: activeNode.anchorName,
357
- nodeType: mappedNodeType,
358
- rootPos: (_mappedRootPos$pos = (_mappedRootPos = mappedRootPos) === null || _mappedRootPos === void 0 ? void 0 : _mappedRootPos.pos) !== null && _mappedRootPos$pos !== void 0 ? _mappedRootPos$pos : activeNode.rootPos,
359
- rootAnchorName: activeNode.rootAnchorName,
360
- rootNodeType: mappedRootNodeType
361
- };
362
341
  }
342
+ activeNode = {
343
+ pos: mappedPos.pos,
344
+ anchorName: activeNode.anchorName,
345
+ nodeType: mappedNodeType,
346
+ rootPos: (_mappedRootPos$pos = (_mappedRootPos = mappedRootPos) === null || _mappedRootPos === void 0 ? void 0 : _mappedRootPos.pos) !== null && _mappedRootPos$pos !== void 0 ? _mappedRootPos$pos : activeNode.rootPos,
347
+ rootAnchorName: activeNode.rootAnchorName,
348
+ rootNodeType: mappedRootNodeType
349
+ };
363
350
  }
364
351
  if (multiSelectDnD) {
365
352
  multiSelectDnD.anchor = tr.mapping.map(multiSelectDnD.anchor);
@@ -402,43 +389,21 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
402
389
  decorations = decorations.add(newState.doc, newNodeDecs);
403
390
 
404
391
  // enables quick insert
405
- if (!flags.toolbarFlagsEnabled) {
406
- if (latestActiveNode && !isActiveNodeDeleted) {
407
- // Find the newly minted node decs that touch the active node
408
- var findNewNodeDecs = (0, _decorationsAnchor.findNodeDecs)(newState, decorations, latestActiveNode.pos - 1, to);
409
-
410
- // Find the specific dec that the active node corresponds to
411
- var nodeDecsAtActivePos = findNewNodeDecs.filter(function (dec) {
412
- return (dec === null || dec === void 0 ? void 0 : dec.from) === latestActiveNode.pos;
413
- });
414
-
415
- // If multiple decorations at the active node pos, we want the last one
416
- var nodeDecAtActivePos = nodeDecsAtActivePos.pop();
417
-
418
- // Update the active node anchor-name and type for accurate positioning
419
- if (nodeDecAtActivePos) {
420
- isActiveNodeModified = true;
421
- latestActiveNode.anchorName = nodeDecAtActivePos.spec.anchorName;
422
- latestActiveNode.nodeType = nodeDecAtActivePos.spec.nodeType;
423
- }
392
+ if (latestActiveNode && (!isActiveNodeDeleted || isReplacedWithSameSize)) {
393
+ var nodeDecAtActivePos = getDecorationAtPos(newState, decorations, latestActiveNode.pos, to);
394
+ var rootNodeDecAtActivePos = latestActiveNode.rootPos !== undefined ? getDecorationAtPos(newState, decorations, latestActiveNode.rootPos, to) : undefined;
395
+ if (nodeDecAtActivePos || rootNodeDecAtActivePos) {
396
+ isActiveNodeModified = true;
424
397
  }
425
- } else {
426
- if (latestActiveNode && (!isActiveNodeDeleted || isReplacedWithSameSize)) {
427
- var _nodeDecAtActivePos = getDecorationAtPos(newState, decorations, latestActiveNode.pos, to);
428
- var rootNodeDecAtActivePos = latestActiveNode.rootPos !== undefined ? getDecorationAtPos(newState, decorations, latestActiveNode.rootPos, to) : undefined;
429
- if (_nodeDecAtActivePos || rootNodeDecAtActivePos) {
430
- isActiveNodeModified = true;
431
- }
432
398
 
433
- // Update the active node anchor-name and type for accurate positioning
434
- if (_nodeDecAtActivePos) {
435
- latestActiveNode.anchorName = _nodeDecAtActivePos.spec.anchorName;
436
- latestActiveNode.nodeType = _nodeDecAtActivePos.spec.nodeType;
437
- }
438
- if (rootNodeDecAtActivePos) {
439
- latestActiveNode.rootAnchorName = rootNodeDecAtActivePos.spec.anchorName;
440
- latestActiveNode.rootNodeType = rootNodeDecAtActivePos.spec.nodeType;
441
- }
399
+ // Update the active node anchor-name and type for accurate positioning
400
+ if (nodeDecAtActivePos) {
401
+ latestActiveNode.anchorName = nodeDecAtActivePos.spec.anchorName;
402
+ latestActiveNode.nodeType = nodeDecAtActivePos.spec.nodeType;
403
+ }
404
+ if (rootNodeDecAtActivePos) {
405
+ latestActiveNode.rootAnchorName = rootNodeDecAtActivePos.spec.anchorName;
406
+ latestActiveNode.rootNodeType = rootNodeDecAtActivePos.spec.nodeType;
442
407
  }
443
408
  }
444
409
  }
@@ -461,10 +426,8 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
461
426
  var shouldRemoveHandle = latestActiveNode ? isResizerResizing || isActiveNodeDeleted && !isReplacedWithSameSize || (meta === null || meta === void 0 ? void 0 : meta.nodeMoved) : true;
462
427
 
463
428
  // enables quick insert
464
- if (flags.toolbarFlagsEnabled) {
465
- // Remove handle dec when editor is blurred
466
- shouldRemoveHandle = shouldRemoveHandle || (meta === null || meta === void 0 ? void 0 : meta.editorBlurred);
467
- }
429
+ // Remove handle dec when editor is blurred
430
+ shouldRemoveHandle = shouldRemoveHandle || (meta === null || meta === void 0 ? void 0 : meta.editorBlurred);
468
431
 
469
432
  // In view mode with right-side controls, remove any lingering drag handle decorations
470
433
  // (they may carry over from edit mode). Only remove drag handles specifically, not
@@ -497,54 +460,52 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
497
460
  // nodeDecorationRegistry cleanup (e.g. the legacy Remix button) is independent of the legacy
498
461
  // quick-insert button, so this must not be gated by quickInsertButtonEnabled — otherwise a
499
462
  // stale decoration is left behind whenever platform_editor_block_control_migration is on.
500
- if (flags.toolbarFlagsEnabled) {
501
- // enables quick insert
502
- if (quickInsertButtonEnabled) {
503
- var _activeNode7, _activeNode8;
504
- var oldQuickInsertButton = (0, _decorationsQuickInsertButton.findQuickInsertInsertButtonDecoration)(decorations, (_activeNode7 = activeNode) === null || _activeNode7 === void 0 ? void 0 : _activeNode7.rootPos, (_activeNode8 = activeNode) === null || _activeNode8 === void 0 ? void 0 : _activeNode8.rootPos);
505
- decorations = decorations.remove(oldQuickInsertButton);
463
+ // enables quick insert
464
+ if (quickInsertButtonEnabled) {
465
+ var _activeNode7, _activeNode8;
466
+ var oldQuickInsertButton = (0, _decorationsQuickInsertButton.findQuickInsertInsertButtonDecoration)(decorations, (_activeNode7 = activeNode) === null || _activeNode7 === void 0 ? void 0 : _activeNode7.rootPos, (_activeNode8 = activeNode) === null || _activeNode8 === void 0 ? void 0 : _activeNode8.rootPos);
467
+ decorations = decorations.remove(oldQuickInsertButton);
468
+ }
469
+ var _iterator = _createForOfIteratorHelper(nodeDecorationRegistry),
470
+ _step;
471
+ try {
472
+ var _loop2 = function _loop2() {
473
+ var _activeNode1, _activeNode10;
474
+ var factory = _step.value;
475
+ var old = decorations.find((_activeNode1 = activeNode) === null || _activeNode1 === void 0 ? void 0 : _activeNode1.rootPos, (_activeNode10 = activeNode) === null || _activeNode10 === void 0 ? void 0 : _activeNode10.rootPos, function (spec) {
476
+ return spec.type === factory.type;
477
+ });
478
+ decorations = decorations.remove(old);
479
+ };
480
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
481
+ _loop2();
506
482
  }
507
- var _iterator = _createForOfIteratorHelper(nodeDecorationRegistry),
508
- _step;
483
+ } catch (err) {
484
+ _iterator.e(err);
485
+ } finally {
486
+ _iterator.f();
487
+ }
488
+ if (rightSideControlsEnabled && isViewMode) {
489
+ var _iterator2 = _createForOfIteratorHelper(nodeDecorationRegistry),
490
+ _step2;
509
491
  try {
510
- var _loop2 = function _loop2() {
511
- var _activeNode1, _activeNode10;
512
- var factory = _step.value;
513
- var old = decorations.find((_activeNode1 = activeNode) === null || _activeNode1 === void 0 ? void 0 : _activeNode1.rootPos, (_activeNode10 = activeNode) === null || _activeNode10 === void 0 ? void 0 : _activeNode10.rootPos, function (spec) {
514
- return spec.type === factory.type;
515
- });
516
- decorations = decorations.remove(old);
492
+ var _loop = function _loop() {
493
+ var factory = _step2.value;
494
+ if (factory.showInViewMode) {
495
+ var _activeNode9, _activeNode0;
496
+ var old = decorations.find((_activeNode9 = activeNode) === null || _activeNode9 === void 0 ? void 0 : _activeNode9.rootPos, (_activeNode0 = activeNode) === null || _activeNode0 === void 0 ? void 0 : _activeNode0.rootPos, function (spec) {
497
+ return spec.type === factory.type;
498
+ });
499
+ decorations = decorations.remove(old);
500
+ }
517
501
  };
518
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
519
- _loop2();
502
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
503
+ _loop();
520
504
  }
521
505
  } catch (err) {
522
- _iterator.e(err);
506
+ _iterator2.e(err);
523
507
  } finally {
524
- _iterator.f();
525
- }
526
- if (rightSideControlsEnabled && isViewMode) {
527
- var _iterator2 = _createForOfIteratorHelper(nodeDecorationRegistry),
528
- _step2;
529
- try {
530
- var _loop = function _loop() {
531
- var factory = _step2.value;
532
- if (factory.showInViewMode) {
533
- var _activeNode9, _activeNode0;
534
- var old = decorations.find((_activeNode9 = activeNode) === null || _activeNode9 === void 0 ? void 0 : _activeNode9.rootPos, (_activeNode0 = activeNode) === null || _activeNode0 === void 0 ? void 0 : _activeNode0.rootPos, function (spec) {
535
- return spec.type === factory.type;
536
- });
537
- decorations = decorations.remove(old);
538
- }
539
- };
540
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
541
- _loop();
542
- }
543
- } catch (err) {
544
- _iterator2.e(err);
545
- } finally {
546
- _iterator2.f();
547
- }
508
+ _iterator2.f();
548
509
  }
549
510
  }
550
511
  } else if (api) {
@@ -622,9 +583,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
622
583
  }
623
584
  }
624
585
  }
625
- if (shouldRecreateQuickInsertButton && ((_latestActiveNode5 = latestActiveNode) === null || _latestActiveNode5 === void 0 ? void 0 : _latestActiveNode5.rootPos) !== undefined && (quickInsertButtonEnabled || nodeDecorationRegistry.length > 0) &&
626
- // enables quick insert
627
- flags.toolbarFlagsEnabled && (!rightSideControlsEnabled || !isViewMode)) {
586
+ if (shouldRecreateQuickInsertButton && ((_latestActiveNode5 = latestActiveNode) === null || _latestActiveNode5 === void 0 ? void 0 : _latestActiveNode5.rootPos) !== undefined && (quickInsertButtonEnabled || nodeDecorationRegistry.length > 0) && (!rightSideControlsEnabled || !isViewMode)) {
628
587
  var _latestActiveNode1;
629
588
  if (quickInsertButtonEnabled) {
630
589
  var _activeNode13, _activeNode14, _latestActiveNode6, _latestActiveNode7, _latestActiveNode8, _latestActiveNode9, _latestActiveNode0;
@@ -730,7 +689,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
730
689
  var rootPos = (_latestActiveNode10 = latestActiveNode) === null || _latestActiveNode10 === void 0 ? void 0 : _latestActiveNode10.rootPos;
731
690
  // rootPos is computed using the same logic as the floating insert menu, so it always points to a top-level (doc child) block when defined.
732
691
  var isDocLevel = rootPos !== undefined && !isNaN(rootPos);
733
- if (isViewMode && isDocLevel && flags.toolbarFlagsEnabled && rightSideControlsEnabled) {
692
+ if (isViewMode && isDocLevel && rightSideControlsEnabled) {
734
693
  var _iterator5 = _createForOfIteratorHelper(nodeDecorationRegistry),
735
694
  _step5;
736
695
  try {
@@ -842,21 +801,15 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
842
801
  decorations = decorations.add(newState.doc, [(0, _decorationsDragHandle.emptyParagraphNodeDecorations)()]);
843
802
  }
844
803
  }
845
- var newActiveNode;
804
+
846
805
  // enables quick insert
847
- if (flags.toolbarFlagsEnabled) {
848
- var _latestActiveNode11, _latestActiveNode12;
849
- // remove isEmptyDoc check and let decorations render and determine their own visibility
850
- // In view mode with right-side controls we render node decorations (right-edge button), not the
851
- // handle - so findHandleDec is always empty. Don't clear activeNode in that case.
852
- var hasHandleOrViewModeControls = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') || isViewMode && rightSideControlsEnabled || (0, _decorationsDragHandle.findHandleDec)(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length > 0;
853
- // Keep the registry surface mounted while its Block Menu owns focus.
854
- var keepActiveNodeForOpenBlockMenu = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') && isMenuOpen;
855
- newActiveNode = meta !== null && meta !== void 0 && meta.editorBlurred && !keepActiveNodeForOpenBlockMenu || !(meta !== null && meta !== void 0 && meta.activeNode) && !hasHandleOrViewModeControls ? null : latestActiveNode;
856
- } else {
857
- var _latestActiveNode13, _latestActiveNode14;
858
- newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && !(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') && (0, _decorationsDragHandle.findHandleDec)(decorations, (_latestActiveNode13 = latestActiveNode) === null || _latestActiveNode13 === void 0 ? void 0 : _latestActiveNode13.pos, (_latestActiveNode14 = latestActiveNode) === null || _latestActiveNode14 === void 0 ? void 0 : _latestActiveNode14.pos).length === 0 ? null : latestActiveNode;
859
- }
806
+ // remove isEmptyDoc check and let decorations render and determine their own visibility
807
+ // In view mode with right-side controls we render node decorations (right-edge button), not the
808
+ // handle - so findHandleDec is always empty. Don't clear activeNode in that case.
809
+ var hasHandleOrViewModeControls = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') || isViewMode && rightSideControlsEnabled || (0, _decorationsDragHandle.findHandleDec)(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length > 0;
810
+ // Keep the registry surface mounted while its Block Menu owns focus.
811
+ var keepActiveNodeForOpenBlockMenu = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') && isMenuOpen;
812
+ var newActiveNode = meta !== null && meta !== void 0 && meta.editorBlurred && !keepActiveNodeForOpenBlockMenu || !(meta !== null && meta !== void 0 && meta.activeNode) && !hasHandleOrViewModeControls ? null : latestActiveNode;
860
813
  var nextMenuTriggerByNode = (meta === null || meta === void 0 || (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.triggerByNode) || menuTriggerByNode;
861
814
  if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_block_control_migration') && tr.docChanged && menuTriggerByNode && !(meta !== null && meta !== void 0 && meta.toggleMenu)) {
862
815
  var _menuTriggerByNode$ro, _newState$doc$nodeAt4;
@@ -878,11 +831,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
878
831
  var isSameAnchor = (meta === null || meta === void 0 ? void 0 : meta.toggleMenu.anchorName) === menuTriggerBy;
879
832
  isMenuOpen = menuTriggerBy === undefined || isSameAnchor || !isMenuOpen && !isSameAnchor ? !isMenuOpen : isMenuOpen;
880
833
  }
881
- if (flags.toolbarFlagsEnabled) {
882
- isSelectedViaDragHandle = (meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle) !== undefined ? meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle : isSelectedViaDragHandle;
883
- } else {
884
- isSelectedViaDragHandle = false;
885
- }
834
+ isSelectedViaDragHandle = (meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle) !== undefined ? meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle : isSelectedViaDragHandle;
886
835
  return {
887
836
  decorations: decorations,
888
837
  surfaceNodePositions: surfaceNodePositions,
@@ -916,10 +865,6 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
916
865
  var isAdvancedLayoutEnabled = (0, _editorExperiment.editorExperiment)('advanced_layouts', true, {
917
866
  exposure: true
918
867
  });
919
- var toolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
920
- var flags = {
921
- toolbarFlagsEnabled: toolbarFlagsEnabled
922
- };
923
868
  var anchorRectCache;
924
869
  if (!(0, _anchorUtils.isAnchorSupported)()) {
925
870
  anchorRectCache = new _anchorUtils.AnchorRectCache();
@@ -968,7 +913,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
968
913
  return _objectSpread({}, initialState);
969
914
  },
970
915
  apply: function apply(tr, currentState, _, newState) {
971
- return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, limitedModeTeardown);
916
+ return _apply(api, formatMessage, tr, currentState, newState, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, limitedModeTeardown);
972
917
  }
973
918
  },
974
919
  props: {
@@ -7,7 +7,6 @@ exports.setCursorPositionAtMovedNode = exports.selectNode = exports.rootTaskList
7
7
  var _nodeSelection = require("@atlaskit/editor-common/node-selection");
8
8
  var _selection2 = require("@atlaskit/editor-common/selection");
9
9
  var _selection3 = require("@atlaskit/editor-common/selection/gap-cursor/selection");
10
- var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
11
10
  var _state = require("@atlaskit/editor-prosemirror/state");
12
11
  var _utils = require("@atlaskit/editor-prosemirror/utils");
13
12
  var _selectTableClosestToPos = require("@atlaskit/editor-tables/select-table-closest-to-pos");
@@ -74,7 +73,7 @@ var selectNode = exports.selectNode = function selectNode(tr, start, nodeType, a
74
73
  }
75
74
  return tr;
76
75
  };
77
- var setCursorPositionAtMovedNode = exports.setCursorPositionAtMovedNode = function setCursorPositionAtMovedNode(tr, start, api) {
76
+ var setCursorPositionAtMovedNode = exports.setCursorPositionAtMovedNode = function setCursorPositionAtMovedNode(tr, start) {
78
77
  var node = tr.doc.nodeAt(start);
79
78
  var isNodeSelection = node && _state.NodeSelection.isSelectable(node);
80
79
  var nodeSize = node ? node.nodeSize : 1;
@@ -88,7 +87,7 @@ var setCursorPositionAtMovedNode = exports.setCursorPositionAtMovedNode = functi
88
87
  }
89
88
 
90
89
  // this is a fix for empty paragraph selection - can safely use start position as the paragraph is empty
91
- if ((node === null || node === void 0 ? void 0 : node.type.name) === 'paragraph' && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(api === null || api === void 0 ? void 0 : api.toolbar))) {
90
+ if ((node === null || node === void 0 ? void 0 : node.type.name) === 'paragraph' && (node === null || node === void 0 ? void 0 : node.childCount) === 0) {
92
91
  var _selection = new _state.TextSelection(tr.doc.resolve(start));
93
92
  tr.setSelection(_selection);
94
93
  return tr;
@@ -51,7 +51,7 @@ var isStepContentReplacedWithAnotherOfSameSize = function isStepContentReplacedW
51
51
  * Number of ReplaceStep and ReplaceAroundStep steps 'numReplaceSteps'.
52
52
  * 'isAllText' if all steps are represent adding inline text or a backspace/delete or no-op
53
53
  */
54
- var getTrMetadata = exports.getTrMetadata = function getTrMetadata(tr, flags) {
54
+ var getTrMetadata = exports.getTrMetadata = function getTrMetadata(tr) {
55
55
  var from;
56
56
  var to;
57
57
  var numReplaceSteps = 0;
@@ -63,10 +63,7 @@ var getTrMetadata = exports.getTrMetadata = function getTrMetadata(tr, flags) {
63
63
  isAllText = false;
64
64
  }
65
65
  // Fixes drag handle and quick insert button overlap issues
66
- if (flags.toolbarFlagsEnabled) {
67
- // fixes drag handle and quick insert button overlap issues
68
- isReplacedWithSameSize = isStepContentReplacedWithAnotherOfSameSize(s);
69
- }
66
+ isReplacedWithSameSize = isStepContentReplacedWithAnotherOfSameSize(s);
70
67
  var mappedTo = tr.mapping.map(s.to);
71
68
  var $to = s.from + s.slice.size;
72
69
  $to = $to > mappedTo ? $to : mappedTo;