@atlaskit/editor-plugin-block-controls 2.13.14 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
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
+
3
15
  ## 2.13.14
4
16
 
5
17
  ### 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
  }
@@ -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
+ };
@@ -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
  }
@@ -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
+ };
@@ -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
  }
@@ -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
+ };
@@ -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;
@@ -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,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;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "2.13.14",
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.16.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",