@atlaskit/editor-plugin-block-controls 11.1.1 → 11.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 11.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4642f37c59f0f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4642f37c59f0f) -
8
+ Fix Remix button not appearing when hovering over tables in live page view mode. When the
9
+ `platform_editor_native_anchor_with_dnd` experiment is disabled, table rows only have
10
+ `data-node-anchor` (not `data-drag-handler-anchor-name`), so hover detection and anchor resolution
11
+ now fall back to `data-node-anchor`. Also fixes right-edge positioning for wide/max breakout
12
+ tables using `getBoundingClientRect`.
13
+ - Updated dependencies
14
+
15
+ ## 11.2.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [`64134fd6d8fee`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/64134fd6d8fee) -
20
+ clean up platform_editor_block_control_optimise_render
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies
25
+
3
26
  ## 11.1.1
4
27
 
5
28
  ### Patch Changes
@@ -50,16 +50,6 @@ var shouldIgnoreNode = function shouldIgnoreNode(node, ignore_nodes, depth, pare
50
50
  exposure: true
51
51
  }) ? true : ignore_nodes.includes(node.type.name);
52
52
  };
53
- var getPositionBeforeNodeAtPos = function getPositionBeforeNodeAtPos(state, pos) {
54
- if (pos <= 0 || pos >= state.doc.nodeSize - 2) {
55
- return pos;
56
- }
57
- var $pos = state.doc.resolve(pos);
58
- if ($pos.depth > 0) {
59
- return $pos.before();
60
- }
61
- return pos;
62
- };
63
53
 
64
54
  /**
65
55
  * Find node decorations corresponding to nodes with starting position between from and to (non-inclusive)
@@ -69,43 +59,25 @@ var getPositionBeforeNodeAtPos = function getPositionBeforeNodeAtPos(state, pos)
69
59
  */
