@atlaskit/editor-plugin-block-controls 33.0.0 → 34.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/blockControlsPlugin.js +1 -2
  3. package/dist/cjs/editor-commands/move-node.js +1 -1
  4. package/dist/cjs/pm-plugins/handle-mouse-over.js +21 -33
  5. package/dist/cjs/pm-plugins/interaction-tracking/handle-mouse-move.js +8 -14
  6. package/dist/cjs/pm-plugins/interaction-tracking/pm-plugin.js +11 -24
  7. package/dist/cjs/pm-plugins/main.js +115 -170
  8. package/dist/cjs/pm-plugins/utils/getSelection.js +2 -3
  9. package/dist/cjs/pm-plugins/utils/transactions.js +2 -5
  10. package/dist/cjs/ui/global-styles.js +1 -19
  11. package/dist/es2019/blockControlsPlugin.js +1 -2
  12. package/dist/es2019/editor-commands/move-node.js +1 -1
  13. package/dist/es2019/pm-plugins/handle-mouse-over.js +21 -33
  14. package/dist/es2019/pm-plugins/interaction-tracking/handle-mouse-move.js +8 -14
  15. package/dist/es2019/pm-plugins/interaction-tracking/pm-plugin.js +11 -24
  16. package/dist/es2019/pm-plugins/main.js +85 -138
  17. package/dist/es2019/pm-plugins/utils/getSelection.js +2 -3
  18. package/dist/es2019/pm-plugins/utils/transactions.js +2 -5
  19. package/dist/es2019/ui/global-styles.js +1 -22
  20. package/dist/esm/blockControlsPlugin.js +1 -2
  21. package/dist/esm/editor-commands/move-node.js +1 -1
  22. package/dist/esm/pm-plugins/handle-mouse-over.js +21 -33
  23. package/dist/esm/pm-plugins/interaction-tracking/handle-mouse-move.js +8 -14
  24. package/dist/esm/pm-plugins/interaction-tracking/pm-plugin.js +11 -24
  25. package/dist/esm/pm-plugins/main.js +115 -170
  26. package/dist/esm/pm-plugins/utils/getSelection.js +2 -3
  27. package/dist/esm/pm-plugins/utils/transactions.js +2 -5
  28. package/dist/esm/ui/global-styles.js +1 -19
  29. package/dist/types/pm-plugins/main.d.ts +1 -4
  30. package/dist/types/pm-plugins/utils/getSelection.d.ts +1 -1
  31. package/dist/types/pm-plugins/utils/transactions.d.ts +1 -2
  32. package/package.json +25 -22
@@ -1,6 +1,5 @@
1
1
  import memoizeOne from 'memoize-one';
2
2
  import { isMultiBlockSelection } from '@atlaskit/editor-common/selection/utils';
3
- import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
4
3
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
5
4
  import { fg } from '@atlaskit/platform-feature-flags/fg';
6
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
@@ -101,7 +100,6 @@ export const handleMouseOver = (view, event, api) => {
101
100
  };
102
101
  const editorViewMode = 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;
103
102
  const isViewMode = editorViewMode === 'view';
104
- const toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
105
103
 
106
104
  // EDITOR-7926: bail out while a diff is on screen (or a suggestion card is open) so hovering
107
105
  // doesn't dispatch showDragHandleAt and cause the drag handle to jitter over the diff.
@@ -245,47 +243,37 @@ export const handleMouseOver = (view, event, api) => {
245
243
  const targetPos = view.state.doc.resolve(pos).pos;
246
244
  let rootAnchorName;
247
245
  let rootNodeType;
248
- let rootPos;
249
-
250
246
  // enables quick insert
251
- if (toolbarFlagsEnabled) {
252
- rootPos = view.state.doc.resolve(pos).before(1);
253
- if (targetPos !== rootPos) {
254
- const rootDOM = view.nodeDOM(rootPos);
255
- if (rootDOM instanceof HTMLElement) {
256
- var _ref2, _rootDOM$getAttribute, _rootDOM$getAttribute2;
257
- rootAnchorName = (_ref2 = (_rootDOM$getAttribute = rootDOM.getAttribute(getAnchorAttrName())) !== null && _rootDOM$getAttribute !== void 0 ? _rootDOM$getAttribute : rootDOM.getAttribute(NODE_ANCHOR_ATTR_NAME)) !== null && _ref2 !== void 0 ? _ref2 : undefined;
258
- rootNodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootDOM) : // Fallback: breakout mark wrappers have no data-drag-handler-node-type;
259
- // use data-prosemirror-node-name instead.
260
- (_rootDOM$getAttribute2 = rootDOM.getAttribute('data-drag-handler-node-type')) !== null && _rootDOM$getAttribute2 !== void 0 ? _rootDOM$getAttribute2 : getTypeNameFromDom(rootDOM);
261
- }
247
+ const rootPos = view.state.doc.resolve(pos).before(1);
248
+ if (targetPos !== rootPos) {
249
+ const rootDOM = view.nodeDOM(rootPos);
250
+ if (rootDOM instanceof HTMLElement) {
251
+ var _ref2, _rootDOM$getAttribute, _rootDOM$getAttribute2;
252
+ rootAnchorName = (_ref2 = (_rootDOM$getAttribute = rootDOM.getAttribute(getAnchorAttrName())) !== null && _rootDOM$getAttribute !== void 0 ? _rootDOM$getAttribute : rootDOM.getAttribute(NODE_ANCHOR_ATTR_NAME)) !== null && _ref2 !== void 0 ? _ref2 : undefined;
253
+ rootNodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootDOM) : // Fallback: breakout mark wrappers have no data-drag-handler-node-type;
254
+ // use data-prosemirror-node-name instead.
255
+ (_rootDOM$getAttribute2 = rootDOM.getAttribute('data-drag-handler-node-type')) !== null && _rootDOM$getAttribute2 !== void 0 ? _rootDOM$getAttribute2 : getTypeNameFromDom(rootDOM);
262
256
  }
263
257
  }
264
258
  const nodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootElement) : // Fallback for table nodes: tr has data-prosemirror-node-name but not data-drag-handler-node-type.
