@atlaskit/editor-plugin-block-controls 7.5.4 → 7.5.6

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,22 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 7.5.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`945cca63ae433`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/945cca63ae433) -
8
+ ED-29335: Fixed drop hints height not right for layout column inline drop targets
9
+ - Updated dependencies
10
+
11
+ ## 7.5.5
12
+
13
+ ### Patch Changes
14
+
15
+ - [`c094becfaeeaa`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c094becfaeeaa) -
16
+ EDITOR-2476 Introduce new utility method to check if nested tables is supported in the schema to
17
+ facilitate removal of gate `platform_editor_use_nested_table_pm_nodes`
18
+ - Updated dependencies
19
+
3
20
  ## 7.5.4
4
21
 
5
22
  ### Patch Changes
@@ -10,6 +10,8 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _reactDom = _interopRequireDefault(require("react-dom"));
12
12
  var _uuid = _interopRequireDefault(require("uuid"));
13
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
14
+
13
15
  var TYPE_DROP_TARGET_DEC = exports.TYPE_DROP_TARGET_DEC = 'drop-target-decoration';
14
16
  var TYPE_HANDLE_DEC = exports.TYPE_HANDLE_DEC = 'drag-handle';
15
17
  var TYPE_NODE_DEC = exports.TYPE_NODE_DEC = 'node-decoration';
