@atlaskit/editor-plugin-block-controls 2.13.13 → 2.13.15

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 (37) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/commands/move-node.js +15 -0
  3. package/dist/cjs/commands/move-to-layout.js +7 -3
  4. package/dist/cjs/pm-plugins/decorations-drop-target.js +3 -0
  5. package/dist/cjs/ui/drop-target-layout.js +7 -4
  6. package/dist/cjs/ui/drop-target-v2.js +4 -5
  7. package/dist/cjs/ui/inline-drop-target.js +8 -2
  8. package/dist/cjs/utils/drag-layout-column.js +24 -0
  9. package/dist/cjs/utils/inline-drop-target.js +4 -0
  10. package/dist/cjs/utils/validation.js +6 -5
  11. package/dist/es2019/commands/move-node.js +15 -0
  12. package/dist/es2019/commands/move-to-layout.js +6 -2
  13. package/dist/es2019/pm-plugins/decorations-drop-target.js +3 -0
  14. package/dist/es2019/ui/drop-target-layout.js +8 -5
  15. package/dist/es2019/ui/drop-target-v2.js +5 -5
  16. package/dist/es2019/ui/inline-drop-target.js +8 -2
  17. package/dist/es2019/utils/drag-layout-column.js +18 -0
  18. package/dist/es2019/utils/inline-drop-target.js +4 -1
  19. package/dist/es2019/utils/validation.js +6 -5
  20. package/dist/esm/commands/move-node.js +15 -0
  21. package/dist/esm/commands/move-to-layout.js +6 -2
  22. package/dist/esm/pm-plugins/decorations-drop-target.js +3 -0
  23. package/dist/esm/ui/drop-target-layout.js +7 -4
  24. package/dist/esm/ui/drop-target-v2.js +4 -5
  25. package/dist/esm/ui/inline-drop-target.js +8 -2
  26. package/dist/esm/utils/drag-layout-column.js +18 -0
  27. package/dist/esm/utils/inline-drop-target.js +4 -0
  28. package/dist/esm/utils/validation.js +6 -5
  29. package/dist/types/commands/move-to-layout.d.ts +3 -0
  30. package/dist/types/ui/drop-target-layout.d.ts +1 -1
  31. package/dist/types/utils/drag-layout-column.d.ts +4 -0
  32. package/dist/types/utils/inline-drop-target.d.ts +2 -1
  33. package/dist/types-ts4.5/commands/move-to-layout.d.ts +3 -0
  34. package/dist/types-ts4.5/ui/drop-target-layout.d.ts +1 -1
  35. package/dist/types-ts4.5/utils/drag-layout-column.d.ts +4 -0
  36. package/dist/types-ts4.5/utils/inline-drop-target.d.ts +2 -1
  37. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 2.13.15