265
259
  (_rootElement$getAttri2 = rootElement.getAttribute('data-drag-handler-node-type')) !== null && _rootElement$getAttri2 !== void 0 ? _rootElement$getAttri2 : getTypeNameFromDom(rootElement);
266
260
  if (nodeType) {
267
- var _api$userIntent2, _api$userIntent2$shar;
261
+ var _selectionPreservatio, _api$userIntent2, _api$userIntent2$shar;
268
262
  // enables quick insert
269
- if (toolbarFlagsEnabled) {
270
- var _selectionPreservatio;
271
- const preservedSelection = (_selectionPreservatio = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
272
- const selection = preservedSelection || view.state.selection;
273
- const isMultipleSelected = selection && isMultiBlockSelection(selection);
263
+ const preservedSelection = (_selectionPreservatio = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection;
264
+ const selection = preservedSelection || view.state.selection;
265
+ const isMultipleSelected = selection && isMultiBlockSelection(selection);
274
266
 
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, _rootPos, _rootAnchorName, _rootNodeType;
280
- api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(targetPos, anchorName, nodeType, undefined, (_rootPos = rootPos) !== null && _rootPos !== void 0 ? _rootPos : targetPos, (_rootAnchorName = rootAnchorName) !== null && _rootAnchorName !== void 0 ? _rootAnchorName : anchorName, (_rootNodeType = rootNodeType) !== null && _rootNodeType !== void 0 ? _rootNodeType : nodeType));
281
- }
282
- } else {
283
- var _api$core2, _api$blockControls4;
284
- api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands.showDragHandleAt(targetPos, anchorName, nodeType));
267
+ // Only execute when selection is not a multi-selection, block menu is open, and menu is opened via keyboard
268
+ // as when it is a multi-selection, the showDragHandleAt command interfere with selection
269
+ // sometimes makes the multi-selection not continous after block menu is opened with keyboard
270
+ if (!(isMultipleSelected && isMenuOpen && blockMenuOptions !== null && blockMenuOptions !== void 0 && blockMenuOptions.openedViaKeyboard)) {
271
+ var _api$core, _api$blockControls3, _rootAnchorName, _rootNodeType;
272
+ api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.showDragHandleAt(targetPos, anchorName, nodeType, undefined, rootPos, (_rootAnchorName = rootAnchorName) !== null && _rootAnchorName !== void 0 ? _rootAnchorName : anchorName, (_rootNodeType = rootNodeType) !== null && _rootNodeType !== void 0 ? _rootNodeType : nodeType));
285
273
  }
286
274
  if (isMenuOpen && originalAnchorName && (api === null || api === void 0 ? void 0 : (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : (_api$userIntent2$shar = _api$userIntent2.sharedState.currentState()) === null || _api$userIntent2$shar === void 0 ? void 0 : _api$userIntent2$shar.currentUserIntent) === 'blockMenuOpen') {
287
- var _api$core3, _api$blockControls5;
288
- api === null || api === void 0 ? void 0 : (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.toggleBlockMenu());
275
+ var _api$core2, _api$blockControls4;
276
+ api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands.toggleBlockMenu());
289
277
  }
290
278
  }
291
279
  }
@@ -1,5 +1,4 @@
1
1
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
2
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
3
2
  import { handleMouseOver } from '../handle-mouse-over';
4
3
  import { clearHoverSide, mouseEnter, mouseLeave, setHoverSide, stopEditing } from './commands';
5
4
  import { RIGHT_MARGIN_ROVO_GAP_PX } from './constants';