70
60
  var findNodeDecs = exports.findNodeDecs = function findNodeDecs(state, decorations, from, to) {
71
61
  var newFrom = from;
72
- if ((0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true)) {
73
- // return empty array if range reversed
74
- if (typeof to === 'number' && typeof newFrom === 'number' && newFrom > to) {
75
- return [];
76
- }
77
- var decs = decorations.find(newFrom, to, function (spec) {
78
- return spec.type === _decorationsCommon.TYPE_NODE_DEC;
79
- });
62
+ var newTo = to;
80
63
 
81
- // Prosemirror finds any decorations that overlap with the provided position range, but we don't want to include decorations of nodes that start outside of the range
82
- if (typeof to === 'number' && typeof newFrom === 'number') {
83
- decs = decs.filter(function (dec) {
84
- return dec.from >= (newFrom || 0) && dec.from < to;
85
- });
86
- }
87
- return decs;
88
- } else {
89
- var newTo = to;
90
-
91
- // make it non-inclusive
92
- if (newFrom !== undefined) {
93
- newFrom++;
94
- }
64
+ // make it non-inclusive
65
+ if (newFrom !== undefined) {
66
+ newFrom++;
67
+ }
95
68
 
96
- // make it non-inclusive
97
- if (newTo !== undefined) {
98
- newTo--;
99
- }
69
+ // make it non-inclusive
70
+ if (newTo !== undefined) {
71
+ newTo--;
72
+ }
100
73
 
101
- // return empty array if range reversed
102
- if (newFrom !== undefined && newTo !== undefined && newFrom > newTo) {
103
- return [];
104
- }
105
- return decorations.find(newFrom, newTo, function (spec) {
106
- return spec.type === _decorationsCommon.TYPE_NODE_DEC;
107
- });
74
+ // return empty array if range reversed
75
+ if (newFrom !== undefined && newTo !== undefined && newFrom > newTo) {
76
+ return [];
108
77
  }
78
+ return decorations.find(newFrom, newTo, function (spec) {
79
+ return spec.type === _decorationsCommon.TYPE_NODE_DEC;
80
+ });
109
81
  };
110
82
  var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newState, from, to) {
111
83
  var decs = [];
@@ -120,12 +92,6 @@ var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newStat
120
92
  var shouldDescend = shouldDescendIntoNode(node);
121
93
  var anchorName = (0, _decorationsCommon.getNodeAnchor)(node);
122
94
  var nodeTypeWithLevel = (0, _decorationsCommon.getNodeTypeWithLevel)(node);
123
- if ((0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true)) {
124
- // We don't want to create decorations for nodes that start outside of the provided position range
125
- if (pos < getPositionBeforeNodeAtPos(newState, docFrom)) {
126
- return shouldDescend;
127
- }
128
- }
129
95
 
130
96
  // Doesn't descend into a node
131
97
  if (node.isInline) {
@@ -43,11 +43,7 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
43
43
  handleOptions = _ref.handleOptions,
44
44
  anchorRectCache = _ref.anchorRectCache,
45
45
  editorState = _ref.editorState;
46
- if (!(0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true, {
47
- exposure: true
48
- })) {
49
- (0, _decorationsCommon.unmountDecorations)(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
50
- }
46
+ (0, _decorationsCommon.unmountDecorations)(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
51
47
  var unbind;
52
48
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
53
49
  var key = (0, _uuid.default)();
@@ -64,9 +60,6 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
64
60
  marks: (0, _expValEquals.expValEquals)('platform_editor_clean_up_widget_mark_logic', 'isEnabled', true) ? [] : (0, _marks.getActiveBlockMarks)(editorState, pos),
65
61
  destroy: function destroy(node) {
66
62
  unbind && unbind();
67
- if ((0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) && node instanceof HTMLElement) {
68
- _reactDom.default.unmountComponentAtNode(node);
69
- }
70
63
  }
71
64
  } : {
72
65
  side: -1,
@@ -76,9 +69,6 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
76
69
  marks: (0, _expValEquals.expValEquals)('platform_editor_clean_up_widget_mark_logic', 'isEnabled', true) ? [] : (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? (0, _marks.getActiveBlockMarks)(editorState, pos) : undefined,
77
70
  destroy: function destroy(node) {
78
71
  unbind && unbind();
79
- if ((0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) && node instanceof HTMLElement) {
80
- _reactDom.default.unmountComponentAtNode(node);
81
- }
82
72
  }
83
73
  };
84
74
  return _view.Decoration.widget(pos, function (view, getPosUnsafe) {
@@ -13,7 +13,6 @@ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
13
13
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
14
14
  var _quickInsertButton = require("../ui/quick-insert-button");
15
15
  var _marks = require("./utils/marks");
16
- var _vanillaQuickInsert = require("./vanilla-quick-insert");
17
16
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
18
17
 
19
18
  var TYPE_QUICK_INSERT = 'INSERT_BUTTON';
@@ -79,23 +78,6 @@ var quickInsertButtonDecoration = exports.quickInsertButtonDecoration = function
79
78
  element.setAttribute('data-blocks-quick-insert-button', 'true');
80
79
  }
81
80
  element.setAttribute('data-testid', 'block-ctrl-quick-insert-button');
82
- if ((0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true, {
83
- exposure: true
84
- })) {
85
- var vanillaElement = (0, _vanillaQuickInsert.createVanillaButton)({
86
- formatMessage: formatMessage,
87
- api: api,
88
- view: view,
89
- getPos: getPos,
90
- cleanupCallbacks: cleanupCallbacks,
91
- rootAnchorName: rootAnchorName !== null && rootAnchorName !== void 0 ? rootAnchorName : nodeType,
92
- anchorName: anchorName,
93
- rootNodeType: rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType,
94
- anchorRectCache: anchorRectCache
95
- });
96
- element.appendChild(vanillaElement);
97
- return element;
98
- }
99
81
  nodeViewPortalProviderAPI.render(function () {
100
82
  return /*#__PURE__*/(0, _react.createElement)(_quickInsertButton.QuickInsertWithVisibility, {
101
83
  api: api,
@@ -99,6 +99,19 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
99
99
  }
100
100
  var rootElement = target === null || target === void 0 ? void 0 : target.closest(isNativeAnchorSupported ? getDefaultNodeSelector() : "[data-drag-handler-anchor-name]");
101
101
 
102
+ // Fallback for table nodes in view mode: the table-anchor-names plugin sets data-node-anchor on
103
+ // the first <tr> element.
104
+ // - When platform_editor_native_anchor_with_dnd is disabled, the primary closest() uses
105
+ // [data-drag-handler-anchor-name] and misses table rows. Try data-node-anchor via closest().
106
+ // - For wide/max breakout tables, hovering in the left/right margin area of the full-viewport-
107
+ // width breakout wrapper (ak-editor-breakout-mark) sets event.target to the wrapper div, which
108
+ // has no anchor attribute. Use querySelector to find the [data-node-anchor] descendant inside.
109
+ // Both cases apply only in view mode with right-side remix controls.
110
+ if (!rootElement && isViewMode && rightSideControlsEnabled) {
111
+ var _ref3, _target$closest;
112
+ rootElement = (_ref3 = (_target$closest = target === null || target === void 0 ? void 0 : target.closest("[".concat(_domAttrName.NODE_ANCHOR_ATTR_NAME, "]"))) !== null && _target$closest !== void 0 ? _target$closest : target instanceof HTMLElement ? target.querySelector("[".concat(_domAttrName.NODE_ANCHOR_ATTR_NAME, "]")) : null) !== null && _ref3 !== void 0 ? _ref3 : null;
113
+ }
114
+
102
115
  // When hovering over the right-edge button (rendered in a portal outside the block), resolve the
103
116
  // block from the container's anchor so activeNode stays set and the button remains visible.
104
117
  if (!rootElement && rightSideControlsEnabled && (0, _platformFeatureFlags.fg)('confluence_remix_button_right_side_block_fg')) {
@@ -111,7 +124,7 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
111
124
  }
112
125
  }
113
126
  if (rootElement) {
114
- var _rootElement$parentEl;
127
+ var _rootElement$parentEl, _rootElement$getAttri2;
115
128
  // We want to exlude handles from showing for empty paragraph and heading nodes
116
129
  if (isEmptyNestedParagraphOrHeading(rootElement)) {
117
130
  return false;
@@ -184,6 +197,11 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
184
197
  // Ignored via go/ees005
185
198
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
186
199
  anchorName = rootElement.getAttribute((0, _domAttrName.getAnchorAttrName)());
200
+ // Fallback for table nodes that only have data-node-anchor (not data-drag-handler-anchor-name).
201
+ if (!anchorName) {
202
+ var _rootElement$getAttri;
203
+ anchorName = (_rootElement$getAttri = rootElement.getAttribute(_domAttrName.NODE_ANCHOR_ATTR_NAME)) !== null && _rootElement$getAttri !== void 0 ? _rootElement$getAttri : anchorName;
204
+ }
187
205
  }
188
206
 
189
207
  // No need to update handle position if its already there
@@ -231,13 +249,16 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
231
249
  if (targetPos !== rootPos) {
232
250
  var rootDOM = view.nodeDOM(rootPos);
233
251
  if (rootDOM instanceof HTMLElement) {
234
- var _rootDOM$getAttribute;
235
- rootAnchorName = (_rootDOM$getAttribute = rootDOM.getAttribute((0, _domAttrName.getAnchorAttrName)())) !== null && _rootDOM$getAttribute !== void 0 ? _rootDOM$getAttribute : undefined;
236
- rootNodeType = isNativeAnchorSupported ? (0, _domAttrName.getTypeNameFromDom)(rootDOM) : rootDOM.getAttribute('data-drag-handler-node-type');
252
+ var _ref4, _rootDOM$getAttribute, _rootDOM$getAttribute2;
253
+ 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;
254
+ rootNodeType = isNativeAnchorSupported ? (0, _domAttrName.getTypeNameFromDom)(rootDOM) : // Fallback: breakout mark wrappers have no data-drag-handler-node-type;
255
+ // use data-prosemirror-node-name instead.
256
+ (_rootDOM$getAttribute2 = rootDOM.getAttribute('data-drag-handler-node-type')) !== null && _rootDOM$getAttribute2 !== void 0 ? _rootDOM$getAttribute2 : (0, _domAttrName.getTypeNameFromDom)(rootDOM);
237
257
  }
238
258
  }
239
259
  }
240
- var nodeType = isNativeAnchorSupported ? (0, _domAttrName.getTypeNameFromDom)(rootElement) : rootElement.getAttribute('data-drag-handler-node-type');
260
+ var nodeType = isNativeAnchorSupported ? (0, _domAttrName.getTypeNameFromDom)(rootElement) : // Fallback for table nodes: tr has data-prosemirror-node-name but not data-drag-handler-node-type.
261
+ (_rootElement$getAttri2 = rootElement.getAttribute('data-drag-handler-node-type')) !== null && _rootElement$getAttri2 !== void 0 ? _rootElement$getAttri2 : (0, _domAttrName.getTypeNameFromDom)(rootElement);
241
262
  if (nodeType) {
242
263
  // platform_editor_controls note: enables quick insert
243
264
  if (toolbarFlagsEnabled) {
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.key = exports.getDecorations = exports.getBlockControlsMeta = exports.createPlugin = exports.apply = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
10
+ var _browserApis = require("@atlaskit/browser-apis");
10
11
  var _analytics = require("@atlaskit/editor-common/analytics");
11
12
  var _browser = require("@atlaskit/editor-common/browser");
12
13
  var _nodeAnchor = require("@atlaskit/editor-common/node-anchor");
@@ -56,7 +57,8 @@ var isHTMLElement = function isHTMLElement(element) {
56
57
  return element instanceof HTMLElement;
57
58
  };
58
59
  var destroyFn = function destroyFn(api, editorView) {
59
- var scrollable = document.querySelector('.fabric-editor-popup-scroll-parent');
60
+ var _getDocument$querySel, _getDocument;
61
+ var scrollable = (_getDocument$querySel = (_getDocument = (0, _browserApis.getDocument)()) === null || _getDocument === void 0 ? void 0 : _getDocument.querySelector('.fabric-editor-popup-scroll-parent')) !== null && _getDocument$querySel !== void 0 ? _getDocument$querySel : null;
60
62
  var cleanupFn = [];
61
63
  if (scrollable) {
62
64
  cleanupFn.push((0, _element.autoScrollForElements)({
@@ -231,7 +233,7 @@ var getDecorations = exports.getDecorations = function getDecorations(state) {
231
233
  };
232
234
  var getDecorationAtPos = function getDecorationAtPos(state, decorations, pos, to) {
233
235
  // Find the newly minted node decs that touch the active node
234
- var findNewNodeDecs = (0, _decorationsAnchor.findNodeDecs)(state, decorations, (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? pos : pos - 1, to);
236
+ var findNewNodeDecs = (0, _decorationsAnchor.findNodeDecs)(state, decorations, pos - 1, to);
235
237
 
236
238
  // Find the specific dec that the active node corresponds to
237
239
  var nodeDecsAtActivePos = findNewNodeDecs.filter(function (dec) {
@@ -275,10 +277,11 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
275
277
  var meta = tr.getMeta(key);
276
278
  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;
277
279
  if (hasDocumentSizeBreachedThreshold) {
280
+ var _getDocument$querySel2, _getDocument2;
278
281
  /**
279
282
  * 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().
280
283
  */
281
- var editorContentArea = document.querySelector('.fabric-editor-popup-scroll-parent');
284
+ var editorContentArea = (_getDocument$querySel2 = (_getDocument2 = (0, _browserApis.getDocument)()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.querySelector('.fabric-editor-popup-scroll-parent')) !== null && _getDocument$querySel2 !== void 0 ? _getDocument$querySel2 : null;
282
285
  if (editorContentArea && resizeObserverWidth) {
283
286
  resizeObserverWidth.unobserve(editorContentArea);
284
287
  }
@@ -378,7 +381,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
378
381
  if (!flags.toolbarFlagsEnabled) {
379
382
  if (latestActiveNode && !isActiveNodeDeleted) {
380
383
  // Find the newly minted node decs that touch the active node
381
- var findNewNodeDecs = (0, _decorationsAnchor.findNodeDecs)(newState, decorations, (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? latestActiveNode.pos : latestActiveNode.pos - 1, to);
384
+ var findNewNodeDecs = (0, _decorationsAnchor.findNodeDecs)(newState, decorations, latestActiveNode.pos - 1, to);
382
385
 
383
386
  // Find the specific dec that the active node corresponds to
384
387
  var nodeDecsAtActivePos = findNewNodeDecs.filter(function (dec) {
@@ -441,6 +444,16 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
441
444
  // Remove handle dec when editor is blurred
442
445
  shouldRemoveHandle = shouldRemoveHandle || (meta === null || meta === void 0 ? void 0 : meta.editorBlurred);
443
446
  }
447
+
448
+ // In view mode with right-side controls, remove any lingering drag handle decorations
449
+ // (they may carry over from edit mode). Only remove drag handles specifically, not
450
+ // the remix button decorations (those are managed separately via showInViewMode).
451
+ if (isViewMode && rightSideControlsEnabled) {
452
+ var allHandleDecs = (0, _decorationsDragHandle.findHandleDec)(decorations, 0, newState.doc.content.size);
453
+ if (allHandleDecs.length > 0) {
454
+ decorations = decorations.remove(allHandleDecs);
455
+ }
456
+ }
444
457
  if (shouldRemoveHandle) {
445
458
  var _activeNode5, _activeNode6;
446
459
  var oldHandle = (0, _decorationsDragHandle.findHandleDec)(decorations, (_activeNode5 = activeNode) === null || _activeNode5 === void 0 ? void 0 : _activeNode5.pos, (_activeNode6 = activeNode) === null || _activeNode6 === void 0 ? void 0 : _activeNode6.pos);
@@ -808,7 +821,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
808
821
  },
809
822
  props: {
810
823
  decorations: function decorations(state) {
811
- var _api$limitedMode2, _api$editorDisabled, _key$getState2;
824
+ var _api$limitedMode2, _api$editorDisabled, _key$getState2, _api$editorViewMode3;
812
825
  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) {
813
826
  return;
814
827
  }
@@ -821,7 +834,16 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
821
834
  return;
822
835
  }
823
836
  }
824
- return (_key$getState2 = key.getState(state)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.decorations;
837
+ var decorationSet = (_key$getState2 = key.getState(state)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.decorations;
838
+ // In view mode with right-side controls, remove any lingering drag-handle decorations
839
+ // (created in edit mode) that may not have been cleaned up on mode switch.
840
+ if (decorationSet && rightSideControlsEnabled && (api === null || api === void 0 || (_api$editorViewMode3 = api.editorViewMode) === null || _api$editorViewMode3 === void 0 || (_api$editorViewMode3 = _api$editorViewMode3.sharedState.currentState()) === null || _api$editorViewMode3 === void 0 ? void 0 : _api$editorViewMode3.mode) === 'view') {
841
+ var handleDecs = (0, _decorationsDragHandle.findHandleDec)(decorationSet, 0, state.doc.content.size);
842
+ if (handleDecs.length > 0) {
843
+ decorationSet = decorationSet.remove(handleDecs);
844
+ }
845
+ }
846
+ return decorationSet;
825
847
  },
826
848
  handleDOMEvents: {
827
849
  drop: function drop(view, event) {
@@ -365,20 +365,16 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
365
365
  _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
366
366
  blockCardWidth = _useState6[0],
367
367
  setBlockCardWidth = _useState6[1];
368
- var _useState7 = (0, _react.useState)(false),
369
- _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
370
- recalculatePosition = _useState8[0],
371
- setRecalculatePosition = _useState8[1];
372
- var _useState9 = (0, _react.useState)({
368
+ var _useState7 = (0, _react.useState)({
373
369
  display: 'none'
374
370
  }),
371
+ _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
372
+ positionStylesOld = _useState8[0],
373
+ setPositionStylesOld = _useState8[1];
374
+ var _useState9 = (0, _react.useState)(Boolean(handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused)),
375
375
  _useState0 = (0, _slicedToArray2.default)(_useState9, 2),
376
- positionStylesOld = _useState0[0],
377
- setPositionStylesOld = _useState0[1];
378
- var _useState1 = (0, _react.useState)(Boolean(handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused)),
379
- _useState10 = (0, _slicedToArray2.default)(_useState1, 2),
380
- isFocused = _useState10[0],
381
- setIsFocused = _useState10[1];
376
+ isFocused = _useState0[0],
377
+ setIsFocused = _useState0[1];
382
378
  var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['featureFlags', 'selection', 'blockControls', 'interaction'], function (states) {
383
379
  var _states$featureFlagsS, _states$selectionStat, _states$blockControls, _states$interactionSt;
384
380
  return {
@@ -414,9 +410,6 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
414
410
  // just rely on the dynamic value (rename it to isTopLevelNode for simplicitiy)
415
411
  var isTopLevelNodeValue = (0, _expValEquals.expValEquals)('platform_editor_nested_drag_handle_icon', 'isEnabled', true) ? isTopLevelNodeDynamic : isTopLevelNode;
416
412
  (0, _react.useEffect)(function () {
417
- if ((0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true)) {
418
- return;
419
- }
420
413
  // blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
421
414
  if (nodeType === 'blockCard') {
422
415
  var dom = view.dom.querySelector("[".concat((0, _domAttrName.getAnchorAttrName)(), "=\"").concat(anchorName, "\"]"));
@@ -810,60 +803,6 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
810
803
  }
811
804
  });
812
805
  }, [anchorName, api, getPos, isMultiSelect, nodeType, start, view]);
813
- var positionStyles = (0, _react.useMemo)(function () {
814
- if (!(0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true)) {
815
- return {};
816
- }
817
-
818
- // This is a no-op to allow recalculatePosition to be used as a dependency
819
- if (recalculatePosition) {
820
- setRecalculatePosition(recalculatePosition);
821
- }
822
- var pos = getPos();
823
- var $pos = (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? typeof pos === 'number' && view.state.doc.resolve(pos) : pos && view.state.doc.resolve(pos);
824
- var parentPos = $pos && $pos.depth ? $pos.before() : undefined;
825
- var node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
826
- var parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
827
- var supportsAnchor = CSS.supports('top', "anchor(".concat(anchorName, " start)")) && CSS.supports('left', "anchor(".concat(anchorName, " start)"));
828
- var safeAnchorName = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _anchorName.refreshAnchorName)({
829
- getPos: getPos,
830
- view: view,
831
- anchorName: anchorName
832
- }) : anchorName;
833
- var dom = view.dom.querySelector("[".concat((0, _domAttrName.getAnchorAttrName)(), "=\"").concat(safeAnchorName, "\"]"));
834
- var hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
835
- var isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension' || nodeType === 'multiBodiedExtension';
836
- var isBlockCard = nodeType === 'blockCard';
837
- var isEmbedCard = nodeType === 'embedCard';
838
- var isMacroInteractionUpdates = macroInteractionUpdates && isExtension;
839
- var innerContainer = null;
840
- if (dom) {
841
- if (isEmbedCard) {
842
- innerContainer = dom.querySelector('.rich-media-item');
843
- } else if (hasResizer) {
844
- innerContainer = dom.querySelector('.resizer-item');
845
- } else if (isExtension) {
846
- innerContainer = dom.querySelector('.extension-container[data-layout]');
847
- } else if (isBlockCard) {
848
- //specific to datasource blockCard
849
- innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
850
- }
851
- }
852
- var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
853
- var isSticky = (0, _dragHandlePositions.shouldBeSticky)(nodeType);
854
- if (supportsAnchor) {
855
- var bottom = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _dragHandlePositions.getControlBottomCSSValue)(safeAnchorName, isSticky, isTopLevelNodeValue, isLayoutColumn) : {};
856
- return _objectSpread({
857
- left: isEdgeCase ? "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc((anchor(".concat(safeAnchorName, " right) + anchor(").concat(safeAnchorName, " left))/2 - ").concat(_consts2.DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(_styles.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts2.dragHandleGap)(nodeType, parentNodeType), "px)"),
858
- top: (0, _experiments.editorExperiment)('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(safeAnchorName, " top) - ").concat(_styles.DRAG_HANDLE_WIDTH, "px)") : "calc(anchor(".concat(safeAnchorName, " start) + ").concat((0, _consts2.topPositionAdjustment)((0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? $pos && $pos.nodeAfter && (0, _decorationsCommon.getNodeTypeWithLevel)($pos.nodeAfter) || nodeType : nodeType, (dom === null || dom === void 0 ? void 0 : dom.getAttribute('layout')) || ''), "px)")
859
- }, bottom);
860
- }
861
- var height = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _dragHandlePositions.getControlHeightCSSValue)((0, _dragHandlePositions.getNodeHeight)(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNodeValue, "".concat(_consts2.DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
862
- return _objectSpread({
863
- left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType),
864
- top: (0, _dragHandlePositions.getTopPosition)(dom, nodeType)
865
- }, height);
866
- }, [anchorName, getPos, view, nodeType, macroInteractionUpdates, anchorRectCache, isTopLevelNodeValue, isLayoutColumn, recalculatePosition]);
867
806
  var calculatePositionOld = (0, _react.useCallback)(function () {
868
807
  var pos = getPos();
869
808
  var $pos = (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? typeof pos === 'number' && view.state.doc.resolve(pos) : pos && view.state.doc.resolve(pos);
@@ -911,9 +850,6 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
911
850
  }, height);
912
851
  }, [anchorName, getPos, view, nodeType, blockCardWidth, macroInteractionUpdates, anchorRectCache, isTopLevelNodeValue, isLayoutColumn]);
913
852
  (0, _react.useEffect)(function () {
914
- if ((0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true)) {
915
- return;
916
- }
917
853
  var cleanUpTransitionListener;
918
854
  if (nodeType === 'extension' || nodeType === 'embedCard') {
919
855
  var dom = view.dom.querySelector("[".concat((0, _domAttrName.getAnchorAttrName)(), "=\"").concat(anchorName, "\"]"));
@@ -936,28 +872,6 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
936
872
  (_cleanUpTransitionLis = cleanUpTransitionListener) === null || _cleanUpTransitionLis === void 0 || _cleanUpTransitionLis();
937
873
  };
938
874
  }, [calculatePositionOld, view.dom, anchorName, nodeType]);
939
- (0, _react.useEffect)(function () {
940
- if (!(0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true)) {
941
- return;
942
- }
943
- var cleanUpTransitionListener;
944
- if (nodeType === 'extension' || nodeType === 'embedCard') {
945
- var dom = view.dom.querySelector("[".concat((0, _domAttrName.getAnchorAttrName)(), "=\"").concat(anchorName, "\"]"));
946
- if (!dom) {
947
- return;
948
- }
949
- cleanUpTransitionListener = (0, _bindEventListener.bind)(dom, {
950
- type: 'transitionend',
951
- listener: function listener() {
952
- setRecalculatePosition(!recalculatePosition);
953
- }
954
- });
955
- }
956
- return function () {
957
- var _cleanUpTransitionLis2;
958
- (_cleanUpTransitionLis2 = cleanUpTransitionListener) === null || _cleanUpTransitionLis2 === void 0 || _cleanUpTransitionLis2();
959
- };
960
- }, [view, anchorName, nodeType, recalculatePosition]);
961
875
  (0, _react.useEffect)(function () {
962
876
  if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current) {
963
877
  var id = requestAnimationFrame(function () {
@@ -966,9 +880,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
966
880
  });
967
881
  return function () {
968
882
  cancelAnimationFrame(id);
969
- if (!(0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true)) {
970
- view.focus();
971
- }
883
+ view.focus();
972
884
  };
973
885
  }
974
886
  }, [buttonRef, handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused, view]);
@@ -1084,7 +996,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
1084
996
  ref: buttonRef
1085
997
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
1086
998
  ,
1087
- style: !(0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld : {},
999
+ style: !(0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? positionStylesOld : {},
1088
1000
  onMouseDown: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_selection_toolbar_block_handle', 'isEnabled', true) ? handleMouseDown : undefined,
1089
1001
  onMouseUp: (0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? handleMouseUp : undefined,
1090
1002
  onClick: (0, _experiments.editorExperiment)('platform_editor_block_menu', true) ? handleOnClickNew : handleOnClick,
@@ -1138,7 +1050,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
1138
1050
  return (0, _react2.jsx)(_primitives.Box
1139
1051
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
1140
1052
  , {
1141
- style: (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld
1053
+ style: positionStylesOld
1142
1054
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
1143
1055
  ,
1144
1056
  xcss: [dragHandleContainerStyles],
@@ -1168,7 +1080,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
1168
1080
  return (0, _react2.jsx)(_primitives.Box
1169
1081
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
1170
1082
  , {
1171
- style: (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld
1083
+ style: positionStylesOld
1172
1084
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
1173
1085
  ,
1174
1086
  xcss: [dragHandleContainerStyles],
@@ -12,7 +12,6 @@ var _styles = require("@atlaskit/editor-common/styles");
12
12
  var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
13
13
  var _whitespace = require("@atlaskit/editor-common/whitespace");
14
14
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
15
- var _constants = require("@atlaskit/theme/constants");
16
15
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
17
16
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
18
17
  var _consts = require("./consts");
@@ -249,89 +248,6 @@ var globalStyles = function globalStyles() {
249
248
  }
250
249
  });
251
250
  };
252
- var quickInsertStyles = function quickInsertStyles() {
253
- return (0, _react.css)({
254
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
255
- '.blocks-quick-insert-button': {
256
- backgroundColor: 'transparent',
257
- top: "var(--top-override,8px)",
258
- position: 'sticky',
259
- boxSizing: 'border-box',
260
- display: 'flex',
261
- flexDirection: 'column',
262
- justifyContent: 'center',
263
- alignItems: 'center',
264
- height: "var(--ds-space-300, 24px)",
265
- width: "var(--ds-space-300, 24px)",
266
- border: 'none',
267
- borderRadius: "var(--ds-radius-full, 9999px)",
268
- zIndex: _constants.layers.card(),
269
- outline: 'none',
270
- cursor: 'pointer',
271
- color: "var(--ds-icon-subtle, #505258)"
272
- },
273
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
274
- '[data-blocks-quick-insert-container]:has(~ [data-prosemirror-node-name="table"] .pm-table-with-controls tr.sticky) &': {
275
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
276
- '--top-override': "".concat(_styles.tableControlsSpacing, "px")
277
- },
278
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
279
- '[data-prosemirror-mark-name="breakout"]:has([data-blocks-quick-insert-container]):has(~ [data-prosemirror-node-name="table"] .pm-table-with-controls tr.sticky) &': {
280
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
281
- '--top-override': "".concat(_styles.tableControlsSpacing, "px")
282
- },
283
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
284
- '.blocks-quick-insert-button:hover': {
285
- backgroundColor: "var(--ds-background-neutral-subtle-hovered, #0515240F)"
286
- },
287
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
288
- '.blocks-quick-insert-button:active': {
289
- backgroundColor: "var(--ds-background-neutral-subtle-pressed, #0B120E24)"
290
- },
291
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
292
- '.blocks-quick-insert-button:focus': {
293
- outline: "var(--ds-border-width-focused, 2px)".concat(" solid ", "var(--ds-border-focused, #4688EC)")
294
- },
295
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
296
- '.blocks-quick-insert-visible-container': {
297
- transition: 'opacity 0.1s ease-in-out, visibility 0.1s ease-in-out',
298
- opacity: 1,
299
- visibility: 'visible'
300
- },
301
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
302
- '.blocks-quick-insert-invisible-container': {
303
- transition: 'opacity 0.1s ease-in-out, visibility 0.1s ease-in-out',
304
- opacity: 0,
305
- visibility: 'hidden'
306
- },
307
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
308
- '.blocks-quick-insert-tooltip': {
309
- zIndex: _constants.layers.tooltip(),
310
- borderRadius: "var(--ds-radius-small, 4px)",
311
- padding: "var(--ds-space-050, 4px)".concat(" 0"),
312
- boxSizing: 'border-box',
313
- maxWidth: '240px',
314
- backgroundColor: "var(--ds-background-neutral-bold, #292A2E)",
315
- color: "var(--ds-text-inverse, #FFFFFF)",
316
- font: "var(--ds-font-body-small, normal 400 12px/16px \"Atlassian Sans\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
317
- insetBlockStart: "var(--ds-space-0, 0px)",
318
- insetInlineStart: "var(--ds-space-0, 0px)",
319
- overflowWrap: 'break-word',
320
- paddingBlockEnd: "var(--ds-space-025, 2px)",
321
- paddingBlockStart: "var(--ds-space-025, 2px)",
322
- paddingInlineEnd: "var(--ds-space-075, 6px)",
323
- paddingInlineStart: "var(--ds-space-075, 6px)",
324
- wordWrap: 'break-word',
325
- pointerEvents: 'none',
326
- userSelect: 'none',
327
- // Based on: platform/packages/design-system/motion/src/entering/keyframes-motion.tsx
328
- transition: 'opacity .1s ease-in-out, transform .1s ease-in-out, visibility .1s ease-in-out',
329
- '@media (prefers-reduced-motion: reduce)': {
330
- transition: 'none'
331
- }
332
- }
333
- });
334
- };
335
251
  var topLevelNodeMarginStyles = (0, _react.css)({
336
252
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
337
253
  '.ProseMirror': {
@@ -495,6 +411,6 @@ var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWra
495
411
  exposure: true
496
412
  }) ? (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
497
413
  // platform_editor_controls note: this allows drag handles to render on empty lines
498
- toolbarFlagsEnabled ? undefined : withInlineNodeStyle, (0, _experiments.editorExperiment)('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && (0, _expValEquals.expValEquals)('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone, shouldRenderAnchors && (isDragging ? dragAnchorStyles : dragHandlerAnchorStyles)]
414
+ toolbarFlagsEnabled ? undefined : withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, (0, _experiments.editorExperiment)('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, (0, _expValEquals.expValEquals)('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && (0, _expValEquals.expValEquals)('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone, shouldRenderAnchors && (isDragging ? dragAnchorStyles : dragHandlerAnchorStyles)]
499
415
  });
500
416
  };