@@ -32,6 +34,7 @@ var ObjHash = /*#__PURE__*/function () {
32
34
  if (this.caching.has(node)) {
33
35
  return this.caching.get(node);
34
36
  }
37
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
35
38
  var uniqueId = (0, _uuid.default)();
36
39
  this.caching.set(node, uniqueId);
37
40
  return uniqueId;
@@ -16,6 +16,8 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
16
16
  var _dragHandle = require("../ui/drag-handle");
17
17
  var _decorationsCommon = require("./decorations-common");
18
18
  var _marks = require("./utils/marks");
19
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
20
+
19
21
  var emptyParagraphNodeDecorations = exports.emptyParagraphNodeDecorations = function emptyParagraphNodeDecorations() {
20
22
  var anchorName = "--node-anchor-paragraph-0";
21
23
  var style = "anchor-name: ".concat(anchorName, "; margin-top: 0px;");
@@ -46,10 +48,12 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
46
48
  (0, _decorationsCommon.unmountDecorations)(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
47
49
  }
48
50
  var unbind;
51
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
49
52
  var key = (0, _uuid.default)();
50
53
  var widgetSpec = (0, _experiments.editorExperiment)('platform_editor_breakout_resizing', true) ? {
51
54
  side: -1,
52
55
  type: _decorationsCommon.TYPE_HANDLE_DEC,
56
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
53
57
  testid: "".concat(_decorationsCommon.TYPE_HANDLE_DEC, "-").concat((0, _uuid.default)()),
54
58
  /**
55
59
  * sigh - `marks` influences the position that the widget is drawn (as described on the `side` property).
@@ -66,6 +70,7 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
66
70
  } : {
67
71
  side: -1,
68
72
  type: _decorationsCommon.TYPE_HANDLE_DEC,
73
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
69
74
  testid: "".concat(_decorationsCommon.TYPE_HANDLE_DEC, "-").concat((0, _uuid.default)()),
70
75
  destroy: function destroy(node) {
71
76
  unbind && unbind();
@@ -11,6 +11,8 @@ var _uuid = _interopRequireDefault(require("uuid"));
11
11
  var _selection = require("@atlaskit/editor-common/selection");
12
12
  var _utils = require("@atlaskit/editor-common/utils");
13
13
  var _view = require("@atlaskit/editor-prosemirror/view");
14
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
14
16
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
15
17
  var _consts = require("../ui/consts");
16
18
  var _dropTarget = require("../ui/drop-target");
@@ -19,7 +21,7 @@ var _decorationsCommon = require("./decorations-common");
19
21
  var _consts2 = require("./utils/consts");
20
22
  var _validation = require("./utils/validation");
21
23
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
24
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
23
25
  var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem', 'caption'];
24
26
  var PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension'];
25
27
  var DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
@@ -83,6 +85,7 @@ var findDropTargetDecs = exports.findDropTargetDecs = function findDropTargetDec
83
85
  });
84
86
  };
85
87
  var createDropTargetDecoration = exports.createDropTargetDecoration = function createDropTargetDecoration(pos, props, nodeViewPortalProviderAPI, side, anchorRectCache, isSameLayout) {
88
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
86
89
  var key = (0, _uuid.default)();
87
90
  return _view.Decoration.widget(pos, function (_, getPosUnsafe) {
88
91
  var getPos = function getPos() {
@@ -121,6 +124,7 @@ var createDropTargetDecoration = exports.createDropTargetDecoration = function c
121
124
  });
122
125
  };
123
126
  var createLayoutDropTargetDecoration = exports.createLayoutDropTargetDecoration = function createLayoutDropTargetDecoration(pos, props, nodeViewPortalProviderAPI, anchorRectCache) {
127
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
124
128
  var key = (0, _uuid.default)();
125
129
  return _view.Decoration.widget(pos, function (_, getPosUnsafe) {
126
130
  var getPos = function getPos() {
@@ -134,8 +138,9 @@ var createLayoutDropTargetDecoration = exports.createLayoutDropTargetDecoration
134
138
  element.setAttribute('data-blocks-drop-target-container', 'true');
135
139
  element.setAttribute('data-blocks-drop-target-key', key);
136
140
  element.style.clear = 'unset';
141
+ var DropTargetLayoutComponent = (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('editor_native_anchor_update_layout_drop_hint') ? _dropTargetLayout.DropTargetLayoutNativeAnchorSupport : _dropTargetLayout.DropTargetLayout;
137
142
  nodeViewPortalProviderAPI.render(function () {
138
- return /*#__PURE__*/(0, _react.createElement)(_dropTargetLayout.DropTargetLayout, _objectSpread(_objectSpread({}, props), {}, {
143
+ return /*#__PURE__*/(0, _react.createElement)(DropTargetLayoutComponent, _objectSpread(_objectSpread({}, props), {}, {
139
144
  getPos: getPos,
140
145
  anchorRectCache: anchorRectCache
141
146
  }));
@@ -14,6 +14,8 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
14
14
  var _quickInsertButton = require("../ui/quick-insert-button");
15
15
  var _marks = require("./utils/marks");
16
16
  var _vanillaQuickInsert = require("./vanilla-quick-insert");
17
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
18
+
17
19
  var TYPE_QUICK_INSERT = 'INSERT_BUTTON';
18
20
  var findQuickInsertInsertButtonDecoration = exports.findQuickInsertInsertButtonDecoration = function findQuickInsertInsertButtonDecoration(decorations, from, to) {
19
21
  return decorations.find(from, to, function (spec) {
@@ -31,6 +33,7 @@ var quickInsertButtonDecoration = exports.quickInsertButtonDecoration = function
31
33
  rootNodeType = _ref.rootNodeType,
32
34
  anchorRectCache = _ref.anchorRectCache,
33
35
  editorState = _ref.editorState;
36
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
34
37
  var key = (0, _uuid.default)();
35
38
  var cleanupCallbacks = [];
36
39
  var widgetSpec = (0, _experiments.editorExperiment)('platform_editor_breakout_resizing', true) ? {
@@ -113,7 +113,7 @@ function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNodePos,
113
113
  var destParentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type;
114
114
  var activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type;
115
115
  var layoutColumnContent = srcNode.content;
116
- var isNestingTablesSupported = (0, _platformFeatureFlags.fg)('platform_editor_use_nested_table_pm_nodes') && (0, _experiments.editorExperiment)('nested-tables-in-tables', true, {
116
+ var isNestingTablesSupported = (0, _nesting.isNestedTablesSupported)(schema) && (0, _platformFeatureFlags.fg)('platform_editor_use_nested_table_pm_nodes') && (0, _experiments.editorExperiment)('nested-tables-in-tables', true, {
117
117
  exposure: true
118
118
  });
119
119
  if (activeNodeType === layoutColumn && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
@@ -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.DropTargetLayout = void 0;
7
+ exports.DropTargetLayoutNativeAnchorSupport = exports.DropTargetLayout = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _react = require("react");
@@ -130,9 +130,122 @@ var DropTargetLayout = exports.DropTargetLayout = function DropTargetLayout(prop
130
130
  edge: "right",
131
131
  gap: "-".concat(DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH, "px")
132
132
  }) : (isActiveAnchor || (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true)) && (0, _react2.jsx)("div", {
133
- "data-testid": "block-ctrl-drop-hint"
133
+ "data-testid": "block-ctrl-drop-hint",
134
+ css: dropTargetLayoutHintStyle
135
+ }));
136
+ };
137
+ var DropTargetLayoutNativeAnchorSupport = exports.DropTargetLayoutNativeAnchorSupport = function DropTargetLayoutNativeAnchorSupport(props) {
138
+ var _api$blockControls3;
139
+ var api = props.api,
140
+ getPos = props.getPos,
141
+ parent = props.parent,
142
+ anchorRectCache = props.anchorRectCache;
143
+ var ref = (0, _react.useRef)(null);
144
+ var _useState3 = (0, _react.useState)(false),
145
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
146
+ isDraggedOver = _useState4[0],
147
+ setIsDraggedOver = _useState4[1];
148
+ var anchorName = (0, _decorationsCommon.getNodeAnchor)(parent);
149
+ var _useState5 = (0, _react.useState)(null),
150
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
151
+ nextNodeAnchorName = _useState6[0],
152
+ setNextNodeAnchorName = _useState6[1];
153
+ var readNextNodeAnchor = (0, _react.useCallback)(function () {
154
+ var _ref$current2, _nextElementSibling$g;
155
+ var nextElementSibling = (_ref$current2 = ref.current) === null || _ref$current2 === void 0 || (_ref$current2 = _ref$current2.parentElement) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.nextElementSibling;
156
+ var attrName = (0, _domAttrName.getAnchorAttrName)();
157
+ var nextAnchorName = (_nextElementSibling$g = nextElementSibling === null || nextElementSibling === void 0 ? void 0 : nextElementSibling.getAttribute(attrName)) !== null && _nextElementSibling$g !== void 0 ? _nextElementSibling$g : null;
158
+ setNextNodeAnchorName(function (prev) {
159
+ return prev === nextAnchorName ? prev : nextAnchorName;
160
+ });
161
+ }, []);
162
+ var height = (0, _react.useMemo)(function () {
163
+ if (nextNodeAnchorName) {
164
+ if ((0, _anchorUtils.isAnchorSupported)()) {
165
+ return "anchor-size(".concat(nextNodeAnchorName, " height)");
166
+ } else if (anchorRectCache) {
167
+ var layoutColumnRect = anchorRectCache.getRect(nextNodeAnchorName);
168
+ return "".concat((layoutColumnRect === null || layoutColumnRect === void 0 ? void 0 : layoutColumnRect.height) || 0, "px");
169
+ }
170
+ }
171
+ // Stacked mode fallback: minimal height to avoid oversized hint on first render
172
+ return '0px';
173
+ }, [nextNodeAnchorName, anchorRectCache]);
174
+ (0, _react.useLayoutEffect)(function () {
175
+ var raf = requestAnimationFrame(function () {
176
+ readNextNodeAnchor();
177
+ });
178
+ return function () {
179
+ return cancelAnimationFrame(raf);
180
+ };
181
+ }, [readNextNodeAnchor]);
182
+ var dropTargetStackLayoutHintStyle = (0, _react2.css)((0, _defineProperty2.default)({}, "@container layout-area (max-width:".concat(_editorSharedStyles.layoutBreakpointWidth.MEDIUM - 1, "px)"), {
183
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
184
+ height: height,
185
+ marginTop: "var(--ds-space-050, 4px)"
186
+ }));
187
+ var _useActiveAnchorTrack3 = (0, _activeAnchorTracker.useActiveAnchorTracker)(anchorName),
188
+ _useActiveAnchorTrack4 = (0, _slicedToArray2.default)(_useActiveAnchorTrack3, 1),
189
+ isActiveAnchor = _useActiveAnchorTrack4[0];
190
+ var _ref4 = (api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.sharedState.currentState()) || {},
191
+ activeNode = _ref4.activeNode;
192
+ var onDrop = (0, _react.useCallback)(function () {
193
+ if (!activeNode) {
194
+ return;
195
+ }
196
+ var to = getPos();
197
+ var mappedTo;
198
+ if (to !== undefined) {
199
+ var _api$core3, _api$core4;
200
+ var from = activeNode.pos;
201
+ api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref5) {
202
+ var _api$blockControls4;
203
+ var tr = _ref5.tr;
204
+ api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || (_api$blockControls4 = _api$blockControls4.commands) === null || _api$blockControls4 === void 0 || _api$blockControls4.moveToLayout(from, to)({
205
+ tr: tr
206
+ });
207
+ var insertColumnStep = (0, _updateSelection.getInsertLayoutStep)(tr);
208
+ mappedTo = insertColumnStep === null || insertColumnStep === void 0 ? void 0 : insertColumnStep.from;
209
+ return tr;
210
+ });
211
+ api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref6) {
212
+ var tr = _ref6.tr;
213
+ if (mappedTo !== undefined) {
214
+ (0, _updateSelection.updateSelection)(tr, mappedTo);
215
+ }
216
+ return tr;
217
+ });
218
+ }
219
+ }, [api, getPos, activeNode]);
220
+ (0, _react.useEffect)(function () {
221
+ if (ref.current) {
222
+ return (0, _adapter.dropTargetForElements)({
223
+ element: ref.current,
224
+ onDragEnter: function onDragEnter() {
225
+ setIsDraggedOver(true);
226
+ readNextNodeAnchor();
227
+ },
228
+ onDragLeave: function onDragLeave() {
229
+ setIsDraggedOver(false);
230
+ },
231
+ onDrop: onDrop
232
+ });
233
+ }
234
+ }, [onDrop, readNextNodeAnchor]);
235
+ if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') {
236
+ return null;
237
+ }
238
+ return (0, _react2.jsx)("div", {
239
+ ref: ref
134
240
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
135
241
  ,
242
+ css: [dropTargetLayoutStyle, dropTargetStackLayoutHintStyle],
243
+ "data-testid": "block-ctrl-drop-indicator"
244
+ }, isDraggedOver ? (0, _react2.jsx)(_box.DropIndicator, {
245
+ edge: "right",
246
+ gap: "-".concat(DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH, "px")
247
+ }) : (isActiveAnchor || (0, _expValEquals.expValEquals)('platform_editor_native_anchor_support', 'isEnabled', true)) && (0, _react2.jsx)("div", {
248
+ "data-testid": "block-ctrl-drop-hint",
136
249
  css: dropTargetLayoutHintStyle
137
250
  }));
138
251
  };
@@ -1,5 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import ReactDOM from 'react-dom';
3
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
3
4
  import uuid from 'uuid';
4
5
  export const TYPE_DROP_TARGET_DEC = 'drop-target-decoration';
5
6
  export const TYPE_HANDLE_DEC = 'drag-handle';
@@ -18,6 +19,7 @@ class ObjHash {
18
19
  if (this.caching.has(node)) {
19
20
  return this.caching.get(node);
20
21
  }
22
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
21
23
  const uniqueId = uuid();
22
24
  this.caching.set(node, uniqueId);
23
25
  return uniqueId;
@@ -1,6 +1,7 @@
1
1
  import { createElement } from 'react';
2
2
  import { bind } from 'bind-event-listener';
3
3
  import ReactDOM from 'react-dom';
4
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
4
5
  import uuid from 'uuid';
5
6
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
6
7
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -38,10 +39,12 @@ export const dragHandleDecoration = ({
38
39
  unmountDecorations(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
39
40
  }
40
41
  let unbind;
42
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
41
43
  const key = uuid();
42
44
  const widgetSpec = editorExperiment('platform_editor_breakout_resizing', true) ? {
43
45
  side: -1,
44
46
  type: TYPE_HANDLE_DEC,
47
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
45
48
  testid: `${TYPE_HANDLE_DEC}-${uuid()}`,
46
49
  /**
47
50
  * sigh - `marks` influences the position that the widget is drawn (as described on the `side` property).
@@ -58,6 +61,7 @@ export const dragHandleDecoration = ({
58
61
  } : {
59
62
  side: -1,
60
63
  type: TYPE_HANDLE_DEC,
64
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
61
65
  testid: `${TYPE_HANDLE_DEC}-${uuid()}`,
62
66
  destroy: node => {
63
67
  unbind && unbind();
@@ -1,12 +1,15 @@
1
1
  import { createElement } from 'react';
2
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
2
3
  import uuid from 'uuid';
3
4
  import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
4
5
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
5
6
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
8
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
9
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
10
  import { nodeMargins } from '../ui/consts';
8
11
  import { DropTarget, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET } from '../ui/drop-target';
9
- import { DropTargetLayout } from '../ui/drop-target-layout';
12
+ import { DropTargetLayout, DropTargetLayoutNativeAnchorSupport } from '../ui/drop-target-layout';
10
13
  import { NESTED_DEPTH, TYPE_DROP_TARGET_DEC } from './decorations-common';
11
14
  import { maxLayoutColumnSupported } from './utils/consts';
12
15
  import { canMoveNodeToIndex, canMoveSliceToIndex, isInSameLayout } from './utils/validation';
@@ -71,6 +74,7 @@ export const findDropTargetDecs = (decorations, from, to) => {
71
74
  return decorations.find(from, to, spec => spec.type === TYPE_DROP_TARGET_DEC);
72
75
  };
73
76
  export const createDropTargetDecoration = (pos, props, nodeViewPortalProviderAPI, side, anchorRectCache, isSameLayout) => {
77
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
74
78
  const key = uuid();
75
79
  return Decoration.widget(pos, (_, getPosUnsafe) => {
76
80
  const getPos = () => {
@@ -109,6 +113,7 @@ export const createDropTargetDecoration = (pos, props, nodeViewPortalProviderAPI
109
113
  });
110
114
  };
111
115
  export const createLayoutDropTargetDecoration = (pos, props, nodeViewPortalProviderAPI, anchorRectCache) => {
116
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
112
117
  const key = uuid();
113
118
  return Decoration.widget(pos, (_, getPosUnsafe) => {
114
119
  const getPos = () => {
@@ -122,7 +127,8 @@ export const createLayoutDropTargetDecoration = (pos, props, nodeViewPortalProvi
122
127
  element.setAttribute('data-blocks-drop-target-container', 'true');
123
128
  element.setAttribute('data-blocks-drop-target-key', key);
124
129
  element.style.clear = 'unset';
125
- nodeViewPortalProviderAPI.render(() => /*#__PURE__*/createElement(DropTargetLayout, {
130
+ const DropTargetLayoutComponent = expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) && fg('editor_native_anchor_update_layout_drop_hint') ? DropTargetLayoutNativeAnchorSupport : DropTargetLayout;
131
+ nodeViewPortalProviderAPI.render(() => /*#__PURE__*/createElement(DropTargetLayoutComponent, {
126
132
  ...props,
127
133
  getPos,
128
134
  anchorRectCache
@@ -1,4 +1,5 @@
1
1
  import { createElement } from 'react';
2
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
2
3
  import uuid from 'uuid';
3
4
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
4
5
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -23,6 +24,7 @@ export const quickInsertButtonDecoration = ({
23
24
  anchorRectCache,
24
25
  editorState
25
26
  }) => {
27
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
26
28
  const key = uuid();
27
29
  const cleanupCallbacks = [];
28
30
  const widgetSpec = editorExperiment('platform_editor_breakout_resizing', true) ? {
@@ -1,5 +1,5 @@
1
1
  import memoizeOne from 'memoize-one';
2
- import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
2
+ import { getParentOfTypeCount, isNestedTablesSupported } from '@atlaskit/editor-common/nesting';
3
3
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
4
4
  import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -104,7 +104,7 @@ export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNo
104
104
  const destParentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type;
105
105
  const activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type;
106
106
  const layoutColumnContent = srcNode.content;
107
- const isNestingTablesSupported = fg('platform_editor_use_nested_table_pm_nodes') && editorExperiment('nested-tables-in-tables', true, {
107
+ const isNestingTablesSupported = isNestedTablesSupported(schema) && fg('platform_editor_use_nested_table_pm_nodes') && editorExperiment('nested-tables-in-tables', true, {
108
108
  exposure: true
109
109
  });
110
110
  if (activeNodeType === layoutColumn && editorExperiment('advanced_layouts', true)) {
@@ -2,7 +2,7 @@
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
4
  */
5
- import { useCallback, useEffect, useRef, useState } from 'react';
5
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
6
6
 
7
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
8
8
  import { css, jsx } from '@emotion/react';
@@ -127,9 +127,121 @@ export const DropTargetLayout = props => {
127
127
  edge: "right",
128
128
  gap: `-${DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH}px`
129
129
  }) : (isActiveAnchor || expValEquals('platform_editor_native_anchor_support', 'isEnabled', true)) && jsx("div", {
130
- "data-testid": "block-ctrl-drop-hint"
130
+ "data-testid": "block-ctrl-drop-hint",
131
+ css: dropTargetLayoutHintStyle
132
+ }));
133
+ };
134
+ export const DropTargetLayoutNativeAnchorSupport = props => {
135
+ var _api$blockControls3;
136
+ const {
137
+ api,
138
+ getPos,
139
+ parent,
140
+ anchorRectCache
141
+ } = props;
142
+ const ref = useRef(null);
143
+ const [isDraggedOver, setIsDraggedOver] = useState(false);
144
+ const anchorName = getNodeAnchor(parent);
145
+ const [nextNodeAnchorName, setNextNodeAnchorName] = useState(null);
146
+ const readNextNodeAnchor = useCallback(() => {
147
+ var _ref$current2, _ref$current2$parentE, _nextElementSibling$g;
148
+ const nextElementSibling = (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : (_ref$current2$parentE = _ref$current2.parentElement) === null || _ref$current2$parentE === void 0 ? void 0 : _ref$current2$parentE.nextElementSibling;
149
+ const attrName = getAnchorAttrName();
150
+ const nextAnchorName = (_nextElementSibling$g = nextElementSibling === null || nextElementSibling === void 0 ? void 0 : nextElementSibling.getAttribute(attrName)) !== null && _nextElementSibling$g !== void 0 ? _nextElementSibling$g : null;
151
+ setNextNodeAnchorName(prev => prev === nextAnchorName ? prev : nextAnchorName);
152
+ }, []);
153
+ const height = useMemo(() => {
154
+ if (nextNodeAnchorName) {
155
+ if (isAnchorSupported()) {
156
+ return `anchor-size(${nextNodeAnchorName} height)`;
157
+ } else if (anchorRectCache) {
158
+ const layoutColumnRect = anchorRectCache.getRect(nextNodeAnchorName);
159
+ return `${(layoutColumnRect === null || layoutColumnRect === void 0 ? void 0 : layoutColumnRect.height) || 0}px`;
160
+ }
161
+ }
162
+ // Stacked mode fallback: minimal height to avoid oversized hint on first render
163
+ return '0px';
164
+ }, [nextNodeAnchorName, anchorRectCache]);
165
+ useLayoutEffect(() => {
166
+ const raf = requestAnimationFrame(() => {
167
+ readNextNodeAnchor();
168
+ });
169
+ return () => cancelAnimationFrame(raf);
170
+ }, [readNextNodeAnchor]);
171
+ const dropTargetStackLayoutHintStyle = css({
172
+ // jest warning: JSDOM version (22) doesn't support the new @container CSS rule
173
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-container-queries, @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
174
+ [`@container layout-area (max-width:${layoutBreakpointWidth.MEDIUM - 1}px)`]: {
175
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
176
+ height,
177
+ marginTop: `${"var(--ds-space-050, 4px)"}`
178
+ }
179
+ });
180
+ const [isActiveAnchor] = useActiveAnchorTracker(anchorName);
181
+ const {
182
+ activeNode
183
+ } = (api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.sharedState.currentState()) || {};
184
+ const onDrop = useCallback(() => {
185
+ if (!activeNode) {
186
+ return;
187
+ }
188
+ const to = getPos();
189
+ let mappedTo;
190
+ if (to !== undefined) {
191
+ var _api$core3, _api$core4;
192
+ const {
193
+ pos: from
194
+ } = activeNode;
195
+ api === null || api === void 0 ? void 0 : (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(({
196
+ tr
197
+ }) => {
198
+ var _api$blockControls4, _api$blockControls4$c;
199
+ api === null || api === void 0 ? void 0 : (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : (_api$blockControls4$c = _api$blockControls4.commands) === null || _api$blockControls4$c === void 0 ? void 0 : _api$blockControls4$c.moveToLayout(from, to)({
200
+ tr
201
+ });
202
+ const insertColumnStep = getInsertLayoutStep(tr);
203
+ mappedTo = insertColumnStep === null || insertColumnStep === void 0 ? void 0 : insertColumnStep.from;
204
+ return tr;
205
+ });
206
+ api === null || api === void 0 ? void 0 : (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions.execute(({
207
+ tr
208
+ }) => {
209
+ if (mappedTo !== undefined) {
210
+ updateSelection(tr, mappedTo);
211
+ }
212
+ return tr;
213
+ });
214
+ }
215
+ }, [api, getPos, activeNode]);
216
+ useEffect(() => {
217
+ if (ref.current) {
218
+ return dropTargetForElements({
219
+ element: ref.current,
220
+ onDragEnter: () => {
221
+ setIsDraggedOver(true);
222
+ readNextNodeAnchor();
223
+ },
224
+ onDragLeave: () => {
225
+ setIsDraggedOver(false);
226
+ },
227
+ onDrop
228
+ });
229
+ }
230
+ }, [onDrop, readNextNodeAnchor]);
231
+ if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') {
232
+ return null;
233
+ }
234
+ return jsx("div", {
235
+ ref: ref
131
236
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
132
237
  ,
238
+ css: [dropTargetLayoutStyle, dropTargetStackLayoutHintStyle],
239
+ "data-testid": "block-ctrl-drop-indicator"
240
+ }, isDraggedOver ? jsx(DropIndicator, {
241
+ edge: "right",
242
+ gap: `-${DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH}px`
243
+ }) : (isActiveAnchor || expValEquals('platform_editor_native_anchor_support', 'isEnabled', true)) && jsx("div", {
244
+ "data-testid": "block-ctrl-drop-hint",
133
245
  css: dropTargetLayoutHintStyle
134
246
  }));
135
247
  };
@@ -2,6 +2,7 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import ReactDOM from 'react-dom';
5
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
5
6
  import uuid from 'uuid';
6
7
  export var TYPE_DROP_TARGET_DEC = 'drop-target-decoration';
7
8
  export var TYPE_HANDLE_DEC = 'drag-handle';
@@ -25,6 +26,7 @@ var ObjHash = /*#__PURE__*/function () {
25
26
  if (this.caching.has(node)) {
26
27
  return this.caching.get(node);
27
28
  }
29
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
28
30
  var uniqueId = uuid();
29
31
  this.caching.set(node, uniqueId);
30
32
  return uniqueId;
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { createElement } from 'react';
3
3
  import { bind } from 'bind-event-listener';
4
4
  import ReactDOM from 'react-dom';
5
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
5
6
  import uuid from 'uuid';
6
7
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
7
8
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -39,10 +40,12 @@ export var dragHandleDecoration = function dragHandleDecoration(_ref) {
39
40
  unmountDecorations(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
40
41
  }
41
42
  var unbind;
43
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
42
44
  var key = uuid();
43
45
  var widgetSpec = editorExperiment('platform_editor_breakout_resizing', true) ? {
44
46
  side: -1,
45
47
  type: TYPE_HANDLE_DEC,
48
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
46
49
  testid: "".concat(TYPE_HANDLE_DEC, "-").concat(uuid()),
47
50
  /**
48
51
  * sigh - `marks` influences the position that the widget is drawn (as described on the `side` property).
@@ -59,6 +62,7 @@ export var dragHandleDecoration = function dragHandleDecoration(_ref) {
59
62
  } : {
60
63
  side: -1,
61
64
  type: TYPE_HANDLE_DEC,
65
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
62
66
  testid: "".concat(TYPE_HANDLE_DEC, "-").concat(uuid()),
63
67
  destroy: function destroy(node) {
64
68
  unbind && unbind();
@@ -2,14 +2,17 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  import { createElement } from 'react';
5
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
5
6
  import uuid from 'uuid';
6
7
  import { expandSelectionBounds } from '@atlaskit/editor-common/selection';
7
8
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
8
9
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
11
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
9
12
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
13
  import { nodeMargins } from '../ui/consts';
11
14
  import { DropTarget, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET } from '../ui/drop-target';
12
- import { DropTargetLayout } from '../ui/drop-target-layout';
15
+ import { DropTargetLayout, DropTargetLayoutNativeAnchorSupport } from '../ui/drop-target-layout';
13
16
  import { NESTED_DEPTH, TYPE_DROP_TARGET_DEC } from './decorations-common';
14
17
  import { maxLayoutColumnSupported } from './utils/consts';
15
18
  import { canMoveNodeToIndex, canMoveSliceToIndex, isInSameLayout } from './utils/validation';
@@ -76,6 +79,7 @@ export var findDropTargetDecs = function findDropTargetDecs(decorations, from, t
76
79
  });
77
80
  };
78
81
  export var createDropTargetDecoration = function createDropTargetDecoration(pos, props, nodeViewPortalProviderAPI, side, anchorRectCache, isSameLayout) {
82
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
79
83
  var key = uuid();
80
84
  return Decoration.widget(pos, function (_, getPosUnsafe) {
81
85
  var getPos = function getPos() {
@@ -114,6 +118,7 @@ export var createDropTargetDecoration = function createDropTargetDecoration(pos,
114
118
  });
115
119
  };
116
120
  export var createLayoutDropTargetDecoration = function createLayoutDropTargetDecoration(pos, props, nodeViewPortalProviderAPI, anchorRectCache) {
121
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
117
122
  var key = uuid();
118
123
  return Decoration.widget(pos, function (_, getPosUnsafe) {
119
124
  var getPos = function getPos() {
@@ -127,8 +132,9 @@ export var createLayoutDropTargetDecoration = function createLayoutDropTargetDec
127
132
  element.setAttribute('data-blocks-drop-target-container', 'true');
128
133
  element.setAttribute('data-blocks-drop-target-key', key);
129
134
  element.style.clear = 'unset';
135
+ var DropTargetLayoutComponent = expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) && fg('editor_native_anchor_update_layout_drop_hint') ? DropTargetLayoutNativeAnchorSupport : DropTargetLayout;
130
136
  nodeViewPortalProviderAPI.render(function () {
131
- return /*#__PURE__*/createElement(DropTargetLayout, _objectSpread(_objectSpread({}, props), {}, {
137
+ return /*#__PURE__*/createElement(DropTargetLayoutComponent, _objectSpread(_objectSpread({}, props), {}, {
132
138
  getPos: getPos,
133
139
  anchorRectCache: anchorRectCache
134
140
  }));
@@ -1,4 +1,5 @@
1
1
  import { createElement } from 'react';
2
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
2
3
  import uuid from 'uuid';
3
4
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
4
5
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -24,6 +25,7 @@ export var quickInsertButtonDecoration = function quickInsertButtonDecoration(_r
24
25
  rootNodeType = _ref.rootNodeType,
25
26
  anchorRectCache = _ref.anchorRectCache,
26
27
  editorState = _ref.editorState;
28
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
27
29
  var key = uuid();
28
30
  var cleanupCallbacks = [];
29
31
  var widgetSpec = editorExperiment('platform_editor_breakout_resizing', true) ? {
@@ -1,5 +1,5 @@
1
1
  import memoizeOne from 'memoize-one';
2
- import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
2
+ import { getParentOfTypeCount, isNestedTablesSupported } from '@atlaskit/editor-common/nesting';
3
3
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
4
4
  import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -103,7 +103,7 @@ export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNo
103
103
  var destParentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type;
104
104
  var activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type;
105
105
  var layoutColumnContent = srcNode.content;
106
- var isNestingTablesSupported = fg('platform_editor_use_nested_table_pm_nodes') && editorExperiment('nested-tables-in-tables', true, {
106
+ var isNestingTablesSupported = isNestedTablesSupported(schema) && fg('platform_editor_use_nested_table_pm_nodes') && editorExperiment('nested-tables-in-tables', true, {
107
107
  exposure: true
108
108
  });
109
109
  if (activeNodeType === layoutColumn && editorExperiment('advanced_layouts', true)) {
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  * @jsxRuntime classic
5
5
  * @jsx jsx
6
6
  */
7
- import { useCallback, useEffect, useRef, useState } from 'react';
7
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
8
8
 
9
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
10
10
  import { css, jsx } from '@emotion/react';
@@ -123,9 +123,122 @@ export var DropTargetLayout = function DropTargetLayout(props) {
123
123
  edge: "right",
124
124
  gap: "-".concat(DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH, "px")
125
125
  }) : (isActiveAnchor || expValEquals('platform_editor_native_anchor_support', 'isEnabled', true)) && jsx("div", {
126
- "data-testid": "block-ctrl-drop-hint"
126
+ "data-testid": "block-ctrl-drop-hint",
127
+ css: dropTargetLayoutHintStyle
128
+ }));
129
+ };
130
+ export var DropTargetLayoutNativeAnchorSupport = function DropTargetLayoutNativeAnchorSupport(props) {
131
+ var _api$blockControls3;
132
+ var api = props.api,
133
+ getPos = props.getPos,
134
+ parent = props.parent,
135
+ anchorRectCache = props.anchorRectCache;
136
+ var ref = useRef(null);
137
+ var _useState3 = useState(false),
138
+ _useState4 = _slicedToArray(_useState3, 2),
139
+ isDraggedOver = _useState4[0],
140
+ setIsDraggedOver = _useState4[1];
141
+ var anchorName = getNodeAnchor(parent);
142
+ var _useState5 = useState(null),
143
+ _useState6 = _slicedToArray(_useState5, 2),
144
+ nextNodeAnchorName = _useState6[0],
145
+ setNextNodeAnchorName = _useState6[1];
146
+ var readNextNodeAnchor = useCallback(function () {
147
+ var _ref$current2, _nextElementSibling$g;
148
+ var nextElementSibling = (_ref$current2 = ref.current) === null || _ref$current2 === void 0 || (_ref$current2 = _ref$current2.parentElement) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.nextElementSibling;
149
+ var attrName = getAnchorAttrName();
150
+ var nextAnchorName = (_nextElementSibling$g = nextElementSibling === null || nextElementSibling === void 0 ? void 0 : nextElementSibling.getAttribute(attrName)) !== null && _nextElementSibling$g !== void 0 ? _nextElementSibling$g : null;
151
+ setNextNodeAnchorName(function (prev) {
152
+ return prev === nextAnchorName ? prev : nextAnchorName;
153
+ });
154
+ }, []);
155
+ var height = useMemo(function () {
156
+ if (nextNodeAnchorName) {
157
+ if (isAnchorSupported()) {
158
+ return "anchor-size(".concat(nextNodeAnchorName, " height)");
159
+ } else if (anchorRectCache) {
160
+ var layoutColumnRect = anchorRectCache.getRect(nextNodeAnchorName);
161
+ return "".concat((layoutColumnRect === null || layoutColumnRect === void 0 ? void 0 : layoutColumnRect.height) || 0, "px");
162
+ }
163
+ }
164
+ // Stacked mode fallback: minimal height to avoid oversized hint on first render
165
+ return '0px';
166
+ }, [nextNodeAnchorName, anchorRectCache]);
167
+ useLayoutEffect(function () {
168
+ var raf = requestAnimationFrame(function () {
169
+ readNextNodeAnchor();
170
+ });
171
+ return function () {
172
+ return cancelAnimationFrame(raf);
173
+ };
174
+ }, [readNextNodeAnchor]);
175
+ var dropTargetStackLayoutHintStyle = css(_defineProperty({}, "@container layout-area (max-width:".concat(layoutBreakpointWidth.MEDIUM - 1, "px)"), {
176
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
177
+ height: height,
178
+ marginTop: "var(--ds-space-050, 4px)"
179
+ }));
180
+ var _useActiveAnchorTrack3 = useActiveAnchorTracker(anchorName),
181
+ _useActiveAnchorTrack4 = _slicedToArray(_useActiveAnchorTrack3, 1),
182
+ isActiveAnchor = _useActiveAnchorTrack4[0];
183
+ var _ref4 = (api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.sharedState.currentState()) || {},
184
+ activeNode = _ref4.activeNode;
185
+ var onDrop = useCallback(function () {
186
+ if (!activeNode) {
187
+ return;
188
+ }
189
+ var to = getPos();
190
+ var mappedTo;
191
+ if (to !== undefined) {
192
+ var _api$core3, _api$core4;
193
+ var from = activeNode.pos;
194
+ api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref5) {
195
+ var _api$blockControls4;
196
+ var tr = _ref5.tr;
197
+ api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || (_api$blockControls4 = _api$blockControls4.commands) === null || _api$blockControls4 === void 0 || _api$blockControls4.moveToLayout(from, to)({
198
+ tr: tr
199
+ });
200
+ var insertColumnStep = getInsertLayoutStep(tr);
201
+ mappedTo = insertColumnStep === null || insertColumnStep === void 0 ? void 0 : insertColumnStep.from;
202
+ return tr;
203
+ });
204
+ api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref6) {
205
+ var tr = _ref6.tr;
206
+ if (mappedTo !== undefined) {
207
+ updateSelection(tr, mappedTo);
208
+ }
209
+ return tr;
210
+ });
211
+ }
212
+ }, [api, getPos, activeNode]);
213
+ useEffect(function () {
214
+ if (ref.current) {
215
+ return dropTargetForElements({
216
+ element: ref.current,
217
+ onDragEnter: function onDragEnter() {
218
+ setIsDraggedOver(true);
219
+ readNextNodeAnchor();
220
+ },
221
+ onDragLeave: function onDragLeave() {
222
+ setIsDraggedOver(false);
223
+ },
224
+ onDrop: onDrop
225
+ });
226
+ }
227
+ }, [onDrop, readNextNodeAnchor]);
228
+ if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') {
229
+ return null;
230
+ }
231
+ return jsx("div", {
232
+ ref: ref
127
233
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
128
234
  ,
235
+ css: [dropTargetLayoutStyle, dropTargetStackLayoutHintStyle],
236
+ "data-testid": "block-ctrl-drop-indicator"
237
+ }, isDraggedOver ? jsx(DropIndicator, {
238
+ edge: "right",
239
+ gap: "-".concat(DROP_TARGET_LAYOUT_DROP_ZONE_WIDTH, "px")
240
+ }) : (isActiveAnchor || expValEquals('platform_editor_native_anchor_support', 'isEnabled', true)) && jsx("div", {
241
+ "data-testid": "block-ctrl-drop-hint",
129
242
  css: dropTargetLayoutHintStyle
130
243
  }));
131
244
  };
@@ -13,3 +13,6 @@ export type DropTargetLayoutProps = {
13
13
  export declare const DropTargetLayout: (props: DropTargetLayoutProps & {
14
14
  anchorRectCache?: AnchorRectCache;
15
15
  }) => jsx.JSX.Element | null;
16
+ export declare const DropTargetLayoutNativeAnchorSupport: (props: DropTargetLayoutProps & {
17
+ anchorRectCache?: AnchorRectCache;
18
+ }) => jsx.JSX.Element | null;
@@ -13,3 +13,6 @@ export type DropTargetLayoutProps = {
13
13
  export declare const DropTargetLayout: (props: DropTargetLayoutProps & {
14
14
  anchorRectCache?: AnchorRectCache;
15
15
  }) => jsx.JSX.Element | null;
16
+ export declare const DropTargetLayoutNativeAnchorSupport: (props: DropTargetLayoutProps & {
17
+ anchorRectCache?: AnchorRectCache;
18
+ }) => jsx.JSX.Element | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "7.5.4",
3
+ "version": "7.5.6",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -53,9 +53,9 @@
53
53
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
54
54
  "@atlaskit/primitives": "^16.1.0",
55
55
  "@atlaskit/theme": "^21.0.0",
56
- "@atlaskit/tmp-editor-statsig": "^13.29.0",
56
+ "@atlaskit/tmp-editor-statsig": "^13.32.0",
57
57
  "@atlaskit/tokens": "^7.1.0",
58
- "@atlaskit/tooltip": "^20.7.0",
58
+ "@atlaskit/tooltip": "^20.8.0",
59
59
  "@babel/runtime": "^7.0.0",
60
60
  "@emotion/react": "^11.7.1",
61
61
  "@popperjs/core": "^2.11.8",
@@ -65,7 +65,7 @@
65
65
  "uuid": "^3.1.0"
66
66
  },
67
67
  "peerDependencies": {
68
- "@atlaskit/editor-common": "^110.22.0",
68
+ "@atlaskit/editor-common": "^110.24.0",
69
69
  "react": "^18.2.0",
70
70
  "react-dom": "^18.2.0",
71
71
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -156,6 +156,9 @@
156
156
  },
157
157
  "platform_editor_toolbar_aifc_user_intent_fix": {
158
158
  "type": "boolean"
159
+ },
160
+ "editor_native_anchor_update_layout_drop_hint": {
161
+ "type": "boolean"
159
162
  }
160
163
  }
161
164
  }