@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.
@@ -350,7 +350,6 @@ export const DragHandle = ({
350
350
  const [dragHandleSelected, setDragHandleSelected] = useState(false);
351
351
  const [dragHandleDisabled, setDragHandleDisabled] = useState(false);
352
352
  const [blockCardWidth, setBlockCardWidth] = useState(768);
353
- const [recalculatePosition, setRecalculatePosition] = useState(false);
354
353
  const [positionStylesOld, setPositionStylesOld] = useState({
355
354
  display: 'none'
356
355
  });
@@ -391,9 +390,6 @@ export const DragHandle = ({
391
390
  // just rely on the dynamic value (rename it to isTopLevelNode for simplicitiy)
392
391
  const isTopLevelNodeValue = expValEquals('platform_editor_nested_drag_handle_icon', 'isEnabled', true) ? isTopLevelNodeDynamic : isTopLevelNode;
393
392
  useEffect(() => {
394
- if (editorExperiment('platform_editor_block_control_optimise_render', true)) {
395
- return;
396
- }
397
393
  // blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
398
394
  if (nodeType === 'blockCard') {
399
395
  const dom = view.dom.querySelector(`[${getAnchorAttrName()}="${anchorName}"]`);
@@ -788,62 +784,6 @@ export const DragHandle = ({
788
784
  }
789
785
  });
790
786
  }, [anchorName, api, getPos, isMultiSelect, nodeType, start, view]);
791
- const positionStyles = useMemo(() => {
792
- if (!editorExperiment('platform_editor_block_control_optimise_render', true)) {
793
- return {};
794
- }
795
-
796
- // This is a no-op to allow recalculatePosition to be used as a dependency
797
- if (recalculatePosition) {
798
- setRecalculatePosition(recalculatePosition);
799
- }
800
- const pos = getPos();
801
- const $pos = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? typeof pos === 'number' && view.state.doc.resolve(pos) : pos && view.state.doc.resolve(pos);
802
- const parentPos = $pos && $pos.depth ? $pos.before() : undefined;
803
- const node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
804
- const parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
805
- const supportsAnchor = CSS.supports('top', `anchor(${anchorName} start)`) && CSS.supports('left', `anchor(${anchorName} start)`);
806
- const safeAnchorName = editorExperiment('platform_editor_controls', 'variant1') ? refreshAnchorName({
807
- getPos,
808
- view,
809
- anchorName
810
- }) : anchorName;
811
- const dom = view.dom.querySelector(`[${getAnchorAttrName()}="${safeAnchorName}"]`);
812
- const hasResizer = nodeType === 'table' || nodeType === 'mediaSingle';
813
- const isExtension = nodeType === 'extension' || nodeType === 'bodiedExtension' || nodeType === 'multiBodiedExtension';
814
- const isBlockCard = nodeType === 'blockCard';
815
- const isEmbedCard = nodeType === 'embedCard';
816
- const isMacroInteractionUpdates = macroInteractionUpdates && isExtension;
817
- let innerContainer = null;
818
- if (dom) {
819
- if (isEmbedCard) {
820
- innerContainer = dom.querySelector('.rich-media-item');
821
- } else if (hasResizer) {
822
- innerContainer = dom.querySelector('.resizer-item');
823
- } else if (isExtension) {
824
- innerContainer = dom.querySelector('.extension-container[data-layout]');
825
- } else if (isBlockCard) {
826
- //specific to datasource blockCard
827
- innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
828
- }
829
- }
830
- const isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
831
- const isSticky = shouldBeSticky(nodeType);
832
- if (supportsAnchor) {
833
- const bottom = editorExperiment('platform_editor_controls', 'variant1') ? getControlBottomCSSValue(safeAnchorName, isSticky, isTopLevelNodeValue, isLayoutColumn) : {};
834
- return {
835
- left: isEdgeCase ? `calc(anchor(${safeAnchorName} start) + ${getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType)})` : editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc((anchor(${safeAnchorName} right) + anchor(${safeAnchorName} left))/2 - ${DRAG_HANDLE_HEIGHT / 2}px)` : `calc(anchor(${safeAnchorName} start) - ${DRAG_HANDLE_WIDTH}px - ${dragHandleGap(nodeType, parentNodeType)}px)`,
836
- top: editorExperiment('advanced_layouts', true) && isLayoutColumn ? `calc(anchor(${safeAnchorName} top) - ${DRAG_HANDLE_WIDTH}px)` : `calc(anchor(${safeAnchorName} start) + ${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)`,
837
- ...bottom
838
- };
839
- }
840
- const height = editorExperiment('platform_editor_controls', 'variant1') ? getControlHeightCSSValue(getNodeHeight(dom, safeAnchorName, anchorRectCache) || 0, isSticky, isTopLevelNodeValue, `${DRAG_HANDLE_HEIGHT}`, isLayoutColumn) : {};
841
- return {
842
- left: isEdgeCase ? `calc(${(dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0}px + ${getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType)})` : getLeftPosition(dom, nodeType, innerContainer, isMacroInteractionUpdates, parentNodeType),
843
- top: getTopPosition(dom, nodeType),
844
- ...height
845
- };
846
- }, [anchorName, getPos, view, nodeType, macroInteractionUpdates, anchorRectCache, isTopLevelNodeValue, isLayoutColumn, recalculatePosition]);
847
787
  const calculatePositionOld = useCallback(() => {
848
788
  const pos = getPos();
849
789
  const $pos = expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? typeof pos === 'number' && view.state.doc.resolve(pos) : pos && view.state.doc.resolve(pos);
@@ -893,9 +833,6 @@ export const DragHandle = ({
893
833
  };
894
834
  }, [anchorName, getPos, view, nodeType, blockCardWidth, macroInteractionUpdates, anchorRectCache, isTopLevelNodeValue, isLayoutColumn]);
895
835
  useEffect(() => {
896
- if (editorExperiment('platform_editor_block_control_optimise_render', true)) {
897
- return;
898
- }
899
836
  let cleanUpTransitionListener;
900
837
  if (nodeType === 'extension' || nodeType === 'embedCard') {
901
838
  const dom = view.dom.querySelector(`[${getAnchorAttrName()}="${anchorName}"]`);
@@ -918,28 +855,6 @@ export const DragHandle = ({
918
855
  (_cleanUpTransitionLis = cleanUpTransitionListener) === null || _cleanUpTransitionLis === void 0 ? void 0 : _cleanUpTransitionLis();
919
856
  };
920
857
  }, [calculatePositionOld, view.dom, anchorName, nodeType]);
921
- useEffect(() => {
922
- if (!editorExperiment('platform_editor_block_control_optimise_render', true)) {
923
- return;
924
- }
925
- let cleanUpTransitionListener;
926
- if (nodeType === 'extension' || nodeType === 'embedCard') {
927
- const dom = view.dom.querySelector(`[${getAnchorAttrName()}="${anchorName}"]`);
928
- if (!dom) {
929
- return;
930
- }
931
- cleanUpTransitionListener = bind(dom, {
932
- type: 'transitionend',
933
- listener: () => {
934
- setRecalculatePosition(!recalculatePosition);
935
- }
936
- });
937
- }
938
- return () => {
939
- var _cleanUpTransitionLis2;
940
- (_cleanUpTransitionLis2 = cleanUpTransitionListener) === null || _cleanUpTransitionLis2 === void 0 ? void 0 : _cleanUpTransitionLis2();
941
- };
942
- }, [view, anchorName, nodeType, recalculatePosition]);
943
858
  useEffect(() => {
944
859
  if (handleOptions !== null && handleOptions !== void 0 && handleOptions.isFocused && buttonRef.current) {
945
860
  const id = requestAnimationFrame(() => {
@@ -948,9 +863,7 @@ export const DragHandle = ({
948
863
  });
949
864
  return () => {
950
865
  cancelAnimationFrame(id);
951
- if (!editorExperiment('platform_editor_block_control_optimise_render', true)) {
952
- view.focus();
953
- }
866
+ view.focus();
954
867
  };
955
868
  }
956
869
  }, [buttonRef, handleOptions === null || handleOptions === void 0 ? void 0 : handleOptions.isFocused, view]);
@@ -1065,7 +978,7 @@ export const DragHandle = ({
1065
978
  ref: buttonRef
1066
979
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
1067
980
  ,
1068
- style: !editorExperiment('platform_editor_controls', 'variant1') ? editorExperiment('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld : {},
981
+ style: !editorExperiment('platform_editor_controls', 'variant1') ? positionStylesOld : {},
1069
982
  onMouseDown: expValEqualsNoExposure('platform_editor_selection_toolbar_block_handle', 'isEnabled', true) ? handleMouseDown : undefined,
1070
983
  onMouseUp: editorExperiment('platform_editor_block_menu', true) ? handleMouseUp : undefined,
1071
984
  onClick: editorExperiment('platform_editor_block_menu', true) ? handleOnClickNew : handleOnClick,
@@ -1117,7 +1030,7 @@ export const DragHandle = ({
1117
1030
  const stickyWithTooltip = () => jsx(Box
1118
1031
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
1119
1032
  , {
1120
- style: editorExperiment('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld
1033
+ style: positionStylesOld
1121
1034
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
1122
1035
  ,
1123
1036
  xcss: [dragHandleContainerStyles],
@@ -1145,7 +1058,7 @@ export const DragHandle = ({
1145
1058
  const stickyWithoutTooltip = () => jsx(Box
1146
1059
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
1147
1060
  , {
1148
- style: editorExperiment('platform_editor_block_control_optimise_render', true) ? positionStyles : positionStylesOld
1061
+ style: positionStylesOld
1149
1062
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
1150
1063
  ,
1151
1064
  xcss: [dragHandleContainerStyles],
@@ -5,11 +5,10 @@
5
5
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports
6
6
  import { css, Global, jsx } from '@emotion/react';
7
7
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
8
- import { ANCHOR_VARIABLE_NAME, DRAG_HANDLE_WIDTH, isCSSAnchorSupported, tableControlsSpacing } from '@atlaskit/editor-common/styles';
8
+ import { ANCHOR_VARIABLE_NAME, DRAG_HANDLE_WIDTH, isCSSAnchorSupported } from '@atlaskit/editor-common/styles';
9
9
  import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
10
10
  import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
11
11
  import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport, akEditorFullPageNarrowBreakout, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced } from '@atlaskit/editor-shared-styles';
12
- import { layers } from '@atlaskit/theme/constants';
13
12
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
14
13
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
14
  import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP } from './consts';
@@ -301,87 +300,6 @@ const globalStyles = () => css({
301
300
  marginTop: '0 !important'
302
301
  }
303
302
  });
304
- const quickInsertStyles = () => css({
305
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
306
- '.blocks-quick-insert-button': {
307
- backgroundColor: 'transparent',
308
- top: `var(--top-override,8px)`,
309
- position: 'sticky',
310
- boxSizing: 'border-box',
311
- display: 'flex',
312
- flexDirection: 'column',
313
- justifyContent: 'center',
314
- alignItems: 'center',
315
- height: "var(--ds-space-300, 24px)",
316
- width: "var(--ds-space-300, 24px)",
317
- border: 'none',
318
- borderRadius: "var(--ds-radius-full, 9999px)",
319
- zIndex: layers.card(),
320
- outline: 'none',
321
- cursor: 'pointer',
322
- color: "var(--ds-icon-subtle, #505258)"
323
- },
324
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
325
- '[data-blocks-quick-insert-container]:has(~ [data-prosemirror-node-name="table"] .pm-table-with-controls tr.sticky) &': {
326
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
327
- '--top-override': `${tableControlsSpacing}px`
328
- },
329
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
330
- '[data-prosemirror-mark-name="breakout"]:has([data-blocks-quick-insert-container]):has(~ [data-prosemirror-node-name="table"] .pm-table-with-controls tr.sticky) &': {
331
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
332
- '--top-override': `${tableControlsSpacing}px`
333
- },
334
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
335
- '.blocks-quick-insert-button:hover': {
336
- backgroundColor: "var(--ds-background-neutral-subtle-hovered, #0515240F)"
337
- },
338
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
339
- '.blocks-quick-insert-button:active': {
340
- backgroundColor: "var(--ds-background-neutral-subtle-pressed, #0B120E24)"
341
- },
342
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
343
- '.blocks-quick-insert-button:focus': {
344
- outline: `${"var(--ds-border-width-focused, 2px)"} solid ${"var(--ds-border-focused, #4688EC)"}`
345
- },
346
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
347
- '.blocks-quick-insert-visible-container': {
348
- transition: 'opacity 0.1s ease-in-out, visibility 0.1s ease-in-out',
349
- opacity: 1,
350
- visibility: 'visible'
351
- },
352
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
353
- '.blocks-quick-insert-invisible-container': {
354
- transition: 'opacity 0.1s ease-in-out, visibility 0.1s ease-in-out',
355
- opacity: 0,
356
- visibility: 'hidden'
357
- },
358
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
359
- '.blocks-quick-insert-tooltip': {
360
- zIndex: layers.tooltip(),
361
- borderRadius: "var(--ds-radius-small, 4px)",
362
- padding: `${"var(--ds-space-050, 4px)"} 0`,
363
- boxSizing: 'border-box',
364
- maxWidth: '240px',
365
- backgroundColor: "var(--ds-background-neutral-bold, #292A2E)",
366
- color: "var(--ds-text-inverse, #FFFFFF)",
367
- 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)",
368
- insetBlockStart: "var(--ds-space-0, 0px)",
369
- insetInlineStart: "var(--ds-space-0, 0px)",
370
- overflowWrap: 'break-word',
371
- paddingBlockEnd: "var(--ds-space-025, 2px)",
372
- paddingBlockStart: "var(--ds-space-025, 2px)",
373
- paddingInlineEnd: "var(--ds-space-075, 6px)",
374
- paddingInlineStart: "var(--ds-space-075, 6px)",
375
- wordWrap: 'break-word',
376
- pointerEvents: 'none',
377
- userSelect: 'none',
378
- // Based on: platform/packages/design-system/motion/src/entering/keyframes-motion.tsx
379
- transition: 'opacity .1s ease-in-out, transform .1s ease-in-out, visibility .1s ease-in-out',
380
- '@media (prefers-reduced-motion: reduce)': {
381
- transition: 'none'
382
- }
383
- }
384
- });
385
303
  const topLevelNodeMarginStyles = css({
386
304
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
387
305
  '.ProseMirror': {
@@ -581,6 +499,6 @@ export const GlobalStylesWrapper = ({
581
499
  exposure: true
582
500
  }) ? expValEquals('platform_editor_native_anchor_with_dnd', 'isEnabled', true) ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
583
501
  // platform_editor_controls note: this allows drag handles to render on empty lines
584
- 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)]
502
+ 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)]
585
503
  });
586
504
  };
@@ -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,
@@ -224,7 +224,7 @@ export var getDecorations = function getDecorations(state) {
224
224
  };
225
225
  var getDecorationAtPos = function getDecorationAtPos(state, decorations, pos, to) {
226
226
  // 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);
227
+ var findNewNodeDecs = findNodeDecs(state, decorations, pos - 1, to);
228
228
 
229
229
  // Find the specific dec that the active node corresponds to
230
230
  var nodeDecsAtActivePos = findNewNodeDecs.filter(function (dec) {
@@ -371,7 +371,7 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
371
371
  if (!flags.toolbarFlagsEnabled) {
372
372
  if (latestActiveNode && !isActiveNodeDeleted) {
373
373
  // 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);
374
+ var findNewNodeDecs = findNodeDecs(newState, decorations, latestActiveNode.pos - 1, to);
375
375
 
376
376
  // Find the specific dec that the active node corresponds to
377
377
  var nodeDecsAtActivePos = findNewNodeDecs.filter(function (dec) {
@@ -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],