@atlaskit/editor-plugin-block-controls 3.3.12 → 3.3.14

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 +16 -0
  2. package/dist/cjs/editor-commands/move-node.js +19 -2
  3. package/dist/cjs/editor-commands/move-to-layout.js +16 -60
  4. package/dist/cjs/pm-plugins/handle-mouse-over.js +1 -1
  5. package/dist/cjs/pm-plugins/main.js +1 -1
  6. package/dist/cjs/pm-plugins/utils/drag-handle-positions.js +2 -7
  7. package/dist/cjs/pm-plugins/utils/validation.js +43 -11
  8. package/dist/cjs/ui/drag-handle.js +2 -4
  9. package/dist/cjs/ui/drag-preview.js +8 -19
  10. package/dist/cjs/ui/drop-target-layout.js +9 -15
  11. package/dist/cjs/ui/global-styles.js +1 -2
  12. package/dist/cjs/ui/inline-drop-target.js +9 -15
  13. package/dist/es2019/editor-commands/move-node.js +21 -4
  14. package/dist/es2019/editor-commands/move-to-layout.js +5 -51
  15. package/dist/es2019/pm-plugins/handle-mouse-over.js +1 -1
  16. package/dist/es2019/pm-plugins/main.js +1 -1
  17. package/dist/es2019/pm-plugins/utils/drag-handle-positions.js +2 -7
  18. package/dist/es2019/pm-plugins/utils/validation.js +39 -9
  19. package/dist/es2019/ui/drag-handle.js +2 -4
  20. package/dist/es2019/ui/drag-preview.js +9 -20
  21. package/dist/es2019/ui/drop-target-layout.js +10 -16
  22. package/dist/es2019/ui/global-styles.js +1 -2
  23. package/dist/es2019/ui/inline-drop-target.js +10 -16
  24. package/dist/esm/editor-commands/move-node.js +21 -4
  25. package/dist/esm/editor-commands/move-to-layout.js +18 -62
  26. package/dist/esm/pm-plugins/handle-mouse-over.js +1 -1
  27. package/dist/esm/pm-plugins/main.js +1 -1
  28. package/dist/esm/pm-plugins/utils/drag-handle-positions.js +2 -7
  29. package/dist/esm/pm-plugins/utils/validation.js +42 -10
  30. package/dist/esm/ui/drag-handle.js +2 -4
  31. package/dist/esm/ui/drag-preview.js +9 -20
  32. package/dist/esm/ui/drop-target-layout.js +9 -15
  33. package/dist/esm/ui/global-styles.js +1 -2
  34. package/dist/esm/ui/inline-drop-target.js +9 -15
  35. package/dist/types/pm-plugins/utils/validation.d.ts +2 -1
  36. package/dist/types-ts4.5/pm-plugins/utils/validation.d.ts +2 -1
  37. package/package.json +7 -10
@@ -4,12 +4,11 @@ import { Fragment, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
6
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
- import { fireInsertLayoutAnalytics, attachMoveNodeAnalytics, getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics';
8
- import { isFragmentOfType, containsNodeOfType } from '../pm-plugins/utils/check-fragment';
7
+ import { attachMoveNodeAnalytics, fireInsertLayoutAnalytics, getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics';
8
+ import { containsNodeOfType, isFragmentOfType } from '../pm-plugins/utils/check-fragment';
9
9
  import { maxLayoutColumnSupported } from '../pm-plugins/utils/consts';
10
10
  import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
11
11
  import { getMultiSelectionIfPosInside } from '../pm-plugins/utils/selection';
12
- import { updateColumnWidths } from '../pm-plugins/utils/update-column-widths';
13
12
  import { isInSameLayout } from '../pm-plugins/utils/validation';
14
13
  import { DEFAULT_COLUMN_DISTRIBUTIONS } from '../ui/consts';
15
14
  const createNewLayout = (schema, layoutContents) => {
@@ -65,20 +64,14 @@ const moveToExistingLayout = (toLayout, toLayoutPos, sourceContent, from, to, tr
65
64
  tr.delete(from, sourceContentEndPos);
66
65
  const mappedTo = tr.mapping.map(to);
67
66
  tr.insert(mappedTo, sourceContent);
68
- if (!fg('platform_editor_advanced_layouts_post_fix_patch_1') || selectMovedNode) {
67
+ if (selectMovedNode) {
69
68
  tr.setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
70
69
  }
71
70
  attachMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf === void 0 ? void 0 : _$originalFrom$nodeAf.type.name) || '', 1, 'layoutSection', true, api, sourceNodeTypes, hasSelectedMultipleNodes);
72
71
  } else if (toLayout.childCount < maxLayoutColumnSupported()) {
73
72
  var _$originalFrom$nodeAf2;
74
- if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
75
- removeFromSource(tr, tr.doc.resolve(from), sourceContentEndPos);
76
- insertToDestinationNoWidthUpdate(tr, tr.mapping.map(to), sourceContent);
77
- } else {
78
- insertToDestination(tr, to, sourceContent, toLayout, toLayoutPos);
79
- const mappedFrom = tr.mapping.map(from);
80
- removeFromSource(tr, tr.doc.resolve(mappedFrom), tr.mapping.map(sourceContentEndPos));
81
- }
73
+ removeFromSource(tr, tr.doc.resolve(from), sourceContentEndPos);
74
+ insertToDestinationNoWidthUpdate(tr, tr.mapping.map(to), sourceContent);
82
75
  attachMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf2 = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf2 === void 0 ? void 0 : _$originalFrom$nodeAf2.type.name) || '', 1, 'layoutSection', false, api, sourceNodeTypes, hasSelectedMultipleNodes);
83
76
  }
