@atlaskit/editor-plugin-block-controls 2.4.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 2.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9bbad837abcb7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9bbad837abcb7) -
8
+ [ux] ED-25119 Fix content shifting on drag if divider or media nested in panel
9
+ - [#151581](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/151581)
10
+ [`5a182ebfe8da5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5a182ebfe8da5) -
11
+ [ux] Fix jittering issue in layout node when there is alignment or indentation applied
12
+
3
13
  ## 2.4.0
4
14
 
5
15
  ### Minor Changes
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.topPositionAdjustment = exports.spaceLookupMap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dragHandleGap = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
7
+ exports.topPositionAdjustment = exports.spaceLookupMap = exports.nodeMargins = exports.getNestedNodeLeftPaddingMargin = exports.dropTargetMarginMap = exports.dragHandleGap = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_NARROW_GAP = exports.DRAG_HANDLE_MAX_WIDTH_PLUS_GAP = exports.DRAG_HANDLE_MAX_GAP = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DEFAULT_GAP = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
10
10
  var _dropTargetMarginMap;
@@ -57,7 +57,7 @@ var topPositionAdjustment = exports.topPositionAdjustment = function topPosition
57
57
  return 0;
58
58
  }
59
59
  };
60
- var dropTargetMarginMap = (_dropTargetMarginMap = {}, (0, _defineProperty2.default)(_dropTargetMarginMap, -24, "var(--ds-space-negative-300, -24px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -20, "var(--ds-space-negative-250, -20px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -16, "var(--ds-space-negative-200, -16px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -12, "var(--ds-space-negative-150, -12px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -8, "var(--ds-space-negative-100, -8px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -6, "var(--ds-space-negative-075, -6px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -4, "var(--ds-space-negative-050, -4px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -2, "var(--ds-space-negative-025, -2px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 0, "var(--ds-space-0, 0)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 2, "var(--ds-space-025, 2px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 4, "var(--ds-space-050, 4px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 6, "var(--ds-space-075, 6px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 8, "var(--ds-space-100, 8px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 12, "var(--ds-space-150, 12px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 16, "var(--ds-space-200, 16px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 20, "var(--ds-space-250, 20px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 24, "var(--ds-space-300, 24px)"), _dropTargetMarginMap);
60
+ var dropTargetMarginMap = exports.dropTargetMarginMap = (_dropTargetMarginMap = {}, (0, _defineProperty2.default)(_dropTargetMarginMap, -24, "var(--ds-space-negative-300, -24px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -20, "var(--ds-space-negative-250, -20px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -16, "var(--ds-space-negative-200, -16px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -12, "var(--ds-space-negative-150, -12px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -8, "var(--ds-space-negative-100, -8px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -6, "var(--ds-space-negative-075, -6px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -4, "var(--ds-space-negative-050, -4px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, -2, "var(--ds-space-negative-025, -2px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 0, "var(--ds-space-0, 0)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 2, "var(--ds-space-025, 2px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 4, "var(--ds-space-050, 4px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 6, "var(--ds-space-075, 6px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 8, "var(--ds-space-100, 8px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 12, "var(--ds-space-150, 12px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 16, "var(--ds-space-200, 16px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 20, "var(--ds-space-250, 20px)"), (0, _defineProperty2.default)(_dropTargetMarginMap, 24, "var(--ds-space-300, 24px)"), _dropTargetMarginMap);
61
61
 
62
62
  /**
63
63
  * This document serves as a quick reference map for correlating various space matches
@@ -122,6 +122,10 @@ var nodeMargins = exports.nodeMargins = {
122
122
  top: 24,
123
123
  bottom: 24
124
124
  },
125
+ media: {
126
+ top: 24,
127
+ bottom: 24
128
+ },
125
129
  bodiedExtension: {
126
130
  top: 0,
127
131
  bottom: 0
@@ -10,6 +10,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
10
10
  var _react = require("react");
11
11
  var _react2 = require("@emotion/react");
12
12
  var _hooks = require("@atlaskit/editor-common/hooks");
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _box = require("@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box");
14
15
  var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
15
16
  var _constants = require("@atlaskit/theme/constants");
@@ -66,6 +67,24 @@ var getNodeMargins = function getNodeMargins(node) {
66
67
  }
67
68
  return _consts.nodeMargins[nodeTypeName] || _consts.nodeMargins['default'];
68
69
  };
70
+ var getNestedDropTargetMarginTop = function getNestedDropTargetMarginTop(prevNode, nextNode, isNestedDropTarget) {
71
+ if (!prevNode || !nextNode) {
72
+ return (0, _react2.css)({
73
+ marginTop: "var(--ds-space-negative-100, -8px)"
74
+ });
75
+ }
76
+ var top = getNodeMargins(nextNode).top;
77
+ var bottom = getNodeMargins(prevNode).bottom;
78
+ if (['rule', 'media', 'mediaSingle'].includes(prevNode.type.name) && isNestedDropTarget && top > 0 && bottom > 0) {
79
+ var collapsedMarginOffset = top === bottom ? top : Math.abs(top - bottom);
80
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
81
+ var marginTop = _consts.dropTargetMarginMap[-collapsedMarginOffset - 8] || "-".concat(collapsedMarginOffset + 8, "px");
82
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
83
+ return (0, _react2.css)({
84
+ marginTop: marginTop
85
+ });
86
+ }
87
+ };
69
88
  var getDropTargetOffsetStyle = function getDropTargetOffsetStyle(prevNode, nextNode) {
70
89
  if (!prevNode || !nextNode) {
71
90
  return null;
@@ -159,14 +178,23 @@ var DropTarget = exports.DropTarget = function DropTarget(_ref3) {
159
178
  }
160
179
  return getDropTargetOffsetStyle(prevNode, nextNode);
161
180
  }, [prevNode, nextNode, parentNode]);
181
+ var dropTargetMarginTopStyles = (0, _react.useMemo)(function () {
182
+ if (parentNode === prevNode) {
183
+ return null;
184
+ }
185
+ return getNestedDropTargetMarginTop(prevNode, nextNode, isNestedDropTarget);
186
+ }, [prevNode, nextNode, parentNode, isNestedDropTarget]);
162
187
  var dynamicStyle = (_dynamicStyle = {
163
188
  width: isNestedDropTarget ? 'unset' : '100%'
164
189
  }, (0, _defineProperty2.default)(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat((widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH, "px")), (0, _defineProperty2.default)(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, isNestedDropTarget ? (0, _consts.getNestedNodeLeftPaddingMargin)(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), (0, _defineProperty2.default)(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, (0, _experiments.editorExperiment)('nested-dnd', true) ? _constants.layers.navigation() : _constants.layers.card()), _dynamicStyle);
165
190
  return (
166
191
  // Note: Firefox has trouble with using a button element as the handle for drag and drop
167
192
  (0, _react2.jsx)("div", {
193
+ css: [styleDropTarget,
194
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
195
+ dropTargetOffsetStyle, isNestedDropTarget && nestedDropIndicatorStyle,
168
196
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
169
- css: [styleDropTarget, dropTargetOffsetStyle, isNestedDropTarget && nestedDropIndicatorStyle]
197
+ (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_2') && dropTargetMarginTopStyles]
170
198
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
171
199
  ,
172
200
  style: dynamicStyle,
@@ -110,6 +110,7 @@ var indentatedParagraphWithTrailingBreakAsOnlyChild = '+ div.fabric-editor-inden
110
110
  var paragraphWithPlaceholder = '+ p > .placeholder-decoration';
111
111
  var dragHandleContainer = '.ProseMirror-widget[data-blocks-drag-handle-container="true"]';
112
112
  var dragHandleSelector = 'button[data-testid="block-ctrl-drag-handle"]';
113
+ var dropTargetContainer = '.ProseMirror-widget[data-blocks-drop-target-container="true"]';
113
114
  var withInlineNodeStyleSelectors = [".ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(".concat(paragraphWithTrailingBreakAsOnlyChild, ")"), ".ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(".concat(indentatedParagraphWithTrailingBreakAsOnlyChild, ")"), ".ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(".concat(paragraphWithPlaceholder, ")")].join(', ');
114
115
  var dividerBodiedInCustomPanelWithNoIconSelector = '[data-panel-type].ak-editor-panel__no-icon .ProseMirror-widget:first-child + .ProseMirror-widget:nth-child(2) + hr, [data-panel-type] hr:first-child';
115
116
  var withInlineNodeStyle = (0, _react.css)((0, _defineProperty2.default)({}, withInlineNodeStyleSelectors, {
@@ -117,6 +118,8 @@ var withInlineNodeStyle = (0, _react.css)((0, _defineProperty2.default)({}, with
117
118
  display: 'none !important'
118
119
  }));
119
120
  var withInlineNodeStyleWithChromeFixSelectors = ["".concat(dragHandleContainer, ":has(").concat(paragraphWithTrailingBreakAsOnlyChild, ") ").concat(dragHandleSelector), "".concat(dragHandleContainer, ":has(").concat(indentatedParagraphWithTrailingBreakAsOnlyChild, ") ").concat(dragHandleSelector), "".concat(dragHandleContainer, ":has(").concat(paragraphWithPlaceholder, ") ").concat(dragHandleSelector)].join(', ');
121
+ var withFormatInLayoutStyleFixSelectors = ["".concat(dragHandleContainer, ":first-child + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + .fabric-editor-alignment > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-alignment > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-alignment > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-indentation-mark > p:first-child")].join(', ');
122
+
120
123
  /**
121
124
  * Please do not change change transform to display:none, or visibility:hidden
122
125
  * Otherwise it might break composition input for Chrome
@@ -153,6 +156,10 @@ var withMediaSingleStyleFix = (0, _react.css)((0, _defineProperty2.default)({},
153
156
  userSelect: 'auto',
154
157
  cursor: 'pointer'
155
158
  }));
159
+ var withFormatInLayoutStyleFix = (0, _react.css)((0, _defineProperty2.default)({}, "".concat(withFormatInLayoutStyleFixSelectors), {
160
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
161
+ marginTop: '0 !important'
162
+ }));
156
163
  var getTextNodeStyle = function getTextNodeStyle() {
157
164
  return (0, _platformFeatureFlags.fg)('platform_editor_element_controls_chrome_input_fix') ? withInlineNodeStyleWithChromeFix : withInlineNodeStyle;
158
165
  };
@@ -160,6 +167,6 @@ var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWra
160
167
  return (0, _react.jsx)(_react.Global, {
161
168
  styles: [globalStyles, (0, _experiments.editorExperiment)('nested-dnd', true) ? extendedHoverZoneNested : extendedHoverZone, getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, (0, _experiments.editorExperiment)('platform_editor_empty_line_prompt', true, {
162
169
  exposure: false
163
- }) ? _globalStyles.emptyBlockExperimentGlobalStyles : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined]
170
+ }) ? _globalStyles.emptyBlockExperimentGlobalStyles : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined]
164
171
  });
165
172
  };
@@ -48,7 +48,7 @@ export const topPositionAdjustment = nodeType => {
48
48
  return 0;
49
49
  }
50
50
  };
51
- const dropTargetMarginMap = {
51
+ export const dropTargetMarginMap = {
52
52
  [-24]: "var(--ds-space-negative-300, -24px)",
53
53
  [-20]: "var(--ds-space-negative-250, -20px)",
54
54
  [-16]: "var(--ds-space-negative-200, -16px)",
@@ -131,6 +131,10 @@ export const nodeMargins = {
131
131
  top: 24,
132
132
  bottom: 24
133
133
  },
134
+ media: {
135
+ top: 24,
136
+ bottom: 24
137
+ },
134
138
  bodiedExtension: {
135
139
  top: 0,
136
140
  bottom: 0
@@ -7,12 +7,13 @@ import { useEffect, useMemo, useRef, useState } from 'react';
7
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
10
11
  import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
11
12
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
12
13
  import { layers } from '@atlaskit/theme/constants';
13
14
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
14
15
  import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
15
- import { getNestedNodeLeftPaddingMargin, nodeMargins, spaceLookupMap } from './consts';
16
+ import { dropTargetMarginMap, getNestedNodeLeftPaddingMargin, nodeMargins, spaceLookupMap } from './consts';
16
17
  const DEFAULT_DROP_INDICATOR_WIDTH = 760;
17
18
  const EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH = '--editor-block-controls-drop-indicator-width';
18
19
  const EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN = '--editor-block-controls-drop-target-leftMargin';
@@ -51,6 +52,24 @@ const getNodeMargins = node => {
51
52
  }
52
53
  return nodeMargins[nodeTypeName] || nodeMargins['default'];
53
54
  };
55
+ const getNestedDropTargetMarginTop = (prevNode, nextNode, isNestedDropTarget) => {
56
+ if (!prevNode || !nextNode) {
57
+ return css({
58
+ marginTop: "var(--ds-space-negative-100, -8px)"
59
+ });
60
+ }
61
+ const top = getNodeMargins(nextNode).top;
62
+ const bottom = getNodeMargins(prevNode).bottom;
63
+ if (['rule', 'media', 'mediaSingle'].includes(prevNode.type.name) && isNestedDropTarget && top > 0 && bottom > 0) {
64
+ const collapsedMarginOffset = top === bottom ? top : Math.abs(top - bottom);
65
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
66
+ const marginTop = dropTargetMarginMap[-collapsedMarginOffset - 8] || `-${collapsedMarginOffset + 8}px`;
67
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
68
+ return css({
69
+ marginTop
70
+ });
71
+ }
72
+ };
54
73
  const getDropTargetOffsetStyle = (prevNode, nextNode) => {
55
74
  if (!prevNode || !nextNode) {
56
75
  return null;
@@ -145,6 +164,12 @@ export const DropTarget = ({
145
164
  }
146
165
  return getDropTargetOffsetStyle(prevNode, nextNode);
147
166
  }, [prevNode, nextNode, parentNode]);
167
+ const dropTargetMarginTopStyles = useMemo(() => {
168
+ if (parentNode === prevNode) {
169
+ return null;
170
+ }
171
+ return getNestedDropTargetMarginTop(prevNode, nextNode, isNestedDropTarget);
172
+ }, [prevNode, nextNode, parentNode, isNestedDropTarget]);
148
173
  const dynamicStyle = {
149
174
  width: isNestedDropTarget ? 'unset' : '100%',
150
175
  [EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH]: isNestedDropTarget ? '100%' : `${(widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH}px`,
@@ -154,8 +179,11 @@ export const DropTarget = ({
154
179
  return (
155
180
  // Note: Firefox has trouble with using a button element as the handle for drag and drop
156
181
  jsx("div", {
182
+ css: [styleDropTarget,
183
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
184
+ dropTargetOffsetStyle, isNestedDropTarget && nestedDropIndicatorStyle,
157
185
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
158
- css: [styleDropTarget, dropTargetOffsetStyle, isNestedDropTarget && nestedDropIndicatorStyle]
186
+ fg('platform_editor_element_dnd_nested_fix_patch_2') && dropTargetMarginTopStyles]
159
187
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
160
188
  ,
161
189
  style: dynamicStyle,
@@ -101,6 +101,7 @@ const indentatedParagraphWithTrailingBreakAsOnlyChild = '+ div.fabric-editor-ind
101
101
  const paragraphWithPlaceholder = '+ p > .placeholder-decoration';
102
102
  const dragHandleContainer = '.ProseMirror-widget[data-blocks-drag-handle-container="true"]';
103
103
  const dragHandleSelector = 'button[data-testid="block-ctrl-drag-handle"]';
104
+ const dropTargetContainer = '.ProseMirror-widget[data-blocks-drop-target-container="true"]';
104
105
  const withInlineNodeStyleSelectors = [`.ProseMirror-widget[data-blocks-drag-handle-container="true"]:has(${paragraphWithTrailingBreakAsOnlyChild})`, `.ProseMirror-widget[data-blocks-drag-handle-container="true"]:has(${indentatedParagraphWithTrailingBreakAsOnlyChild})`, `.ProseMirror-widget[data-blocks-drag-handle-container="true"]:has(${paragraphWithPlaceholder})`].join(', ');
105
106
  const dividerBodiedInCustomPanelWithNoIconSelector = '[data-panel-type].ak-editor-panel__no-icon .ProseMirror-widget:first-child + .ProseMirror-widget:nth-child(2) + hr, [data-panel-type] hr:first-child';
106
107
  const withInlineNodeStyle = css({
@@ -111,6 +112,8 @@ const withInlineNodeStyle = css({
111
112
  }
112
113
  });
113
114
  const withInlineNodeStyleWithChromeFixSelectors = [`${dragHandleContainer}:has(${paragraphWithTrailingBreakAsOnlyChild}) ${dragHandleSelector}`, `${dragHandleContainer}:has(${indentatedParagraphWithTrailingBreakAsOnlyChild}) ${dragHandleSelector}`, `${dragHandleContainer}:has(${paragraphWithPlaceholder}) ${dragHandleSelector}`].join(', ');
115
+ const withFormatInLayoutStyleFixSelectors = [`${dragHandleContainer}:first-child + .fabric-editor-indentation-mark > p:first-child`, `${dragHandleContainer}:first-child + .fabric-editor-alignment > p:first-child`, `${dragHandleContainer}:first-child + ${dropTargetContainer} + .fabric-editor-indentation-mark > p:first-child`, `${dragHandleContainer}:first-child + ${dropTargetContainer} + .fabric-editor-alignment > p:first-child`, `${dropTargetContainer}:first-child + .fabric-editor-alignment > p:first-child`, `${dropTargetContainer}:first-child + .fabric-editor-indentation-mark > p:first-child`].join(', ');
116
+
114
117
  /**
115
118
  * Please do not change change transform to display:none, or visibility:hidden
116
119
  * Otherwise it might break composition input for Chrome
@@ -159,6 +162,13 @@ const withMediaSingleStyleFix = css({
159
162
  cursor: 'pointer'
160
163
  }
161
164
  });
165
+ const withFormatInLayoutStyleFix = css({
166
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
167
+ [`${withFormatInLayoutStyleFixSelectors}`]: {
168
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
169
+ marginTop: '0 !important'
170
+ }
171
+ });
162
172
  const getTextNodeStyle = () => {
163
173
  return fg('platform_editor_element_controls_chrome_input_fix') ? withInlineNodeStyleWithChromeFix : withInlineNodeStyle;
164
174
  };
@@ -166,6 +176,6 @@ export const GlobalStylesWrapper = () => {
166
176
  return jsx(Global, {
167
177
  styles: [globalStyles, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested : extendedHoverZone, getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, editorExperiment('platform_editor_empty_line_prompt', true, {
168
178
  exposure: false
169
- }) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined]
179
+ }) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined]
170
180
  });
171
181
  };
@@ -50,7 +50,7 @@ export var topPositionAdjustment = function topPositionAdjustment(nodeType) {
50
50
  return 0;
51
51
  }
52
52
  };
53
- var dropTargetMarginMap = (_dropTargetMarginMap = {}, _defineProperty(_dropTargetMarginMap, -24, "var(--ds-space-negative-300, -24px)"), _defineProperty(_dropTargetMarginMap, -20, "var(--ds-space-negative-250, -20px)"), _defineProperty(_dropTargetMarginMap, -16, "var(--ds-space-negative-200, -16px)"), _defineProperty(_dropTargetMarginMap, -12, "var(--ds-space-negative-150, -12px)"), _defineProperty(_dropTargetMarginMap, -8, "var(--ds-space-negative-100, -8px)"), _defineProperty(_dropTargetMarginMap, -6, "var(--ds-space-negative-075, -6px)"), _defineProperty(_dropTargetMarginMap, -4, "var(--ds-space-negative-050, -4px)"), _defineProperty(_dropTargetMarginMap, -2, "var(--ds-space-negative-025, -2px)"), _defineProperty(_dropTargetMarginMap, 0, "var(--ds-space-0, 0)"), _defineProperty(_dropTargetMarginMap, 2, "var(--ds-space-025, 2px)"), _defineProperty(_dropTargetMarginMap, 4, "var(--ds-space-050, 4px)"), _defineProperty(_dropTargetMarginMap, 6, "var(--ds-space-075, 6px)"), _defineProperty(_dropTargetMarginMap, 8, "var(--ds-space-100, 8px)"), _defineProperty(_dropTargetMarginMap, 12, "var(--ds-space-150, 12px)"), _defineProperty(_dropTargetMarginMap, 16, "var(--ds-space-200, 16px)"), _defineProperty(_dropTargetMarginMap, 20, "var(--ds-space-250, 20px)"), _defineProperty(_dropTargetMarginMap, 24, "var(--ds-space-300, 24px)"), _dropTargetMarginMap);
53
+ export var dropTargetMarginMap = (_dropTargetMarginMap = {}, _defineProperty(_dropTargetMarginMap, -24, "var(--ds-space-negative-300, -24px)"), _defineProperty(_dropTargetMarginMap, -20, "var(--ds-space-negative-250, -20px)"), _defineProperty(_dropTargetMarginMap, -16, "var(--ds-space-negative-200, -16px)"), _defineProperty(_dropTargetMarginMap, -12, "var(--ds-space-negative-150, -12px)"), _defineProperty(_dropTargetMarginMap, -8, "var(--ds-space-negative-100, -8px)"), _defineProperty(_dropTargetMarginMap, -6, "var(--ds-space-negative-075, -6px)"), _defineProperty(_dropTargetMarginMap, -4, "var(--ds-space-negative-050, -4px)"), _defineProperty(_dropTargetMarginMap, -2, "var(--ds-space-negative-025, -2px)"), _defineProperty(_dropTargetMarginMap, 0, "var(--ds-space-0, 0)"), _defineProperty(_dropTargetMarginMap, 2, "var(--ds-space-025, 2px)"), _defineProperty(_dropTargetMarginMap, 4, "var(--ds-space-050, 4px)"), _defineProperty(_dropTargetMarginMap, 6, "var(--ds-space-075, 6px)"), _defineProperty(_dropTargetMarginMap, 8, "var(--ds-space-100, 8px)"), _defineProperty(_dropTargetMarginMap, 12, "var(--ds-space-150, 12px)"), _defineProperty(_dropTargetMarginMap, 16, "var(--ds-space-200, 16px)"), _defineProperty(_dropTargetMarginMap, 20, "var(--ds-space-250, 20px)"), _defineProperty(_dropTargetMarginMap, 24, "var(--ds-space-300, 24px)"), _dropTargetMarginMap);
54
54
 
55
55
  /**
56
56
  * This document serves as a quick reference map for correlating various space matches
@@ -115,6 +115,10 @@ export var nodeMargins = {
115
115
  top: 24,
116
116
  bottom: 24
117
117
  },
118
+ media: {
119
+ top: 24,
120
+ bottom: 24
121
+ },
118
122
  bodiedExtension: {
119
123
  top: 0,
120
124
  bottom: 0
@@ -9,12 +9,13 @@ import { useEffect, useMemo, useRef, useState } from 'react';
9
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
10
10
  import { css, jsx } from '@emotion/react';
11
11
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
12
+ import { fg } from '@atlaskit/platform-feature-flags';
12
13
  import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
13
14
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
14
15
  import { layers } from '@atlaskit/theme/constants';
15
16
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
16
17
  import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
17
- import { getNestedNodeLeftPaddingMargin, nodeMargins, spaceLookupMap } from './consts';
18
+ import { dropTargetMarginMap, getNestedNodeLeftPaddingMargin, nodeMargins, spaceLookupMap } from './consts';
18
19
  var DEFAULT_DROP_INDICATOR_WIDTH = 760;
19
20
  var EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH = '--editor-block-controls-drop-indicator-width';
20
21
  var EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN = '--editor-block-controls-drop-target-leftMargin';
@@ -58,6 +59,24 @@ var getNodeMargins = function getNodeMargins(node) {
58
59
  }
59
60
  return nodeMargins[nodeTypeName] || nodeMargins['default'];
60
61
  };
62
+ var getNestedDropTargetMarginTop = function getNestedDropTargetMarginTop(prevNode, nextNode, isNestedDropTarget) {
63
+ if (!prevNode || !nextNode) {
64
+ return css({
65
+ marginTop: "var(--ds-space-negative-100, -8px)"
66
+ });
67
+ }
68
+ var top = getNodeMargins(nextNode).top;
69
+ var bottom = getNodeMargins(prevNode).bottom;
70
+ if (['rule', 'media', 'mediaSingle'].includes(prevNode.type.name) && isNestedDropTarget && top > 0 && bottom > 0) {
71
+ var collapsedMarginOffset = top === bottom ? top : Math.abs(top - bottom);
72
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
73
+ var marginTop = dropTargetMarginMap[-collapsedMarginOffset - 8] || "-".concat(collapsedMarginOffset + 8, "px");
74
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
75
+ return css({
76
+ marginTop: marginTop
77
+ });
78
+ }
79
+ };
61
80
  var getDropTargetOffsetStyle = function getDropTargetOffsetStyle(prevNode, nextNode) {
62
81
  if (!prevNode || !nextNode) {
63
82
  return null;
@@ -151,14 +170,23 @@ export var DropTarget = function DropTarget(_ref3) {
151
170
  }
152
171
  return getDropTargetOffsetStyle(prevNode, nextNode);
153
172
  }, [prevNode, nextNode, parentNode]);
173
+ var dropTargetMarginTopStyles = useMemo(function () {
174
+ if (parentNode === prevNode) {
175
+ return null;
176
+ }
177
+ return getNestedDropTargetMarginTop(prevNode, nextNode, isNestedDropTarget);
178
+ }, [prevNode, nextNode, parentNode, isNestedDropTarget]);
154
179
  var dynamicStyle = (_dynamicStyle = {
155
180
  width: isNestedDropTarget ? 'unset' : '100%'
156
181
  }, _defineProperty(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat((widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH, "px")), _defineProperty(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, isNestedDropTarget ? getNestedNodeLeftPaddingMargin(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), _defineProperty(_dynamicStyle, EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, editorExperiment('nested-dnd', true) ? layers.navigation() : layers.card()), _dynamicStyle);
157
182
  return (
158
183
  // Note: Firefox has trouble with using a button element as the handle for drag and drop
159
184
  jsx("div", {
185
+ css: [styleDropTarget,
186
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
187
+ dropTargetOffsetStyle, isNestedDropTarget && nestedDropIndicatorStyle,
160
188
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
161
- css: [styleDropTarget, dropTargetOffsetStyle, isNestedDropTarget && nestedDropIndicatorStyle]
189
+ fg('platform_editor_element_dnd_nested_fix_patch_2') && dropTargetMarginTopStyles]
162
190
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
163
191
  ,
164
192
  style: dynamicStyle,
@@ -102,6 +102,7 @@ var indentatedParagraphWithTrailingBreakAsOnlyChild = '+ div.fabric-editor-inden
102
102
  var paragraphWithPlaceholder = '+ p > .placeholder-decoration';
103
103
  var dragHandleContainer = '.ProseMirror-widget[data-blocks-drag-handle-container="true"]';
104
104
  var dragHandleSelector = 'button[data-testid="block-ctrl-drag-handle"]';
105
+ var dropTargetContainer = '.ProseMirror-widget[data-blocks-drop-target-container="true"]';
105
106
  var withInlineNodeStyleSelectors = [".ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(".concat(paragraphWithTrailingBreakAsOnlyChild, ")"), ".ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(".concat(indentatedParagraphWithTrailingBreakAsOnlyChild, ")"), ".ProseMirror-widget[data-blocks-drag-handle-container=\"true\"]:has(".concat(paragraphWithPlaceholder, ")")].join(', ');
106
107
  var dividerBodiedInCustomPanelWithNoIconSelector = '[data-panel-type].ak-editor-panel__no-icon .ProseMirror-widget:first-child + .ProseMirror-widget:nth-child(2) + hr, [data-panel-type] hr:first-child';
107
108
  var withInlineNodeStyle = css(_defineProperty({}, withInlineNodeStyleSelectors, {
@@ -109,6 +110,8 @@ var withInlineNodeStyle = css(_defineProperty({}, withInlineNodeStyleSelectors,
109
110
  display: 'none !important'
110
111
  }));
111
112
  var withInlineNodeStyleWithChromeFixSelectors = ["".concat(dragHandleContainer, ":has(").concat(paragraphWithTrailingBreakAsOnlyChild, ") ").concat(dragHandleSelector), "".concat(dragHandleContainer, ":has(").concat(indentatedParagraphWithTrailingBreakAsOnlyChild, ") ").concat(dragHandleSelector), "".concat(dragHandleContainer, ":has(").concat(paragraphWithPlaceholder, ") ").concat(dragHandleSelector)].join(', ');
113
+ var withFormatInLayoutStyleFixSelectors = ["".concat(dragHandleContainer, ":first-child + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + .fabric-editor-alignment > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-indentation-mark > p:first-child"), "".concat(dragHandleContainer, ":first-child + ").concat(dropTargetContainer, " + .fabric-editor-alignment > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-alignment > p:first-child"), "".concat(dropTargetContainer, ":first-child + .fabric-editor-indentation-mark > p:first-child")].join(', ');
114
+
112
115
  /**
113
116
  * Please do not change change transform to display:none, or visibility:hidden
114
117
  * Otherwise it might break composition input for Chrome
@@ -145,6 +148,10 @@ var withMediaSingleStyleFix = css(_defineProperty({}, '.ProseMirror.ua-firefox .
145
148
  userSelect: 'auto',
146
149
  cursor: 'pointer'
147
150
  }));
151
+ var withFormatInLayoutStyleFix = css(_defineProperty({}, "".concat(withFormatInLayoutStyleFixSelectors), {
152
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
153
+ marginTop: '0 !important'
154
+ }));
148
155
  var getTextNodeStyle = function getTextNodeStyle() {
149
156
  return fg('platform_editor_element_controls_chrome_input_fix') ? withInlineNodeStyleWithChromeFix : withInlineNodeStyle;
150
157
  };
@@ -152,6 +159,6 @@ export var GlobalStylesWrapper = function GlobalStylesWrapper() {
152
159
  return jsx(Global, {
153
160
  styles: [globalStyles, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested : extendedHoverZone, getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, editorExperiment('platform_editor_empty_line_prompt', true, {
154
161
  exposure: false
155
- }) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined]
162
+ }) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined]
156
163
  });
157
164
  };
@@ -10,6 +10,9 @@ export declare const DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT: number;
10
10
  export declare const dragHandleGap: (nodeType: string, parentNodeType?: string) => 4 | 8 | 12;
11
11
  export declare const getNestedNodeLeftPaddingMargin: (nodeType?: string) => "8px" | "16px" | "20px" | "24px" | "28px" | "40px";
12
12
  export declare const topPositionAdjustment: (nodeType: string) => number;
13
+ export declare const dropTargetMarginMap: {
14
+ [key: number]: string;
15
+ };
13
16
  /**
14
17
  * This document serves as a quick reference map for correlating various space matches
15
18
  * to the table provided above.
@@ -10,6 +10,9 @@ export declare const DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT: number;
10
10
  export declare const dragHandleGap: (nodeType: string, parentNodeType?: string) => 4 | 8 | 12;
11
11
  export declare const getNestedNodeLeftPaddingMargin: (nodeType?: string) => "8px" | "16px" | "20px" | "24px" | "28px" | "40px";
12
12
  export declare const topPositionAdjustment: (nodeType: string) => number;
13
+ export declare const dropTargetMarginMap: {
14
+ [key: number]: string;
15
+ };
13
16
  /**
14
17
  * This document serves as a quick reference map for correlating various space matches
15
18
  * to the table provided above.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",