@atlaskit/editor-plugin-block-controls 11.1.1 → 11.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 11.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`64134fd6d8fee`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/64134fd6d8fee) -
8
+ clean up platform_editor_block_control_optimise_render
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
3
14
  ## 11.1.1
4
15
 
5
16
  ### 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,
@@ -231,7 +231,7 @@ var getDecorations = exports.getDecorations = function getDecorations(state) {
231
231
  };
232
232
  var getDecorationAtPos = function getDecorationAtPos(state, decorations, pos, to) {
233
233
  // 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);
234
+ var findNewNodeDecs = (0, _decorationsAnchor.findNodeDecs)(state, decorations, pos - 1, to);
235
235
 
236
236
  // Find the specific dec that the active node corresponds to
237
237
  var nodeDecsAtActivePos = findNewNodeDecs.filter(function (dec) {
@@ -378,7 +378,7 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
378
378
  if (!flags.toolbarFlagsEnabled) {
379
379
  if (latestActiveNode && !isActiveNodeDeleted) {
380
380
  // 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);
381
+ var findNewNodeDecs = (0, _decorationsAnchor.findNodeDecs)(newState, decorations, latestActiveNode.pos - 1, to);
382
382
 
383
383
  // Find the specific dec that the active node corresponds to
384
384
  var nodeDecsAtActivePos = findNewNodeDecs.filter(function (dec) {
@@ -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
  };
@@ -42,16 +42,6 @@ const shouldIgnoreNode = (node, ignore_nodes, depth, parent) => {
42
42
  exposure: true
43
43
  }) ? true : ignore_nodes.includes(node.type.name);
44
44
  };
45
- const getPositionBeforeNodeAtPos = (state, pos) => {
46
- if (pos <= 0 || pos >= state.doc.nodeSize - 2) {
47
- return pos;
48
- }
49
- const $pos = state.doc.resolve(pos);
50
- if ($pos.depth > 0) {
51
- return $pos.before();
52
- }
53
- return pos;
54
- };
55
45
 
56
46
  /**
57
47
  * Find node decorations corresponding to nodes with starting position between from and to (non-inclusive)
@@ -61,39 +51,23 @@ const getPositionBeforeNodeAtPos = (state, pos) => {
61
51
  */
62
52
  export const findNodeDecs = (state, decorations, from, to) => {
63
53
  let newFrom = from;
64
- if (editorExperiment('platform_editor_block_control_optimise_render', true)) {
65
- // return empty array if range reversed
66
- if (typeof to === 'number' && typeof newFrom === 'number' && newFrom > to) {
67
- return [];
68
- }
69
- let decs = decorations.find(newFrom, to, spec => spec.type === TYPE_NODE_DEC);
54
+ let newTo = to;
70
55
 
71
- // 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
72
- if (typeof to === 'number' && typeof newFrom === 'number') {
73
- decs = decs.filter(dec => {
74
- return dec.from >= (newFrom || 0) && dec.from < to;
75
- });
76
- }
77
- return decs;
78
- } else {
79
- let newTo = to;
80
-
81
- // make it non-inclusive
82
- if (newFrom !== undefined) {
83
- newFrom++;
84
- }
56
+ // make it non-inclusive
57
+ if (newFrom !== undefined) {
58
+ newFrom++;
59
+ }
85
60
 
86
- // make it non-inclusive
87
- if (newTo !== undefined) {
88
- newTo--;
89
- }
61
+ // make it non-inclusive
62
+ if (newTo !== undefined) {
63
+ newTo--;
64
+ }
90
65
 
91
- // return empty array if range reversed
92
- if (newFrom !== undefined && newTo !== undefined && newFrom > newTo) {
93
- return [];
94
- }
95
- return decorations.find(newFrom, newTo, spec => spec.type === TYPE_NODE_DEC);
66
+ // return empty array if range reversed
67
+ if (newFrom !== undefined && newTo !== undefined && newFrom > newTo) {
68
+ return [];
96
69
  }
70
+ return decorations.find(newFrom, newTo, spec => spec.type === TYPE_NODE_DEC);
97
71
  };
98
72
  export const nodeDecorations = (newState, from, to) => {
99
73
  const decs = [];
@@ -108,12 +82,6 @@ export const nodeDecorations = (newState, from, to) => {
108
82
  const shouldDescend = shouldDescendIntoNode(node);
109
83
  const anchorName = getNodeAnchor(node);
110
84
  const nodeTypeWithLevel = getNodeTypeWithLevel(node);
111
- if (editorExperiment('platform_editor_block_control_optimise_render', true)) {
112
- // We don't want to create decorations for nodes that start outside of the provided position range
113
- if (pos < getPositionBeforeNodeAtPos(newState, docFrom)) {
114
- return shouldDescend;
115
- }
116
- }
117
85
 
118
86
  // Doesn't descend into a node
119
87
  if (node.isInline) {
@@ -34,11 +34,7 @@ export const dragHandleDecoration = ({
34
34
  anchorRectCache,
35
35
  editorState
36
36
  }) => {
37
- if (!editorExperiment('platform_editor_block_control_optimise_render', true, {
38
- exposure: true
39
- })) {
40
- unmountDecorations(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
41
- }
37
+ unmountDecorations(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
42
38
  let unbind;
43
39
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
44
40
  const key = uuid();
@@ -55,9 +51,6 @@ export const dragHandleDecoration = ({
55
51
  marks: expValEquals('platform_editor_clean_up_widget_mark_logic', 'isEnabled', true) ? [] : getActiveBlockMarks(editorState, pos),
56
52
  destroy: node => {
57
53
  unbind && unbind();
58
- if (editorExperiment('platform_editor_block_control_optimise_render', true) && node instanceof HTMLElement) {
59
- ReactDOM.unmountComponentAtNode(node);
60
- }
61
54
  }
62
55
  } : {
63
56
  side: -1,
@@ -67,9 +60,6 @@ export const dragHandleDecoration = ({
67
60
  marks: expValEquals('platform_editor_clean_up_widget_mark_logic', 'isEnabled', true) ? [] : expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? getActiveBlockMarks(editorState, pos) : undefined,
68
61
  destroy: node => {
69
62
  unbind && unbind();
70
- if (editorExperiment('platform_editor_block_control_optimise_render', true) && node instanceof HTMLElement) {
71
- ReactDOM.unmountComponentAtNode(node);
72
- }
73
63
  }
74
64
  };
75
65
  return Decoration.widget(pos, (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
  const TYPE_QUICK_INSERT = 'INSERT_BUTTON';
12
11
  export const findQuickInsertInsertButtonDecoration = (decorations, from, to) => {
13
12
  return decorations.find(from, to, spec => spec.type === TYPE_QUICK_INSERT);
@@ -70,23 +69,6 @@ export const quickInsertButtonDecoration = ({
70
69
  element.setAttribute('data-blocks-quick-insert-button', 'true');
71
70
  }
72
71
  element.setAttribute('data-testid', 'block-ctrl-quick-insert-button');
73
- if (editorExperiment('platform_editor_block_control_optimise_render', true, {
74
- exposure: true
75
- })) {
76
- const vanillaElement = createVanillaButton({
77
- formatMessage,
78
- api,
79
- view,
80
- getPos,
81
- cleanupCallbacks,
82
- rootAnchorName: rootAnchorName !== null && rootAnchorName !== void 0 ? rootAnchorName : nodeType,
83
- anchorName,
84
- rootNodeType: rootNodeType !== null && rootNodeType !== void 0 ? rootNodeType : nodeType,
85
- anchorRectCache
86
- });
87
- element.appendChild(vanillaElement);
88
- return element;
89
- }
90
72
  nodeViewPortalProviderAPI.render(() => /*#__PURE__*/createElement(QuickInsertWithVisibility, {
91
73
  api,
92
74
  getPos,
@@ -224,7 +224,7 @@ export const getDecorations = state => {
224
224
  };
225
225
  const getDecorationAtPos = (state, decorations, pos, to) => {
226
226
  // Find the newly minted node decs that touch the active node
227
- const findNewNodeDecs = findNodeDecs(state, decorations, editorExperiment('platform_editor_block_control_optimise_render', true) ? pos : pos - 1, to);
227
+ const findNewNodeDecs = findNodeDecs(state, decorations, pos - 1, to);
228
228
 
229
229
  // Find the specific dec that the active node corresponds to
230
230
  const nodeDecsAtActivePos = findNewNodeDecs.filter(dec => (dec === null || dec === void 0 ? void 0 : dec.from) === pos);
@@ -369,7 +369,7 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
369
369
  if (!flags.toolbarFlagsEnabled) {
370
370
  if (latestActiveNode && !isActiveNodeDeleted) {
371
371
  // Find the newly minted node decs that touch the active node
372
- const findNewNodeDecs = findNodeDecs(newState, decorations, editorExperiment('platform_editor_block_control_optimise_render', true) ? latestActiveNode.pos : latestActiveNode.pos - 1, to);
372
+ const findNewNodeDecs = findNodeDecs(newState, decorations, latestActiveNode.pos - 1, to);
373
373
 
374
374
  // Find the specific dec that the active node corresponds to
375
375
  const nodeDecsAtActivePos = findNewNodeDecs.filter(dec => (dec === null || dec === void 0 ? void 0 : dec.from) === latestActiveNode.pos);