@atlaskit/editor-plugin-block-controls 2.13.4 → 2.13.7

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/cjs/commands/move-to-layout.js +2 -2
  3. package/dist/cjs/consts.js +5 -2
  4. package/dist/cjs/pm-plugins/decorations-anchor.js +2 -1
  5. package/dist/cjs/pm-plugins/decorations-drop-target.js +1 -1
  6. package/dist/cjs/pm-plugins/handle-mouse-over.js +13 -0
  7. package/dist/cjs/pm-plugins/main.js +3 -3
  8. package/dist/cjs/ui/drag-handle.js +10 -4
  9. package/dist/cjs/ui/global-styles.js +37 -3
  10. package/dist/cjs/utils/active-anchor-tracker.js +16 -5
  11. package/dist/cjs/utils/drag-handle-positions.js +3 -1
  12. package/dist/cjs/utils/getSelection.js +3 -3
  13. package/dist/cjs/utils/inline-drop-target.js +1 -1
  14. package/dist/es2019/commands/move-to-layout.js +3 -3
  15. package/dist/es2019/consts.js +4 -1
  16. package/dist/es2019/pm-plugins/decorations-anchor.js +2 -1
  17. package/dist/es2019/pm-plugins/decorations-drop-target.js +2 -2
  18. package/dist/es2019/pm-plugins/handle-mouse-over.js +13 -0
  19. package/dist/es2019/pm-plugins/main.js +3 -3
  20. package/dist/es2019/ui/drag-handle.js +10 -4
  21. package/dist/es2019/ui/global-styles.js +38 -4
  22. package/dist/es2019/utils/active-anchor-tracker.js +17 -4
  23. package/dist/es2019/utils/drag-handle-positions.js +4 -2
  24. package/dist/es2019/utils/getSelection.js +3 -3
  25. package/dist/es2019/utils/inline-drop-target.js +2 -2
  26. package/dist/esm/commands/move-to-layout.js +3 -3
  27. package/dist/esm/consts.js +4 -1
  28. package/dist/esm/pm-plugins/decorations-anchor.js +2 -1
  29. package/dist/esm/pm-plugins/decorations-drop-target.js +2 -2
  30. package/dist/esm/pm-plugins/handle-mouse-over.js +13 -0
  31. package/dist/esm/pm-plugins/main.js +3 -3
  32. package/dist/esm/ui/drag-handle.js +10 -4
  33. package/dist/esm/ui/global-styles.js +38 -4
  34. package/dist/esm/utils/active-anchor-tracker.js +17 -4
  35. package/dist/esm/utils/drag-handle-positions.js +4 -2
  36. package/dist/esm/utils/getSelection.js +3 -3
  37. package/dist/esm/utils/inline-drop-target.js +2 -2
  38. package/dist/types/consts.d.ts +1 -1
  39. package/dist/types/utils/active-anchor-tracker.d.ts +1 -1
  40. package/dist/types-ts4.5/consts.d.ts +1 -1
  41. package/dist/types-ts4.5/utils/active-anchor-tracker.d.ts +1 -1
  42. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 2.13.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#160954](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/160954)
