@atlaskit/editor-plugin-block-controls 3.8.1 → 3.8.2
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 +9 -0
- package/dist/cjs/editor-commands/move-node.js +7 -1
- package/dist/cjs/pm-plugins/utils/validation.js +38 -31
- package/dist/cjs/ui/quick-insert-button.js +1 -1
- package/dist/es2019/editor-commands/move-node.js +7 -1
- package/dist/es2019/pm-plugins/utils/validation.js +36 -27
- package/dist/es2019/ui/quick-insert-button.js +1 -1
- package/dist/esm/editor-commands/move-node.js +7 -1
- package/dist/esm/pm-plugins/utils/validation.js +37 -31
- package/dist/esm/ui/quick-insert-button.js +1 -1
- package/dist/types/pm-plugins/utils/validation.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/utils/validation.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 3.8.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#135614](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/135614)
|
|
8
|
+
[`ed711343dbd01`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ed711343dbd01) -
|
|
9
|
+
ED-27111: Dnd layout column into panel
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 3.8.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -92,6 +92,10 @@ var isDragLayoutColumnIntoTable = function isDragLayoutColumnIntoTable($from, $t
|
|
|
92
92
|
var _$from$nodeAfter2;
|
|
93
93
|
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');
|
|
94
94
|
};
|
|
95
|
+
var isDragLayoutColumnIntoPanel = function isDragLayoutColumnIntoPanel($from, $to) {
|
|
96
|
+
var _$from$nodeAfter3;
|
|
97
|
+
return ((_$from$nodeAfter3 = $from.nodeAfter) === null || _$from$nodeAfter3 === void 0 ? void 0 : _$from$nodeAfter3.type.name) === 'layoutColumn' && $from.parent.type.name === 'layoutSection' && $to.parent.type.name === 'panel';
|
|
98
|
+
};
|
|
95
99
|
|
|
96
100
|
/**
|
|
97
101
|
*
|
|
@@ -387,11 +391,13 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
387
391
|
var sourceNode = $handlePos.nodeAfter;
|
|
388
392
|
var dragLayoutColumnToTopLevel = isDragLayoutColumnToTopLevel($handlePos, $to);
|
|
389
393
|
var dragLayoutColumnIntoTable = isDragLayoutColumnIntoTable($handlePos, $to);
|
|
394
|
+
var dragLayoutColumnIntoPanel = isDragLayoutColumnIntoPanel($handlePos, $to);
|
|
390
395
|
|
|
391
396
|
//TODO: ED-26959 - Does this need to be updated with new selection logic above? ^
|
|
392
397
|
// Move a layout column to top level
|
|
393
398
|
// Move a layout column into a table cell, only moves the content into the cell
|
|
394
|
-
|
|
399
|
+
// Move a layout column into a panel, only moves the content into the panel
|
|
400
|
+
if (sourceNode && (dragLayoutColumnToTopLevel || dragLayoutColumnIntoTable || dragLayoutColumnIntoPanel)) {
|
|
395
401
|
// need update after we support single column layout.
|
|
396
402
|
var layoutColumnContent = sourceNode.content;
|
|
397
403
|
var fragment;
|
|
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.canCreateNodeWithContentInsideAnotherNode = void 0;
|
|
7
8
|
exports.canMoveNodeToIndex = canMoveNodeToIndex;
|
|
8
9
|
exports.canMoveSliceToIndex = canMoveSliceToIndex;
|
|
9
10
|
exports.transformSliceExpandToNestedExpand = exports.transformFragmentExpandToNestedExpand = exports.transformExpandToNestedExpand = exports.memoizedTransformExpandToNestedExpand = exports.isNestedExpand = exports.isLayoutColumn = exports.isInsideTable = exports.isInSameLayout = exports.isExpand = exports.isDoc = void 0;
|
|
@@ -87,69 +88,75 @@ var memoizedTransformExpandToNestedExpand = exports.memoizedTransformExpandToNes
|
|
|
87
88
|
return null;
|
|
88
89
|
}
|
|
89
90
|
});
|
|
91
|
+
var canCreateNodeWithContentInsideAnotherNode = exports.canCreateNodeWithContentInsideAnotherNode = function canCreateNodeWithContentInsideAnotherNode(nodeTypesToCreate, nodeWithTargetFragment) {
|
|
92
|
+
try {
|
|
93
|
+
return !!nodeTypesToCreate.every(function (nodeType) {
|
|
94
|
+
return nodeType.createChecked({}, nodeWithTargetFragment);
|
|
95
|
+
});
|
|
96
|
+
} catch (e) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
90
100
|
function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNodePos, destNode) {
|
|
91
101
|
var srcNodeType = srcNode.type;
|
|
92
|
-
var
|
|
102
|
+
var schema = srcNodeType.schema;
|
|
103
|
+
var destParentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type.name;
|
|
93
104
|
var activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.name;
|
|
105
|
+
var layoutColumnContent = srcNode.content;
|
|
94
106
|
var isNestingTablesSupported = (0, _platformFeatureFlags.fg)('platform_editor_use_nested_table_pm_nodes') && (0, _experiments.editorExperiment)('nested-tables-in-tables', true, {
|
|
95
107
|
exposure: true
|
|
96
108
|
});
|
|
97
|
-
var tableNodeType =
|
|
98
|
-
var expandNodeType = srcNode.type.schema.nodes.expand;
|
|
109
|
+
var tableNodeType = schema.nodes.table;
|
|
99
110
|
if (activeNodeType === 'layoutColumn' && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
100
111
|
// Allow drag layout column and drop into layout section
|
|
101
|
-
if ((destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection' ||
|
|
112
|
+
if ((destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection' || destParentNodeType === 'doc') {
|
|
102
113
|
return true;
|
|
103
114
|
}
|
|
104
|
-
if ((
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return
|
|
115
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_drag_layout_column_into_nodes')) {
|
|
116
|
+
if (destParentNodeType === 'tableCell' || destParentNodeType === 'tableHeader') {
|
|
117
|
+
var _schema$nodes = schema.nodes,
|
|
118
|
+
tableCell = _schema$nodes.tableCell,
|
|
119
|
+
tableHeader = _schema$nodes.tableHeader,
|
|
120
|
+
expand = _schema$nodes.expand;
|
|
121
|
+
var contentContainsExpand = (0, _utils.findChildrenByType)(srcNode, expand).length > 0;
|
|
122
|
+
//convert expand to nestedExpand if there are expands inside the layout column
|
|
123
|
+
// otherwise, the createChecked will fail as expand is not a valid child of tableCell/tableHeader, but nestedExpand is
|
|
124
|
+
var convertedFragment = contentContainsExpand ? transformFragmentExpandToNestedExpand(layoutColumnContent) : layoutColumnContent;
|
|
125
|
+
if (!convertedFragment) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
return canCreateNodeWithContentInsideAnotherNode([tableCell, tableHeader], convertedFragment);
|
|
118
129
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
var isAnyTableNestedInExpand = maybeExpandNodesArray.some(function (result) {
|
|
123
|
-
return (0, _utils.findChildrenByType)(result.node, tableNodeType).length > 0;
|
|
124
|
-
});
|
|
125
|
-
return !isAnyTableNestedInExpand;
|
|
130
|
+
if (destParentNodeType === 'panel') {
|
|
131
|
+
var panel = schema.nodes.panel;
|
|
132
|
+
return canCreateNodeWithContentInsideAnotherNode([panel], layoutColumnContent);
|
|
126
133
|
}
|
|
127
134
|
}
|
|
128
135
|
}
|
|
129
136
|
|
|
130
137
|
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
131
138
|
if ((0, _experiments.editorExperiment)('nested-expand-in-expand', false)) {
|
|
132
|
-
if (
|
|
139
|
+
if (destParentNodeType === 'expand' && (activeNodeType === 'expand' || activeNodeType === 'nestedExpand')) {
|
|
133
140
|
return false;
|
|
134
141
|
}
|
|
135
142
|
}
|
|
136
143
|
|
|
137
144
|
// NOTE: this will block drop targets from showing for dragging a table into another table
|
|
138
145
|
// unless nested tables are supported and the nesting depth does not exceed 1
|
|
139
|
-
if ((
|
|
140
|
-
var
|
|
141
|
-
if (!isNestingTablesSupported || isNestingTablesSupported &&
|
|
146
|
+
if ((destParentNodeType === 'tableCell' || destParentNodeType === 'tableHeader') && activeNodeType === 'table') {
|
|
147
|
+
var nestingDepth = (0, _nesting.getParentOfTypeCount)(tableNodeType)($destNodePos);
|
|
148
|
+
if (!isNestingTablesSupported || isNestingTablesSupported && nestingDepth > 1) {
|
|
142
149
|
return false;
|
|
143
150
|
}
|
|
144
151
|
}
|
|
145
152
|
if (isInsideTable(destParent.type) && isExpand(srcNodeType)) {
|
|
146
153
|
if (memoizedTransformExpandToNestedExpand(srcNode)) {
|
|
147
|
-
srcNodeType =
|
|
154
|
+
srcNodeType = schema.nodes.nestedExpand;
|
|
148
155
|
} else {
|
|
149
156
|
return false;
|
|
150
157
|
}
|
|
151
158
|
} else if ((isDoc(destParent.type) || isLayoutColumn(destParent.type)) && isNestedExpand(srcNodeType)) {
|
|
152
|
-
srcNodeType =
|
|
159
|
+
srcNodeType = schema.nodes.expand;
|
|
153
160
|
}
|
|
154
161
|
return destParent.canReplaceWith(indexIntoParent, indexIntoParent, srcNodeType);
|
|
155
162
|
}
|
|
@@ -246,7 +246,7 @@ var TypeAheadControl = exports.TypeAheadControl = function TypeAheadControl(_ref
|
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
|
-
(_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl');
|
|
249
|
+
(_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl', true);
|
|
250
250
|
}, [api, getPos, view]);
|
|
251
251
|
var handleMouseDown = (0, _react.useCallback)(function () {
|
|
252
252
|
var _api$typeAhead;
|
|
@@ -85,6 +85,10 @@ const isDragLayoutColumnIntoTable = ($from, $to) => {
|
|
|
85
85
|
var _$from$nodeAfter2;
|
|
86
86
|
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');
|
|
87
87
|
};
|
|
88
|
+
const isDragLayoutColumnIntoPanel = ($from, $to) => {
|
|
89
|
+
var _$from$nodeAfter3;
|
|
90
|
+
return ((_$from$nodeAfter3 = $from.nodeAfter) === null || _$from$nodeAfter3 === void 0 ? void 0 : _$from$nodeAfter3.type.name) === 'layoutColumn' && $from.parent.type.name === 'layoutSection' && $to.parent.type.name === 'panel';
|
|
91
|
+
};
|
|
88
92
|
|
|
89
93
|
/**
|
|
90
94
|
*
|
|
@@ -390,11 +394,13 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
|
|
|
390
394
|
const sourceNode = $handlePos.nodeAfter;
|
|
391
395
|
const dragLayoutColumnToTopLevel = isDragLayoutColumnToTopLevel($handlePos, $to);
|
|
392
396
|
const dragLayoutColumnIntoTable = isDragLayoutColumnIntoTable($handlePos, $to);
|
|
397
|
+
const dragLayoutColumnIntoPanel = isDragLayoutColumnIntoPanel($handlePos, $to);
|
|
393
398
|
|
|
394
399
|
//TODO: ED-26959 - Does this need to be updated with new selection logic above? ^
|
|
395
400
|
// Move a layout column to top level
|
|
396
401
|
// Move a layout column into a table cell, only moves the content into the cell
|
|
397
|
-
|
|
402
|
+
// Move a layout column into a panel, only moves the content into the panel
|
|
403
|
+
if (sourceNode && (dragLayoutColumnToTopLevel || dragLayoutColumnIntoTable || dragLayoutColumnIntoPanel)) {
|
|
398
404
|
// need update after we support single column layout.
|
|
399
405
|
const layoutColumnContent = sourceNode.content;
|
|
400
406
|
let fragment;
|
|
@@ -80,54 +80,63 @@ export const memoizedTransformExpandToNestedExpand = memoizeOne(node => {
|
|
|
80
80
|
return null;
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
|
+
export const canCreateNodeWithContentInsideAnotherNode = (nodeTypesToCreate, nodeWithTargetFragment) => {
|
|
84
|
+
try {
|
|
85
|
+
return !!nodeTypesToCreate.every(nodeType => nodeType.createChecked({}, nodeWithTargetFragment));
|
|
86
|
+
} catch (e) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
83
90
|
export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNodePos, destNode) {
|
|
84
91
|
let srcNodeType = srcNode.type;
|
|
85
|
-
const
|
|
92
|
+
const schema = srcNodeType.schema;
|
|
93
|
+
const destParentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type.name;
|
|
86
94
|
const activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.name;
|
|
95
|
+
const layoutColumnContent = srcNode.content;
|
|
87
96
|
const isNestingTablesSupported = fg('platform_editor_use_nested_table_pm_nodes') && editorExperiment('nested-tables-in-tables', true, {
|
|
88
97
|
exposure: true
|
|
89
98
|
});
|
|
90
|
-
const tableNodeType =
|
|
91
|
-
const expandNodeType = srcNode.type.schema.nodes.expand;
|
|
99
|
+
const tableNodeType = schema.nodes.table;
|
|
92
100
|
if (activeNodeType === 'layoutColumn' && editorExperiment('advanced_layouts', true)) {
|
|
93
101
|
// Allow drag layout column and drop into layout section
|
|
94
|
-
if ((destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection' ||
|
|
102
|
+
if ((destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection' || destParentNodeType === 'doc') {
|
|
95
103
|
return true;
|
|
96
104
|
}
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
if (fg('platform_editor_drag_layout_column_into_nodes')) {
|
|
106
|
+
if (destParentNodeType === 'tableCell' || destParentNodeType === 'tableHeader') {
|
|
107
|
+
const {
|
|
108
|
+
tableCell,
|
|
109
|
+
tableHeader,
|
|
110
|
+
expand
|
|
111
|
+
} = schema.nodes;
|
|
112
|
+
const contentContainsExpand = findChildrenByType(srcNode, expand).length > 0;
|
|
113
|
+
//convert expand to nestedExpand if there are expands inside the layout column
|
|
114
|
+
// otherwise, the createChecked will fail as expand is not a valid child of tableCell/tableHeader, but nestedExpand is
|
|
115
|
+
const convertedFragment = contentContainsExpand ? transformFragmentExpandToNestedExpand(layoutColumnContent) : layoutColumnContent;
|
|
116
|
+
if (!convertedFragment) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return canCreateNodeWithContentInsideAnotherNode([tableCell, tableHeader], convertedFragment);
|
|
111
120
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return
|
|
121
|
+
if (destParentNodeType === 'panel') {
|
|
122
|
+
const {
|
|
123
|
+
panel
|
|
124
|
+
} = schema.nodes;
|
|
125
|
+
return canCreateNodeWithContentInsideAnotherNode([panel], layoutColumnContent);
|
|
117
126
|
}
|
|
118
127
|
}
|
|
119
128
|
}
|
|
120
129
|
|
|
121
130
|
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
122
131
|
if (editorExperiment('nested-expand-in-expand', false)) {
|
|
123
|
-
if (
|
|
132
|
+
if (destParentNodeType === 'expand' && (activeNodeType === 'expand' || activeNodeType === 'nestedExpand')) {
|
|
124
133
|
return false;
|
|
125
134
|
}
|
|
126
135
|
}
|
|
127
136
|
|
|
128
137
|
// NOTE: this will block drop targets from showing for dragging a table into another table
|
|
129
138
|
// unless nested tables are supported and the nesting depth does not exceed 1
|
|
130
|
-
if ((
|
|
139
|
+
if ((destParentNodeType === 'tableCell' || destParentNodeType === 'tableHeader') && activeNodeType === 'table') {
|
|
131
140
|
const nestingDepth = getParentOfTypeCount(tableNodeType)($destNodePos);
|
|
132
141
|
if (!isNestingTablesSupported || isNestingTablesSupported && nestingDepth > 1) {
|
|
133
142
|
return false;
|
|
@@ -135,12 +144,12 @@ export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNo
|
|
|
135
144
|
}
|
|
136
145
|
if (isInsideTable(destParent.type) && isExpand(srcNodeType)) {
|
|
137
146
|
if (memoizedTransformExpandToNestedExpand(srcNode)) {
|
|
138
|
-
srcNodeType =
|
|
147
|
+
srcNodeType = schema.nodes.nestedExpand;
|
|
139
148
|
} else {
|
|
140
149
|
return false;
|
|
141
150
|
}
|
|
142
151
|
} else if ((isDoc(destParent.type) || isLayoutColumn(destParent.type)) && isNestedExpand(srcNodeType)) {
|
|
143
|
-
srcNodeType =
|
|
152
|
+
srcNodeType = schema.nodes.expand;
|
|
144
153
|
}
|
|
145
154
|
return destParent.canReplaceWith(indexIntoParent, indexIntoParent, srcNodeType);
|
|
146
155
|
}
|
|
@@ -232,7 +232,7 @@ export const TypeAheadControl = ({
|
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
|
-
(_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 ? void 0 : _api$quickInsert.actions.openTypeAhead('blockControl');
|
|
235
|
+
(_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 ? void 0 : _api$quickInsert.actions.openTypeAhead('blockControl', true);
|
|
236
236
|
}, [api, getPos, view]);
|
|
237
237
|
const handleMouseDown = useCallback(() => {
|
|
238
238
|
var _api$typeAhead;
|
|
@@ -86,6 +86,10 @@ var isDragLayoutColumnIntoTable = function isDragLayoutColumnIntoTable($from, $t
|
|
|
86
86
|
var _$from$nodeAfter2;
|
|
87
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
88
|
};
|
|
89
|
+
var isDragLayoutColumnIntoPanel = function isDragLayoutColumnIntoPanel($from, $to) {
|
|
90
|
+
var _$from$nodeAfter3;
|
|
91
|
+
return ((_$from$nodeAfter3 = $from.nodeAfter) === null || _$from$nodeAfter3 === void 0 ? void 0 : _$from$nodeAfter3.type.name) === 'layoutColumn' && $from.parent.type.name === 'layoutSection' && $to.parent.type.name === 'panel';
|
|
92
|
+
};
|
|
89
93
|
|
|
90
94
|
/**
|
|
91
95
|
*
|
|
@@ -381,11 +385,13 @@ export var moveNode = function moveNode(api) {
|
|
|
381
385
|
var sourceNode = $handlePos.nodeAfter;
|
|
382
386
|
var dragLayoutColumnToTopLevel = isDragLayoutColumnToTopLevel($handlePos, $to);
|
|
383
387
|
var dragLayoutColumnIntoTable = isDragLayoutColumnIntoTable($handlePos, $to);
|
|
388
|
+
var dragLayoutColumnIntoPanel = isDragLayoutColumnIntoPanel($handlePos, $to);
|
|
384
389
|
|
|
385
390
|
//TODO: ED-26959 - Does this need to be updated with new selection logic above? ^
|
|
386
391
|
// Move a layout column to top level
|
|
387
392
|
// Move a layout column into a table cell, only moves the content into the cell
|
|
388
|
-
|
|
393
|
+
// Move a layout column into a panel, only moves the content into the panel
|
|
394
|
+
if (sourceNode && (dragLayoutColumnToTopLevel || dragLayoutColumnIntoTable || dragLayoutColumnIntoPanel)) {
|
|
389
395
|
// need update after we support single column layout.
|
|
390
396
|
var layoutColumnContent = sourceNode.content;
|
|
391
397
|
var fragment;
|
|
@@ -78,69 +78,75 @@ export var memoizedTransformExpandToNestedExpand = memoizeOne(function (node) {
|
|
|
78
78
|
return null;
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
|
+
export var canCreateNodeWithContentInsideAnotherNode = function canCreateNodeWithContentInsideAnotherNode(nodeTypesToCreate, nodeWithTargetFragment) {
|
|
82
|
+
try {
|
|
83
|
+
return !!nodeTypesToCreate.every(function (nodeType) {
|
|
84
|
+
return nodeType.createChecked({}, nodeWithTargetFragment);
|
|
85
|
+
});
|
|
86
|
+
} catch (e) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
81
90
|
export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNodePos, destNode) {
|
|
82
91
|
var srcNodeType = srcNode.type;
|
|
83
|
-
var
|
|
92
|
+
var schema = srcNodeType.schema;
|
|
93
|
+
var destParentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type.name;
|
|
84
94
|
var activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.name;
|
|
95
|
+
var layoutColumnContent = srcNode.content;
|
|
85
96
|
var isNestingTablesSupported = fg('platform_editor_use_nested_table_pm_nodes') && editorExperiment('nested-tables-in-tables', true, {
|
|
86
97
|
exposure: true
|
|
87
98
|
});
|
|
88
|
-
var tableNodeType =
|
|
89
|
-
var expandNodeType = srcNode.type.schema.nodes.expand;
|
|
99
|
+
var tableNodeType = schema.nodes.table;
|
|
90
100
|
if (activeNodeType === 'layoutColumn' && editorExperiment('advanced_layouts', true)) {
|
|
91
101
|
// Allow drag layout column and drop into layout section
|
|
92
|
-
if ((destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection' ||
|
|
102
|
+
if ((destNode === null || destNode === void 0 ? void 0 : destNode.type.name) === 'layoutSection' || destParentNodeType === 'doc') {
|
|
93
103
|
return true;
|
|
94
104
|
}
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return
|
|
105
|
+
if (fg('platform_editor_drag_layout_column_into_nodes')) {
|
|
106
|
+
if (destParentNodeType === 'tableCell' || destParentNodeType === 'tableHeader') {
|
|
107
|
+
var _schema$nodes = schema.nodes,
|
|
108
|
+
tableCell = _schema$nodes.tableCell,
|
|
109
|
+
tableHeader = _schema$nodes.tableHeader,
|
|
110
|
+
expand = _schema$nodes.expand;
|
|
111
|
+
var contentContainsExpand = findChildrenByType(srcNode, expand).length > 0;
|
|
112
|
+
//convert expand to nestedExpand if there are expands inside the layout column
|
|
113
|
+
// otherwise, the createChecked will fail as expand is not a valid child of tableCell/tableHeader, but nestedExpand is
|
|
114
|
+
var convertedFragment = contentContainsExpand ? transformFragmentExpandToNestedExpand(layoutColumnContent) : layoutColumnContent;
|
|
115
|
+
if (!convertedFragment) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
return canCreateNodeWithContentInsideAnotherNode([tableCell, tableHeader], convertedFragment);
|
|
109
119
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var isAnyTableNestedInExpand = maybeExpandNodesArray.some(function (result) {
|
|
114
|
-
return findChildrenByType(result.node, tableNodeType).length > 0;
|
|
115
|
-
});
|
|
116
|
-
return !isAnyTableNestedInExpand;
|
|
120
|
+
if (destParentNodeType === 'panel') {
|
|
121
|
+
var panel = schema.nodes.panel;
|
|
122
|
+
return canCreateNodeWithContentInsideAnotherNode([panel], layoutColumnContent);
|
|
117
123
|
}
|
|
118
124
|
}
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
122
128
|
if (editorExperiment('nested-expand-in-expand', false)) {
|
|
123
|
-
if (
|
|
129
|
+
if (destParentNodeType === 'expand' && (activeNodeType === 'expand' || activeNodeType === 'nestedExpand')) {
|
|
124
130
|
return false;
|
|
125
131
|
}
|
|
126
132
|
}
|
|
127
133
|
|
|
128
134
|
// NOTE: this will block drop targets from showing for dragging a table into another table
|
|
129
135
|
// unless nested tables are supported and the nesting depth does not exceed 1
|
|
130
|
-
if ((
|
|
131
|
-
var
|
|
132
|
-
if (!isNestingTablesSupported || isNestingTablesSupported &&
|
|
136
|
+
if ((destParentNodeType === 'tableCell' || destParentNodeType === 'tableHeader') && activeNodeType === 'table') {
|
|
137
|
+
var nestingDepth = getParentOfTypeCount(tableNodeType)($destNodePos);
|
|
138
|
+
if (!isNestingTablesSupported || isNestingTablesSupported && nestingDepth > 1) {
|
|
133
139
|
return false;
|
|
134
140
|
}
|
|
135
141
|
}
|
|
136
142
|
if (isInsideTable(destParent.type) && isExpand(srcNodeType)) {
|
|
137
143
|
if (memoizedTransformExpandToNestedExpand(srcNode)) {
|
|
138
|
-
srcNodeType =
|
|
144
|
+
srcNodeType = schema.nodes.nestedExpand;
|
|
139
145
|
} else {
|
|
140
146
|
return false;
|
|
141
147
|
}
|
|
142
148
|
} else if ((isDoc(destParent.type) || isLayoutColumn(destParent.type)) && isNestedExpand(srcNodeType)) {
|
|
143
|
-
srcNodeType =
|
|
149
|
+
srcNodeType = schema.nodes.expand;
|
|
144
150
|
}
|
|
145
151
|
return destParent.canReplaceWith(indexIntoParent, indexIntoParent, srcNodeType);
|
|
146
152
|
}
|
|
@@ -236,7 +236,7 @@ export var TypeAheadControl = function TypeAheadControl(_ref) {
|
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
(_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl');
|
|
239
|
+
(_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.actions.openTypeAhead('blockControl', true);
|
|
240
240
|
}, [api, getPos, view]);
|
|
241
241
|
var handleMouseDown = useCallback(function () {
|
|
242
242
|
var _api$typeAhead;
|
|
@@ -17,5 +17,6 @@ export declare const transformExpandToNestedExpand: (expandNode: PMNode) => PMNo
|
|
|
17
17
|
export declare const transformFragmentExpandToNestedExpand: (fragment: Fragment) => Fragment | null;
|
|
18
18
|
export declare const transformSliceExpandToNestedExpand: (slice: Slice) => Slice | null;
|
|
19
19
|
export declare const memoizedTransformExpandToNestedExpand: import("memoize-one").MemoizedFn<(node: PMNode) => PMNode | null>;
|
|
20
|
+
export declare const canCreateNodeWithContentInsideAnotherNode: (nodeTypesToCreate: NodeType[], nodeWithTargetFragment: Fragment) => boolean;
|
|
20
21
|
export declare function canMoveNodeToIndex(destParent: PMNode, indexIntoParent: number, srcNode: PMNode, $destNodePos: ResolvedPos, destNode?: PMNode): boolean;
|
|
21
22
|
export declare function canMoveSliceToIndex(slice: Slice, sliceFromPos: number, sliceToPos: number, destParent: PMNode, indexIntoParent: number, $destNodePos: ResolvedPos, destNode?: PMNode): boolean;
|
|
@@ -17,5 +17,6 @@ export declare const transformExpandToNestedExpand: (expandNode: PMNode) => PMNo
|
|
|
17
17
|
export declare const transformFragmentExpandToNestedExpand: (fragment: Fragment) => Fragment | null;
|
|
18
18
|
export declare const transformSliceExpandToNestedExpand: (slice: Slice) => Slice | null;
|
|
19
19
|
export declare const memoizedTransformExpandToNestedExpand: import("memoize-one").MemoizedFn<(node: PMNode) => PMNode | null>;
|
|
20
|
+
export declare const canCreateNodeWithContentInsideAnotherNode: (nodeTypesToCreate: NodeType[], nodeWithTargetFragment: Fragment) => boolean;
|
|
20
21
|
export declare function canMoveNodeToIndex(destParent: PMNode, indexIntoParent: number, srcNode: PMNode, $destNodePos: ResolvedPos, destNode?: PMNode): boolean;
|
|
21
22
|
export declare function canMoveSliceToIndex(slice: Slice, sliceFromPos: number, sliceToPos: number, destParent: PMNode, indexIntoParent: number, $destNodePos: ResolvedPos, destNode?: PMNode): boolean;
|