@@ -64,9 +63,7 @@ const classifyRightMarginPosition = (view, event) => {
64
63
  if (event.clientX <= found.rect.right) {
65
64
  return null;
66
65
  }
67
- return event.clientX > getRightMarginBoundary(view) && !expValEqualsNoExposure('cc_maui_remix_button_hover_corridor', 'isEnabled', true) ? {
68
- type: 'gap'
69
- } : {
66
+ return {
70
67
  type: 'active',
71
68
  block: found.block
72
69
  };
@@ -103,7 +100,7 @@ const processHoverSide = (view, api) => {
103
100
  // This is more reliable than bounds when controls are in portals outside the editor DOM.
104
101
  const rightEdgeElement = target === null || target === void 0 ? void 0 : target.closest(getRightControlSelector());
105
102
  if (rightEdgeElement) {
106
- if (state !== null && state !== void 0 && state.isMouseOut && expValEqualsNoExposure('cc_maui_remix_button_hover_corridor', 'isEnabled', true)) {
103
+ if (state !== null && state !== void 0 && state.isMouseOut) {
107
104
  mouseEnter(view, 'right');
108
105
  return;
109
106
  }
@@ -131,11 +128,8 @@ const processHoverSide = (view, api) => {
131
128
  }, api);
132
129
  // mouseenter doesn't fire over the click overlay, so clear isMouseOut here to re-show.
133
130
  if (state !== null && state !== void 0 && state.isMouseOut) {
134
- if (expValEqualsNoExposure('cc_maui_remix_button_hover_corridor', 'isEnabled', true)) {
135
- mouseEnter(view, 'right');
136
- return;
137
- }
138
- mouseEnter(view);
131
+ mouseEnter(view, 'right');
132
+ return;
139
133
  }
140
134
  if ((state === null || state === void 0 ? void 0 : state.hoverSide) !== 'right') {
141
135
  setHoverSide(view, 'right');
@@ -143,9 +137,9 @@ const processHoverSide = (view, api) => {
143
137
  return;
144
138
  }
145
139
 
146
- // Keep the existing fixed Rovo gap in the control cohort. The treatment uses explicitly marked
147
- // control surfaces instead, so the rest of the right margin remains hoverable.
148
- if ((marginZone === null || marginZone === void 0 ? void 0 : marginZone.type) === 'gap' || event.clientX > getRightMarginBoundary(view) && (!blockElement || !expValEqualsNoExposure('cc_maui_remix_button_hover_corridor', 'isEnabled', true))) {
140
+ // Explicitly marked control surfaces handle the Rovo area, so the rest of the right margin
141
+ // remains hoverable; only clear hover when past the boundary and not over a block.
142
+ if (event.clientX > getRightMarginBoundary(view) && !blockElement) {
149
143
  if (!(state !== null && state !== void 0 && state.isMouseOut)) {
150
144
  clearHoverSide(view);
151
145
  mouseLeave(view);
@@ -164,7 +158,7 @@ const processHoverSide = (view, api) => {
164
158
  const midpoint = (left + right) / 2;
165
159
  const nextHoverSide = event.clientX > midpoint ? 'right' : 'left';
166
160
  if ((state === null || state === void 0 ? void 0 : state.hoverSide) !== nextHoverSide) {
167
- if (state !== null && state !== void 0 && state.isMouseOut && target !== null && target !== void 0 && target.closest(BLOCK_SELECTORS) && expValEqualsNoExposure('cc_maui_remix_button_hover_corridor', 'isEnabled', true)) {
161
+ if (state !== null && state !== void 0 && state.isMouseOut && target !== null && target !== void 0 && target.closest(BLOCK_SELECTORS)) {
168
162
  mouseEnter(view, nextHoverSide);
169
163
  return;
170
164
  }
@@ -3,7 +3,6 @@ import { isBlockControlsSuppressionTarget } from '@atlaskit/editor-common/block-
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
5
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
6
- import { UNSAFE_expValNoExposure } from '@atlaskit/platform-feature-experiments/unsafe-exp-val-no-exposure';
7
6
  import { RIGHT_MARGIN_ROVO_GAP_PX } from './constants';
8
7
  import { handleKeyDown } from './handle-key-down';
9
8
  import { handleMouseEnter, handleMouseLeave, handleMouseMove } from './handle-mouse-move';
@@ -114,22 +113,22 @@ export const createInteractionTrackingPlugin = (rightSideControlsEnabled = false
114
113
  mouseLeaveTimeoutId = null;
115
114
  }
116
115
 
117
- // Preserve the existing hover targets for the control cohort.
116
+ // Preserve hover while moving onto block controls or an active click area.
118
117
  if (rightSideControlsEnabled && (isMovingToBlockControlsArea(event.relatedTarget) || isOverActiveClickArea(event.relatedTarget, event.clientX))) {
119
118
  return;
120
119
  }
121
- if (rightSideControlsEnabled && isExperimentEnabled('cc_maui_remix_button_hover_corridor') && isOverTreatmentClickArea(event.relatedTarget, editorContentArea, event.clientX)) {
120
+ if (rightSideControlsEnabled && isOverTreatmentClickArea(event.relatedTarget, editorContentArea, event.clientX)) {
122
121
  return;
123
122
  }
124
123
  mouseLeaveTimeoutId = setTimeout(() => {
125
124
  mouseLeaveTimeoutId = null;
126
- // Re-check the control cohort's existing hover targets after the debounce.
125
+ // Re-check hover targets after the debounce.
127
126
  if (rightSideControlsEnabled && typeof document !== 'undefined') {
128
127
  const el = document.elementFromPoint(lastMousePosition.x, lastMousePosition.y);
129
128
  if (el && (isMovingToBlockControlsArea(el) || isOverActiveClickArea(el, lastMousePosition.x))) {
130
129
  return;
131
130
  }
132
- if (el && isExperimentEnabled('cc_maui_remix_button_hover_corridor') && isOverTreatmentClickArea(el, editorContentArea, lastMousePosition.x)) {
131
+ if (el && isOverTreatmentClickArea(el, editorContentArea, lastMousePosition.x)) {
133
132
  return;
134
133
  }
135
134
  }
@@ -171,25 +170,13 @@ export const createInteractionTrackingPlugin = (rightSideControlsEnabled = false
171
170
  };
172
171
  if (editorContentArea) {
173
172
  if (rightSideControlsEnabled && typeof document !== 'undefined') {
174
- // RemixButtonDecoration fires exposure when the control is visible; this
175
- // mount-time split only selects the appropriate interaction listener.
176
- if (UNSAFE_expValNoExposure('cc_maui_remix_button_hover_corridor', 'isEnabled', false) === true) {
177
- unbindDocumentMouseMove = bind(document, {
178
- type: 'mousemove',
179
- listener: handleTreatmentDocumentMouseMove,
180
- options: {
181
- passive: true
182
- }
183
- });
184
- } else {
185
- unbindDocumentMouseMove = bind(document, {
186
- type: 'mousemove',
187
- listener: handleDocumentMouseMove,
188
- options: {
189
- passive: true
190
- }
191
- });
192
- }
173
+ unbindDocumentMouseMove = bind(document, {
174
+ type: 'mousemove',
175
+ listener: handleTreatmentDocumentMouseMove,
176
+ options: {
177
+ passive: true
178
+ }
179
+ });
193
180
  }
194
181
  unbindMouseEnter = bind(editorContentArea, {
195
182
  type: 'mouseenter',
@@ -6,7 +6,6 @@ import { getBrowserInfo } from '@atlaskit/editor-common/browser';
6
6
  import { getNodeIdProvider } from '@atlaskit/editor-common/node-anchor-provider';
7
7
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
8
8
  import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles/drag-handle';
9
- import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
10
9
  import { EDIT_AREA_ID } from '@atlaskit/editor-common/ui-toolbar';
11
10
  import { isEmptyDocument } from '@atlaskit/editor-common/utils';
12
11
  import { PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
@@ -171,8 +170,8 @@ const getDecorationAtPos = (state, decorations, pos, to) => {
171
170
  const nodeDecAtActivePos = nodeDecsAtActivePos.pop();
172
171
  return nodeDecAtActivePos;
173
172
  };
174
- export const apply = (api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled = false, quickInsertButtonEnabled = true, anchorRectCache, resizeObserverWidth, pragmaticCleanup, limitedModeTeardown) => {
175
- var _meta$multiSelectDnD, _api$editorViewMode, _api$editorViewMode$s, _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;
173
+ export const apply = (api, formatMessage, tr, currentState, newState, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled = false, quickInsertButtonEnabled = true, anchorRectCache, resizeObserverWidth, pragmaticCleanup, limitedModeTeardown) => {
174
+ var _meta$multiSelectDnD, _api$editorViewMode, _api$editorViewMode$s, _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;
176
175
  let {
177
176
  activeNode,
178
177
  decorations,
@@ -202,7 +201,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
202
201
  numReplaceSteps,
203
202
  isAllText,
204
203
  isReplacedWithSameSize
205
- } = getTrMetadata(tr, flags);
204
+ } = getTrMetadata(tr);
206
205
  const meta = tr.getMeta(key);
207
206
  if (isExperimentEnabled('platform_editor_dynamic_limited_mode')) {
208
207
  var _api$limitedMode, _api$limitedMode$shar;
@@ -297,62 +296,50 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
297
296
 
298
297
  // enables quick insert
299
298
  // don't remap activeNode if it's being dragged
300
- if (!flags.toolbarFlagsEnabled) {
301
- if (activeNode) {
302
- const mappedPos = tr.mapping.mapResult(activeNode.pos);
299
+ if (activeNode && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== true) {
300
+ var _mappedRootPos$pos, _mappedRootPos;
301
+ let mappedPos;
302
+ const browser = getBrowserInfo();
303
+ // In safari,
304
+ // sometimes the drag handle for the layout disppears after you click on the handle for a few times
305
+ // Which caused the drag handle onClick event not firing, then block menu wouldn't be opened
306
+ // This is caused by the mappedPos.deletedAfter sometimes returning true in webkit browsers even though the active node still exists
307
+ // 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
308
+ if (browser.webkit) {
309
+ mappedPos = tr.mapping.mapResult(activeNode.pos);
303
310
  isActiveNodeDeleted = mappedPos.deleted;
304
- activeNode = {
305
- pos: mappedPos.pos,
306
- anchorName: activeNode.anchorName,
307
- nodeType: activeNode.nodeType
308
- };
311
+ } else {
312
+ mappedPos = tr.mapping.mapResult(activeNode.pos, -1);
313
+ isActiveNodeDeleted = mappedPos.deletedAfter;
309
314
  }
310
- } else {
311
- if (activeNode && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== true) {
312
- var _mappedRootPos$pos, _mappedRootPos;
313
- let mappedPos;
314
- const browser = getBrowserInfo();
315
- // In safari,
316
- // sometimes the drag handle for the layout disppears after you click on the handle for a few times
317
- // Which caused the drag handle onClick event not firing, then block menu wouldn't be opened
318
- // This is caused by the mappedPos.deletedAfter sometimes returning true in webkit browsers even though the active node still exists
319
- // 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
320
- if (browser.webkit) {
321
- mappedPos = tr.mapping.mapResult(activeNode.pos);
322
- isActiveNodeDeleted = mappedPos.deleted;
323
- } else {
324
- mappedPos = tr.mapping.mapResult(activeNode.pos, -1);
325
- isActiveNodeDeleted = mappedPos.deletedAfter;
315
+ // for editor controls, remap the rootPos as well
316
+ let mappedRootPos;
317
+ if (activeNode.rootPos !== undefined) {
318
+ mappedRootPos = tr.mapping.mapResult(activeNode.rootPos, -1);
319
+ }
320
+ let mappedNodeType = activeNode.nodeType;
321
+ let mappedRootNodeType = activeNode.rootNodeType;
322
+ // Sparse mode does not redraw the old decorations. A block-type transaction may report
323
+ // a text range that excludes the active block position, so always refresh the already
324
+ // active node and root from the new document (for example, paragraph → heading-1).
325
+ if (isExperimentEnabled('platform_editor_block_control_migration')) {
326
+ const mappedNode = newState.doc.nodeAt(mappedPos.pos);
327
+ if (mappedNode !== null && mappedNode !== void 0 && mappedNode.isBlock) {
328
+ mappedNodeType = getNodeTypeWithLevel(mappedNode);
326
329
  }
327
- // for editor controls, remap the rootPos as well
328
- let mappedRootPos;
329
- if (activeNode.rootPos !== undefined) {
330
- mappedRootPos = tr.mapping.mapResult(activeNode.rootPos, -1);
330
+ const mappedRootNode = mappedRootPos ? mappedRootPos.pos === mappedPos.pos && mappedNode ? mappedNode : newState.doc.nodeAt(mappedRootPos.pos) : undefined;
331
+ if (mappedRootNode !== null && mappedRootNode !== void 0 && mappedRootNode.isBlock) {
332
+ mappedRootNodeType = getNodeTypeWithLevel(mappedRootNode);
331
333
  }
332
- let mappedNodeType = activeNode.nodeType;
333
- let mappedRootNodeType = activeNode.rootNodeType;
334
- // Sparse mode does not redraw the old decorations. A block-type transaction may report
335
- // a text range that excludes the active block position, so always refresh the already
336
- // active node and root from the new document (for example, paragraph → heading-1).
337
- if (isExperimentEnabled('platform_editor_block_control_migration')) {
338
- const mappedNode = newState.doc.nodeAt(mappedPos.pos);
339
- if (mappedNode !== null && mappedNode !== void 0 && mappedNode.isBlock) {
340
- mappedNodeType = getNodeTypeWithLevel(mappedNode);
341
- }
342
- const mappedRootNode = mappedRootPos ? mappedRootPos.pos === mappedPos.pos && mappedNode ? mappedNode : newState.doc.nodeAt(mappedRootPos.pos) : undefined;
343
- if (mappedRootNode !== null && mappedRootNode !== void 0 && mappedRootNode.isBlock) {
344
- mappedRootNodeType = getNodeTypeWithLevel(mappedRootNode);
345
- }
346
- }
347
- activeNode = {
348
- pos: mappedPos.pos,
349
- anchorName: activeNode.anchorName,
350
- nodeType: mappedNodeType,
351
- rootPos: (_mappedRootPos$pos = (_mappedRootPos = mappedRootPos) === null || _mappedRootPos === void 0 ? void 0 : _mappedRootPos.pos) !== null && _mappedRootPos$pos !== void 0 ? _mappedRootPos$pos : activeNode.rootPos,
352
- rootAnchorName: activeNode.rootAnchorName,
353
- rootNodeType: mappedRootNodeType
354
- };
355
334
  }
335
+ activeNode = {
336
+ pos: mappedPos.pos,
337
+ anchorName: activeNode.anchorName,
338
+ nodeType: mappedNodeType,
339
+ rootPos: (_mappedRootPos$pos = (_mappedRootPos = mappedRootPos) === null || _mappedRootPos === void 0 ? void 0 : _mappedRootPos.pos) !== null && _mappedRootPos$pos !== void 0 ? _mappedRootPos$pos : activeNode.rootPos,
340
+ rootAnchorName: activeNode.rootAnchorName,
341
+ rootNodeType: mappedRootNodeType
342
+ };
356
343
  }
357
344
  if (multiSelectDnD) {
358
345
  multiSelectDnD.anchor = tr.mapping.map(multiSelectDnD.anchor);
@@ -395,41 +382,21 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
395
382
  decorations = decorations.add(newState.doc, newNodeDecs);
396
383
 
397
384
  // enables quick insert
398
- if (!flags.toolbarFlagsEnabled) {
399
- if (latestActiveNode && !isActiveNodeDeleted) {
400
- // Find the newly minted node decs that touch the active node
401
- const findNewNodeDecs = findNodeDecs(newState, decorations, latestActiveNode.pos - 1, to);
402
-
403
- // Find the specific dec that the active node corresponds to
404
- const nodeDecsAtActivePos = findNewNodeDecs.filter(dec => (dec === null || dec === void 0 ? void 0 : dec.from) === latestActiveNode.pos);
405
-
406
- // If multiple decorations at the active node pos, we want the last one
407
- const nodeDecAtActivePos = nodeDecsAtActivePos.pop();
408
-
409
- // Update the active node anchor-name and type for accurate positioning
410
- if (nodeDecAtActivePos) {
411
- isActiveNodeModified = true;
412
- latestActiveNode.anchorName = nodeDecAtActivePos.spec.anchorName;
413
- latestActiveNode.nodeType = nodeDecAtActivePos.spec.nodeType;
414
- }
385
+ if (latestActiveNode && (!isActiveNodeDeleted || isReplacedWithSameSize)) {
386
+ const nodeDecAtActivePos = getDecorationAtPos(newState, decorations, latestActiveNode.pos, to);
387
+ const rootNodeDecAtActivePos = latestActiveNode.rootPos !== undefined ? getDecorationAtPos(newState, decorations, latestActiveNode.rootPos, to) : undefined;
388
+ if (nodeDecAtActivePos || rootNodeDecAtActivePos) {
389
+ isActiveNodeModified = true;
415
390
  }
416
- } else {
417
- if (latestActiveNode && (!isActiveNodeDeleted || isReplacedWithSameSize)) {
418
- const nodeDecAtActivePos = getDecorationAtPos(newState, decorations, latestActiveNode.pos, to);
419
- const rootNodeDecAtActivePos = latestActiveNode.rootPos !== undefined ? getDecorationAtPos(newState, decorations, latestActiveNode.rootPos, to) : undefined;
420
- if (nodeDecAtActivePos || rootNodeDecAtActivePos) {
421
- isActiveNodeModified = true;
422
- }
423
391
 
424
- // Update the active node anchor-name and type for accurate positioning
425
- if (nodeDecAtActivePos) {
426
- latestActiveNode.anchorName = nodeDecAtActivePos.spec.anchorName;
427
- latestActiveNode.nodeType = nodeDecAtActivePos.spec.nodeType;
428
- }
429
- if (rootNodeDecAtActivePos) {
430
- latestActiveNode.rootAnchorName = rootNodeDecAtActivePos.spec.anchorName;
431
- latestActiveNode.rootNodeType = rootNodeDecAtActivePos.spec.nodeType;
432
- }
392
+ // Update the active node anchor-name and type for accurate positioning
393
+ if (nodeDecAtActivePos) {
394
+ latestActiveNode.anchorName = nodeDecAtActivePos.spec.anchorName;
395
+ latestActiveNode.nodeType = nodeDecAtActivePos.spec.nodeType;
396
+ }
397
+ if (rootNodeDecAtActivePos) {
398
+ latestActiveNode.rootAnchorName = rootNodeDecAtActivePos.spec.anchorName;
399
+ latestActiveNode.rootNodeType = rootNodeDecAtActivePos.spec.nodeType;
433
400
  }
434
401
  }
435
402
  }
@@ -452,10 +419,8 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
452
419
  let shouldRemoveHandle = latestActiveNode ? isResizerResizing || isActiveNodeDeleted && !isReplacedWithSameSize || (meta === null || meta === void 0 ? void 0 : meta.nodeMoved) : true;
453
420
 
454
421
  // enables quick insert
455
- if (flags.toolbarFlagsEnabled) {
456
- // Remove handle dec when editor is blurred
457
- shouldRemoveHandle = shouldRemoveHandle || (meta === null || meta === void 0 ? void 0 : meta.editorBlurred);
458
- }
422
+ // Remove handle dec when editor is blurred
423
+ shouldRemoveHandle = shouldRemoveHandle || (meta === null || meta === void 0 ? void 0 : meta.editorBlurred);
459
424
 
460
425
  // In view mode with right-side controls, remove any lingering drag handle decorations
461
426
  // (they may carry over from edit mode). Only remove drag handles specifically, not
@@ -488,25 +453,23 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
488
453
  // nodeDecorationRegistry cleanup (e.g. the legacy Remix button) is independent of the legacy
489
454
  // quick-insert button, so this must not be gated by quickInsertButtonEnabled — otherwise a
490
455
  // stale decoration is left behind whenever platform_editor_block_control_migration is on.
491
- if (flags.toolbarFlagsEnabled) {
492
- // enables quick insert
493
- if (quickInsertButtonEnabled) {
494
- var _activeNode7, _activeNode8;
495
- const oldQuickInsertButton = findQuickInsertInsertButtonDecoration(decorations, (_activeNode7 = activeNode) === null || _activeNode7 === void 0 ? void 0 : _activeNode7.rootPos, (_activeNode8 = activeNode) === null || _activeNode8 === void 0 ? void 0 : _activeNode8.rootPos);
496
- decorations = decorations.remove(oldQuickInsertButton);
497
- }
456
+ // enables quick insert
457
+ if (quickInsertButtonEnabled) {
458
+ var _activeNode7, _activeNode8;
459
+ const oldQuickInsertButton = findQuickInsertInsertButtonDecoration(decorations, (_activeNode7 = activeNode) === null || _activeNode7 === void 0 ? void 0 : _activeNode7.rootPos, (_activeNode8 = activeNode) === null || _activeNode8 === void 0 ? void 0 : _activeNode8.rootPos);
460
+ decorations = decorations.remove(oldQuickInsertButton);
461
+ }
462
+ for (const factory of nodeDecorationRegistry) {
463
+ var _activeNode9, _activeNode0;
464
+ const old = decorations.find((_activeNode9 = activeNode) === null || _activeNode9 === void 0 ? void 0 : _activeNode9.rootPos, (_activeNode0 = activeNode) === null || _activeNode0 === void 0 ? void 0 : _activeNode0.rootPos, spec => spec.type === factory.type);
465
+ decorations = decorations.remove(old);
466
+ }
467
+ if (rightSideControlsEnabled && isViewMode) {
498
468
  for (const factory of nodeDecorationRegistry) {
499
- var _activeNode9, _activeNode0;
500
- const old = decorations.find((_activeNode9 = activeNode) === null || _activeNode9 === void 0 ? void 0 : _activeNode9.rootPos, (_activeNode0 = activeNode) === null || _activeNode0 === void 0 ? void 0 : _activeNode0.rootPos, spec => spec.type === factory.type);
501
- decorations = decorations.remove(old);
502
- }
503
- if (rightSideControlsEnabled && isViewMode) {
504
- for (const factory of nodeDecorationRegistry) {
505
- if (factory.showInViewMode) {
506
- var _activeNode1, _activeNode10;
507
- const old = decorations.find((_activeNode1 = activeNode) === null || _activeNode1 === void 0 ? void 0 : _activeNode1.rootPos, (_activeNode10 = activeNode) === null || _activeNode10 === void 0 ? void 0 : _activeNode10.rootPos, spec => spec.type === factory.type);
508
- decorations = decorations.remove(old);
509
- }
469
+ if (factory.showInViewMode) {
470
+ var _activeNode1, _activeNode10;
471
+ const old = decorations.find((_activeNode1 = activeNode) === null || _activeNode1 === void 0 ? void 0 : _activeNode1.rootPos, (_activeNode10 = activeNode) === null || _activeNode10 === void 0 ? void 0 : _activeNode10.rootPos, spec => spec.type === factory.type);
472
+ decorations = decorations.remove(old);
510
473
  }
511
474
  }
512
475
  }
@@ -585,9 +548,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
585
548
  }
586
549
  }
587
550
  }
588
- if (shouldRecreateQuickInsertButton && ((_latestActiveNode5 = latestActiveNode) === null || _latestActiveNode5 === void 0 ? void 0 : _latestActiveNode5.rootPos) !== undefined && (quickInsertButtonEnabled || nodeDecorationRegistry.length > 0) &&
589
- // enables quick insert
590
- flags.toolbarFlagsEnabled && (!rightSideControlsEnabled || !isViewMode)) {
551
+ if (shouldRecreateQuickInsertButton && ((_latestActiveNode5 = latestActiveNode) === null || _latestActiveNode5 === void 0 ? void 0 : _latestActiveNode5.rootPos) !== undefined && (quickInsertButtonEnabled || nodeDecorationRegistry.length > 0) && (!rightSideControlsEnabled || !isViewMode)) {
591
552
  var _latestActiveNode1;
592
553
  if (quickInsertButtonEnabled) {
593
554
  var _activeNode13, _activeNode14, _latestActiveNode6, _latestActiveNode7, _latestActiveNode8, _latestActiveNode9, _latestActiveNode0;
@@ -663,7 +624,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
663
624
  const rootPos = (_latestActiveNode10 = latestActiveNode) === null || _latestActiveNode10 === void 0 ? void 0 : _latestActiveNode10.rootPos;
664
625
  // 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.
665
626
  const isDocLevel = rootPos !== undefined && !isNaN(rootPos);
666
- if (isViewMode && isDocLevel && flags.toolbarFlagsEnabled && rightSideControlsEnabled) {
627
+ if (isViewMode && isDocLevel && rightSideControlsEnabled) {
667
628
  for (const factory of nodeDecorationRegistry) {
668
629
  if (factory.showInViewMode) {
669
630
  if (!latestActiveNode || latestActiveNode.rootPos === undefined) {
@@ -744,21 +705,15 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
744
705
  decorations = decorations.add(newState.doc, [emptyParagraphNodeDecorations()]);
745
706
  }
746
707
  }
747
- let newActiveNode;
708
+
748
709
  // enables quick insert
749
- if (flags.toolbarFlagsEnabled) {
750
- var _latestActiveNode11, _latestActiveNode12;
751
- // remove isEmptyDoc check and let decorations render and determine their own visibility
752
- // In view mode with right-side controls we render node decorations (right-edge button), not the
753
- // handle - so findHandleDec is always empty. Don't clear activeNode in that case.
754
- const hasHandleOrViewModeControls = isExperimentEnabled('platform_editor_block_control_migration') || isViewMode && rightSideControlsEnabled || findHandleDec(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length > 0;
755
- // Keep the registry surface mounted while its Block Menu owns focus.
756
- const keepActiveNodeForOpenBlockMenu = isExperimentEnabled('platform_editor_block_control_migration') && isMenuOpen;
757
- newActiveNode = meta !== null && meta !== void 0 && meta.editorBlurred && !keepActiveNodeForOpenBlockMenu || !(meta !== null && meta !== void 0 && meta.activeNode) && !hasHandleOrViewModeControls ? null : latestActiveNode;
758
- } else {
759
- var _latestActiveNode13, _latestActiveNode14;
760
- newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && !isExperimentEnabled('platform_editor_block_control_migration') && 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;
761
- }
710
+ // remove isEmptyDoc check and let decorations render and determine their own visibility
711
+ // In view mode with right-side controls we render node decorations (right-edge button), not the
712
+ // handle - so findHandleDec is always empty. Don't clear activeNode in that case.
713
+ const hasHandleOrViewModeControls = isExperimentEnabled('platform_editor_block_control_migration') || isViewMode && rightSideControlsEnabled || findHandleDec(decorations, (_latestActiveNode11 = latestActiveNode) === null || _latestActiveNode11 === void 0 ? void 0 : _latestActiveNode11.pos, (_latestActiveNode12 = latestActiveNode) === null || _latestActiveNode12 === void 0 ? void 0 : _latestActiveNode12.pos).length > 0;
714
+ // Keep the registry surface mounted while its Block Menu owns focus.
715
+ const keepActiveNodeForOpenBlockMenu = isExperimentEnabled('platform_editor_block_control_migration') && isMenuOpen;
716
+ const newActiveNode = meta !== null && meta !== void 0 && meta.editorBlurred && !keepActiveNodeForOpenBlockMenu || !(meta !== null && meta !== void 0 && meta.activeNode) && !hasHandleOrViewModeControls ? null : latestActiveNode;
762
717
  let nextMenuTriggerByNode = (meta === null || meta === void 0 ? void 0 : (_meta$toggleMenu = meta.toggleMenu) === null || _meta$toggleMenu === void 0 ? void 0 : _meta$toggleMenu.triggerByNode) || menuTriggerByNode;
763
718
  if (isExperimentEnabled('platform_editor_block_control_migration') && tr.docChanged && menuTriggerByNode && !(meta !== null && meta !== void 0 && meta.toggleMenu)) {
764
719
  var _menuTriggerByNode$ro, _newState$doc$nodeAt4;
@@ -781,11 +736,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
781
736
  const isSameAnchor = (meta === null || meta === void 0 ? void 0 : meta.toggleMenu.anchorName) === menuTriggerBy;
782
737
  isMenuOpen = menuTriggerBy === undefined || isSameAnchor || !isMenuOpen && !isSameAnchor ? !isMenuOpen : isMenuOpen;
783
738
  }
784
- if (flags.toolbarFlagsEnabled) {
785
- isSelectedViaDragHandle = (meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle) !== undefined ? meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle : isSelectedViaDragHandle;
786
- } else {
787
- isSelectedViaDragHandle = false;
788
- }
739
+ isSelectedViaDragHandle = (meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle) !== undefined ? meta === null || meta === void 0 ? void 0 : meta.isSelectedViaDragHandle : isSelectedViaDragHandle;
789
740
  return {
790
741
  decorations,
791
742
  surfaceNodePositions,
@@ -818,10 +769,6 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
818
769
  const isAdvancedLayoutEnabled = editorExperiment('advanced_layouts', true, {
819
770
  exposure: true
820
771
  });
821
- const toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
822
- const flags = {
823
- toolbarFlagsEnabled
824
- };
825
772
  let anchorRectCache;
826
773
  if (!isAnchorSupported()) {
827
774
  anchorRectCache = new AnchorRectCache();
@@ -869,7 +816,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
869
816
  init: () => ({
870
817
  ...initialState
871
818
  }),
872
- apply: (tr, currentState, _, newState) => apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, limitedModeTeardown)
819
+ apply: (tr, currentState, _, newState) => apply(api, formatMessage, tr, currentState, newState, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, limitedModeTeardown)
873
820
  },
874
821
  props: {
875
822
  decorations: state => {
@@ -1,7 +1,6 @@
1
1
  import { getNodeSelectionForPos, selectNodeAtPos } from '@atlaskit/editor-common/node-selection';
2
2
  import { Side } from '@atlaskit/editor-common/selection';
3
3
  import { GapCursorSelection } from '@atlaskit/editor-common/selection/gap-cursor/selection';
4
- import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
5
4
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
5
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
6
  import { selectTableClosestToPos } from '@atlaskit/editor-tables/select-table-closest-to-pos';
@@ -68,7 +67,7 @@ export const selectNode = (tr, start, nodeType, api) => {
68
67
  }
69
68
  return tr;
70
69
  };
71
- export const setCursorPositionAtMovedNode = (tr, start, api) => {
70
+ export const setCursorPositionAtMovedNode = (tr, start) => {
72
71
  const node = tr.doc.nodeAt(start);
73
72
  const isNodeSelection = node && NodeSelection.isSelectable(node);
74
73
  const nodeSize = node ? node.nodeSize : 1;
@@ -82,7 +81,7 @@ export const setCursorPositionAtMovedNode = (tr, start, api) => {
82
81
  }
83
82
 
84
83
  // this is a fix for empty paragraph selection - can safely use start position as the paragraph is empty
85
- if ((node === null || node === void 0 ? void 0 : node.type.name) === 'paragraph' && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar))) {
84
+ if ((node === null || node === void 0 ? void 0 : node.type.name) === 'paragraph' && (node === null || node === void 0 ? void 0 : node.childCount) === 0) {
86
85
  const selection = new TextSelection(tr.doc.resolve(start));
87
86
  tr.setSelection(selection);
88
87
  return tr;
@@ -45,7 +45,7 @@ const isStepContentReplacedWithAnotherOfSameSize = s => {
45
45
  * Number of ReplaceStep and ReplaceAroundStep steps 'numReplaceSteps'.
46
46
  * 'isAllText' if all steps are represent adding inline text or a backspace/delete or no-op
47
47
  */
48
- export const getTrMetadata = (tr, flags) => {
48
+ export const getTrMetadata = tr => {
49
49
  let from;
50
50
  let to;
51
51
  let numReplaceSteps = 0;
@@ -57,10 +57,7 @@ export const getTrMetadata = (tr, flags) => {
57
57
  isAllText = false;
58
58
  }
59
59
  // Fixes drag handle and quick insert button overlap issues
60
- if (flags.toolbarFlagsEnabled) {
61
- // fixes drag handle and quick insert button overlap issues
62
- isReplacedWithSameSize = isStepContentReplacedWithAnotherOfSameSize(s);
63
- }
60
+ isReplacedWithSameSize = isStepContentReplacedWithAnotherOfSameSize(s);
64
61
  const mappedTo = tr.mapping.map(s.to);
65
62
  let $to = s.from + s.slice.size;
66
63
  $to = $to > mappedTo ? $to : mappedTo;