84
77
  return tr;
@@ -124,42 +117,6 @@ const insertToDestinationNoWidthUpdate = (tr, to, sourceContent) => {
124
117
  }
125
118
  return tr;
126
119
  };
127
- const insertToDestination = (tr, to, sourceContent, toLayout, toLayoutPos) => {
128
- const {
129
- newColumnWidth
130
- } = updateColumnWidths(tr, toLayout, toLayoutPos, toLayout.childCount + 1) || {};
131
- const {
132
- layoutColumn
133
- } = tr.doc.type.schema.nodes || {};
134
- let content = null;
135
- try {
136
- if (editorExperiment('platform_editor_element_drag_and_drop_multiselect', true)) {
137
- if (sourceContent instanceof Fragment) {
138
- var _sourceContent$firstC;
139
- content = layoutColumn.createChecked({
140
- width: newColumnWidth
141
- }, isFragmentOfType(sourceContent, 'layoutColumn') ? (_sourceContent$firstC = sourceContent.firstChild) === null || _sourceContent$firstC === void 0 ? void 0 : _sourceContent$firstC.content : sourceContent);
142
- }
143
- } else {
144
- if (sourceContent instanceof PMNode) {
145
- content = layoutColumn.createChecked({
146
- width: newColumnWidth
147
- }, sourceContent.type.name === 'layoutColumn' ? sourceContent.content : sourceContent);
148
- }
149
- }
150
- } catch (error) {
151
- logException(error, {
152
- location: 'editor-plugin-block-controls/move-to-layout'
153
- });
154
- }
155
- if (content) {
156
- tr.insert(to, content);
157
- }
158
- if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
159
- tr.setSelection(new NodeSelection(tr.doc.resolve(to))).scrollIntoView();
160
- }
161
- return tr;
162
- };
163
120
 