4
+
5
+ ### Patch Changes
6
+
7
+ - [#165354](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/165354)
8
+ [`387f345afdec1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/387f345afdec1) -
9
+ ED-25703 fix inline drop targert position
10
+ - [#162957](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/162957)
11
+ [`bd48c403d1fdd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bd48c403d1fdd) -
12
+ ED-25059 drag layout column to top level
13
+ - Updated dependencies
14
+
15
+ ## 2.13.14
16
+
17
+ ### Patch Changes
18
+
19
+ - [#163579](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/163579)
20
+ [`15dc53a3077f1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/15dc53a3077f1) -
21
+ Hide unnecessary inline drop targets
22
+ - Updated dependencies
23
+
3
24
  ## 2.13.13
4
25
 
5
26
  ### Patch Changes
@@ -11,6 +11,8 @@ var _messages = require("@atlaskit/editor-common/messages");
11
11
  var _selection = require("@atlaskit/editor-common/selection");
12
12
  var _transforms = require("@atlaskit/editor-common/transforms");
13
13
  var _utils = require("@atlaskit/editor-common/utils");
14
+ var _model = require("@atlaskit/editor-prosemirror/model");
15
+ var _state = require("@atlaskit/editor-prosemirror/state");
14
16
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
15
17
  var _utils3 = require("@atlaskit/editor-tables/utils");
16
18
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
@@ -18,8 +20,10 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
18
20
  var _consts = require("../consts");
19
21
  var _main = require("../pm-plugins/main");
20
22
  var _utils4 = require("../utils");
23
+ var _dragLayoutColumn = require("../utils/drag-layout-column");
21
24
  var _getSelection = require("../utils/getSelection");
22
25
  var _validation = require("../utils/validation");
26
+ var _moveToLayout = require("./move-to-layout");
23
27
  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; }
24
28
  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; }
25
29
  /**
@@ -169,6 +173,17 @@ var moveNode = exports.moveNode = function moveNode(api) {
169
173
  var $from = tr.doc.resolve(start);
170
174
  var destType = $to.node().type;
171
175
  var destParent = $to.node($to.depth);
176
+ var sourceNode = $from.nodeAfter;
177
+
178
+ // Move a layout column to top level
179
+ if (sourceNode && (0, _dragLayoutColumn.isDragLayoutColumnToTopLevel)($from, $to)) {
180
+ // need update after we support single column layout.
181
+ var fragment = _model.Fragment.from(sourceNode.content);
182
+ (0, _moveToLayout.removeFromSource)(tr, $from);
183
+ var _mappedTo = tr.mapping.map(to);
184
+ tr.insert(_mappedTo, fragment).setSelection(_state.Selection.near(tr.doc.resolve(_mappedTo))).scrollIntoView();
185
+ return tr;
186
+ }
172
187
  if (!(0, _validation.canMoveNodeToIndex)(destParent, $to.index(), $from.node().child($from.index()))) {
173
188
  return tr;
174
189
  }
@@ -3,11 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.moveToLayout = void 0;
6
+ exports.removeFromSource = exports.moveToLayout = void 0;
7
7
  var _model = require("@atlaskit/editor-prosemirror/model");
8
8
  var _state = require("@atlaskit/editor-prosemirror/state");
9
9
  var _consts = require("../consts");
10
10
  var _consts2 = require("../ui/consts");
11
+ var _dragLayoutColumn = require("../utils/drag-layout-column");
11
12
  var _validation = require("../utils/validation");
12
13
  var createNewLayout = function createNewLayout(schema, layoutContents) {
13
14
  if (layoutContents.length === 0 || layoutContents.length > (0, _consts.maxLayoutColumnSupported)()) {
@@ -60,7 +61,7 @@ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos,
60
61
  }
61
62
  return tr;
62
63
  };
63
- var removeFromSource = function removeFromSource(tr, $from) {
64
+ var removeFromSource = exports.removeFromSource = function removeFromSource(tr, $from) {
64
65
  var sourceNode = $from.nodeAfter;
65
66
  var sourceParent = $from.parent;
66
67
  if (!sourceNode) {
@@ -177,10 +178,13 @@ var moveToLayout = exports.moveToLayout = function moveToLayout(api) {
177
178
  // resolve again the source node after node updated (remove breakout marks)
178
179
  toNodeWithoutBreakout = tr.doc.resolve(to).nodeAfter || toNode;
179
180
  }
181
+ if (fromNodeWithoutBreakout.type.name === 'layoutColumn') {
182
+ fromNodeWithoutBreakout = fromNodeWithoutBreakout.content;
183
+ }
180
184
  var layoutContents = options !== null && options !== void 0 && options.moveToEnd ? [toNodeWithoutBreakout, fromNodeWithoutBreakout] : [fromNodeWithoutBreakout, toNodeWithoutBreakout];
181
185
  var newLayout = createNewLayout(tr.doc.type.schema, layoutContents);
182
186
  if (newLayout) {
183
- tr.delete(from, from + fromNode.nodeSize);
187
+ tr = (0, _dragLayoutColumn.deleteSourceNode)(tr, $from, $to);
184
188
  var mappedTo = tr.mapping.map(to);
185
189
  tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout).setSelection(new _state.NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
186
190
  }
@@ -163,6 +163,9 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
163
163
  if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
164
164
  depth = $pos.depth;
165
165
  if (isAdvancedLayoutsPreRelease2) {
166
+ if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos) === pos && activeNode.nodeType !== 'layoutColumn') {
167
+ return false;
168
+ }
166
169
  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 && (
167
170
  // Not the first node
168
171
  (parent === null || parent === void 0 ? void 0 : parent.childCount) < (0, _consts.maxLayoutColumnSupported)() || isSameLayout)) {
@@ -39,6 +39,7 @@ var dropTargetLayoutHintStyle = (0, _react2.css)({
39
39
  width: 0
40
40
  });
41
41
  var DropTargetLayout = exports.DropTargetLayout = function DropTargetLayout(props) {
42
+ var _api$blockControls;
42
43
  var api = props.api,
43
44
  getPos = props.getPos,
44
45
  parent = props.parent;
@@ -51,10 +52,9 @@ var DropTargetLayout = exports.DropTargetLayout = function DropTargetLayout(prop
51
52
  var _useActiveAnchorTrack = (0, _activeAnchorTracker.useActiveAnchorTracker)(anchorName),
52
53
  _useActiveAnchorTrack2 = (0, _slicedToArray2.default)(_useActiveAnchorTrack, 1),
53
54
  isActiveAnchor = _useActiveAnchorTrack2[0];
55
+ var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
56
+ activeNode = _ref.activeNode;
54
57
  var onDrop = (0, _react.useCallback)(function () {
55
- var _api$blockControls;
56
- var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
57
- activeNode = _ref.activeNode;
58
58
  if (!activeNode) {
59
59
  return;
60
60
  }
@@ -64,7 +64,7 @@ var DropTargetLayout = exports.DropTargetLayout = function DropTargetLayout(prop
64
64
  var from = activeNode.pos;
65
65
  api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.moveToLayout(from, to));
66
66
  }
67
- }, [api, getPos]);
67
+ }, [api, getPos, activeNode]);
68
68
  (0, _react.useEffect)(function () {
69
69
  if (ref.current) {
70
70
  return (0, _adapter.dropTargetForElements)({
@@ -79,6 +79,9 @@ var DropTargetLayout = exports.DropTargetLayout = function DropTargetLayout(prop
79
79
  });
80
80
  }
81
81
  }, [onDrop]);
82
+ if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') {
83
+ return null;
84
+ }
82
85
  return (0, _react2.jsx)("div", {
83
86
  ref: ref,
84
87
  css: dropTargetLayoutStyle,
@@ -178,7 +178,7 @@ var HoverZone = function HoverZone(_ref) {
178
178
  });
179
179
  };
180
180
  var DropTargetV2 = exports.DropTargetV2 = function DropTargetV2(props) {
181
- var _dynamicStyle;
181
+ var _api$blockControls, _dynamicStyle;
182
182
  var api = props.api,
183
183
  getPos = props.getPos,
184
184
  prevNode = props.prevNode,
@@ -196,10 +196,9 @@ var DropTargetV2 = exports.DropTargetV2 = function DropTargetV2(props) {
196
196
  var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width']),
197
197
  widthState = _useSharedPluginState.widthState;
198
198
  var isNestedDropTarget = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) !== 'doc';
199
+ var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
200
+ activeNode = _ref2.activeNode;
199
201
  var onDrop = function onDrop() {
200
- var _api$blockControls;
201
- var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
202
- activeNode = _ref2.activeNode;
203
202
  if (!activeNode) {
204
203
  return;
205
204
  }
@@ -255,7 +254,7 @@ var DropTargetV2 = exports.DropTargetV2 = function DropTargetV2(props) {
255
254
  anchorRectCache: anchorRectCache,
256
255
  position: "lower",
257
256
  isNestedDropTarget: isNestedDropTarget
258
- }), (0, _inlineDropTarget.shouldAllowInlineDropTarget)(isNestedDropTarget, nextNode, isSameLayout) && (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_inlineDropTarget2.InlineDropTarget, (0, _extends2.default)({}, props, {
257
+ }), (0, _inlineDropTarget.shouldAllowInlineDropTarget)(isNestedDropTarget, nextNode, isSameLayout, activeNode) && (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_inlineDropTarget2.InlineDropTarget, (0, _extends2.default)({}, props, {
259
258
  position: "left"
260
259
  })), (0, _react2.jsx)(_inlineDropTarget2.InlineDropTarget, (0, _extends2.default)({}, props, {
261
260
  position: "right"
@@ -61,6 +61,7 @@ var getWidthOffset = function getWidthOffset(node, width, position) {
61
61
  return '-12px';
62
62
  }
63
63
  };
64
+ var TABLE_NUMBERED_COLUMN_WIDTH = 42;
64
65
  var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref) {
65
66
  var api = _ref.api,
66
67
  nextNode = _ref.nextNode,
@@ -92,9 +93,14 @@ var InlineDropTarget = exports.InlineDropTarget = function InlineDropTarget(_ref
92
93
  innerContainerWidth = 'max(calc(var(--ak-editor-max-container-width) - var(--ak-editor--default-gutter-padding) * 2), var(--ak-editor--line-length))';
93
94
  }
94
95
  } else if (nextNode.type.name === 'table' && nextNode.firstChild) {
95
- var _anchorRectCache$getR;
96
96
  var tableWidthAnchor = (0, _decorationsCommon.getNodeAnchor)(nextNode.firstChild);
97
- innerContainerWidth = (0, _anchorUtils.isAnchorSupported)() ? "anchor-size(".concat(tableWidthAnchor, " width)") : "".concat((anchorRectCache === null || anchorRectCache === void 0 || (_anchorRectCache$getR = anchorRectCache.getRect(tableWidthAnchor)) === null || _anchorRectCache$getR === void 0 ? void 0 : _anchorRectCache$getR.width) || 0, "px");
97
+ var isNumberColumnEnabled = Boolean(nextNode.attrs.isNumberColumnEnabled);
98
+ if ((0, _anchorUtils.isAnchorSupported)()) {
99
+ innerContainerWidth = isNumberColumnEnabled ? "calc(anchor-size(".concat(tableWidthAnchor, " width) + ").concat(TABLE_NUMBERED_COLUMN_WIDTH, "px)") : "anchor-size(".concat(tableWidthAnchor, " width)");
100
+ } else {
101
+ var _anchorRectCache$getR;
102
+ innerContainerWidth = "".concat(((anchorRectCache === null || anchorRectCache === void 0 || (_anchorRectCache$getR = anchorRectCache.getRect(tableWidthAnchor)) === null || _anchorRectCache$getR === void 0 ? void 0 : _anchorRectCache$getR.width) || 0) + TABLE_NUMBERED_COLUMN_WIDTH, "px");
103
+ }
98
104
  if (nextNode.attrs.width) {
99
105
  // when the table has horizontal scroll
100
106
  innerContainerWidth = "min(".concat(nextNode.attrs.width, "px, ").concat(innerContainerWidth, ")");
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isDragLayoutColumnToTopLevel = exports.deleteSourceNode = void 0;
7
+ var isDragLayoutColumnToTopLevel = exports.isDragLayoutColumnToTopLevel = function isDragLayoutColumnToTopLevel($from, $to) {
8
+ var _$from$nodeAfter;
9
+ return ((_$from$nodeAfter = $from.nodeAfter) === null || _$from$nodeAfter === void 0 ? void 0 : _$from$nodeAfter.type.name) === 'layoutColumn' && $from.parent.type.name === 'layoutSection' && $to.depth === 0;
10
+ };
11
+ var deleteSourceNode = exports.deleteSourceNode = function deleteSourceNode(tr, $from, $to) {
12
+ if ($from.nodeAfter) {
13
+ var fromNode = $from.nodeAfter;
14
+ if (isDragLayoutColumnToTopLevel($from, $to)) {
15
+ // need update after we support single column layout.
16
+ if ($from.parent.childCount <= 2) {
17
+ tr.deleteRange($from.pos + 1, $from.pos + fromNode.nodeSize - 1);
18
+ return tr;
19
+ }
20
+ }
21
+ tr.deleteRange($from.pos, $from.pos + fromNode.nodeSize);
22
+ }
23
+ return tr;
24
+ };
@@ -10,12 +10,16 @@ var _advancedLayoutsFlags = require("./advanced-layouts-flags");
10
10
  var _checkMediaLayout = require("./check-media-layout");
11
11
  var shouldAllowInlineDropTarget = exports.shouldAllowInlineDropTarget = function shouldAllowInlineDropTarget(isNested, node) {
12
12
  var isSameLayout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
13
+ var activeNode = arguments.length > 3 ? arguments[3] : undefined;
13
14
  if (!(0, _advancedLayoutsFlags.isPreRelease1)() || isNested) {
14
15
  return false;
15
16
  }
16
17
  if ((0, _checkMediaLayout.isWrappedMedia)(node)) {
17
18
  return false;
18
19
  }
20
+ if ((0, _advancedLayoutsFlags.isPreRelease2)() && (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') {
21
+ return false;
22
+ }
19
23
  if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
20
24
  return node.childCount < (0, _consts.maxLayoutColumnSupported)() || (0, _advancedLayoutsFlags.isPreRelease2)() && isSameLayout;
21
25
  }
@@ -78,14 +78,15 @@ var memoizedTransformExpandToNestedExpand = exports.memoizedTransformExpandToNes
78
78
  }
79
79
  });
80
80
  function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, destNode) {
81
- if ((0, _advancedLayoutsFlags.isPreRelease2)() &&
82
- // Allow drag layout column and drop into layout section
83
- srcNode.type.name === 'layoutColumn' && (destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection') {
84
- return true;
85
- }
86
81
  var srcNodeType = srcNode.type;
87
82
  var parentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type.name;
88
83
  var activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.name;
84
+ if ((0, _advancedLayoutsFlags.isPreRelease2)() && activeNodeType === 'layoutColumn') {
85
+ // Allow drag layout column and drop into layout section
86
+ if ((destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection' || parentNodeType === 'doc') {
87
+ return true;
88
+ }
89
+ }
89
90
 
90
91
  // Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
91
92
  if ((0, _experiments.editorExperiment)('nest-media-and-codeblock-in-quote', false)) {
@@ -3,6 +3,8 @@ import { blockControlsMessages } from '@atlaskit/editor-common/messages';
3
3
  import { GapCursorSelection } from '@atlaskit/editor-common/selection';
4
4
  import { transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
5
5
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
6
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
7
+ import { Selection } from '@atlaskit/editor-prosemirror/state';
6
8
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
9
  import { findTable, isInTable, isTableSelected } from '@atlaskit/editor-tables/utils';
8
10
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -10,8 +12,10 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
12
  import { DIRECTION } from '../consts';
11
13
  import { key } from '../pm-plugins/main';
12
14
  import { getNestedNodePosition, selectNode } from '../utils';
15
+ import { isDragLayoutColumnToTopLevel } from '../utils/drag-layout-column';
13
16
  import { setCursorPositionAtMovedNode } from '../utils/getSelection';
14
17
  import { canMoveNodeToIndex, isInsideTable, transformSliceExpandToNestedExpand } from '../utils/validation';
18
+ import { removeFromSource } from './move-to-layout';
15
19
 
16
20
  /**
17
21
  * This function transforms the slice to move
@@ -163,6 +167,17 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
163
167
  const $from = tr.doc.resolve(start);
164
168
  const destType = $to.node().type;
165
169
  const destParent = $to.node($to.depth);
170
+ const sourceNode = $from.nodeAfter;
171
+
172
+ // Move a layout column to top level
173
+ if (sourceNode && isDragLayoutColumnToTopLevel($from, $to)) {
174
+ // need update after we support single column layout.
175
+ const fragment = Fragment.from(sourceNode.content);
176
+ removeFromSource(tr, $from);
177
+ const mappedTo = tr.mapping.map(to);
178
+ tr.insert(mappedTo, fragment).setSelection(Selection.near(tr.doc.resolve(mappedTo))).scrollIntoView();
179
+ return tr;
180
+ }
166
181
  if (!canMoveNodeToIndex(destParent, $to.index(), $from.node().child($from.index()))) {
167
182
  return tr;
168
183
  }
@@ -2,6 +2,7 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
2
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { maxLayoutColumnSupported, MIN_LAYOUT_COLUMN } from '../consts';
4
4
  import { DEFAULT_COLUMN_DISTRIBUTIONS } from '../ui/consts';
5
+ import { deleteSourceNode } from '../utils/drag-layout-column';
5
6
  import { isInSameLayout } from '../utils/validation';
6
7
  const createNewLayout = (schema, layoutContents) => {
7
8
  if (layoutContents.length === 0 || layoutContents.length > maxLayoutColumnSupported()) {
@@ -55,7 +56,7 @@ const moveToExistingLayout = (toLayout, toLayoutPos, sourceNode, from, to, tr, i
55
56
  }
56
57
  return tr;
57
58
  };
58
- const removeFromSource = (tr, $from) => {
59
+ export const removeFromSource = (tr, $from) => {
59
60
  const sourceNode = $from.nodeAfter;
60
61
  const sourceParent = $from.parent;
61
62
  if (!sourceNode) {
@@ -174,10 +175,13 @@ export const moveToLayout = api => (from, to, options) => ({
174
175
  // resolve again the source node after node updated (remove breakout marks)
175
176
  toNodeWithoutBreakout = tr.doc.resolve(to).nodeAfter || toNode;
176
177
  }
178
+ if (fromNodeWithoutBreakout.type.name === 'layoutColumn') {
179
+ fromNodeWithoutBreakout = fromNodeWithoutBreakout.content;
180
+ }
177
181
  const layoutContents = options !== null && options !== void 0 && options.moveToEnd ? [toNodeWithoutBreakout, fromNodeWithoutBreakout] : [fromNodeWithoutBreakout, toNodeWithoutBreakout];
178
182
  const newLayout = createNewLayout(tr.doc.type.schema, layoutContents);
179
183
  if (newLayout) {
180
- tr.delete(from, from + fromNode.nodeSize);
184
+ tr = deleteSourceNode(tr, $from, $to);
181
185
  const mappedTo = tr.mapping.map(to);
182
186
  tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout).setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
183
187
  }
@@ -155,6 +155,9 @@ export const dropTargetDecorations = (newState, api, formatMessage, activeNode,
155
155
  if (editorExperiment('nested-dnd', true)) {
156
156
  depth = $pos.depth;
157
157
  if (isAdvancedLayoutsPreRelease2) {
158
+ if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos) === pos && activeNode.nodeType !== 'layoutColumn') {
159
+ return false;
160
+ }
158
161
  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 && (
159
162
  // Not the first node
160
163
  (parent === null || parent === void 0 ? void 0 : parent.childCount) < maxLayoutColumnSupported() || isSameLayout)) {
@@ -31,6 +31,7 @@ const dropTargetLayoutHintStyle = css({
31
31
  width: 0
32
32
  });
33
33
  export const DropTargetLayout = props => {
34
+ var _api$blockControls;
34
35
  const {
35
36
  api,
36
37
  getPos,
@@ -40,11 +41,10 @@ export const DropTargetLayout = props => {
40
41
  const [isDraggedOver, setIsDraggedOver] = useState(false);
41
42
  const anchorName = getNodeAnchor(parent);
42
43
  const [isActiveAnchor] = useActiveAnchorTracker(anchorName);
44
+ const {
45
+ activeNode
46
+ } = (api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {};
43
47
  const onDrop = useCallback(() => {
44
- var _api$blockControls;
45
- const {
46
- activeNode
47
- } = (api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {};
48
48
  if (!activeNode) {
49
49
  return;
50
50
  }
@@ -56,7 +56,7 @@ export const DropTargetLayout = props => {
56
56
  } = activeNode;
57
57
  api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : (_api$blockControls2$c = _api$blockControls2.commands) === null || _api$blockControls2$c === void 0 ? void 0 : _api$blockControls2$c.moveToLayout(from, to));
58
58
  }
59
- }, [api, getPos]);
59
+ }, [api, getPos, activeNode]);
60
60
  useEffect(() => {
61
61
  if (ref.current) {
62
62
  return dropTargetForElements({
@@ -71,6 +71,9 @@ export const DropTargetLayout = props => {
71
71
  });
72
72
  }
73
73
  }, [onDrop]);
74
+ if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') {
75
+ return null;
76
+ }
74
77
  return jsx("div", {
75
78
  ref: ref,
76
79
  css: dropTargetLayoutStyle,
@@ -166,6 +166,7 @@ const HoverZone = ({
166
166
  });
167
167
  };
168
168
  export const DropTargetV2 = props => {
169
+ var _api$blockControls;
169
170
  const {
170
171
  api,
171
172
  getPos,
@@ -182,11 +183,10 @@ export const DropTargetV2 = props => {
182
183
  widthState
183
184
  } = useSharedPluginState(api, ['width']);
184
185
  const isNestedDropTarget = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) !== 'doc';
186
+ const {
187
+ activeNode
188
+ } = (api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {};
185
189
  const onDrop = () => {
186
- var _api$blockControls;
187
- const {
188
- activeNode
189
- } = (api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {};
190
190
  if (!activeNode) {
191
191
  return;
192
192
  }
@@ -239,7 +239,7 @@ export const DropTargetV2 = props => {
239
239
  anchorRectCache: anchorRectCache,
240
240
  position: "lower",
241
241
  isNestedDropTarget: isNestedDropTarget
242
- }), shouldAllowInlineDropTarget(isNestedDropTarget, nextNode, isSameLayout) && jsx(Fragment, null, jsx(InlineDropTarget, _extends({}, props, {
242
+ }), shouldAllowInlineDropTarget(isNestedDropTarget, nextNode, isSameLayout, activeNode) && jsx(Fragment, null, jsx(InlineDropTarget, _extends({}, props, {
243
243
  position: "left"
244
244
  })), jsx(InlineDropTarget, _extends({}, props, {
245
245
  position: "right"
@@ -52,6 +52,7 @@ const getWidthOffset = (node, width, position) => {
52
52
  return '-12px';
53
53
  }
54
54
  };
55
+ const TABLE_NUMBERED_COLUMN_WIDTH = 42;
55
56
  export const InlineDropTarget = ({
56
57
  api,
57
58
  nextNode,
@@ -79,9 +80,14 @@ export const InlineDropTarget = ({
79
80
  innerContainerWidth = 'max(calc(var(--ak-editor-max-container-width) - var(--ak-editor--default-gutter-padding) * 2), var(--ak-editor--line-length))';
80
81
  }
81
82
  } else if (nextNode.type.name === 'table' && nextNode.firstChild) {
82
- var _anchorRectCache$getR;
83
83
  const tableWidthAnchor = getNodeAnchor(nextNode.firstChild);
84
- innerContainerWidth = isAnchorSupported() ? `anchor-size(${tableWidthAnchor} width)` : `${(anchorRectCache === null || anchorRectCache === void 0 ? void 0 : (_anchorRectCache$getR = anchorRectCache.getRect(tableWidthAnchor)) === null || _anchorRectCache$getR === void 0 ? void 0 : _anchorRectCache$getR.width) || 0}px`;
84
+ const isNumberColumnEnabled = Boolean(nextNode.attrs.isNumberColumnEnabled);
85
+ if (isAnchorSupported()) {
86
+ innerContainerWidth = isNumberColumnEnabled ? `calc(anchor-size(${tableWidthAnchor} width) + ${TABLE_NUMBERED_COLUMN_WIDTH}px)` : `anchor-size(${tableWidthAnchor} width)`;
87
+ } else {
88
+ var _anchorRectCache$getR;
89
+ innerContainerWidth = `${((anchorRectCache === null || anchorRectCache === void 0 ? void 0 : (_anchorRectCache$getR = anchorRectCache.getRect(tableWidthAnchor)) === null || _anchorRectCache$getR === void 0 ? void 0 : _anchorRectCache$getR.width) || 0) + TABLE_NUMBERED_COLUMN_WIDTH}px`;
90
+ }
85
91
  if (nextNode.attrs.width) {
86
92
  // when the table has horizontal scroll
87
93
  innerContainerWidth = `min(${nextNode.attrs.width}px, ${innerContainerWidth})`;
@@ -0,0 +1,18 @@
1
+ export const isDragLayoutColumnToTopLevel = ($from, $to) => {
2
+ var _$from$nodeAfter;
3
+ return ((_$from$nodeAfter = $from.nodeAfter) === null || _$from$nodeAfter === void 0 ? void 0 : _$from$nodeAfter.type.name) === 'layoutColumn' && $from.parent.type.name === 'layoutSection' && $to.depth === 0;
4
+ };
5
+ export const deleteSourceNode = (tr, $from, $to) => {
6
+ if ($from.nodeAfter) {
7
+ const fromNode = $from.nodeAfter;
8
+ if (isDragLayoutColumnToTopLevel($from, $to)) {
9
+ // need update after we support single column layout.
10
+ if ($from.parent.childCount <= 2) {
11
+ tr.deleteRange($from.pos + 1, $from.pos + fromNode.nodeSize - 1);
12
+ return tr;
13
+ }
14
+ }
15
+ tr.deleteRange($from.pos, $from.pos + fromNode.nodeSize);
16
+ }
17
+ return tr;
18
+ };
@@ -6,13 +6,16 @@ export const shouldAllowInlineDropTarget = (isNested, node,
6
6
  /**
7
7
  * Is the active node in the same layout as the target node
8
8
  */
9
- isSameLayout = false) => {
9
+ isSameLayout = false, activeNode) => {
10
10
  if (!isPreRelease1() || isNested) {
11
11
  return false;
12
12
  }
13
13
  if (isWrappedMedia(node)) {
14
14
  return false;
15
15
  }
16
+ if (isPreRelease2() && (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') {
17
+ return false;
18
+ }
16
19
  if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
17
20
  return node.childCount < maxLayoutColumnSupported() || isPreRelease2() && isSameLayout;
18
21
  }
@@ -72,14 +72,15 @@ export const memoizedTransformExpandToNestedExpand = memoizeOne(node => {
72
72
  }
73
73
  });
74
74
  export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, destNode) {
75
- if (isPreRelease2() &&
76
- // Allow drag layout column and drop into layout section
77
- srcNode.type.name === 'layoutColumn' && (destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection') {
78
- return true;
79
- }
80
75
  let srcNodeType = srcNode.type;
81
76
  const parentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type.name;
82
77
  const activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.name;
78
+ if (isPreRelease2() && activeNodeType === 'layoutColumn') {
79
+ // Allow drag layout column and drop into layout section
80
+ if ((destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection' || parentNodeType === 'doc') {
81
+ return true;
82
+ }
83
+ }
83
84
 
84
85
  // Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
85
86
  if (editorExperiment('nest-media-and-codeblock-in-quote', false)) {
@@ -6,6 +6,8 @@ import { blockControlsMessages } from '@atlaskit/editor-common/messages';
6
6
  import { GapCursorSelection } from '@atlaskit/editor-common/selection';
7
7
  import { transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/transforms';
8
8
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
9
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
10
+ import { Selection } from '@atlaskit/editor-prosemirror/state';
9
11
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
10
12
  import { findTable, isInTable, isTableSelected } from '@atlaskit/editor-tables/utils';
11
13
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -13,8 +15,10 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
13
15
  import { DIRECTION } from '../consts';
14
16
  import { key } from '../pm-plugins/main';
15
17
  import { getNestedNodePosition, selectNode } from '../utils';
18
+ import { isDragLayoutColumnToTopLevel } from '../utils/drag-layout-column';
16
19
  import { setCursorPositionAtMovedNode } from '../utils/getSelection';
17
20
  import { canMoveNodeToIndex, isInsideTable, transformSliceExpandToNestedExpand } from '../utils/validation';
21
+ import { removeFromSource } from './move-to-layout';
18
22
 
19
23
  /**
20
24
  * This function transforms the slice to move
@@ -163,6 +167,17 @@ export var moveNode = function moveNode(api) {
163
167
  var $from = tr.doc.resolve(start);
164
168
  var destType = $to.node().type;
165
169
  var destParent = $to.node($to.depth);
170
+ var sourceNode = $from.nodeAfter;
171
+
172
+ // Move a layout column to top level
173
+ if (sourceNode && isDragLayoutColumnToTopLevel($from, $to)) {
174
+ // need update after we support single column layout.
175
+ var fragment = Fragment.from(sourceNode.content);
176
+ removeFromSource(tr, $from);
177
+ var _mappedTo = tr.mapping.map(to);
178
+ tr.insert(_mappedTo, fragment).setSelection(Selection.near(tr.doc.resolve(_mappedTo))).scrollIntoView();
179
+ return tr;
180
+ }
166
181
  if (!canMoveNodeToIndex(destParent, $to.index(), $from.node().child($from.index()))) {
167
182
  return tr;
168
183
  }
@@ -2,6 +2,7 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
2
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { maxLayoutColumnSupported, MIN_LAYOUT_COLUMN } from '../consts';
4
4
  import { DEFAULT_COLUMN_DISTRIBUTIONS } from '../ui/consts';
5
+ import { deleteSourceNode } from '../utils/drag-layout-column';
5
6
  import { isInSameLayout } from '../utils/validation';
6
7
  var createNewLayout = function createNewLayout(schema, layoutContents) {
7
8
  if (layoutContents.length === 0 || layoutContents.length > maxLayoutColumnSupported()) {
@@ -54,7 +55,7 @@ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos,
54
55
  }
55
56
  return tr;
56
57
  };
57
- var removeFromSource = function removeFromSource(tr, $from) {
58
+ export var removeFromSource = function removeFromSource(tr, $from) {
58
59
  var sourceNode = $from.nodeAfter;
59
60
  var sourceParent = $from.parent;
60
61
  if (!sourceNode) {
@@ -171,10 +172,13 @@ export var moveToLayout = function moveToLayout(api) {
171
172
  // resolve again the source node after node updated (remove breakout marks)
172
173
  toNodeWithoutBreakout = tr.doc.resolve(to).nodeAfter || toNode;
173
174
  }
175
+ if (fromNodeWithoutBreakout.type.name === 'layoutColumn') {
176
+ fromNodeWithoutBreakout = fromNodeWithoutBreakout.content;
177
+ }
174
178
  var layoutContents = options !== null && options !== void 0 && options.moveToEnd ? [toNodeWithoutBreakout, fromNodeWithoutBreakout] : [fromNodeWithoutBreakout, toNodeWithoutBreakout];
175
179
  var newLayout = createNewLayout(tr.doc.type.schema, layoutContents);
176
180
  if (newLayout) {
177
- tr.delete(from, from + fromNode.nodeSize);
181
+ tr = deleteSourceNode(tr, $from, $to);
178
182
  var mappedTo = tr.mapping.map(to);
179
183
  tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout).setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
180
184
  }
@@ -156,6 +156,9 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
156
156
  if (editorExperiment('nested-dnd', true)) {
157
157
  depth = $pos.depth;
158
158
  if (isAdvancedLayoutsPreRelease2) {
159
+ if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos) === pos && activeNode.nodeType !== 'layoutColumn') {
160
+ return false;
161
+ }
159
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 && (
160
163
  // Not the first node
161
164
  (parent === null || parent === void 0 ? void 0 : parent.childCount) < maxLayoutColumnSupported() || isSameLayout)) {
@@ -32,6 +32,7 @@ var dropTargetLayoutHintStyle = css({
32
32
  width: 0
33
33
  });
34
34
  export var DropTargetLayout = function DropTargetLayout(props) {
35
+ var _api$blockControls;
35
36
  var api = props.api,
36
37
  getPos = props.getPos,
37
38
  parent = props.parent;
@@ -44,10 +45,9 @@ export var DropTargetLayout = function DropTargetLayout(props) {
44
45
  var _useActiveAnchorTrack = useActiveAnchorTracker(anchorName),
45
46
  _useActiveAnchorTrack2 = _slicedToArray(_useActiveAnchorTrack, 1),
46
47
  isActiveAnchor = _useActiveAnchorTrack2[0];
48
+ var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
49
+ activeNode = _ref.activeNode;
47
50
  var onDrop = useCallback(function () {
48
- var _api$blockControls;
49
- var _ref = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
50
- activeNode = _ref.activeNode;
51
51
  if (!activeNode) {
52
52
  return;
53
53
  }
@@ -57,7 +57,7 @@ export var DropTargetLayout = function DropTargetLayout(props) {
57
57
  var from = activeNode.pos;
58
58
  api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.moveToLayout(from, to));
59
59
  }
60
- }, [api, getPos]);
60
+ }, [api, getPos, activeNode]);
61
61
  useEffect(function () {
62
62
  if (ref.current) {
63
63
  return dropTargetForElements({
@@ -72,6 +72,9 @@ export var DropTargetLayout = function DropTargetLayout(props) {
72
72
  });
73
73
  }
74
74
  }, [onDrop]);
75
+ if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') {
76
+ return null;
77
+ }
75
78
  return jsx("div", {
76
79
  ref: ref,
77
80
  css: dropTargetLayoutStyle,
@@ -170,7 +170,7 @@ var HoverZone = function HoverZone(_ref) {
170
170
  });
171
171
  };
172
172
  export var DropTargetV2 = function DropTargetV2(props) {
173
- var _dynamicStyle;
173
+ var _api$blockControls, _dynamicStyle;
174
174
  var api = props.api,
175
175
  getPos = props.getPos,
176
176
  prevNode = props.prevNode,
@@ -188,10 +188,9 @@ export var DropTargetV2 = function DropTargetV2(props) {
188
188
  var _useSharedPluginState = useSharedPluginState(api, ['width']),
189
189
  widthState = _useSharedPluginState.widthState;
190
190
  var isNestedDropTarget = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) !== 'doc';
191
+ var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
192
+ activeNode = _ref2.activeNode;
191
193
  var onDrop = function onDrop() {
192
- var _api$blockControls;
193
- var _ref2 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
194
- activeNode = _ref2.activeNode;
195
194
  if (!activeNode) {
196
195
  return;
197
196
  }
@@ -247,7 +246,7 @@ export var DropTargetV2 = function DropTargetV2(props) {
247
246
  anchorRectCache: anchorRectCache,
248
247
  position: "lower",
249
248
  isNestedDropTarget: isNestedDropTarget
250
- }), shouldAllowInlineDropTarget(isNestedDropTarget, nextNode, isSameLayout) && jsx(Fragment, null, jsx(InlineDropTarget, _extends({}, props, {
249
+ }), shouldAllowInlineDropTarget(isNestedDropTarget, nextNode, isSameLayout, activeNode) && jsx(Fragment, null, jsx(InlineDropTarget, _extends({}, props, {
251
250
  position: "left"
252
251
  })), jsx(InlineDropTarget, _extends({}, props, {
253
252
  position: "right"
@@ -53,6 +53,7 @@ var getWidthOffset = function getWidthOffset(node, width, position) {
53
53
  return '-12px';
54
54
  }
55
55
  };
56
+ var TABLE_NUMBERED_COLUMN_WIDTH = 42;
56
57
  export var InlineDropTarget = function InlineDropTarget(_ref) {
57
58
  var api = _ref.api,
58
59
  nextNode = _ref.nextNode,
@@ -84,9 +85,14 @@ export var InlineDropTarget = function InlineDropTarget(_ref) {
84
85
  innerContainerWidth = 'max(calc(var(--ak-editor-max-container-width) - var(--ak-editor--default-gutter-padding) * 2), var(--ak-editor--line-length))';
85
86
  }
86
87
  } else if (nextNode.type.name === 'table' && nextNode.firstChild) {
87
- var _anchorRectCache$getR;
88
88
  var tableWidthAnchor = getNodeAnchor(nextNode.firstChild);
89
- innerContainerWidth = isAnchorSupported() ? "anchor-size(".concat(tableWidthAnchor, " width)") : "".concat((anchorRectCache === null || anchorRectCache === void 0 || (_anchorRectCache$getR = anchorRectCache.getRect(tableWidthAnchor)) === null || _anchorRectCache$getR === void 0 ? void 0 : _anchorRectCache$getR.width) || 0, "px");
89
+ var isNumberColumnEnabled = Boolean(nextNode.attrs.isNumberColumnEnabled);
90
+ if (isAnchorSupported()) {
91
+ innerContainerWidth = isNumberColumnEnabled ? "calc(anchor-size(".concat(tableWidthAnchor, " width) + ").concat(TABLE_NUMBERED_COLUMN_WIDTH, "px)") : "anchor-size(".concat(tableWidthAnchor, " width)");
92
+ } else {
93
+ var _anchorRectCache$getR;
94
+ innerContainerWidth = "".concat(((anchorRectCache === null || anchorRectCache === void 0 || (_anchorRectCache$getR = anchorRectCache.getRect(tableWidthAnchor)) === null || _anchorRectCache$getR === void 0 ? void 0 : _anchorRectCache$getR.width) || 0) + TABLE_NUMBERED_COLUMN_WIDTH, "px");
95
+ }
90
96
  if (nextNode.attrs.width) {
91
97
  // when the table has horizontal scroll
92
98
  innerContainerWidth = "min(".concat(nextNode.attrs.width, "px, ").concat(innerContainerWidth, ")");
@@ -0,0 +1,18 @@
1
+ export var isDragLayoutColumnToTopLevel = function isDragLayoutColumnToTopLevel($from, $to) {
2
+ var _$from$nodeAfter;
3
+ return ((_$from$nodeAfter = $from.nodeAfter) === null || _$from$nodeAfter === void 0 ? void 0 : _$from$nodeAfter.type.name) === 'layoutColumn' && $from.parent.type.name === 'layoutSection' && $to.depth === 0;
4
+ };
5
+ export var deleteSourceNode = function deleteSourceNode(tr, $from, $to) {
6
+ if ($from.nodeAfter) {
7
+ var fromNode = $from.nodeAfter;
8
+ if (isDragLayoutColumnToTopLevel($from, $to)) {
9
+ // need update after we support single column layout.
10
+ if ($from.parent.childCount <= 2) {
11
+ tr.deleteRange($from.pos + 1, $from.pos + fromNode.nodeSize - 1);
12
+ return tr;
13
+ }
14
+ }
15
+ tr.deleteRange($from.pos, $from.pos + fromNode.nodeSize);
16
+ }
17
+ return tr;
18
+ };
@@ -4,12 +4,16 @@ import { isPreRelease1, isPreRelease2 } from './advanced-layouts-flags';
4
4
  import { isWrappedMedia } from './check-media-layout';
5
5
  export var shouldAllowInlineDropTarget = function shouldAllowInlineDropTarget(isNested, node) {
6
6
  var isSameLayout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
7
+ var activeNode = arguments.length > 3 ? arguments[3] : undefined;
7
8
  if (!isPreRelease1() || isNested) {
8
9
  return false;
9
10
  }
10
11
  if (isWrappedMedia(node)) {
11
12
  return false;
12
13
  }
14
+ if (isPreRelease2() && (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') {
15
+ return false;
16
+ }
13
17
  if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
14
18
  return node.childCount < maxLayoutColumnSupported() || isPreRelease2() && isSameLayout;
15
19
  }
@@ -70,14 +70,15 @@ export var memoizedTransformExpandToNestedExpand = memoizeOne(function (node) {
70
70
  }
71
71
  });
72
72
  export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, destNode) {
73
- if (isPreRelease2() &&
74
- // Allow drag layout column and drop into layout section
75
- srcNode.type.name === 'layoutColumn' && (destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection') {
76
- return true;
77
- }
78
73
  var srcNodeType = srcNode.type;
79
74
  var parentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type.name;
80
75
  var activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.name;
76
+ if (isPreRelease2() && activeNodeType === 'layoutColumn') {
77
+ // Allow drag layout column and drop into layout section
78
+ if ((destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection' || parentNodeType === 'doc') {
79
+ return true;
80
+ }
81
+ }
81
82
 
82
83
  // Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
83
84
  if (editorExperiment('nest-media-and-codeblock-in-quote', false)) {
@@ -1,5 +1,8 @@
1
1
  import type { EditorCommand, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import { type ResolvedPos } from '@atlaskit/editor-prosemirror/model';
3
+ import { type Transaction } from '@atlaskit/editor-prosemirror/state';
2
4
  import type { BlockControlsPlugin } from '../types';
5
+ export declare const removeFromSource: (tr: Transaction, $from: ResolvedPos) => Transaction;
3
6
  export declare const moveToLayout: (api?: ExtractInjectionAPI<BlockControlsPlugin>) => (from: number, to: number, options?: {
4
7
  moveToEnd?: boolean;
5
8
  }) => EditorCommand;
@@ -9,4 +9,4 @@ export type DropTargetLayoutProps = {
9
9
  parent: PMNode;
10
10
  formatMessage?: IntlShape['formatMessage'];
11
11
  };
12
- export declare const DropTargetLayout: (props: DropTargetLayoutProps) => jsx.JSX.Element;
12
+ export declare const DropTargetLayout: (props: DropTargetLayoutProps) => jsx.JSX.Element | null;
@@ -0,0 +1,4 @@
1
+ import { type ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
+ import { type Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ export declare const isDragLayoutColumnToTopLevel: ($from: ResolvedPos, $to: ResolvedPos) => boolean;
4
+ export declare const deleteSourceNode: (tr: Transaction, $from: ResolvedPos, $to: ResolvedPos) => Transaction;
@@ -1,2 +1,3 @@
1
1
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- export declare const shouldAllowInlineDropTarget: (isNested: boolean, node?: PMNode, isSameLayout?: boolean) => boolean;
2
+ import { type ActiveNode } from '../types';
3
+ export declare const shouldAllowInlineDropTarget: (isNested: boolean, node?: PMNode, isSameLayout?: boolean, activeNode?: ActiveNode) => boolean;
@@ -1,5 +1,8 @@
1
1
  import type { EditorCommand, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import { type ResolvedPos } from '@atlaskit/editor-prosemirror/model';
3
+ import { type Transaction } from '@atlaskit/editor-prosemirror/state';
2
4
  import type { BlockControlsPlugin } from '../types';
5
+ export declare const removeFromSource: (tr: Transaction, $from: ResolvedPos) => Transaction;
3
6
  export declare const moveToLayout: (api?: ExtractInjectionAPI<BlockControlsPlugin>) => (from: number, to: number, options?: {
4
7
  moveToEnd?: boolean;
5
8
  }) => EditorCommand;
@@ -9,4 +9,4 @@ export type DropTargetLayoutProps = {
9
9
  parent: PMNode;
10
10
  formatMessage?: IntlShape['formatMessage'];
11
11
  };
12
- export declare const DropTargetLayout: (props: DropTargetLayoutProps) => jsx.JSX.Element;
12
+ export declare const DropTargetLayout: (props: DropTargetLayoutProps) => jsx.JSX.Element | null;
@@ -0,0 +1,4 @@
1
+ import { type ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
+ import { type Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ export declare const isDragLayoutColumnToTopLevel: ($from: ResolvedPos, $to: ResolvedPos) => boolean;
4
+ export declare const deleteSourceNode: (tr: Transaction, $from: ResolvedPos, $to: ResolvedPos) => Transaction;
@@ -1,2 +1,3 @@
1
1
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- export declare const shouldAllowInlineDropTarget: (isNested: boolean, node?: PMNode, isSameLayout?: boolean) => boolean;
2
+ import { type ActiveNode } from '../types';
3
+ export declare const shouldAllowInlineDropTarget: (isNested: boolean, node?: PMNode, isSameLayout?: boolean, activeNode?: ActiveNode) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "2.13.13",
3
+ "version": "2.13.15",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@atlaskit/adf-schema": "^44.2.0",
34
- "@atlaskit/editor-common": "^94.21.0",
34
+ "@atlaskit/editor-common": "^94.22.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",
@@ -48,7 +48,7 @@
48
48
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
49
49
  "@atlaskit/primitives": "^13.2.0",
50
50
  "@atlaskit/theme": "^14.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^2.15.0",
51
+ "@atlaskit/tmp-editor-statsig": "^2.17.0",
52
52
  "@atlaskit/tokens": "^2.2.0",
53
53
  "@atlaskit/tooltip": "^18.9.0",
54
54
  "@babel/runtime": "^7.0.0",