@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.
@@ -43,16 +43,6 @@ var shouldIgnoreNode = function shouldIgnoreNode(node, ignore_nodes, depth, pare
43
43
  exposure: true
44
44
  }) ? true : ignore_nodes.includes(node.type.name);
45
45
  };
46
- var getPositionBeforeNodeAtPos = function getPositionBeforeNodeAtPos(state, pos) {
47
- if (pos <= 0 || pos >= state.doc.nodeSize - 2) {
48
- return pos;
49
- }
50
- var $pos = state.doc.resolve(pos);
51
- if ($pos.depth > 0) {
52
- return $pos.before();
53
- }
54
- return pos;
55
- };
56
46
 
57
47
  /**
58
48
  * Find node decorations corresponding to nodes with starting position between from and to (non-inclusive)
@@ -62,43 +52,25 @@ var getPositionBeforeNodeAtPos = function getPositionBeforeNodeAtPos(state, pos)
62
52
  */
63
53
  export var findNodeDecs = function findNodeDecs(state, decorations, from, to) {
64
54
  var newFrom = from;
65
- if (editorExperiment('platform_editor_block_control_optimise_render', true)) {
66
- // return empty array if range reversed
67
- if (typeof to === 'number' && typeof newFrom === 'number' && newFrom > to) {
68
- return [];
69
- }
70
- var decs = decorations.find(newFrom, to, function (spec) {
71
- return spec.type === TYPE_NODE_DEC;
72
- });
55
+ var newTo = to;
73
56
 
74
- // 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
75
- if (typeof to === 'number' && typeof newFrom === 'number') {
76
- decs = decs.filter(function (dec) {
77
- return dec.from >= (newFrom || 0) && dec.from < to;
78
- });
79
- }
80
- return decs;
81
- } else {
82
- var newTo = to;
83
-
84
- // make it non-inclusive
85
- if (newFrom !== undefined) {
86
- newFrom++;
87
- }
57
+ // make it non-inclusive
58
+ if (newFrom !== undefined) {
59
+ newFrom++;
60
+ }
88
61
 
89
- // make it non-inclusive
90
- if (newTo !== undefined) {
91
- newTo--;
92
- }
62
+ // make it non-inclusive
63
+ if (newTo !== undefined) {
64
+ newTo--;
65
+ }
93
66
 
94
- // return empty array if range reversed
95
- if (newFrom !== undefined && newTo !== undefined && newFrom > newTo) {
96
- return [];
97
- }
98
- return decorations.find(newFrom, newTo, function (spec) {
99
- return spec.type === TYPE_NODE_DEC;
100
- });
67
+ // return empty array if range reversed
68
+ if (newFrom !== undefined && newTo !== undefined && newFrom > newTo) {
69
+ return [];
101
70
  }
71
+ return decorations.find(newFrom, newTo, function (spec) {
72
+ return spec.type === TYPE_NODE_DEC;
73
+ });
102
74
  };
103
75
  export var nodeDecorations = function nodeDecorations(newState, from, to) {
104
76
  var decs = [];
@@ -113,12 +85,6 @@ export var nodeDecorations = function nodeDecorations(newState, from, to) {
113
85
  var shouldDescend = shouldDescendIntoNode(node);
114
86
  var anchorName = getNodeAnchor(node);
115
87
  var nodeTypeWithLevel = getNodeTypeWithLevel(node);
116
- if (editorExperiment('platform_editor_block_control_optimise_render', true)) {
117
- // We don't want to create decorations for nodes that start outside of the provided position range
118
- if (pos < getPositionBeforeNodeAtPos(newState, docFrom)) {
119
- return shouldDescend;
120
- }
121
- }
122
88
 
123
89
  // Doesn't descend into a node
124
90
  if (node.isInline) {
@@ -35,11 +35,7 @@ export var dragHandleDecoration = function dragHandleDecoration(_ref) {
35
35
  handleOptions = _ref.handleOptions,
36
36
  anchorRectCache = _ref.anchorRectCache,
37
37
  editorState = _ref.editorState;
38
- if (!editorExperiment('platform_editor_block_control_optimise_render', true, {
39
- exposure: true
40
- })) {
41
- unmountDecorations(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
42
- }
38
+ unmountDecorations(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
43
39
  var unbind;
44
40
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
45
41
  var key = uuid();
@@ -56,9 +52,6 @@ export var dragHandleDecoration = function dragHandleDecoration(_ref) {
56
52
  marks: expValEquals('platform_editor_clean_up_widget_mark_logic', 'isEnabled', true) ? [] : getActiveBlockMarks(editorState, pos),
57
53
  destroy: function destroy(node) {
58
54
  unbind && unbind();
59
- if (editorExperiment('platform_editor_block_control_optimise_render', true) && node instanceof HTMLElement) {
60
- ReactDOM.unmountComponentAtNode(node);
61
- }
62
55
  }
63
56
  } : {
64
57
  side: -1,
@@ -68,9 +61,6 @@ export var dragHandleDecoration = function dragHandleDecoration(_ref) {
68
61
  marks: expValEquals('platform_editor_clean_up_widget_mark_logic', 'isEnabled', true) ? [] : expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? getActiveBlockMarks(editorState, pos) : undefined,
69
62
  destroy: function destroy(node) {
70
63
  unbind && unbind();
71
- if (editorExperiment('platform_editor_block_control_optimise_render', true) && node instanceof HTMLElement) {
72
- ReactDOM.unmountComponentAtNode(node);
73
- }
74
64
  }
75
65
  };
76
66
  return Decoration.widget(pos, function (view, getPosUnsafe) {
@@ -7,7 +7,6 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
7
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
8
  import { QuickInsertWithVisibility } from '../ui/quick-insert-button';
9
9
  import { getActiveBlockMarks } from './utils/marks';
10
- import { createVanillaButton } from './vanilla-quick-insert';
11
10
  var TYPE_QUICK_INSERT = 'INSERT_BUTTON';
12
11
  export var findQuickInsertInsertButtonDecoration = function findQuickInsertInsertButtonDecoration(decorations, from, to) {
13
12
  return decorations.find(from, to, function (spec) {
@@ -71,23 +70,6 @@ export var quickInsertButtonDecoration = function quickInsertButtonDecoration(_r
71
70
  element.setAttribute('data-blocks-quick-insert-button', 'true');
72
71
  }
73
72
  element.setAttribute('data-testid', 'block-ctrl-quick-insert-button');
74
- if (editorExperiment('platform_editor_block_control_optimise_render', true, {
75
- exposure: true
76
- })) {
77
- var vanillaElement = createVanillaButton({
78
- formatMessage: formatMessage,
79
- api: api,
80
- view: view,
81
- getPos: getPos,
82
- cleanupCallbacks: cleanupCallbacks,
83
- rootAnchorName: rootAnchorName !== null && rootAnchorName !== void 0 ? rootAnchorName : nodeType,
84
- anchorName: anchorName,
85
- rootNodeType: rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType,
86
- anchorRectCache: anchorRectCache
87
- });
88
- element.appendChild(vanillaElement);
89
- return element;
90
- }
91
73
  nodeViewPortalProviderAPI.render(function () {
92
74
  return /*#__PURE__*/createElement(QuickInsertWithVisibility, {
93
75
  api: api,
@@ -92,6 +92,19 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
92
92
  }
93
93
  var rootElement = target === null || target === void 0 ? void 0 : target.closest(isNativeAnchorSupported ? getDefaultNodeSelector() : "[data-drag-handler-anchor-name]");
94
94
 
95
+ // Fallback for table nodes in view mode: the table-anchor-names plugin sets data-node-anchor on
96
+ // the first <tr> element.
97
+ // - When platform_editor_native_anchor_with_dnd is disabled, the primary closest() uses
98
+ // [data-drag-handler-anchor-name] and misses table rows. Try data-node-anchor via closest().
99
+ // - For wide/max breakout tables, hovering in the left/right margin area of the full-viewport-
100
+ // width breakout wrapper (ak-editor-breakout-mark) sets event.target to the wrapper div, which
101
+ // has no anchor attribute. Use querySelector to find the [data-node-anchor] descendant inside.
102
+ // Both cases apply only in view mode with right-side remix controls.
103
+ if (!rootElement && isViewMode && rightSideControlsEnabled) {
104
+ var _ref3, _target$closest;
105
+ rootElement = (_ref3 = (_target$closest = target === null || target === void 0 ? void 0 : target.closest("[".concat(NODE_ANCHOR_ATTR_NAME, "]"))) !== null && _target$closest !== void 0 ? _target$closest : target instanceof HTMLElement ? target.querySelector("[".concat(NODE_ANCHOR_ATTR_NAME, "]")) : null) !== null && _ref3 !== void 0 ? _ref3 : null;
106
+ }
107
+
95
108
  // When hovering over the right-edge button (rendered in a portal outside the block), resolve the
96
109
  // block from the container's anchor so activeNode stays set and the button remains visible.
97
110
  if (!rootElement && rightSideControlsEnabled && fg('confluence_remix_button_right_side_block_fg')) {
@@ -104,7 +117,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
104
117
  }
105
118
  }
106
119
  if (rootElement) {
107
- var _rootElement$parentEl;
120
+ var _rootElement$parentEl, _rootElement$getAttri2;
108
121
  // We want to exlude handles from showing for empty paragraph and heading nodes
109
122
  if (isEmptyNestedParagraphOrHeading(rootElement)) {
110
123
  return false;
@@ -177,6 +190,11 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
177
190
  // Ignored via go/ees005
178
191
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
179
192
  anchorName = rootElement.getAttribute(getAnchorAttrName());
193
+ // Fallback for table nodes that only have data-node-anchor (not data-drag-handler-anchor-name).
194
+ if (!anchorName) {
195
+ var _rootElement$getAttri;
196
+ anchorName = (_rootElement$getAttri = rootElement.getAttribute(NODE_ANCHOR_ATTR_NAME)) !== null && _rootElement$getAttri !== void 0 ? _rootElement$getAttri : anchorName;
197
+ }
180
198
  }
181
199
 
182
200
  // No need to update handle position if its already there
@@ -224,13 +242,16 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
224
242
  if (targetPos !== rootPos) {
225
243
  var rootDOM = view.nodeDOM(rootPos);
226
244
  if (rootDOM instanceof HTMLElement) {
227
- var _rootDOM$getAttribute;
228
- rootAnchorName = (_rootDOM$getAttribute = rootDOM.getAttribute(getAnchorAttrName())) !== null && _rootDOM$getAttribute !== void 0 ? _rootDOM$getAttribute : undefined;
229
- rootNodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootDOM) : rootDOM.getAttribute('data-drag-handler-node-type');
245
+ var _ref4, _rootDOM$getAttribute, _rootDOM$getAttribute2;
246
+ rootAnchorName = (_ref4 = (_rootDOM$getAttribute = rootDOM.getAttribute(getAnchorAttrName())) !== null && _rootDOM$getAttribute !== void 0 ? _rootDOM$getAttribute : rootDOM.getAttribute(NODE_ANCHOR_ATTR_NAME)) !== null && _ref4 !== void 0 ? _ref4 : undefined;
247
+ rootNodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootDOM) : // Fallback: breakout mark wrappers have no data-drag-handler-node-type;
248
+ // use data-prosemirror-node-name instead.
249
+ (_rootDOM$getAttribute2 = rootDOM.getAttribute('data-drag-handler-node-type')) !== null && _rootDOM$getAttribute2 !== void 0 ? _rootDOM$getAttribute2 : getTypeNameFromDom(rootDOM);
230
250
  }
231
251
  }
232
252
  }
233
- var nodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootElement) : rootElement.getAttribute('data-drag-handler-node-type');
253
+ var nodeType = isNativeAnchorSupported ? getTypeNameFromDom(rootElement) : // Fallback for table nodes: tr has data-prosemirror-node-name but not data-drag-handler-node-type.
254
+ (_rootElement$getAttri2 = rootElement.getAttribute('data-drag-handler-node-type')) !== null && _rootElement$getAttri2 !== void 0 ? _rootElement$getAttri2 : getTypeNameFromDom(rootElement);
234
255
  if (nodeType) {
235
256
  // platform_editor_controls note: enables quick insert
236
257
  if (toolbarFlagsEnabled) {
@@ -5,6 +5,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
5
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  import rafSchedule from 'raf-schd';
8
+ import { getDocument } from '@atlaskit/browser-apis';
8
9
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
9
10
  import { getBrowserInfo } from '@atlaskit/editor-common/browser';
10
11
  import { getNodeIdProvider } from '@atlaskit/editor-common/node-anchor';
@@ -49,7 +50,8 @@ var isHTMLElement = function isHTMLElement(element) {
49
50
  return element instanceof HTMLElement;
50
51
  };
51
52
  var destroyFn = function destroyFn(api, editorView) {
52
- var scrollable = document.querySelector('.fabric-editor-popup-scroll-parent');
53
+ var _getDocument$querySel, _getDocument;
54
+ var scrollable = (_getDocument$querySel = (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.querySelector('.fabric-editor-popup-scroll-parent')) !== null && _getDocument$querySel !== void 0 ? _getDocument$querySel : null;
53
55
  var cleanupFn = [];
54
56
  if (scrollable) {
55
57
  cleanupFn.push(autoScrollForElements({
@@ -224,7 +226,7 @@ export var getDecorations = function getDecorations(state) {
224
226
  };
225
227
  var getDecorationAtPos = function getDecorationAtPos(state, decorations, pos, to) {
226
228
  // Find the newly minted node decs that touch the active node
227
- var findNewNodeDecs = findNodeDecs(state, decorations, editorExperiment('platform_editor_block_control_optimise_render', true) ? pos : pos - 1, to);
229
+ var findNewNodeDecs = findNodeDecs(state, decorations, pos - 1, to);
228
230
 
229
231
  // Find the specific dec that the active node corresponds to
230
232
  var nodeDecsAtActivePos = findNewNodeDecs.filter(function (dec) {
@@ -268,10 +270,11 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
268
270
  var meta = tr.getMeta(key);
269
271
  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;
270
272
  if (hasDocumentSizeBreachedThreshold) {
273
+ var _getDocument$querySel2, _getDocument2;
271
274
  /**
272
275
  * 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().
273
276
  */
274
- var editorContentArea = document.querySelector('.fabric-editor-popup-scroll-parent');
277
+ var editorContentArea = (_getDocument$querySel2 = (_getDocument2 = getDocument()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.querySelector('.fabric-editor-popup-scroll-parent')) !== null && _getDocument$querySel2 !== void 0 ? _getDocument$querySel2 : null;
275
278
  if (editorContentArea && resizeObserverWidth) {
276
279
  resizeObserverWidth.unobserve(editorContentArea);
277
280
  }
@@ -371,7 +374,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
371
374
  if (!flags.toolbarFlagsEnabled) {
372
375
  if (latestActiveNode && !isActiveNodeDeleted) {
373
376
  // Find the newly minted node decs that touch the active node
374
- var findNewNodeDecs = findNodeDecs(newState, decorations, editorExperiment('platform_editor_block_control_optimise_render', true) ? latestActiveNode.pos : latestActiveNode.pos - 1, to);
377
+ var findNewNodeDecs = findNodeDecs(newState, decorations, latestActiveNode.pos - 1, to);
375
378
 
376
379
  // Find the specific dec that the active node corresponds to
377
380
  var nodeDecsAtActivePos = findNewNodeDecs.filter(function (dec) {
@@ -434,6 +437,16 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
434
437
  // Remove handle dec when editor is blurred
435
438
  shouldRemoveHandle = shouldRemoveHandle || (meta === null || meta === void 0 ? void 0 : meta.editorBlurred);
436
439
  }
440
+
441
+ // In view mode with right-side controls, remove any lingering drag handle decorations
442
+ // (they may carry over from edit mode). Only remove drag handles specifically, not
443
+ // the remix button decorations (those are managed separately via showInViewMode).
444
+ if (isViewMode && rightSideControlsEnabled) {
445
+ var allHandleDecs = findHandleDec(decorations, 0, newState.doc.content.size);
446
+ if (allHandleDecs.length > 0) {
447
+ decorations = decorations.remove(allHandleDecs);
448
+ }
449
+ }
437
450
  if (shouldRemoveHandle) {
438
451
  var _activeNode5, _activeNode6;
439
452
  var oldHandle = findHandleDec(decorations, (_activeNode5 = activeNode) === null || _activeNode5 === void 0 ? void 0 : _activeNode5.pos, (_activeNode6 = activeNode) === null || _activeNode6 === void 0 ? void 0 : _activeNode6.pos);
@@ -802,7 +815,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
802
815
  },
803
816
  props: {
804
817
  decorations: function decorations(state) {
805
- var _api$limitedMode2, _api$editorDisabled, _key$getState2;
818
+ var _api$limitedMode2, _api$editorDisabled, _key$getState2, _api$editorViewMode3;
806
819
  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) {
807
820
  return;
808
821
  }
@@ -815,7 +828,16 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
815
828
  return;
816
829
  }
817
830
  }
818
- return (_key$getState2 = key.getState(state)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.decorations;
831
+ var decorationSet = (_key$getState2 = key.getState(state)) === null || _key$getState2 === void 0 ? void 0 : _key$getState2.decorations;
832
+ // In view mode with right-side controls, remove any lingering drag-handle decorations
833
+ // (created in edit mode) that may not have been cleaned up on mode switch.
834
+ 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') {
835
+ var handleDecs = findHandleDec(decorationSet, 0, state.doc.content.size);
836
+ if (handleDecs.length > 0) {
837
+ decorationSet = decorationSet.remove(handleDecs);
838
+ }
839
+ }
840
+ return decorationSet;
819
841
  },
820
842
  handleDOMEvents: {
821
843
  drop: function drop(view, event) {
@@ -361,20 +361,16 @@ export var DragHandle = function DragHandle(_ref) {
361
361
  _useState6 = _slicedToArray(_useState5, 2),
362
362
  blockCardWidth = _useState6[0],
363
363
  setBlockCardWidth = _useState6[1];
364
- var _useState7 = useState(false),
365
- _useState8 = _slicedToArray(_useState7, 2),
366
- recalculatePosition = _useState8[0],
367
- setRecalculatePosition = _useState8[1];
368
- var _useState9 = useState({
364
+ var _useState7 = useState({
369
365
  display: 'none'
370
366
  }),
367
+ _useState8 = _slicedToArray(_useState7, 2),
368
+ positionStylesOld = _useState8[0],
369
+ setPositionStylesOld = _useState8[1];
370
+ var _useState9 = useState(Boolean(handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused)),
371
371
  _useState0 = _slicedToArray(_useState9, 2),
372
- positionStylesOld = _useState0[0],
373
- setPositionStylesOld = _useState0[1];
374
- var _useState1 = useState(Boolean(handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused)),
375
- _useState10 = _slicedToArray(_useState1, 2),
376
- isFocused = _useState10[0],
377
- setIsFocused = _useState10[1];
372
+ isFocused = _useState0[0],
373
+ setIsFocused = _useState0[1];
378
374
  var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['featureFlags', 'selection', 'blockControls', 'interaction'], function (states) {
379
375
  var _states$featureFlagsS, _states$selectionStat, _states$blockControls, _states$interactionSt;
380
376
  return {
@@ -410,9 +406,6 @@ export var DragHandle = function DragHandle(_ref) {
410
406
  // just rely on the dynamic value (rename it to isTopLevelNode for simplicitiy)
411
407
  var isTopLevelNodeValue = expValEquals('platform_editor_nested_drag_handle_icon', 'isEnabled', true) ? isTopLevelNodeDynamic : isTopLevelNode;
412
408
  useEffect(function () {
413
- if (editorExperiment('platform_editor_block_control_optimise_render', true)) {
414
- return;
415
- }
416
409
  // blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
417
410
  if (nodeType === 'blockCard') {
418
411
  var dom = view.dom.querySelector("[".concat(getAnchorAttrName(), "=\"").concat(anchorName, "\"]"));
@@ -806,60 +799,6 @@ export var DragHandle = function DragHandle(_ref) {
806
799
  }
807
800
  });
808
801
  }, [anchorName, api, getPos, isMultiSelect, nodeType, start, view]);
809
- var positionStyles = useMemo(function () {
810
- if (!editorExperiment('platform_editor_block_control_optimise_render', true)) {
811
- return {};
812
- }
813
-
814
- // This is a no-op to allow recalculatePosition to be used as a dependency
815
- if (recalculatePosition) {
816
- setRecalculatePosition(recalculatePosition);
817
- }
818
- var pos = getPos();
819
- var $pos = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? typeof pos === 'number' && view.state.doc.resolve(pos) : pos && view.state.doc.resolve(pos);
820
- var parentPos = $pos && $pos.depth ? $pos.before() : undefined;
821
- var node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
822
- var parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
823
- var supportsAnchor = CSS.supports('top', "anchor(".concat(anchorName, " start)")) && CSS.supports('left', "anchor(".concat(anchorName, " start)"));
824
- var safeAnchorName = editorExperiment('platform_editor_controls', 'variant1') ? refreshAnchorName({
825
- getPos: getPos,
826
- view: view,
827
- anchorName: anchorName
828
- }) : anchorName;
829
- var dom = view.dom.querySelector("[".concat(getAnchorAttrName(), "=\"").concat(safeAnchorName, "\"]"));
830
- var hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
831
- var isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension' || nodeType === 'multiBodiedExtension';
832
- var isBlockCard = nodeType === 'blockCard';
833
- var isEmbedCard = nodeType === 'embedCard';
834
- var isMacroInteractionUpdates = macroInteractionUpdates && isExtension;
835
- var innerContainer = null;
836
- if (dom) {
837
- if (isEmbedCard) {
838
- innerContainer = dom.querySelector('.rich-media-item');
839
- } else if (hasResizer) {
840
- innerContainer = dom.querySelector('.resizer-item');
841
- } else if (isExtension) {
842
- innerContainer = dom.querySelector('.extension-container[data-layout]');
843
- } else if (isBlockCard) {
844
- //specific to datasource blockCard
845
- innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
846
- }
847
- }
848
- var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
849
- var isSticky = shouldBeSticky(nodeType);
850
- if (supportsAnchor) {
851
- var bottom = editorExperiment('platform_editor_controls', 'variant1') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNodeValue, isLayoutColumn) : {};
852
- return _objectSpread({
853
- left: isEdgeCase ? "calc(anchor(".concat(safeAnchorName, " start) + ").concat(getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : editorExperiment('advanced_layouts', true) && isLayoutColumn ? "calc((anchor(".concat(safeAnchorName, " right) + anchor(").concat(safeAnchorName, " left))/2 - ").concat(DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(safeAnchorName, " start) - ").concat(DRAG_HANDLE_WIDTH, "px - ").concat(dragHandleGap(nodeType, parentNodeType), "px)"),
854
- top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? "calc(anchor(".concat(safeAnchorName, " top) - ").concat(DRAG_HANDLE_WIDTH, "px)") : "calc(anchor(".concat(safeAnchorName, " start) + ").concat(topPositionAdjustment(expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? $pos && $pos.nodeAfter && getNodeTypeWithLevel($pos.nodeAfter) || nodeType : nodeType, (dom === null || dom === void 0 ? void 0 : dom.getAttribute('layout')) || ''), "px)")
855
- }, bottom);
856
- }
857
- var height = editorExperiment('platform_editor_controls', 'variant1') ? getControlHeightCSSValue(getNodeHeight(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNodeValue, "".concat(DRAG_HANDLE_HEIGHT), isLayoutColumn) : {};
858
- return _objectSpread({
859
- left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat(getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType), ")") : getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType),
860
- top: getTopPosition(dom, nodeType)
861
- }, height);
862
- }, [anchorName, getPos, view, nodeType, macroInteractionUpdates, anchorRectCache, isTopLevelNodeValue, isLayoutColumn, recalculatePosition]);
863
802
  var calculatePositionOld = useCallback(function () {
864
803
  var pos = getPos();
865
804
  var $pos = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? typeof pos === 'number' && view.state.doc.resolve(pos) : pos && view.state.doc.resolve(pos);
@@ -907,9 +846,6 @@ export var DragHandle = function DragHandle(_ref) {
907
846
  }, height);
908
847
  }, [anchorName, getPos, view, nodeType, blockCardWidth, macroInteractionUpdates, anchorRectCache, isTopLevelNodeValue, isLayoutColumn]);
909
848
  useEffect(function () {
910
- if (editorExperiment('platform_editor_block_control_optimise_render', true)) {
911
- return;
912
- }
913
849
  var cleanUpTransitionListener;
914
850
  if (nodeType === 'extension' || nodeType === 'embedCard') {
915
851
  var dom = view.dom.querySelector("[".concat(getAnchorAttrName(), "=\"").concat(anchorName, "\"]"));
@@ -932,28 +868,6 @@ export var DragHandle = function DragHandle(_ref) {
932
868
  (_cleanUpTransitionLis = cleanUpTransitionListener) === null || _cleanUpTransitionLis === void 0 || _cleanUpTransitionLis();
933
869
  };
934
870
  }, [calculatePositionOld, view.dom, anchorName, nodeType]);
935
- useEffect(function () {
936
- if (!editorExperiment('platform_editor_block_control_optimise_render', true)) {
937
- return;
938
- }
939
- var cleanUpTransitionListener;
940
- if (nodeType === 'extension' || nodeType === 'embedCard') {
941
- var dom = view.dom.querySelector("[".concat(getAnchorAttrName(), "=\"").concat(anchorName, "\"]"));
942
- if (!dom) {
943
- return;
944
- }
945
- cleanUpTransitionListener = bind(dom, {
946
- type: 'transitionend',
947
- listener: function listener() {
948
- setRecalculatePosition(!recalculatePosition);
949
- }
950
- });
951
- }
952
- return function () {
953
- var _cleanUpTransitionLis2;
954
- (_cleanUpTransitionLis2 = cleanUpTransitionListener) === null || _cleanUpTransitionLis2 === void 0 || _cleanUpTransitionLis2();
955
- };
956
- }, [view, anchorName, nodeType, recalculatePosition]);
957
871
  useEffect(function () {
958
872
  if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current) {
959
873
  var id = requestAnimationFrame(function () {
@@ -962,9 +876,7 @@ export var DragHandle = function DragHandle(_ref) {
962
876
  });
963
877
  return function () {
964
878
  cancelAnimationFrame(id);
965
- if (!editorExperiment('platform_editor_block_control_optimise_render', true)) {
966
- view.focus();
967
- }
879
+ view.focus();
968
880
  };
969
881
  }
970
882
  }, [buttonRef, handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused, view]);
@@ -1080,7 +992,7 @@ export var DragHandle = function DragHandle(_ref) {
1080
992
  ref: buttonRef
1081
993
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
1082
994
  ,
1083
- style: !editorExperiment('platform_editor_controls', 'variant1') ? editorExperiment('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld : {},
995
+ style: !editorExperiment('platform_editor_controls', 'variant1') ? positionStylesOld : {},
1084
996
  onMouseDown: expValEqualsNoExposure('platform_editor_selection_toolbar_block_handle', 'isEnabled', true) ? handleMouseDown : undefined,
1085
997
  onMouseUp: editorExperiment('platform_editor_block_menu', true) ? handleMouseUp : undefined,
1086
998
  onClick: editorExperiment('platform_editor_block_menu', true) ? handleOnClickNew : handleOnClick,
@@ -1134,7 +1046,7 @@ export var DragHandle = function DragHandle(_ref) {
1134
1046
  return jsx(Box
1135
1047
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
1136
1048
  , {
1137
- style: editorExperiment('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld
1049
+ style: positionStylesOld
1138
1050
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
1139
1051
  ,
1140
1052
  xcss: [dragHandleContainerStyles],
@@ -1164,7 +1076,7 @@ export var DragHandle = function DragHandle(_ref) {
1164
1076
  return jsx(Box
1165
1077
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
1166
1078
  , {
1167
- style: editorExperiment('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld
1079
+ style: positionStylesOld
1168
1080
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
1169
1081
  ,
1170
1082
  xcss: [dragHandleContainerStyles],
@@ -6,11 +6,10 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
6
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports
7
7
  import { css, Global, jsx } from '@emotion/react';
8
8
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
9
- import { ANCHOR_VARIABLE_NAME, DRAG_HANDLE_WIDTH, isCSSAnchorSupported, tableControlsSpacing } from '@atlaskit/editor-common/styles';
9
+ import { ANCHOR_VARIABLE_NAME, DRAG_HANDLE_WIDTH, isCSSAnchorSupported } from '@atlaskit/editor-common/styles';
10
10
  import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
11
11
  import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
12
12
  import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport, akEditorFullPageNarrowBreakout, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced } from '@atlaskit/editor-shared-styles';
13
- import { layers } from '@atlaskit/theme/constants';
14
13
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
15
14
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
16
15
  import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP } from './consts';
@@ -242,89 +241,6 @@ var globalStyles = function globalStyles() {
242
241
  }
243
242
  });
244
243
  };
245
- var quickInsertStyles = function quickInsertStyles() {
246
- return css({
247
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
248
- '.blocks-quick-insert-button': {
249
- backgroundColor: 'transparent',
250
- top: "var(--top-override,8px)",
251
- position: 'sticky',
252
- boxSizing: 'border-box',
253
- display: 'flex',
254
- flexDirection: 'column',
255
- justifyContent: 'center',
256
- alignItems: 'center',
257
- height: "var(--ds-space-300, 24px)",
258
- width: "var(--ds-space-300, 24px)",
259
- border: 'none',
260
- borderRadius: "var(--ds-radius-full, 9999px)",
261
- zIndex: layers.card(),
262
- outline: 'none',
263
- cursor: 'pointer',
264
- color: "var(--ds-icon-subtle, #505258)"
265
- },
266
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
267
- '[data-blocks-quick-insert-container]:has(~ [data-prosemirror-node-name="table"] .pm-table-with-controls tr.sticky) &': {
268
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
269
- '--top-override': "".concat(tableControlsSpacing, "px")
270
- },
271
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
272
- '[data-prosemirror-mark-name="breakout"]:has([data-blocks-quick-insert-container]):has(~ [data-prosemirror-node-name="table"] .pm-table-with-controls tr.sticky) &': {
273
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
274
- '--top-override': "".concat(tableControlsSpacing, "px")
275
- },
276
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
277
- '.blocks-quick-insert-button:hover': {
278
- backgroundColor: "var(--ds-background-neutral-subtle-hovered, #0515240F)"
279
- },
280
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
281
- '.blocks-quick-insert-button:active': {
282
- backgroundColor: "var(--ds-background-neutral-subtle-pressed, #0B120E24)"
283
- },
284
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
285
- '.blocks-quick-insert-button:focus': {
286
- outline: "var(--ds-border-width-focused, 2px)".concat(" solid ", "var(--ds-border-focused, #4688EC)")
287
- },
288
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
289
- '.blocks-quick-insert-visible-container': {
290
- transition: 'opacity 0.1s ease-in-out, visibility 0.1s ease-in-out',
291
- opacity: 1,
292
- visibility: 'visible'
293
- },
294
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
295
- '.blocks-quick-insert-invisible-container': {
296
- transition: 'opacity 0.1s ease-in-out, visibility 0.1s ease-in-out',
297
- opacity: 0,
298
- visibility: 'hidden'
299
- },
300
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
301
- '.blocks-quick-insert-tooltip': {
302
- zIndex: layers.tooltip(),
303
- borderRadius: "var(--ds-radius-small, 4px)",
304
- padding: "var(--ds-space-050, 4px)".concat(" 0"),
305
- boxSizing: 'border-box',
306
- maxWidth: '240px',
307
- backgroundColor: "var(--ds-background-neutral-bold, #292A2E)",
308
- color: "var(--ds-text-inverse, #FFFFFF)",
309
- 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)",
310
- insetBlockStart: "var(--ds-space-0, 0px)",
311
- insetInlineStart: "var(--ds-space-0, 0px)",
312
- overflowWrap: 'break-word',
313
- paddingBlockEnd: "var(--ds-space-025, 2px)",
314
- paddingBlockStart: "var(--ds-space-025, 2px)",
315
- paddingInlineEnd: "var(--ds-space-075, 6px)",
316
- paddingInlineStart: "var(--ds-space-075, 6px)",
317
- wordWrap: 'break-word',
318
- pointerEvents: 'none',
319
- userSelect: 'none',
320
- // Based on: platform/packages/design-system/motion/src/entering/keyframes-motion.tsx
321
- transition: 'opacity .1s ease-in-out, transform .1s ease-in-out, visibility .1s ease-in-out',
322
- '@media (prefers-reduced-motion: reduce)': {
323
- transition: 'none'
324
- }
325
- }
326
- });
327
- };
328
244
  var topLevelNodeMarginStyles = css({
329
245
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
330
246
  '.ProseMirror': {
@@ -488,6 +404,6 @@ export var GlobalStylesWrapper = function GlobalStylesWrapper(_ref) {
488
404
  exposure: true
489
405
  }) ? expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
490
406
  // platform_editor_controls note: this allows drag handles to render on empty lines
491
- toolbarFlagsEnabled ? undefined : withInlineNodeStyle, editorExperiment('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && expValEquals('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone, shouldRenderAnchors && (isDragging ? dragAnchorStyles : dragHandlerAnchorStyles)]
407
+ toolbarFlagsEnabled ? undefined : withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) && expValEquals('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone, shouldRenderAnchors && (isDragging ? dragAnchorStyles : dragHandlerAnchorStyles)]
492
408
  });
493
409
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "11.1.1",
3
+ "version": "11.2.1",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "@atlaskit/browser-apis": "^0.0.1",
32
32
  "@atlaskit/button": "^23.11.0",
33
- "@atlaskit/editor-plugin-accessibility-utils": "^10.0.0",
33
+ "@atlaskit/editor-plugin-accessibility-utils": "^10.1.0",
34
34
  "@atlaskit/editor-plugin-analytics": "^10.0.0",
35
35
  "@atlaskit/editor-plugin-editor-disabled": "^10.0.0",
36
36
  "@atlaskit/editor-plugin-editor-viewmode": "^12.0.0",
@@ -38,7 +38,7 @@
38
38
  "@atlaskit/editor-plugin-interaction": "^19.0.0",
39
39
  "@atlaskit/editor-plugin-limited-mode": "^7.0.0",
40
40
  "@atlaskit/editor-plugin-metrics": "^11.0.0",
41
- "@atlaskit/editor-plugin-quick-insert": "^10.0.0",
41
+ "@atlaskit/editor-plugin-quick-insert": "^10.1.0",
42
42
  "@atlaskit/editor-plugin-selection": "^10.0.0",
43
43
  "@atlaskit/editor-plugin-toolbar": "^7.0.0",
44
44
  "@atlaskit/editor-plugin-type-ahead": "^10.0.0",
@@ -56,7 +56,7 @@
56
56
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
57
57
  "@atlaskit/primitives": "^19.0.0",
58
58
  "@atlaskit/theme": "^23.1.0",
59
- "@atlaskit/tmp-editor-statsig": "^64.0.0",
59
+ "@atlaskit/tmp-editor-statsig": "^65.0.0",
60
60
  "@atlaskit/tokens": "^13.0.0",
61
61
  "@atlaskit/tooltip": "^21.1.0",
62
62
  "@babel/runtime": "^7.0.0",
@@ -67,7 +67,7 @@
67
67
  "uuid": "^3.1.0"
68
68
  },
69
69
  "peerDependencies": {
70
- "@atlaskit/editor-common": "^114.5.0",
70
+ "@atlaskit/editor-common": "^114.6.0",
71
71
  "react": "^18.2.0",
72
72
  "react-dom": "^18.2.0",
73
73
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"