164
121
  /**
165
122
  * Check if the node at `from` can be moved to node at `to` to create/expand a layout.
@@ -356,9 +313,6 @@ export const moveToLayout = api => (from, to, options) => ({
356
313
  tr = removeFromSource(tr, $sourceFrom, sourceTo);
357
314
  const mappedTo = tr.mapping.map(to);
358
315
  tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout);
359
- if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
360
- tr.setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
361
- }
362
316
  breakoutMode && tr.setNodeMarkup(mappedTo, newLayout.type, newLayout.attrs, [breakout.create({
363
317
  mode: breakoutMode
364
318
  })]);
@@ -41,7 +41,7 @@ export const handleMouseOver = (view, event, api) => {
41
41
  }
42
42
  const parentElement = (_rootElement$parentEl = rootElement.parentElement) === null || _rootElement$parentEl === void 0 ? void 0 : _rootElement$parentEl.closest('[data-drag-handler-anchor-name]');
43
43
  const parentElementType = parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute('data-drag-handler-node-type');
44
- if (editorExperiment('advanced_layouts', true) && fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
44
+ if (editorExperiment('advanced_layouts', true)) {
45
45
  // We want to exclude handles from showing for direct descendant of table nodes (i.e. nodes in cells)
46
46
  if (parentElement && (parentElementType === 'table' || parentElementType === 'tableRow') && editorExperiment('nested-dnd', true)) {
47
47
  rootElement = parentElement;
@@ -624,7 +624,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
624
624
  // Currently we can only drag one node at a time
625
625
  // so we only need to check first child
626
626
  const draggable = dragging === null || dragging === void 0 ? void 0 : dragging.slice.content.firstChild;
627
- if (dndDragCancelled && isMultiSelectEnabled || (draggable === null || draggable === void 0 ? void 0 : draggable.type.name) === 'layoutColumn' && fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
627
+ if (dndDragCancelled && isMultiSelectEnabled || (draggable === null || draggable === void 0 ? void 0 : draggable.type.name) === 'layoutColumn') {
628
628
  // we prevent native DnD for layoutColumn to prevent single column layout.
629
629
  event.preventDefault();
630
630
  return false;
@@ -1,21 +1,16 @@
1
- import { fg } from '@atlaskit/platform-feature-flags';
2
1
  import { DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, DRAG_HANDLE_H1_TOP_ADJUSTMENT, DRAG_HANDLE_H2_TOP_ADJUSTMENT, DRAG_HANDLE_H4_TOP_ADJUSTMENT, DRAG_HANDLE_H5_TOP_ADJUSTMENT, DRAG_HANDLE_H6_TOP_ADJUSTMENT, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_PARAGRAPH_TOP_ADJUSTMENT, DRAG_HANDLE_WIDTH, dragHandleGap } from '../../ui/consts';
3
2
  export const getTopPosition = (dom, type) => {
4
3
  if (!dom) {
5
4
  return 'auto';
6
5
  }
7
6
  const table = dom.querySelector('table');
8
- const isTable = fg('platform_editor_advanced_layouts_post_fix_patch_1') ? table && (!type || type === 'table') : table;
7
+ const isTable = table && (!type || type === 'table');
9
8
  if (isTable) {
10
9
  return `${dom.offsetTop + ((table === null || table === void 0 ? void 0 : table.offsetTop) || 0)}px`;
11
10
  } else if (type === 'rule') {
12
11
  return `${dom.offsetTop - DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT}px`;
13
12
  } else if (type === 'layoutColumn') {
14
- if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
15
- return `${-dom.offsetTop / 2}px`;
16
- } else {
17
- return `${-DRAG_HANDLE_WIDTH}px`;
18
- }
13
+ return `${-dom.offsetTop / 2}px`;
19
14
  } else if (type === 'heading-1') {
20
15
  return `${dom.offsetTop + DRAG_HANDLE_H1_TOP_ADJUSTMENT}px`;
21
16
  } else if (type === 'heading-2') {
@@ -1,6 +1,7 @@
1
1
  import memoizeOne from 'memoize-one';
2
2
  import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
3
3
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
4
+ import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
4
5
  import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
7
  export const isInsideTable = nodeType => {
@@ -47,10 +48,10 @@ export const transformExpandToNestedExpand = expandNode => {
47
48
  }
48
49
  return null;
49
50
  };
50
- export const transformSliceExpandToNestedExpand = slice => {
51
+ export const transformFragmentExpandToNestedExpand = fragment => {
51
52
  const children = [];
52
53
  try {
53
- slice.content.forEach(node => {
54
+ fragment.forEach(node => {
54
55
  if (isExpand(node.type)) {
55
56
  const nestedExpandNode = transformExpandToNestedExpand(node);
56
57
  if (nestedExpandNode) {
@@ -63,7 +64,14 @@ export const transformSliceExpandToNestedExpand = slice => {
63
64
  } catch (e) {
64
65
  return null;
65
66
  }
66
- return new Slice(Fragment.fromArray(children), slice.openStart, slice.openEnd);
67
+ return Fragment.fromArray(children);
68
+ };
69
+ export const transformSliceExpandToNestedExpand = slice => {
70
+ const fragment = transformFragmentExpandToNestedExpand(slice.content);
71
+ if (!fragment) {
72
+ return null;
73
+ }
74
+ return new Slice(fragment, slice.openStart, slice.openEnd);
67
75
  };
68
76
  export const memoizedTransformExpandToNestedExpand = memoizeOne(node => {
69
77
  try {
@@ -76,11 +84,38 @@ export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNo
76
84
  let srcNodeType = srcNode.type;
77
85
  const parentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type.name;
78
86
  const activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.name;
87
+ const isNestingTablesSupported = fg('platform_editor_use_nested_table_pm_nodes') && editorExperiment('nested-tables-in-tables', true, {
88
+ exposure: true
89
+ });
90
+ const tableNodeType = srcNode.type.schema.nodes.table;
91
+ const expandNodeType = srcNode.type.schema.nodes.expand;
79
92
  if (activeNodeType === 'layoutColumn' && editorExperiment('advanced_layouts', true)) {
80
93
  // Allow drag layout column and drop into layout section
81
94
  if ((destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection' || parentNodeType === 'doc') {
82
95
  return true;
83
96
  }
97
+ if ((parentNodeType === 'tableCell' || parentNodeType === 'tableHeader') && fg('platform_editor_drag_layout_column_into_nodes')) {
98
+ const maybeExpandNodesArray = findChildrenByType(srcNode, expandNodeType);
99
+ const layoutColumnContainExpand = maybeExpandNodesArray.length > 0;
100
+ const layoutColumnContainTable = findChildrenByType(srcNode, tableNodeType).length > 0;
101
+
102
+ // when layout column content does not contain table, allow to drop into table cell
103
+ if (!layoutColumnContainTable) {
104
+ return true;
105
+ }
106
+
107
+ // when layout column content contains table, but does not contain expand, allow drop into table cell if nesting tables is supported, and the nesting depth does not exceed 1
108
+ if (layoutColumnContainTable && !layoutColumnContainExpand) {
109
+ const nestingDepth = getParentOfTypeCount(tableNodeType)($destNodePos);
110
+ return isNestingTablesSupported && nestingDepth <= 1;
111
+ }
112
+
113
+ // when layout column content contains an expand, and there is a table inside the expand, should not allow to drop into table cell
114
+ if (layoutColumnContainTable && layoutColumnContainExpand) {
115
+ const isAnyTableNestedInExpand = maybeExpandNodesArray.some(result => findChildrenByType(result.node, tableNodeType).length > 0);
116
+ return !isAnyTableNestedInExpand;
117
+ }
118
+ }
84
119
  }
85
120
 
86
121
  // Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
@@ -90,15 +125,10 @@ export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNo
90
125
  }
91
126
  }
92
127
 
93
- // Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
94
- const isNestingTablesSupported = fg('platform_editor_use_nested_table_pm_nodes') && editorExperiment('nested-tables-in-tables', true, {
95
- exposure: true
96
- });
97
-
98
128
  // NOTE: this will block drop targets from showing for dragging a table into another table
99
129
  // unless nested tables are supported and the nesting depth does not exceed 1
100
130
  if ((parentNodeType === 'tableCell' || parentNodeType === 'tableHeader') && activeNodeType === 'table') {
101
- const nestingDepth = getParentOfTypeCount(srcNode === null || srcNode === void 0 ? void 0 : srcNode.type)($destNodePos);
131
+ const nestingDepth = getParentOfTypeCount(tableNodeType)($destNodePos);
102
132
  if (!isNestingTablesSupported || isNestingTablesSupported && nestingDepth > 1) {
103
133
  return false;
104
134
  }
@@ -222,11 +222,9 @@ export const DragHandle = ({
222
222
  // but ensures the preview is generated correctly.
223
223
  const handleMouseDown = useCallback(() => {
224
224
  if (editorExperiment('advanced_layouts', true)) {
225
+ var _buttonRef$current;
225
226
  // prevent native drag and drop.
226
- if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
227
- var _buttonRef$current;
228
- (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
229
- }
227
+ (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
230
228
  if (!isLayoutColumn) {
231
229
  return undefined;
232
230
  }
@@ -1,29 +1,19 @@
1
1
  import { browser } from '@atlaskit/editor-common/browser';
2
- import { fg } from '@atlaskit/platform-feature-flags';
3
- import { B200, N20, N30 } from '@atlaskit/theme/colors';
4
- const previewStyleNew = {
2
+ import { N20, N30 } from '@atlaskit/theme/colors';
3
+ const previewStyle = {
5
4
  borderColor: `var(--ds-border, ${N30})`,
6
5
  borderStyle: 'solid',
7
6
  borderRadius: "var(--ds-border-radius-100, 3px)",
8
7
  borderWidth: "var(--ds-border-width-outline, 2px)",
9
8
  backgroundColor: `var(--ds-skeleton-subtle, ${N20})`
10
9
  };
11
- const previewStyleOld = {
12
- borderColor: `var(--ds-border-focused, ${B200})`,
13
- borderStyle: 'solid',
14
- borderRadius: "var(--ds-border-radius-100, 3px)",
15
- borderWidth: "var(--ds-border-width-outline, 2px)",
16
- backgroundColor: "var(--ds-blanket-selected, #388BFF14)"
17
- };
18
10
  const getPreviewContainerDimensionsForSingle = (dom, nodeType) => {
19
11
  let nodeContainer = dom;
20
- if (fg('platform_editor_elements_drag_and_drop_ed_23189')) {
21
- const iframeContainer = dom.querySelector('iframe');
22
- if (nodeType === 'embedCard') {
23
- nodeContainer = dom.querySelector('.rich-media-item') || dom;
24
- } else if (nodeType === 'extension' && iframeContainer) {
25
- nodeContainer = iframeContainer;
26
- }
12
+ const iframeContainer = dom.querySelector('iframe');
13
+ if (nodeType === 'embedCard') {
14
+ nodeContainer = dom.querySelector('.rich-media-item') || dom;
15
+ } else if (nodeType === 'extension' && iframeContainer) {
16
+ nodeContainer = iframeContainer;
27
17
  }
28
18
  const nodeContainerRect = nodeContainer.getBoundingClientRect();
29
19
  return {
@@ -54,7 +44,6 @@ const createGenericPreview = () => {
54
44
  const generalPreview = document.createElement('div');
55
45
  // ProseMirror class is required to make sure the cloned dom is styled correctly
56
46
  generalPreview.classList.add('ProseMirror', 'block-ctrl-drag-preview');
57
- const previewStyle = fg('platform_editor_elements_drag_and_drop_ed_23189') ? previewStyleNew : previewStyleOld;
58
47
  generalPreview.style.border = `${previewStyle.borderWidth} ${previewStyle.borderStyle} ${previewStyle.borderColor}`;
59
48
  generalPreview.style.borderRadius = previewStyle.borderRadius;
60
49
  generalPreview.style.backgroundColor = previewStyle.backgroundColor;
@@ -78,13 +67,13 @@ const createContentPreviewElement = (dom, nodeType, nodeSpacing) => {
78
67
  clonedDom.style.marginRight = '0';
79
68
  clonedDom.style.marginBottom = nodeSpacing ? `${nodeSpacing.bottom}` : '0';
80
69
  clonedDom.style.boxShadow = 'none';
81
- clonedDom.style.opacity = browser.windows ? '1' : fg('platform_editor_elements_drag_and_drop_ed_23189') ? '0.31' : '0.4';
70
+ clonedDom.style.opacity = browser.windows ? '1' : '0.31';
82
71
  contentPreviewOneElement.appendChild(clonedDom);
83
72
  return contentPreviewOneElement;
84
73
  };
85
74
  const isGenericPreview = (dom, nodeType) => {
86
75
  const embedCard = dom.querySelector('.embedCardView-content-wrap');
87
- return fg('platform_editor_elements_drag_and_drop_ed_23189') ? nodeType === 'embedCard' || !!embedCard || nodeType === 'extension' && !!dom.querySelector('iframe') : nodeType === 'embedCard' || !!embedCard || nodeType === 'extension';
76
+ return nodeType === 'embedCard' || !!embedCard || nodeType === 'extension' && !!dom.querySelector('iframe');
88
77
  };
89
78
  const createPreviewForElement = (dom, nodeType, nodeSpacing) => {
90
79
  const shouldBeGenericPreview = isGenericPreview(dom, nodeType);
@@ -7,7 +7,6 @@ import { useCallback, useEffect, useRef, useState } from 'react';
7
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import { layoutBreakpointWidth } from '@atlaskit/editor-shared-styles';
10
- import { fg } from '@atlaskit/platform-feature-flags';
11
10
  import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
12
11
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
13
12
  import { B200 } from '@atlaskit/theme/colors';
@@ -73,7 +72,7 @@ export const DropTargetLayout = props => {
73
72
  const to = getPos();
74
73
  let mappedTo;
75
74
  if (to !== undefined) {
76
- var _api$core;
75
+ var _api$core, _api$core2;
77
76
  const {
78
77
  pos: from
79
78
  } = activeNode;
@@ -84,23 +83,18 @@ export const DropTargetLayout = props => {
84
83
  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)({
85
84
  tr
86
85
  });
87
- if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
88
- const insertColumnStep = getInsertLayoutStep(tr);
89
- mappedTo = insertColumnStep === null || insertColumnStep === void 0 ? void 0 : insertColumnStep.from;
86
+ const insertColumnStep = getInsertLayoutStep(tr);
87
+ mappedTo = insertColumnStep === null || insertColumnStep === void 0 ? void 0 : insertColumnStep.from;
88
+ return tr;
89
+ });
90
+ api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
91
+ tr
92
+ }) => {
93
+ if (mappedTo !== undefined) {
94
+ updateSelection(tr, mappedTo);
90
95
  }
91
96
  return tr;
92
97
  });
93
- if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
94
- var _api$core2;
95
- api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
96
- tr
97
- }) => {
98
- if (mappedTo !== undefined) {
99
- updateSelection(tr, mappedTo);
100
- }
101
- return tr;
102
- });
103
- }
104
98
  }
105
99
  }, [api, getPos, activeNode]);
106
100
  useEffect(() => {
@@ -5,7 +5,6 @@
5
5
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
6
  import { css, Global, jsx } from '@emotion/react';
7
7
  import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport } from '@atlaskit/editor-shared-styles';
8
- import { fg } from '@atlaskit/platform-feature-flags';
9
8
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
9
  import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, DRAG_HANDLE_WIDTH } from './consts';
11
10
 
@@ -260,6 +259,6 @@ const blockCardWithoutLayout = css({
260
259
  });
261
260
  export const GlobalStylesWrapper = () => {
262
261
  return jsx(Global, {
263
- styles: [globalStyles(), fg('platform_editor_advanced_layouts_post_fix_patch_1') && globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
262
+ styles: [globalStyles(), globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
264
263
  });
265
264
  };
@@ -9,7 +9,6 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
9
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
10
10
  import { css, jsx } from '@emotion/react';
11
11
  import { akEditorBreakoutPadding } from '@atlaskit/editor-shared-styles';
12
- import { fg } from '@atlaskit/platform-feature-flags';
13
12
  import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
14
13
  import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
15
14
  import { B200 } from '@atlaskit/theme/colors';
@@ -178,7 +177,7 @@ export const InlineDropTarget = ({
178
177
  const toPos = getPos();
179
178
  let mappedTo;
180
179
  if (activeNode && toPos !== undefined) {
181
- var _api$core;
180
+ var _api$core, _api$core2;
182
181
  const {
183
182
  pos: start
184
183
  } = activeNode;
@@ -192,23 +191,18 @@ export const InlineDropTarget = ({
192
191
  })({
193
192
  tr
194
193
  });
195
- if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
196
- const insertLayoutStep = getInsertLayoutStep(tr);
197
- mappedTo = insertLayoutStep === null || insertLayoutStep === void 0 ? void 0 : insertLayoutStep.from;
194
+ const insertLayoutStep = getInsertLayoutStep(tr);
195
+ mappedTo = insertLayoutStep === null || insertLayoutStep === void 0 ? void 0 : insertLayoutStep.from;
196
+ return tr;
197
+ });
198
+ api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
199
+ tr
200
+ }) => {
201
+ if (mappedTo !== undefined) {
202
+ updateSelection(tr, mappedTo, moveToEnd);
198
203
  }
199
204
  return tr;
200
205
  });
201
- if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
202
- var _api$core2;
203
- api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
204
- tr
205
- }) => {
206
- if (mappedTo !== undefined) {
207
- updateSelection(tr, mappedTo, moveToEnd);
208
- }
209
- return tr;
210
- });
211
- }
212
206
  }
213
207
  }, [api, getPos, position]);
214
208
  const hoverZoneRectStyle = useMemo(() => {
@@ -9,7 +9,7 @@ import { transformSliceNestedExpandToExpand } from '@atlaskit/editor-common/tran
9
9
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
10
10
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
11
11
  import { Selection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
12
- import { findParentNodeOfType, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
12
+ import { findChildrenByType, findParentNodeOfType, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
13
13
  import { findTable, isInTable, isTableSelected } from '@atlaskit/editor-tables/utils';
14
14
  import { fg } from '@atlaskit/platform-feature-flags';
15
15
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
@@ -21,7 +21,7 @@ import { selectNode, setCursorPositionAtMovedNode } from '../pm-plugins/utils/ge
21
21
  import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
22
22
  import { getSelectedSlicePosition } from '../pm-plugins/utils/selection';
23
23
  import { getInsertLayoutStep, updateSelection } from '../pm-plugins/utils/update-selection';
24
- import { canMoveNodeToIndex, isInsideTable, transformSliceExpandToNestedExpand } from '../pm-plugins/utils/validation';
24
+ import { canMoveNodeToIndex, isInsideTable, transformSliceExpandToNestedExpand, transformFragmentExpandToNestedExpand } from '../pm-plugins/utils/validation';
25
25
 
26
26
  /**
27
27
  * This function transforms the slice to move
@@ -82,6 +82,10 @@ var isDragLayoutColumnToTopLevel = function isDragLayoutColumnToTopLevel($from,
82
82
  var _$from$nodeAfter;
83
83
  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;
84
84
  };
85
+ var isDragLayoutColumnIntoTable = function isDragLayoutColumnIntoTable($from, $to) {
86
+ var _$from$nodeAfter2;
87
+ return ((_$from$nodeAfter2 = $from.nodeAfter) === null || _$from$nodeAfter2 === void 0 ? void 0 : _$from$nodeAfter2.type.name) === 'layoutColumn' && $from.parent.type.name === 'layoutSection' && ($to.parent.type.name === 'tableCell' || $to.parent.type.name === 'tableHeader');
88
+ };
85
89
 
86
90
  /**
87
91
  *
@@ -370,12 +374,25 @@ export var moveNode = function moveNode(api) {
370
374
  var destType = $to.node().type;
371
375
  var destParent = $to.node($to.depth);
372
376
  var sourceNode = $handlePos.nodeAfter;
377
+ var dragLayoutColumnToTopLevel = isDragLayoutColumnToTopLevel($handlePos, $to);
378
+ var dragLayoutColumnIntoTable = isDragLayoutColumnIntoTable($handlePos, $to);
373
379
 
374
380
  //TODO: ED-26959 - Does this need to be updated with new selection logic above? ^
375
381
  // Move a layout column to top level
376
- if (sourceNode && isDragLayoutColumnToTopLevel($handlePos, $to)) {
382
+ // Move a layout column into a table cell, only moves the content into the cell
383
+ if (sourceNode && (dragLayoutColumnToTopLevel || dragLayoutColumnIntoTable)) {
377
384
  // need update after we support single column layout.
378
- var fragment = Fragment.from(sourceNode.content);
385
+ var layoutColumnContent = sourceNode.content;
386
+ var fragment;
387
+ if (dragLayoutColumnIntoTable) {
388
+ var contentContainsExpand = findChildrenByType(sourceNode, expand).length > 0;
389
+ fragment = contentContainsExpand ? transformFragmentExpandToNestedExpand(Fragment.from(layoutColumnContent)) : Fragment.from(layoutColumnContent);
390
+ if (!fragment) {
391
+ return tr;
392
+ }
393
+ } else {
394
+ fragment = Fragment.from(layoutColumnContent);
395
+ }
379
396
  removeFromSource(tr, $handlePos, $handlePos.pos + sourceNode.nodeSize);
380
397
  var _mappedTo = tr.mapping.map(to);
381
398
  tr.insert(_mappedTo, fragment).setSelection(Selection.near(tr.doc.resolve(_mappedTo))).scrollIntoView();
@@ -4,12 +4,11 @@ import { Fragment, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
6
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
- import { fireInsertLayoutAnalytics, attachMoveNodeAnalytics, getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics';
8
- import { isFragmentOfType, containsNodeOfType } from '../pm-plugins/utils/check-fragment';
7
+ import { attachMoveNodeAnalytics, fireInsertLayoutAnalytics, getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics';
8
+ import { containsNodeOfType, isFragmentOfType } from '../pm-plugins/utils/check-fragment';
9
9
  import { maxLayoutColumnSupported } from '../pm-plugins/utils/consts';
10
10
  import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
11
11
  import { getMultiSelectionIfPosInside } from '../pm-plugins/utils/selection';
12
- import { updateColumnWidths } from '../pm-plugins/utils/update-column-widths';
13
12
  import { isInSameLayout } from '../pm-plugins/utils/validation';
14
13
  import { DEFAULT_COLUMN_DISTRIBUTIONS } from '../ui/consts';
15
14
  var createNewLayout = function createNewLayout(schema, layoutContents) {
@@ -64,20 +63,14 @@ var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos,
64
63
  tr.delete(from, sourceContentEndPos);
65
64
  var mappedTo = tr.mapping.map(to);
66
65
  tr.insert(mappedTo, sourceContent);
67
- if (!fg('platform_editor_advanced_layouts_post_fix_patch_1') || selectMovedNode) {
66
+ if (selectMovedNode) {
68
67
  tr.setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
69
68
  }
70
69
  attachMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf === void 0 ? void 0 : _$originalFrom$nodeAf.type.name) || '', 1, 'layoutSection', true, api, sourceNodeTypes, hasSelectedMultipleNodes);
71
70
  } else if (toLayout.childCount < maxLayoutColumnSupported()) {
72
71
  var _$originalFrom$nodeAf2;
73
- if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
74
- removeFromSource(tr, tr.doc.resolve(from), sourceContentEndPos);
75
- insertToDestinationNoWidthUpdate(tr, tr.mapping.map(to), sourceContent);
76
- } else {
77
- insertToDestination(tr, to, sourceContent, toLayout, toLayoutPos);
78
- var mappedFrom = tr.mapping.map(from);
79
- removeFromSource(tr, tr.doc.resolve(mappedFrom), tr.mapping.map(sourceContentEndPos));
80
- }
72
+ removeFromSource(tr, tr.doc.resolve(from), sourceContentEndPos);
73
+ insertToDestinationNoWidthUpdate(tr, tr.mapping.map(to), sourceContent);
81
74
  attachMoveNodeAnalytics(tr, INPUT_METHOD.DRAG_AND_DROP, $originalFrom.depth, ((_$originalFrom$nodeAf2 = $originalFrom.nodeAfter) === null || _$originalFrom$nodeAf2 === void 0 ? void 0 : _$originalFrom$nodeAf2.type.name) || '', 1, 'layoutSection', false, api, sourceNodeTypes, hasSelectedMultipleNodes);
82
75
  }
83
76
  return tr;
@@ -122,40 +115,6 @@ var insertToDestinationNoWidthUpdate = function insertToDestinationNoWidthUpdate
122
115
  }
123
116
  return tr;
124
117
  };
125
- var insertToDestination = function insertToDestination(tr, to, sourceContent, toLayout, toLayoutPos) {
126
- var _ref3 = updateColumnWidths(tr, toLayout, toLayoutPos, toLayout.childCount + 1) || {},
127
- newColumnWidth = _ref3.newColumnWidth;
128
- var _ref4 = tr.doc.type.schema.nodes || {},
129
- layoutColumn = _ref4.layoutColumn;
130
- var content = null;
131
- try {
132
- if (editorExperiment('platform_editor_element_drag_and_drop_multiselect', true)) {
133
- if (sourceContent instanceof Fragment) {
134
- var _sourceContent$firstC;
135
- content = layoutColumn.createChecked({
136
- width: newColumnWidth
137
- }, isFragmentOfType(sourceContent, 'layoutColumn') ? (_sourceContent$firstC = sourceContent.firstChild) === null || _sourceContent$firstC === void 0 ? void 0 : _sourceContent$firstC.content : sourceContent);
138
- }
139
- } else {
140
- if (sourceContent instanceof PMNode) {
141
- content = layoutColumn.createChecked({
142
- width: newColumnWidth
143
- }, sourceContent.type.name === 'layoutColumn' ? sourceContent.content : sourceContent);
144
- }
145
- }
146
- } catch (error) {
147
- logException(error, {
148
- location: 'editor-plugin-block-controls/move-to-layout'
149
- });
150
- }
151
- if (content) {
152
- tr.insert(to, content);
153
- }
154
- if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
155
- tr.setSelection(new NodeSelection(tr.doc.resolve(to))).scrollIntoView();
156
- }
157
- return tr;
158
- };
159
118
 
160
119
  /**
161
120
  * Check if the node at `from` can be moved to node at `to` to create/expand a layout.
@@ -165,10 +124,10 @@ var canMoveToLayout = function canMoveToLayout(api, from, to, tr, moveNodeAtCurs
165
124
  if (from === to) {
166
125
  return;
167
126
  }
168
- var _ref5 = tr.doc.type.schema.nodes || {},
169
- layoutSection = _ref5.layoutSection,
170
- layoutColumn = _ref5.layoutColumn,
171
- doc = _ref5.doc;
127
+ var _ref3 = tr.doc.type.schema.nodes || {},
128
+ layoutSection = _ref3.layoutSection,
129
+ layoutColumn = _ref3.layoutColumn,
130
+ doc = _ref3.doc;
172
131
 
173
132
  // layout plugin does not exist
174
133
  if (!layoutSection || !layoutColumn) {
@@ -218,8 +177,8 @@ var canMoveToLayout = function canMoveToLayout(api, from, to, tr, moveNodeAtCurs
218
177
  };
219
178
  var removeBreakoutMarks = function removeBreakoutMarks(tr, $from, to) {
220
179
  var fromContentWithoutBreakout = $from.nodeAfter;
221
- var _ref6 = tr.doc.type.schema.marks || {},
222
- breakout = _ref6.breakout;
180
+ var _ref4 = tr.doc.type.schema.marks || {},
181
+ breakout = _ref4.breakout;
223
182
  if (editorExperiment('platform_editor_element_drag_and_drop_multiselect', true)) {
224
183
  tr.doc.nodesBetween($from.pos, to, function (node, pos, parent) {
225
184
  // breakout doesn't exist on nested nodes
@@ -282,8 +241,8 @@ var getBreakoutMode = function getBreakoutMode(content, breakout) {
282
241
  // source content variable that has type of `PMNode | Fragment` should be updated to `Fragment` only
283
242
  export var moveToLayout = function moveToLayout(api) {
284
243
  return function (from, to, options) {
285
- return function (_ref7) {
286
- var tr = _ref7.tr;
244
+ return function (_ref5) {
245
+ var tr = _ref5.tr;
287
246
  if (!api) {
288
247
  return tr;
289
248
  }
@@ -296,11 +255,11 @@ export var moveToLayout = function moveToLayout(api) {
296
255
  sourceContent = canMove.sourceContent,
297
256
  $sourceFrom = canMove.$sourceFrom,
298
257
  sourceTo = canMove.sourceTo;
299
- var _ref8 = tr.doc.type.schema.nodes || {},
300
- layoutSection = _ref8.layoutSection,
301
- layoutColumn = _ref8.layoutColumn;
302
- var _ref9 = tr.doc.type.schema.marks || {},
303
- breakout = _ref9.breakout;
258
+ var _ref6 = tr.doc.type.schema.nodes || {},
259
+ layoutSection = _ref6.layoutSection,
260
+ layoutColumn = _ref6.layoutColumn;
261
+ var _ref7 = tr.doc.type.schema.marks || {},
262
+ breakout = _ref7.breakout;
304
263
 
305
264
  // get breakout mode from destination node,
306
265
  // if not found, get from source node,
@@ -358,9 +317,6 @@ export var moveToLayout = function moveToLayout(api) {
358
317
  tr = removeFromSource(tr, $sourceFrom, sourceTo);
359
318
  var mappedTo = tr.mapping.map(to);
360
319
  tr.delete(mappedTo, mappedTo + toNodeWithoutBreakout.nodeSize).insert(mappedTo, newLayout);
361
- if (!fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
362
- tr.setSelection(new NodeSelection(tr.doc.resolve(mappedTo))).scrollIntoView();
363
- }
364
320
  breakoutMode && tr.setNodeMarkup(mappedTo, newLayout.type, newLayout.attrs, [breakout.create({
365
321
  mode: breakoutMode
366
322
  })]);
@@ -40,7 +40,7 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
40
40
  }
41
41
  var parentElement = (_rootElement$parentEl = rootElement.parentElement) === null || _rootElement$parentEl === void 0 ? void 0 : _rootElement$parentEl.closest('[data-drag-handler-anchor-name]');
42
42
  var parentElementType = parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute('data-drag-handler-node-type');
43
- if (editorExperiment('advanced_layouts', true) && fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
43
+ if (editorExperiment('advanced_layouts', true)) {
44
44
  // We want to exclude handles from showing for direct descendant of table nodes (i.e. nodes in cells)
45
45
  if (parentElement && (parentElementType === 'table' || parentElementType === 'tableRow') && editorExperiment('nested-dnd', true)) {
46
46
  rootElement = parentElement;