8
+ [`3d5a71c2d5e22`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3d5a71c2d5e22) -
9
+ Fix issue with zindex on DnD psudo-element
10
+
11
+ ## 2.13.6
12
+
13
+ ### Patch Changes
14
+
15
+ - [#160415](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/160415)
16
+ [`9dd7911f0fb16`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9dd7911f0fb16) -
17
+ [ux] [ED-25057] Implement drag handle for layout column (position, hover zone, selection)
18
+ - Updated dependencies
19
+
20
+ ## 2.13.5
21
+
22
+ ### Patch Changes
23
+
24
+ - [#158691](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/158691)
25
+ [`f71feb1fedb07`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f71feb1fedb07) -
26
+ ED-25618 enable 5 columns for pre release 2
27
+ - [#158691](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/158691)
28
+ [`70ef661bbbb4d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/70ef661bbbb4d) -
29
+ Update feature flag to gate
30
+ - Updated dependencies
31
+
3
32
  ## 2.13.4
4
33
 
5
34
  ### Patch Changes
@@ -9,7 +9,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
9
9
  var _consts = require("../consts");
10
10
  var _consts2 = require("../ui/consts");
11
11
  var createNewLayout = function createNewLayout(schema, layoutContents) {
12
- if (layoutContents.length === 0 || layoutContents.length > _consts.MAX_LAYOUT_COLUMN_SUPPORTED) {
12
+ if (layoutContents.length === 0 || layoutContents.length > (0, _consts.maxLayoutColumnSupported)()) {
13
13
  return null;
14
14
  }
15
15
  var width = _consts2.DEFAULT_COLUMN_DISTRIBUTIONS[layoutContents.length];
@@ -54,7 +54,7 @@ var moveNode = function moveNode(from, to, newNode, sourceNodeSize, tr) {
54
54
  return tr;
55
55
  };
56
56
  var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos, sourceNode, from, to, tr) {
57
- if (toLayout.childCount < _consts.MAX_LAYOUT_COLUMN_SUPPORTED) {
57
+ if (toLayout.childCount < (0, _consts.maxLayoutColumnSupported)()) {
58
58
  var newColumnWidth = _consts2.DEFAULT_COLUMN_DISTRIBUTIONS[toLayout.childCount + 1];
59
59
  updateColumnWidths(tr, toLayout, toLayoutPos, newColumnWidth);
60
60
  var _ref2 = tr.doc.type.schema.nodes || {},
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.MAX_LAYOUT_COLUMN_SUPPORTED = exports.DIRECTION = void 0;
6
+ exports.maxLayoutColumnSupported = exports.DIRECTION = void 0;
7
+ var _advancedLayoutsFlags = require("./utils/advanced-layouts-flags");
7
8
  var DIRECTION = exports.DIRECTION = /*#__PURE__*/function (DIRECTION) {
8
9
  DIRECTION["UP"] = "up";
9
10
  DIRECTION["DOWN"] = "down";
@@ -11,4 +12,6 @@ var DIRECTION = exports.DIRECTION = /*#__PURE__*/function (DIRECTION) {
11
12
  DIRECTION["RIGHT"] = "right";
12
13
  return DIRECTION;
13
14
  }({});
14
- var MAX_LAYOUT_COLUMN_SUPPORTED = exports.MAX_LAYOUT_COLUMN_SUPPORTED = 3;
15
+ var maxLayoutColumnSupported = exports.maxLayoutColumnSupported = function maxLayoutColumnSupported() {
16
+ return (0, _advancedLayoutsFlags.isPreRelease2)() ? 5 : 3;
17
+ };
@@ -9,8 +9,9 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _view = require("@atlaskit/editor-prosemirror/view");
10
10
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
11
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
12
+ var _advancedLayoutsFlags = require("../utils/advanced-layouts-flags");
12
13
  var _decorationsCommon = require("./decorations-common");
13
- var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem', 'caption'];
14
+ var IGNORE_NODES = (0, _advancedLayoutsFlags.isPreRelease2)() ? ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption'] : ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption', 'layoutColumn'];
14
15
  var IGNORE_NODE_DESCENDANTS = ['listItem', 'taskList', 'decisionList', 'mediaSingle'];
15
16
  var shouldDescendIntoNode = exports.shouldDescendIntoNode = function shouldDescendIntoNode(node) {
16
17
  // Optimisation to avoid drawing node decorations for empty table cells
@@ -161,7 +161,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
161
161
  if (isAdvancedLayoutsPreRelease2) {
162
162
  if (node.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && (parent === null || parent === void 0 ? void 0 : parent.firstChild) !== node &&
163
163
  // Not the first node
164
- (parent === null || parent === void 0 ? void 0 : parent.childCount) < _consts.MAX_LAYOUT_COLUMN_SUPPORTED) {
164
+ (parent === null || parent === void 0 ? void 0 : parent.childCount) < (0, _consts.maxLayoutColumnSupported)()) {
165
165
  decs.push(createLayoutDropTargetDecoration(pos, {
166
166
  api: api,
167
167
  parent: parent,
@@ -4,8 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.handleMouseOver = void 0;
7
+ var _whitespace = require("@atlaskit/editor-common/whitespace");
7
8
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
9
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
10
+ var _advancedLayoutsFlags = require("../utils/advanced-layouts-flags");
9
11
  var isEmptyNestedParagraphOrHeading = function isEmptyNestedParagraphOrHeading(target) {
10
12
  if (target instanceof HTMLHeadingElement || target instanceof HTMLParagraphElement) {
11
13
  var _target$parentElement;
@@ -13,6 +15,12 @@ var isEmptyNestedParagraphOrHeading = function isEmptyNestedParagraphOrHeading(t
13
15
  }
14
16
  return false;
15
17
  };
18
+ var isLayoutColumnWithoutContent = function isLayoutColumnWithoutContent(target) {
19
+ var _target$textContent;
20
+ return target instanceof HTMLDivElement && (target === null || target === void 0 ? void 0 : target.getAttribute('data-drag-handler-node-type')) === 'layoutColumn' &&
21
+ // Remove placeholder text
22
+ ((_target$textContent = target.textContent) === null || _target$textContent === void 0 ? void 0 : _target$textContent.replace(new RegExp(_whitespace.ZERO_WIDTH_SPACE, 'g'), '')) === '';
23
+ };
16
24
  var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, event, api) {
17
25
  var _api$blockControls, _target$classList;
18
26
  var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
@@ -37,6 +45,11 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
37
45
  }
38
46
  var parentElement = (_rootElement$parentEl = rootElement.parentElement) === null || _rootElement$parentEl === void 0 ? void 0 : _rootElement$parentEl.closest('[data-drag-handler-anchor-name]');
39
47
  var parentElementType = parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute('data-drag-handler-node-type');
48
+
49
+ // Don't show drag handle when there is no content/only placeholder in layout column
50
+ if ((0, _advancedLayoutsFlags.isPreRelease2)() && isLayoutColumnWithoutContent(rootElement)) {
51
+ return false;
52
+ }
40
53
  // We want to exlude handles from showing for direct decendant of table nodes (i.e. nodes in cells)
41
54
  if (parentElement && parentElementType === 'table' && (0, _experiments.editorExperiment)('nested-dnd', true) && (0, _experiments.editorExperiment)('table-nested-dnd', false, {
42
55
  exposure: true
@@ -58,9 +58,6 @@ var destroyFn = function destroyFn(api) {
58
58
  if (isHTMLElement(scrollable)) {
59
59
  scrollable.style.setProperty('scroll-behavior', null);
60
60
  }
61
- if ((0, _advancedLayoutsFlags.isPreRelease2)()) {
62
- _activeAnchorTracker.defaultActiveAnchorTracker.reset();
63
- }
64
61
  api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref3) {
65
62
  var tr = _ref3.tr;
66
63
  var _ref4 = source.data,
@@ -519,6 +516,9 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
519
516
  },
520
517
  dragstart: function dragstart(view) {
521
518
  var _anchorRectCache;
519
+ if ((0, _advancedLayoutsFlags.isPreRelease2)()) {
520
+ _activeAnchorTracker.defaultActiveAnchorTracker.reset();
521
+ }
522
522
  (_anchorRectCache = anchorRectCache) === null || _anchorRectCache === void 0 || _anchorRectCache.setEditorView(view);
523
523
  view.dispatch(view.state.tr.setMeta(key, {
524
524
  isPMDragging: true
@@ -23,6 +23,7 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
23
23
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
24
24
  var _main = require("../pm-plugins/main");
25
25
  var _utils = require("../utils");
26
+ var _advancedLayoutsFlags = require("../utils/advanced-layouts-flags");
26
27
  var _dragHandlePositions = require("../utils/drag-handle-positions");
27
28
  var _consts = require("./consts");
28
29
  var _dragPreview = require("./drag-preview");
@@ -64,6 +65,9 @@ var dragHandleButtonStyles = (0, _react2.css)({
64
65
  outline: "2px solid ".concat("var(--ds-border-focused, #388BFF)")
65
66
  }
66
67
  });
68
+ var layoutColumnDragHandleStyles = (0, _react2.css)({
69
+ transform: 'rotate(90deg)'
70
+ });
67
71
  var selectedStyles = (0, _react2.css)({
68
72
  backgroundColor: "var(--ds-background-selected, #E9F2FF)",
69
73
  color: "var(--ds-icon-selected, #0C66E4)"
@@ -277,14 +281,16 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
277
281
  innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
278
282
  }
279
283
  }
284
+ var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
285
+ var isLayoutColumn = nodeType === 'layoutColumn';
280
286
  if (supportsAnchor) {
281
287
  return {
282
- left: (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer ? "calc(anchor(".concat(anchorName, " start) + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType), ")") : "calc(anchor(".concat(anchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType, parentNodeType), "px)"),
283
- top: (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_ed_23674') ? "calc(anchor(".concat(anchorName, " start) + ").concat((0, _consts.topPositionAdjustment)(nodeType), "px)") : anchorName.includes('table') ? "calc(anchor(".concat(anchorName, " start) + ").concat(_consts.DRAG_HANDLE_HEIGHT, "px)") : "anchor(".concat(anchorName, " start)")
288
+ left: isEdgeCase ? "calc(anchor(".concat(anchorName, " start) + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType), ")") : (0, _advancedLayoutsFlags.isPreRelease2)() && isLayoutColumn ? "calc((anchor(".concat(anchorName, " right) + anchor(").concat(anchorName, " left))/2 - ").concat(_consts.DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(anchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType, parentNodeType), "px)"),
289
+ top: (0, _advancedLayoutsFlags.isPreRelease2)() && isLayoutColumn ? "calc(anchor(".concat(anchorName, " top) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px)") : (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_ed_23674') ? "calc(anchor(".concat(anchorName, " start) + ").concat((0, _consts.topPositionAdjustment)(nodeType), "px)") : anchorName.includes('table') ? "calc(anchor(".concat(anchorName, " start) + ").concat(_consts.DRAG_HANDLE_HEIGHT, "px)") : "anchor(".concat(anchorName, " start)")
284
290
  };
285
291
  }
286
292
  return {
287
- left: (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType), ")") : (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType),
293
+ left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType), ")") : (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType),
288
294
  top: (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_ed_23674') ? (0, _dragHandlePositions.getTopPosition)(dom, nodeType) : (0, _dragHandlePositions.getTopPosition)(dom)
289
295
  };
290
296
  }, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates, getPos]);
@@ -396,7 +402,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
396
402
  // eslint-disable-next-line @atlaskit/design-system/no-html-button
397
403
  (0, _react2.jsx)("button", {
398
404
  type: "button",
399
- css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
405
+ css: [dragHandleButtonStyles, (0, _advancedLayoutsFlags.isPreRelease2)() && nodeType === 'layoutColumn' && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
400
406
  ref: buttonRef
401
407
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
402
408
  ,
@@ -37,7 +37,7 @@ var extendedHoverZone = function extendedHoverZone() {
37
37
  background: 'transparent',
38
38
  cursor: 'default',
39
39
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
40
- zIndex: (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3') ? 1 : -1
40
+ zIndex: -1
41
41
  }
42
42
  },
43
43
  // TODO - ED-23995 this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
@@ -83,7 +83,7 @@ var extendedHoverZoneNested = function extendedHoverZoneNested() {
83
83
  height: '100%',
84
84
  cursor: 'default',
85
85
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
86
- zIndex: (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3') ? 1 : -1
86
+ zIndex: -1
87
87
  },
88
88
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
89
89
  '&& :is(.pm-table-cell-content-wrap, .pm-table-header-content-wrap) > [data-drag-handler-anchor-name]::after': {
@@ -97,6 +97,22 @@ var extendedHoverZoneNested = function extendedHoverZoneNested() {
97
97
  height: '100%',
98
98
  cursor: 'default',
99
99
  zIndex: 1
100
+ },
101
+ // hover zone for layout column should be placed near the top of the column (where drag handle is)
102
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
103
+ '&& [data-drag-handler-anchor-name][data-layout-column]::after': {
104
+ content: '""',
105
+ position: 'absolute',
106
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
107
+ top: "".concat(-_consts.DRAG_HANDLE_WIDTH / 2, "px"),
108
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
109
+ left: 0,
110
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
111
+ width: '100%',
112
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
113
+ height: "".concat(_consts.DRAG_HANDLE_WIDTH, "px"),
114
+ cursor: 'default',
115
+ zIndex: 1
100
116
  }
101
117
  },
102
118
  // TODO - ED-23995 this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
@@ -190,10 +206,28 @@ var withRelativePosStyle = (0, _react.css)({
190
206
  }
191
207
  }
192
208
  });
209
+ var withAnchorNameZindexStyle = (0, _react.css)({
210
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
211
+ '.ProseMirror': {
212
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
213
+ '&& [data-drag-handler-anchor-name]': {
214
+ zIndex: 1
215
+ }
216
+ }
217
+ });
218
+ var withAnchorNameZindexNestedStyle = (0, _react.css)({
219
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
220
+ '.ProseMirror': {
221
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
222
+ '&& [data-drag-handler-anchor-depth="0"][data-drag-handler-anchor-name]': {
223
+ zIndex: 1
224
+ }
225
+ }
226
+ });
193
227
  var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper() {
194
228
  return (0, _react.jsx)(_react.Global, {
195
229
  styles: [globalStyles(), (0, _experiments.editorExperiment)('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, (0, _experiments.editorExperiment)('platform_editor_empty_line_prompt', true, {
196
230
  exposure: false
197
- }) ? _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, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles] : undefined]
231
+ }) ? _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, (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles, (0, _experiments.editorExperiment)('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle] : undefined]
198
232
  });
199
233
  };
@@ -21,17 +21,21 @@ var ActiveAnchorTracker = exports.ActiveAnchorTracker = /*#__PURE__*/function ()
21
21
  (0, _createClass2.default)(ActiveAnchorTracker, [{
22
22
  key: "subscribe",
23
23
  value: function subscribe(anchorName, callback) {
24
- this.emitter.on(anchorName, callback);
24
+ if (this.emitter) {
25
+ this.emitter.on(anchorName, callback);
26
+ }
25
27
  }
26
28
  }, {
27
29
  key: "unsubscribe",
28
30
  value: function unsubscribe(anchorName, callback) {
29
- this.emitter.removeListener(anchorName, callback);
31
+ if (this.emitter) {
32
+ this.emitter.removeListener(anchorName, callback);
33
+ }
30
34
  }
31
35
  }, {
32
36
  key: "emit",
33
37
  value: function emit(anchorName) {
34
- if (this.lastActiveAnchor !== anchorName) {
38
+ if (this.lastActiveAnchor !== anchorName && this.emitter) {
35
39
  this.emitter.emit(this.lastActiveAnchor, false);
36
40
  this.emitter.emit(anchorName, true);
37
41
  this.lastActiveAnchor = anchorName;
@@ -40,11 +44,18 @@ var ActiveAnchorTracker = exports.ActiveAnchorTracker = /*#__PURE__*/function ()
40
44
  }, {
41
45
  key: "reset",
42
46
  value: function reset() {
43
- this.emitter.removeAllListeners();
47
+ if (this.emitter) {
48
+ // To prevent any potential memory leaks,
49
+ // we set the event emitter to null and then create a new event emitter.
50
+ this.emitter.removeAllListeners();
51
+ this.emitter = null;
52
+ this.emitter = new _events.EventEmitter();
53
+ }
44
54
  }
45
55
  }]);
46
56
  return ActiveAnchorTracker;
47
- }();
57
+ }(); // TODO We should use a scoped ActiveAnchorTracker rather than the global static object.
58
+ // Move this into the plugin scope once the newApply functions becomes default apply.
48
59
  var defaultActiveAnchorTracker = exports.defaultActiveAnchorTracker = new ActiveAnchorTracker();
49
60
  var useActiveAnchorTracker = exports.useActiveAnchorTracker = function useActiveAnchorTracker(anchorName) {
50
61
  var activeAnchorTracker = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultActiveAnchorTracker;
@@ -14,6 +14,8 @@ var getTopPosition = exports.getTopPosition = function getTopPosition(dom, type)
14
14
  return "".concat(dom.offsetTop + ((table === null || table === void 0 ? void 0 : table.offsetTop) || 0), "px");
15
15
  } else if (type === 'rule') {
16
16
  return "".concat(dom.offsetTop - _consts.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, "px");
17
+ } else if (type === 'layoutColumn') {
18
+ return "".concat(-_consts.DRAG_HANDLE_WIDTH, "px");
17
19
  } else {
18
20
  return "".concat(dom.offsetTop, "px");
19
21
  }
@@ -23,7 +25,7 @@ var getLeftPosition = exports.getLeftPosition = function getLeftPosition(dom, ty
23
25
  return 'auto';
24
26
  }
25
27
  if (!innerContainer) {
26
- return "".concat(dom.offsetLeft - (0, _consts.dragHandleGap)(type, parentType) - _consts.DRAG_HANDLE_WIDTH, "px");
28
+ return type === 'layoutColumn' ? "".concat(dom.offsetLeft + dom.clientWidth / 2 - _consts.DRAG_HANDLE_HEIGHT / 2, "px") : "".concat(dom.offsetLeft - (0, _consts.dragHandleGap)(type, parentType) - _consts.DRAG_HANDLE_WIDTH, "px");
27
29
  }
28
30
 
29
31
  // There is a showMacroInteractionDesignUpdates prop in extension node wrapper that can add a relative span under the top level div
@@ -47,9 +47,9 @@ var getSelection = exports.getSelection = function getSelection(tr, start) {
47
47
  var $startPos = tr.doc.resolve(start);
48
48
  var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
49
49
  var isBlockQuoteWithMedia = nodeName === 'blockquote' && isNodeWithMedia(tr, start, nodeSize);
50
-
51
- // decisionList node is not selectable, but we want to select the whole node not just text
52
- if (isNodeSelection && nodeName !== 'blockquote' || isBlockQuoteWithMedia || nodeName === 'decisionList') {
50
+ if (isNodeSelection && nodeName !== 'blockquote' || isBlockQuoteWithMedia ||
51
+ // decisionList/layoutColumn node is not selectable, but we want to select the whole node not just text
52
+ ['decisionList', 'layoutColumn'].includes(nodeName || '')) {
53
53
  return new _state.NodeSelection($startPos);
54
54
  } else if (nodeName === 'mediaGroup' && (node === null || node === void 0 ? void 0 : node.childCount) === 1) {
55
55
  var $mediaStartPos = tr.doc.resolve(start + 1);
@@ -16,7 +16,7 @@ var shouldAllowInlineDropTarget = exports.shouldAllowInlineDropTarget = function
16
16
  return false;
17
17
  }
18
18
  if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
19
- return node.childCount < _consts.MAX_LAYOUT_COLUMN_SUPPORTED;
19
+ return node.childCount < (0, _consts.maxLayoutColumnSupported)();
20
20
  }
21
21
  return !(0, _utils.isEmptyParagraph)(node);
22
22
  };
@@ -1,9 +1,9 @@
1
1
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
2
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
- import { MAX_LAYOUT_COLUMN_SUPPORTED } from '../consts';
3
+ import { maxLayoutColumnSupported } from '../consts';
4
4
  import { DEFAULT_COLUMN_DISTRIBUTIONS } from '../ui/consts';
5
5
  const createNewLayout = (schema, layoutContents) => {
6
- if (layoutContents.length === 0 || layoutContents.length > MAX_LAYOUT_COLUMN_SUPPORTED) {
6
+ if (layoutContents.length === 0 || layoutContents.length > maxLayoutColumnSupported()) {
7
7
  return null;
8
8
  }
9
9
  const width = DEFAULT_COLUMN_DISTRIBUTIONS[layoutContents.length];
@@ -49,7 +49,7 @@ const moveNode = (from, to, newNode, sourceNodeSize, tr) => {
49
49
  return tr;
50
50
  };
51
51
  const moveToExistingLayout = (toLayout, toLayoutPos, sourceNode, from, to, tr) => {
52
- if (toLayout.childCount < MAX_LAYOUT_COLUMN_SUPPORTED) {
52
+ if (toLayout.childCount < maxLayoutColumnSupported()) {
53
53
  const newColumnWidth = DEFAULT_COLUMN_DISTRIBUTIONS[toLayout.childCount + 1];
54
54
  updateColumnWidths(tr, toLayout, toLayoutPos, newColumnWidth);
55
55
  const {
@@ -1,3 +1,4 @@
1
+ import { isPreRelease2 } from './utils/advanced-layouts-flags';
1
2
  export let DIRECTION = /*#__PURE__*/function (DIRECTION) {
2
3
  DIRECTION["UP"] = "up";
3
4
  DIRECTION["DOWN"] = "down";
@@ -5,4 +6,6 @@ export let DIRECTION = /*#__PURE__*/function (DIRECTION) {
5
6
  DIRECTION["RIGHT"] = "right";
6
7
  return DIRECTION;
7
8
  }({});
8
- export const MAX_LAYOUT_COLUMN_SUPPORTED = 3;
9
+ export const maxLayoutColumnSupported = () => {
10
+ return isPreRelease2() ? 5 : 3;
11
+ };
@@ -1,8 +1,9 @@
1
1
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
3
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
+ import { isPreRelease2 } from '../utils/advanced-layouts-flags';
4
5
  import { getNestedDepth, getNodeAnchor, TYPE_NODE_DEC } from './decorations-common';
5
- const IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem', 'caption'];
6
+ const IGNORE_NODES = isPreRelease2() ? ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption'] : ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption', 'layoutColumn'];
6
7
  const IGNORE_NODE_DESCENDANTS = ['listItem', 'taskList', 'decisionList', 'mediaSingle'];
7
8
  export const shouldDescendIntoNode = node => {
8
9
  // Optimisation to avoid drawing node decorations for empty table cells
@@ -4,7 +4,7 @@ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
4
4
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
6
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
- import { MAX_LAYOUT_COLUMN_SUPPORTED } from '../consts';
7
+ import { maxLayoutColumnSupported } from '../consts';
8
8
  import { nodeMargins } from '../ui/consts';
9
9
  import { DropTarget } from '../ui/drop-target';
10
10
  import { DropTargetLayout } from '../ui/drop-target-layout';
@@ -153,7 +153,7 @@ export const dropTargetDecorations = (newState, api, formatMessage, activeNode,
153
153
  if (isAdvancedLayoutsPreRelease2) {
154
154
  if (node.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && (parent === null || parent === void 0 ? void 0 : parent.firstChild) !== node &&
155
155
  // Not the first node
156
- (parent === null || parent === void 0 ? void 0 : parent.childCount) < MAX_LAYOUT_COLUMN_SUPPORTED) {
156
+ (parent === null || parent === void 0 ? void 0 : parent.childCount) < maxLayoutColumnSupported()) {
157
157
  decs.push(createLayoutDropTargetDecoration(pos, {
158
158
  api,
159
159
  parent,
@@ -1,5 +1,7 @@
1
+ import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
1
2
  import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
+ import { isPreRelease2 } from '../utils/advanced-layouts-flags';
3
5
  const isEmptyNestedParagraphOrHeading = target => {
4
6
  if (target instanceof HTMLHeadingElement || target instanceof HTMLParagraphElement) {
5
7
  var _target$parentElement;
@@ -7,6 +9,12 @@ const isEmptyNestedParagraphOrHeading = target => {
7
9
  }
8
10
  return false;
9
11
  };
12
+ const isLayoutColumnWithoutContent = target => {
13
+ var _target$textContent;
14
+ return target instanceof HTMLDivElement && (target === null || target === void 0 ? void 0 : target.getAttribute('data-drag-handler-node-type')) === 'layoutColumn' &&
15
+ // Remove placeholder text
16
+ ((_target$textContent = target.textContent) === null || _target$textContent === void 0 ? void 0 : _target$textContent.replace(new RegExp(ZERO_WIDTH_SPACE, 'g'), '')) === '';
17
+ };
10
18
  export const handleMouseOver = (view, event, api) => {
11
19
  var _api$blockControls, _target$classList;
12
20
  const {
@@ -32,6 +40,11 @@ export const handleMouseOver = (view, event, api) => {
32
40
  }
33
41
  const parentElement = (_rootElement$parentEl = rootElement.parentElement) === null || _rootElement$parentEl === void 0 ? void 0 : _rootElement$parentEl.closest('[data-drag-handler-anchor-name]');
34
42
  const parentElementType = parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute('data-drag-handler-node-type');
43
+
44
+ // Don't show drag handle when there is no content/only placeholder in layout column
45
+ if (isPreRelease2() && isLayoutColumnWithoutContent(rootElement)) {
46
+ return false;
47
+ }
35
48
  // We want to exlude handles from showing for direct decendant of table nodes (i.e. nodes in cells)
36
49
  if (parentElement && parentElementType === 'table' && editorExperiment('nested-dnd', true) && editorExperiment('table-nested-dnd', false, {
37
50
  exposure: true
@@ -50,9 +50,6 @@ const destroyFn = api => {
50
50
  if (isHTMLElement(scrollable)) {
51
51
  scrollable.style.setProperty('scroll-behavior', null);
52
52
  }
53
- if (isPreRelease2()) {
54
- defaultActiveAnchorTracker.reset();
55
- }
56
53
  api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
57
54
  tr
58
55
  }) => {
@@ -496,6 +493,9 @@ export const createPlugin = (api, getIntl) => {
496
493
  },
497
494
  dragstart(view) {
498
495
  var _anchorRectCache;
496
+ if (isPreRelease2()) {
497
+ defaultActiveAnchorTracker.reset();
498
+ }
499
499
  (_anchorRectCache = anchorRectCache) === null || _anchorRectCache === void 0 ? void 0 : _anchorRectCache.setEditorView(view);
500
500
  view.dispatch(view.state.tr.setMeta(key, {
501
501
  isPMDragging: true
@@ -19,6 +19,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
19
19
  import Tooltip from '@atlaskit/tooltip';
20
20
  import { key } from '../pm-plugins/main';
21
21
  import { getNestedNodePosition, selectNode } from '../utils';
22
+ import { isPreRelease2 } from '../utils/advanced-layouts-flags';
22
23
  import { getLeftPosition, getTopPosition } from '../utils/drag-handle-positions';
23
24
  import { DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_WIDTH, DRAG_HANDLE_ZINDEX, dragHandleGap, topPositionAdjustment } from './consts';
24
25
  import { dragPreview } from './drag-preview';
@@ -53,6 +54,9 @@ const dragHandleButtonStyles = css({
53
54
  outline: `2px solid ${"var(--ds-border-focused, #388BFF)"}`
54
55
  }
55
56
  });
57
+ const layoutColumnDragHandleStyles = css({
58
+ transform: 'rotate(90deg)'
59
+ });
56
60
  const selectedStyles = css({
57
61
  backgroundColor: "var(--ds-background-selected, #E9F2FF)",
58
62
  color: "var(--ds-icon-selected, #0C66E4)"
@@ -261,14 +265,16 @@ export const DragHandle = ({
261
265
  innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
262
266
  }
263
267
  }
268
+ const isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
269
+ const isLayoutColumn = nodeType === 'layoutColumn';
264
270
  if (supportsAnchor) {
265
271
  return {
266
- left: (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer ? `calc(anchor(${anchorName} start) + ${getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType)})` : `calc(anchor(${anchorName} start) - ${DRAG_HANDLE_WIDTH}px - ${dragHandleGap(nodeType, parentNodeType)}px)`,
267
- top: fg('platform_editor_elements_dnd_ed_23674') ? `calc(anchor(${anchorName} start) + ${topPositionAdjustment(nodeType)}px)` : anchorName.includes('table') ? `calc(anchor(${anchorName} start) + ${DRAG_HANDLE_HEIGHT}px)` : `anchor(${anchorName} start)`
272
+ left: isEdgeCase ? `calc(anchor(${anchorName} start) + ${getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType)})` : isPreRelease2() && isLayoutColumn ? `calc((anchor(${anchorName} right) + anchor(${anchorName} left))/2 - ${DRAG_HANDLE_HEIGHT / 2}px)` : `calc(anchor(${anchorName} start) - ${DRAG_HANDLE_WIDTH}px - ${dragHandleGap(nodeType, parentNodeType)}px)`,
273
+ top: isPreRelease2() && isLayoutColumn ? `calc(anchor(${anchorName} top) - ${DRAG_HANDLE_WIDTH}px)` : fg('platform_editor_elements_dnd_ed_23674') ? `calc(anchor(${anchorName} start) + ${topPositionAdjustment(nodeType)}px)` : anchorName.includes('table') ? `calc(anchor(${anchorName} start) + ${DRAG_HANDLE_HEIGHT}px)` : `anchor(${anchorName} start)`
268
274
  };
269
275
  }
270
276
  return {
271
- left: (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer ? `calc(${(dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0}px + ${getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType)})` : getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType),
277
+ left: isEdgeCase ? `calc(${(dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0}px + ${getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType)})` : getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType),
272
278
  top: fg('platform_editor_elements_dnd_ed_23674') ? getTopPosition(dom, nodeType) : getTopPosition(dom)
273
279
  };
274
280
  }, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates, getPos]);
@@ -376,7 +382,7 @@ export const DragHandle = ({
376
382
  // eslint-disable-next-line @atlaskit/design-system/no-html-button
377
383
  jsx("button", {
378
384
  type: "button",
379
- css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
385
+ css: [dragHandleButtonStyles, isPreRelease2() && nodeType === 'layoutColumn' && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
380
386
  ref: buttonRef
381
387
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
382
388
  ,
@@ -6,7 +6,7 @@
6
6
  import { css, Global, jsx } from '@emotion/react';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
8
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
- import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP } from './consts';
9
+ import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, DRAG_HANDLE_WIDTH } from './consts';
10
10
  import { emptyBlockExperimentGlobalStyles } from './empty-block-experiment/global-styles';
11
11
  const extendedHoverZone = () => css({
12
12
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
@@ -27,7 +27,7 @@ const extendedHoverZone = () => css({
27
27
  background: 'transparent',
28
28
  cursor: 'default',
29
29
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
30
- zIndex: fg('platform_editor_element_dnd_nested_fix_patch_3') ? 1 : -1
30
+ zIndex: -1
31
31
  }
32
32
  },
33
33
  // TODO - ED-23995 this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
@@ -71,7 +71,7 @@ const extendedHoverZoneNested = () => css({
71
71
  height: '100%',
72
72
  cursor: 'default',
73
73
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
74
- zIndex: fg('platform_editor_element_dnd_nested_fix_patch_3') ? 1 : -1
74
+ zIndex: -1
75
75
  },
76
76
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
77
77
  '&& :is(.pm-table-cell-content-wrap, .pm-table-header-content-wrap) > [data-drag-handler-anchor-name]::after': {
@@ -85,6 +85,22 @@ const extendedHoverZoneNested = () => css({
85
85
  height: '100%',
86
86
  cursor: 'default',
87
87
  zIndex: 1
88
+ },
89
+ // hover zone for layout column should be placed near the top of the column (where drag handle is)
90
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
91
+ '&& [data-drag-handler-anchor-name][data-layout-column]::after': {
92
+ content: '""',
93
+ position: 'absolute',
94
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
95
+ top: `${-DRAG_HANDLE_WIDTH / 2}px`,
96
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
97
+ left: 0,
98
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
99
+ width: '100%',
100
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
101
+ height: `${DRAG_HANDLE_WIDTH}px`,
102
+ cursor: 'default',
103
+ zIndex: 1
88
104
  }
89
105
  },
90
106
  // TODO - ED-23995 this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
@@ -193,10 +209,28 @@ const withRelativePosStyle = css({
193
209
  }
194
210
  }
195
211
  });
212
+ const withAnchorNameZindexStyle = css({
213
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
214
+ '.ProseMirror': {
215
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
216
+ '&& [data-drag-handler-anchor-name]': {
217
+ zIndex: 1
218
+ }
219
+ }
220
+ });
221
+ const withAnchorNameZindexNestedStyle = css({
222
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
223
+ '.ProseMirror': {
224
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
225
+ '&& [data-drag-handler-anchor-depth="0"][data-drag-handler-anchor-name]': {
226
+ zIndex: 1
227
+ }
228
+ }
229
+ });
196
230
  export const GlobalStylesWrapper = () => {
197
231
  return jsx(Global, {
198
232
  styles: [globalStyles(), editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, editorExperiment('platform_editor_empty_line_prompt', true, {
199
233
  exposure: false
200
- }) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles] : undefined]
234
+ }) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle] : undefined]
201
235
  });
202
236
  };
@@ -8,22 +8,35 @@ export class ActiveAnchorTracker {
8
8
  this.emitter = new EventEmitter();
9
9
  }
10
10
  subscribe(anchorName, callback) {
11
- this.emitter.on(anchorName, callback);
11
+ if (this.emitter) {
12
+ this.emitter.on(anchorName, callback);
13
+ }
12
14
  }
13
15
  unsubscribe(anchorName, callback) {
14
- this.emitter.removeListener(anchorName, callback);
16
+ if (this.emitter) {
17
+ this.emitter.removeListener(anchorName, callback);
18
+ }
15
19
  }
16
20
  emit(anchorName) {
17
- if (this.lastActiveAnchor !== anchorName) {
21
+ if (this.lastActiveAnchor !== anchorName && this.emitter) {
18
22
  this.emitter.emit(this.lastActiveAnchor, false);
19
23
  this.emitter.emit(anchorName, true);
20
24
  this.lastActiveAnchor = anchorName;
21
25
  }
22
26
  }
23
27
  reset() {
24
- this.emitter.removeAllListeners();
28
+ if (this.emitter) {
29
+ // To prevent any potential memory leaks,
30
+ // we set the event emitter to null and then create a new event emitter.
31
+ this.emitter.removeAllListeners();
32
+ this.emitter = null;
33
+ this.emitter = new EventEmitter();
34
+ }
25
35
  }
26
36
  }
37
+
38
+ // TODO We should use a scoped ActiveAnchorTracker rather than the global static object.
39
+ // Move this into the plugin scope once the newApply functions becomes default apply.
27
40
  export const defaultActiveAnchorTracker = new ActiveAnchorTracker();
28
41
  export const useActiveAnchorTracker = (anchorName, activeAnchorTracker = defaultActiveAnchorTracker) => {
29
42
  const [isActive, setIsActive] = useState(false);
@@ -1,4 +1,4 @@
1
- import { DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, DRAG_HANDLE_WIDTH, dragHandleGap } from '../ui/consts';
1
+ import { DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_WIDTH, dragHandleGap } from '../ui/consts';
2
2
  export const getTopPosition = (dom, type) => {
3
3
  if (!dom) {
4
4
  return 'auto';
@@ -8,6 +8,8 @@ export const getTopPosition = (dom, type) => {
8
8
  return `${dom.offsetTop + ((table === null || table === void 0 ? void 0 : table.offsetTop) || 0)}px`;
9
9
  } else if (type === 'rule') {
10
10
  return `${dom.offsetTop - DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT}px`;
11
+ } else if (type === 'layoutColumn') {
12
+ return `${-DRAG_HANDLE_WIDTH}px`;
11
13
  } else {
12
14
  return `${dom.offsetTop}px`;
13
15
  }
@@ -17,7 +19,7 @@ export const getLeftPosition = (dom, type, innerContainer, macroInteractionUpdat
17
19
  return 'auto';
18
20
  }
19
21
  if (!innerContainer) {
20
- return `${dom.offsetLeft - dragHandleGap(type, parentType) - DRAG_HANDLE_WIDTH}px`;
22
+ return type === 'layoutColumn' ? `${dom.offsetLeft + dom.clientWidth / 2 - DRAG_HANDLE_HEIGHT / 2}px` : `${dom.offsetLeft - dragHandleGap(type, parentType) - DRAG_HANDLE_WIDTH}px`;
21
23
  }
22
24
 
23
25
  // There is a showMacroInteractionDesignUpdates prop in extension node wrapper that can add a relative span under the top level div
@@ -41,9 +41,9 @@ export const getSelection = (tr, start) => {
41
41
  const $startPos = tr.doc.resolve(start);
42
42
  const nodeName = node === null || node === void 0 ? void 0 : node.type.name;
43
43
  const isBlockQuoteWithMedia = nodeName === 'blockquote' && isNodeWithMedia(tr, start, nodeSize);
44
-
45
- // decisionList node is not selectable, but we want to select the whole node not just text
46
- if (isNodeSelection && nodeName !== 'blockquote' || isBlockQuoteWithMedia || nodeName === 'decisionList') {
44
+ if (isNodeSelection && nodeName !== 'blockquote' || isBlockQuoteWithMedia ||
45
+ // decisionList/layoutColumn node is not selectable, but we want to select the whole node not just text
46
+ ['decisionList', 'layoutColumn'].includes(nodeName || '')) {
47
47
  return new NodeSelection($startPos);
48
48
  } else if (nodeName === 'mediaGroup' && (node === null || node === void 0 ? void 0 : node.childCount) === 1) {
49
49
  const $mediaStartPos = tr.doc.resolve(start + 1);
@@ -1,5 +1,5 @@
1
1
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
2
- import { MAX_LAYOUT_COLUMN_SUPPORTED } from '../consts';
2
+ import { maxLayoutColumnSupported } from '../consts';
3
3
  import { isPreRelease1 } from './advanced-layouts-flags';
4
4
  import { isWrappedMedia } from './check-media-layout';
5
5
  export const shouldAllowInlineDropTarget = (isNested, node) => {
@@ -10,7 +10,7 @@ export const shouldAllowInlineDropTarget = (isNested, node) => {
10
10
  return false;
11
11
  }
12
12
  if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
13
- return node.childCount < MAX_LAYOUT_COLUMN_SUPPORTED;
13
+ return node.childCount < maxLayoutColumnSupported();
14
14
  }
15
15
  return !isEmptyParagraph(node);
16
16
  };
@@ -1,9 +1,9 @@
1
1
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
2
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
- import { MAX_LAYOUT_COLUMN_SUPPORTED } from '../consts';
3
+ import { maxLayoutColumnSupported } from '../consts';
4
4
  import { DEFAULT_COLUMN_DISTRIBUTIONS } from '../ui/consts';
5
5
  var createNewLayout = function createNewLayout(schema, layoutContents) {
6
- if (layoutContents.length === 0 || layoutContents.length > MAX_LAYOUT_COLUMN_SUPPORTED) {
6
+ if (layoutContents.length === 0 || layoutContents.length > maxLayoutColumnSupported()) {
7
7
  return null;
8
8
  }
9
9
  var width = DEFAULT_COLUMN_DISTRIBUTIONS[layoutContents.length];
@@ -48,7 +48,7 @@ var moveNode = function moveNode(from, to, newNode, sourceNodeSize, tr) {
48
48
  return tr;
49
49
  };
50
50
  var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos, sourceNode, from, to, tr) {
51
- if (toLayout.childCount < MAX_LAYOUT_COLUMN_SUPPORTED) {
51
+ if (toLayout.childCount < maxLayoutColumnSupported()) {
52
52
  var newColumnWidth = DEFAULT_COLUMN_DISTRIBUTIONS[toLayout.childCount + 1];
53
53
  updateColumnWidths(tr, toLayout, toLayoutPos, newColumnWidth);
54
54
  var _ref2 = tr.doc.type.schema.nodes || {},
@@ -1,3 +1,4 @@
1
+ import { isPreRelease2 } from './utils/advanced-layouts-flags';
1
2
  export var DIRECTION = /*#__PURE__*/function (DIRECTION) {
2
3
  DIRECTION["UP"] = "up";
3
4
  DIRECTION["DOWN"] = "down";
@@ -5,4 +6,6 @@ export var DIRECTION = /*#__PURE__*/function (DIRECTION) {
5
6
  DIRECTION["RIGHT"] = "right";
6
7
  return DIRECTION;
7
8
  }({});
8
- export var MAX_LAYOUT_COLUMN_SUPPORTED = 3;
9
+ export var maxLayoutColumnSupported = function maxLayoutColumnSupported() {
10
+ return isPreRelease2() ? 5 : 3;
11
+ };
@@ -2,8 +2,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
4
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
+ import { isPreRelease2 } from '../utils/advanced-layouts-flags';
5
6
  import { getNestedDepth, getNodeAnchor, TYPE_NODE_DEC } from './decorations-common';
6
- var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem', 'caption'];
7
+ var IGNORE_NODES = isPreRelease2() ? ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption'] : ['tableCell', 'tableHeader', 'tableRow', 'listItem', 'caption', 'layoutColumn'];
7
8
  var IGNORE_NODE_DESCENDANTS = ['listItem', 'taskList', 'decisionList', 'mediaSingle'];
8
9
  export var shouldDescendIntoNode = function shouldDescendIntoNode(node) {
9
10
  // Optimisation to avoid drawing node decorations for empty table cells
@@ -7,7 +7,7 @@ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
7
7
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
9
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
- import { MAX_LAYOUT_COLUMN_SUPPORTED } from '../consts';
10
+ import { maxLayoutColumnSupported } from '../consts';
11
11
  import { nodeMargins } from '../ui/consts';
12
12
  import { DropTarget } from '../ui/drop-target';
13
13
  import { DropTargetLayout } from '../ui/drop-target-layout';
@@ -154,7 +154,7 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
154
154
  if (isAdvancedLayoutsPreRelease2) {
155
155
  if (node.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && (parent === null || parent === void 0 ? void 0 : parent.firstChild) !== node &&
156
156
  // Not the first node
157
- (parent === null || parent === void 0 ? void 0 : parent.childCount) < MAX_LAYOUT_COLUMN_SUPPORTED) {
157
+ (parent === null || parent === void 0 ? void 0 : parent.childCount) < maxLayoutColumnSupported()) {
158
158
  decs.push(createLayoutDropTargetDecoration(pos, {
159
159
  api: api,
160
160
  parent: parent,
@@ -1,5 +1,7 @@
1
+ import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
1
2
  import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
+ import { isPreRelease2 } from '../utils/advanced-layouts-flags';
3
5
  var isEmptyNestedParagraphOrHeading = function isEmptyNestedParagraphOrHeading(target) {
4
6
  if (target instanceof HTMLHeadingElement || target instanceof HTMLParagraphElement) {
5
7
  var _target$parentElement;
@@ -7,6 +9,12 @@ var isEmptyNestedParagraphOrHeading = function isEmptyNestedParagraphOrHeading(t
7
9
  }
8
10
  return false;
9
11
  };
12
+ var isLayoutColumnWithoutContent = function isLayoutColumnWithoutContent(target) {
13
+ var _target$textContent;
14
+ return target instanceof HTMLDivElement && (target === null || target === void 0 ? void 0 : target.getAttribute('data-drag-handler-node-type')) === 'layoutColumn' &&
15
+ // Remove placeholder text
16
+ ((_target$textContent = target.textContent) === null || _target$textContent === void 0 ? void 0 : _target$textContent.replace(new RegExp(ZERO_WIDTH_SPACE, 'g'), '')) === '';
17
+ };
10
18
  export var handleMouseOver = function handleMouseOver(view, event, api) {
11
19
  var _api$blockControls, _target$classList;
12
20
  var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
@@ -31,6 +39,11 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
31
39
  }
32
40
  var parentElement = (_rootElement$parentEl = rootElement.parentElement) === null || _rootElement$parentEl === void 0 ? void 0 : _rootElement$parentEl.closest('[data-drag-handler-anchor-name]');
33
41
  var parentElementType = parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute('data-drag-handler-node-type');
42
+
43
+ // Don't show drag handle when there is no content/only placeholder in layout column
44
+ if (isPreRelease2() && isLayoutColumnWithoutContent(rootElement)) {
45
+ return false;
46
+ }
34
47
  // We want to exlude handles from showing for direct decendant of table nodes (i.e. nodes in cells)
35
48
  if (parentElement && parentElementType === 'table' && editorExperiment('nested-dnd', true) && editorExperiment('table-nested-dnd', false, {
36
49
  exposure: true
@@ -51,9 +51,6 @@ var destroyFn = function destroyFn(api) {
51
51
  if (isHTMLElement(scrollable)) {
52
52
  scrollable.style.setProperty('scroll-behavior', null);
53
53
  }
54
- if (isPreRelease2()) {
55
- defaultActiveAnchorTracker.reset();
56
- }
57
54
  api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref3) {
58
55
  var tr = _ref3.tr;
59
56
  var _ref4 = source.data,
@@ -512,6 +509,9 @@ export var createPlugin = function createPlugin(api, getIntl) {
512
509
  },
513
510
  dragstart: function dragstart(view) {
514
511
  var _anchorRectCache;
512
+ if (isPreRelease2()) {
513
+ defaultActiveAnchorTracker.reset();
514
+ }
515
515
  (_anchorRectCache = anchorRectCache) === null || _anchorRectCache === void 0 || _anchorRectCache.setEditorView(view);
516
516
  view.dispatch(view.state.tr.setMeta(key, {
517
517
  isPMDragging: true
@@ -21,6 +21,7 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
21
21
  import Tooltip from '@atlaskit/tooltip';
22
22
  import { key } from '../pm-plugins/main';
23
23
  import { getNestedNodePosition, selectNode } from '../utils';
24
+ import { isPreRelease2 } from '../utils/advanced-layouts-flags';
24
25
  import { getLeftPosition, getTopPosition } from '../utils/drag-handle-positions';
25
26
  import { DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_WIDTH, DRAG_HANDLE_ZINDEX, dragHandleGap, topPositionAdjustment } from './consts';
26
27
  import { dragPreview } from './drag-preview';
@@ -55,6 +56,9 @@ var dragHandleButtonStyles = css({
55
56
  outline: "2px solid ".concat("var(--ds-border-focused, #388BFF)")
56
57
  }
57
58
  });
59
+ var layoutColumnDragHandleStyles = css({
60
+ transform: 'rotate(90deg)'
61
+ });
58
62
  var selectedStyles = css({
59
63
  backgroundColor: "var(--ds-background-selected, #E9F2FF)",
60
64
  color: "var(--ds-icon-selected, #0C66E4)"
@@ -268,14 +272,16 @@ export var DragHandle = function DragHandle(_ref) {
268
272
  innerContainer = dom.querySelector('.datasourceView-content-inner-wrap');
269
273
  }
270
274
  }
275
+ var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
276
+ var isLayoutColumn = nodeType === 'layoutColumn';
271
277
  if (supportsAnchor) {
272
278
  return {
273
- left: (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer ? "calc(anchor(".concat(anchorName, " start) + ").concat(getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType), ")") : "calc(anchor(".concat(anchorName, " start) - ").concat(DRAG_HANDLE_WIDTH, "px - ").concat(dragHandleGap(nodeType, parentNodeType), "px)"),
274
- top: fg('platform_editor_elements_dnd_ed_23674') ? "calc(anchor(".concat(anchorName, " start) + ").concat(topPositionAdjustment(nodeType), "px)") : anchorName.includes('table') ? "calc(anchor(".concat(anchorName, " start) + ").concat(DRAG_HANDLE_HEIGHT, "px)") : "anchor(".concat(anchorName, " start)")
279
+ left: isEdgeCase ? "calc(anchor(".concat(anchorName, " start) + ").concat(getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType), ")") : isPreRelease2() && isLayoutColumn ? "calc((anchor(".concat(anchorName, " right) + anchor(").concat(anchorName, " left))/2 - ").concat(DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(anchorName, " start) - ").concat(DRAG_HANDLE_WIDTH, "px - ").concat(dragHandleGap(nodeType, parentNodeType), "px)"),
280
+ top: isPreRelease2() && isLayoutColumn ? "calc(anchor(".concat(anchorName, " top) - ").concat(DRAG_HANDLE_WIDTH, "px)") : fg('platform_editor_elements_dnd_ed_23674') ? "calc(anchor(".concat(anchorName, " start) + ").concat(topPositionAdjustment(nodeType), "px)") : anchorName.includes('table') ? "calc(anchor(".concat(anchorName, " start) + ").concat(DRAG_HANDLE_HEIGHT, "px)") : "anchor(".concat(anchorName, " start)")
275
281
  };
276
282
  }
277
283
  return {
278
- left: (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat(getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType), ")") : getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType),
284
+ left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat(getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType), ")") : getLeftPosition(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType),
279
285
  top: fg('platform_editor_elements_dnd_ed_23674') ? getTopPosition(dom, nodeType) : getTopPosition(dom)
280
286
  };
281
287
  }, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates, getPos]);
@@ -387,7 +393,7 @@ export var DragHandle = function DragHandle(_ref) {
387
393
  // eslint-disable-next-line @atlaskit/design-system/no-html-button
388
394
  jsx("button", {
389
395
  type: "button",
390
- css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
396
+ css: [dragHandleButtonStyles, isPreRelease2() && nodeType === 'layoutColumn' && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
391
397
  ref: buttonRef
392
398
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
393
399
  ,
@@ -7,7 +7,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
7
  import { css, Global, jsx } from '@emotion/react';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
9
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
- import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP } from './consts';
10
+ import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, DRAG_HANDLE_WIDTH } from './consts';
11
11
  import { emptyBlockExperimentGlobalStyles } from './empty-block-experiment/global-styles';
12
12
  var extendedHoverZone = function extendedHoverZone() {
13
13
  return css({
@@ -29,7 +29,7 @@ var extendedHoverZone = function extendedHoverZone() {
29
29
  background: 'transparent',
30
30
  cursor: 'default',
31
31
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
32
- zIndex: fg('platform_editor_element_dnd_nested_fix_patch_3') ? 1 : -1
32
+ zIndex: -1
33
33
  }
34
34
  },
35
35
  // TODO - ED-23995 this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
@@ -75,7 +75,7 @@ var extendedHoverZoneNested = function extendedHoverZoneNested() {
75
75
  height: '100%',
76
76
  cursor: 'default',
77
77
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
78
- zIndex: fg('platform_editor_element_dnd_nested_fix_patch_3') ? 1 : -1
78
+ zIndex: -1
79
79
  },
80
80
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
81
81
  '&& :is(.pm-table-cell-content-wrap, .pm-table-header-content-wrap) > [data-drag-handler-anchor-name]::after': {
@@ -89,6 +89,22 @@ var extendedHoverZoneNested = function extendedHoverZoneNested() {
89
89
  height: '100%',
90
90
  cursor: 'default',
91
91
  zIndex: 1
92
+ },
93
+ // hover zone for layout column should be placed near the top of the column (where drag handle is)
94
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
95
+ '&& [data-drag-handler-anchor-name][data-layout-column]::after': {
96
+ content: '""',
97
+ position: 'absolute',
98
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
99
+ top: "".concat(-DRAG_HANDLE_WIDTH / 2, "px"),
100
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
101
+ left: 0,
102
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
103
+ width: '100%',
104
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
105
+ height: "".concat(DRAG_HANDLE_WIDTH, "px"),
106
+ cursor: 'default',
107
+ zIndex: 1
92
108
  }
93
109
  },
94
110
  // TODO - ED-23995 this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
@@ -182,10 +198,28 @@ var withRelativePosStyle = css({
182
198
  }
183
199
  }
184
200
  });
201
+ var withAnchorNameZindexStyle = css({
202
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
203
+ '.ProseMirror': {
204
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
205
+ '&& [data-drag-handler-anchor-name]': {
206
+ zIndex: 1
207
+ }
208
+ }
209
+ });
210
+ var withAnchorNameZindexNestedStyle = css({
211
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
212
+ '.ProseMirror': {
213
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
214
+ '&& [data-drag-handler-anchor-depth="0"][data-drag-handler-anchor-name]': {
215
+ zIndex: 1
216
+ }
217
+ }
218
+ });
185
219
  export var GlobalStylesWrapper = function GlobalStylesWrapper() {
186
220
  return jsx(Global, {
187
221
  styles: [globalStyles(), editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), getTextNodeStyle(), withDeleteLinesStyleFix, withMediaSingleStyleFix, editorExperiment('platform_editor_empty_line_prompt', true, {
188
222
  exposure: false
189
- }) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles] : undefined]
223
+ }) ? emptyBlockExperimentGlobalStyles : undefined, fg('platform_editor_element_dnd_nested_fix_patch_1') ? withDividerInPanelStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_2') ? withFormatInLayoutStyleFix : undefined, fg('platform_editor_element_dnd_nested_fix_patch_3') ? [withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle] : undefined]
190
224
  });
191
225
  };
@@ -14,17 +14,21 @@ export var ActiveAnchorTracker = /*#__PURE__*/function () {
14
14
  _createClass(ActiveAnchorTracker, [{
15
15
  key: "subscribe",
16
16
  value: function subscribe(anchorName, callback) {
17
- this.emitter.on(anchorName, callback);
17
+ if (this.emitter) {
18
+ this.emitter.on(anchorName, callback);
19
+ }
18
20
  }
19
21
  }, {
20
22
  key: "unsubscribe",
21
23
  value: function unsubscribe(anchorName, callback) {
22
- this.emitter.removeListener(anchorName, callback);
24
+ if (this.emitter) {
25
+ this.emitter.removeListener(anchorName, callback);
26
+ }
23
27
  }
24
28
  }, {
25
29
  key: "emit",
26
30
  value: function emit(anchorName) {
27
- if (this.lastActiveAnchor !== anchorName) {
31
+ if (this.lastActiveAnchor !== anchorName && this.emitter) {
28
32
  this.emitter.emit(this.lastActiveAnchor, false);
29
33
  this.emitter.emit(anchorName, true);
30
34
  this.lastActiveAnchor = anchorName;
@@ -33,11 +37,20 @@ export var ActiveAnchorTracker = /*#__PURE__*/function () {
33
37
  }, {
34
38
  key: "reset",
35
39
  value: function reset() {
36
- this.emitter.removeAllListeners();
40
+ if (this.emitter) {
41
+ // To prevent any potential memory leaks,
42
+ // we set the event emitter to null and then create a new event emitter.
43
+ this.emitter.removeAllListeners();
44
+ this.emitter = null;
45
+ this.emitter = new EventEmitter();
46
+ }
37
47
  }
38
48
  }]);
39
49
  return ActiveAnchorTracker;
40
50
  }();
51
+
52
+ // TODO We should use a scoped ActiveAnchorTracker rather than the global static object.
53
+ // Move this into the plugin scope once the newApply functions becomes default apply.
41
54
  export var defaultActiveAnchorTracker = new ActiveAnchorTracker();
42
55
  export var useActiveAnchorTracker = function useActiveAnchorTracker(anchorName) {
43
56
  var activeAnchorTracker = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultActiveAnchorTracker;
@@ -1,4 +1,4 @@
1
- import { DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, DRAG_HANDLE_WIDTH, dragHandleGap } from '../ui/consts';
1
+ import { DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_WIDTH, dragHandleGap } from '../ui/consts';
2
2
  export var getTopPosition = function getTopPosition(dom, type) {
3
3
  if (!dom) {
4
4
  return 'auto';
@@ -8,6 +8,8 @@ export var getTopPosition = function getTopPosition(dom, type) {
8
8
  return "".concat(dom.offsetTop + ((table === null || table === void 0 ? void 0 : table.offsetTop) || 0), "px");
9
9
  } else if (type === 'rule') {
10
10
  return "".concat(dom.offsetTop - DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, "px");
11
+ } else if (type === 'layoutColumn') {
12
+ return "".concat(-DRAG_HANDLE_WIDTH, "px");
11
13
  } else {
12
14
  return "".concat(dom.offsetTop, "px");
13
15
  }
@@ -17,7 +19,7 @@ export var getLeftPosition = function getLeftPosition(dom, type, innerContainer,
17
19
  return 'auto';
18
20
  }
19
21
  if (!innerContainer) {
20
- return "".concat(dom.offsetLeft - dragHandleGap(type, parentType) - DRAG_HANDLE_WIDTH, "px");
22
+ return type === 'layoutColumn' ? "".concat(dom.offsetLeft + dom.clientWidth / 2 - DRAG_HANDLE_HEIGHT / 2, "px") : "".concat(dom.offsetLeft - dragHandleGap(type, parentType) - DRAG_HANDLE_WIDTH, "px");
21
23
  }
22
24
 
23
25
  // There is a showMacroInteractionDesignUpdates prop in extension node wrapper that can add a relative span under the top level div
@@ -41,9 +41,9 @@ export var getSelection = function getSelection(tr, start) {
41
41
  var $startPos = tr.doc.resolve(start);
42
42
  var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
43
43
  var isBlockQuoteWithMedia = nodeName === 'blockquote' && isNodeWithMedia(tr, start, nodeSize);
44
-
45
- // decisionList node is not selectable, but we want to select the whole node not just text
46
- if (isNodeSelection && nodeName !== 'blockquote' || isBlockQuoteWithMedia || nodeName === 'decisionList') {
44
+ if (isNodeSelection && nodeName !== 'blockquote' || isBlockQuoteWithMedia ||
45
+ // decisionList/layoutColumn node is not selectable, but we want to select the whole node not just text
46
+ ['decisionList', 'layoutColumn'].includes(nodeName || '')) {
47
47
  return new NodeSelection($startPos);
48
48
  } else if (nodeName === 'mediaGroup' && (node === null || node === void 0 ? void 0 : node.childCount) === 1) {
49
49
  var $mediaStartPos = tr.doc.resolve(start + 1);
@@ -1,5 +1,5 @@
1
1
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
2
- import { MAX_LAYOUT_COLUMN_SUPPORTED } from '../consts';
2
+ import { maxLayoutColumnSupported } from '../consts';
3
3
  import { isPreRelease1 } from './advanced-layouts-flags';
4
4
  import { isWrappedMedia } from './check-media-layout';
5
5
  export var shouldAllowInlineDropTarget = function shouldAllowInlineDropTarget(isNested, node) {
@@ -10,7 +10,7 @@ export var shouldAllowInlineDropTarget = function shouldAllowInlineDropTarget(is
10
10
  return false;
11
11
  }
12
12
  if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
13
- return node.childCount < MAX_LAYOUT_COLUMN_SUPPORTED;
13
+ return node.childCount < maxLayoutColumnSupported();
14
14
  }
15
15
  return !isEmptyParagraph(node);
16
16
  };
@@ -4,4 +4,4 @@ export declare enum DIRECTION {
4
4
  LEFT = "left",
5
5
  RIGHT = "right"
6
6
  }
7
- export declare const MAX_LAYOUT_COLUMN_SUPPORTED = 3;
7
+ export declare const maxLayoutColumnSupported: () => 5 | 3;
@@ -3,7 +3,7 @@
3
3
  /// <reference types="node/events" />
4
4
  import { EventEmitter } from 'events';
5
5
  export declare class ActiveAnchorTracker {
6
- emitter: EventEmitter;
6
+ emitter: EventEmitter | null;
7
7
  lastActiveAnchor: string;
8
8
  constructor();
9
9
  subscribe(anchorName: string, callback: (isActive: boolean) => void): void;
@@ -4,4 +4,4 @@ export declare enum DIRECTION {
4
4
  LEFT = "left",
5
5
  RIGHT = "right"
6
6
  }
7
- export declare const MAX_LAYOUT_COLUMN_SUPPORTED = 3;
7
+ export declare const maxLayoutColumnSupported: () => 5 | 3;
@@ -3,7 +3,7 @@
3
3
  /// <reference types="node/events" />
4
4
  import { EventEmitter } from 'events';
5
5
  export declare class ActiveAnchorTracker {
6
- emitter: EventEmitter;
6
+ emitter: EventEmitter | null;
7
7
  lastActiveAnchor: string;
8
8
  constructor();
9
9
  subscribe(anchorName: string, callback: (isActive: boolean) => void): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "2.13.4",
3
+ "version": "2.13.7",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,12 +31,12 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@atlaskit/adf-schema": "^44.2.0",
34
- "@atlaskit/editor-common": "^94.11.0",
34
+ "@atlaskit/editor-common": "^94.13.0",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
37
37
  "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
38
38
  "@atlaskit/editor-plugin-feature-flags": "^1.2.0",
39
- "@atlaskit/editor-plugin-quick-insert": "^1.6.0",
39
+ "@atlaskit/editor-plugin-quick-insert": "^1.7.0",
40
40
  "@atlaskit/editor-plugin-width": "^1.3.0",
41
41
  "@atlaskit/editor-prosemirror": "6.0.0",
42
42
  "@atlaskit/editor-shared-styles": "^3.2.0",
@@ -48,8 +48,8 @@
48
48
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
49
49
  "@atlaskit/primitives": "^13.0.0",
50
50
  "@atlaskit/theme": "^14.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^2.11.0",
52
- "@atlaskit/tokens": "^2.1.0",
51
+ "@atlaskit/tmp-editor-statsig": "^2.12.0",
52
+ "@atlaskit/tokens": "^2.2.0",
53
53
  "@atlaskit/tooltip": "^18.8.0",
54
54
  "@babel/runtime": "^7.0.0",
55
55
  "@emotion/react": "^11.7.1",
@@ -99,7 +99,7 @@
99
99
  }
100
100
  },
101
101
  "platform-feature-flags": {
102
- "platform.editor.media.extended-resize-experience": {
102
+ "platform_editor_media_extended_resize_experience": {
103
103
  "type": "boolean",
104
104
  "referenceOnly": true
105
105
  },