@atlaskit/editor-plugin-block-controls 2.13.31 → 2.14.1
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 +20 -0
- package/dist/cjs/editor-commands/move-node.js +1 -1
- package/dist/cjs/pm-plugins/decorations-drop-target.js +1 -1
- package/dist/cjs/pm-plugins/utils/validation.js +17 -1
- package/dist/es2019/editor-commands/move-node.js +1 -1
- package/dist/es2019/pm-plugins/decorations-drop-target.js +1 -1
- package/dist/es2019/pm-plugins/utils/validation.js +17 -1
- package/dist/esm/editor-commands/move-node.js +1 -1
- package/dist/esm/pm-plugins/decorations-drop-target.js +1 -1
- package/dist/esm/pm-plugins/utils/validation.js +17 -1
- package/dist/types/pm-plugins/utils/validation.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/utils/validation.d.ts +1 -1
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.14.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 2.14.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#168172](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/168172)
|
|
14
|
+
[`fa404ae4155f2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fa404ae4155f2) -
|
|
15
|
+
[ux] [ED-25523] This change is adding experiment based gating to the drag and drop logic for
|
|
16
|
+
nested tables. We only allow nesting tables one level deep via drag and drop if the experiment is
|
|
17
|
+
active. Else, you cannot drag and drop a table into another table.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 2.13.31
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -187,7 +187,7 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
187
187
|
tr.insert(_mappedTo, fragment).setSelection(_state.Selection.near(tr.doc.resolve(_mappedTo))).scrollIntoView();
|
|
188
188
|
return tr;
|
|
189
189
|
}
|
|
190
|
-
if (!(0, _validation.canMoveNodeToIndex)(destParent, $to.index(), $from.node().child($from.index()))) {
|
|
190
|
+
if (!(0, _validation.canMoveNodeToIndex)(destParent, $to.index(), $from.node().child($from.index()), $to)) {
|
|
191
191
|
return tr;
|
|
192
192
|
}
|
|
193
193
|
var convertedNodeSlice = transformSourceSlice(nodeCopy, destType);
|
|
@@ -225,7 +225,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
225
225
|
}
|
|
226
226
|
return shouldDescend(node); //skip over, don't consider it a valid depth
|
|
227
227
|
}
|
|
228
|
-
var canDrop = activePMNode && (0, _validation.canMoveNodeToIndex)(parent, index, activePMNode, node);
|
|
228
|
+
var canDrop = activePMNode && (0, _validation.canMoveNodeToIndex)(parent, index, activePMNode, $pos, node);
|
|
229
229
|
|
|
230
230
|
//NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
|
|
231
231
|
if (!canDrop && !(0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
|
|
@@ -7,7 +7,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.canMoveNodeToIndex = canMoveNodeToIndex;
|
|
8
8
|
exports.transformSliceExpandToNestedExpand = exports.transformExpandToNestedExpand = exports.memoizedTransformExpandToNestedExpand = exports.isNestedExpand = exports.isLayoutColumn = exports.isInsideTable = exports.isInSameLayout = exports.isExpand = exports.isDoc = void 0;
|
|
9
9
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
10
|
+
var _nesting = require("@atlaskit/editor-common/nesting");
|
|
10
11
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
13
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
14
|
var isInsideTable = exports.isInsideTable = function isInsideTable(nodeType) {
|
|
13
15
|
var _nodeType$schema$node = nodeType.schema.nodes,
|
|
@@ -76,7 +78,7 @@ var memoizedTransformExpandToNestedExpand = exports.memoizedTransformExpandToNes
|
|
|
76
78
|
return null;
|
|
77
79
|
}
|
|
78
80
|
});
|
|
79
|
-
function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, destNode) {
|
|
81
|
+
function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNodePos, destNode) {
|
|
80
82
|
var srcNodeType = srcNode.type;
|
|
81
83
|
var parentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type.name;
|
|
82
84
|
var activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.name;
|
|
@@ -100,6 +102,20 @@ function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, destNode) {
|
|
|
100
102
|
return false;
|
|
101
103
|
}
|
|
102
104
|
}
|
|
105
|
+
|
|
106
|
+
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
107
|
+
var isNestingTablesSupported = (0, _platformFeatureFlags.fg)('platform_editor_use_nested_table_pm_nodes') && (0, _experiments.editorExperiment)('nested-tables-in-tables', true, {
|
|
108
|
+
exposure: true
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// NOTE: this will block drop targets from showing for dragging a table into another table
|
|
112
|
+
// unless nested tables are supported and the nesting depth does not exceed 1
|
|
113
|
+
if ((parentNodeType === 'tableCell' || parentNodeType === 'tableHeader') && activeNodeType === 'table') {
|
|
114
|
+
var nestingDepth = (0, _nesting.getParentOfTypeCount)(srcNode === null || srcNode === void 0 ? void 0 : srcNode.type)($destNodePos);
|
|
115
|
+
if (!isNestingTablesSupported || isNestingTablesSupported && nestingDepth > 1) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
103
119
|
if (isInsideTable(destParent.type) && isExpand(srcNodeType)) {
|
|
104
120
|
if (memoizedTransformExpandToNestedExpand(srcNode)) {
|
|
105
121
|
srcNodeType = srcNodeType.schema.nodes.nestedExpand;
|
|
@@ -181,7 +181,7 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
|
|
|
181
181
|
tr.insert(mappedTo, fragment).setSelection(Selection.near(tr.doc.resolve(mappedTo))).scrollIntoView();
|
|
182
182
|
return tr;
|
|
183
183
|
}
|
|
184
|
-
if (!canMoveNodeToIndex(destParent, $to.index(), $from.node().child($from.index()))) {
|
|
184
|
+
if (!canMoveNodeToIndex(destParent, $to.index(), $from.node().child($from.index()), $to)) {
|
|
185
185
|
return tr;
|
|
186
186
|
}
|
|
187
187
|
const convertedNodeSlice = transformSourceSlice(nodeCopy, destType);
|
|
@@ -214,7 +214,7 @@ export const dropTargetDecorations = (newState, api, formatMessage, nodeViewPort
|
|
|
214
214
|
}
|
|
215
215
|
return shouldDescend(node); //skip over, don't consider it a valid depth
|
|
216
216
|
}
|
|
217
|
-
const canDrop = activePMNode && canMoveNodeToIndex(parent, index, activePMNode, node);
|
|
217
|
+
const canDrop = activePMNode && canMoveNodeToIndex(parent, index, activePMNode, $pos, node);
|
|
218
218
|
|
|
219
219
|
//NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
|
|
220
220
|
if (!canDrop && !isBlocksDragTargetDebug()) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import memoizeOne from 'memoize-one';
|
|
2
|
+
import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
2
3
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
6
|
export const isInsideTable = nodeType => {
|
|
5
7
|
const {
|
|
@@ -70,7 +72,7 @@ export const memoizedTransformExpandToNestedExpand = memoizeOne(node => {
|
|
|
70
72
|
return null;
|
|
71
73
|
}
|
|
72
74
|
});
|
|
73
|
-
export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, destNode) {
|
|
75
|
+
export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNodePos, destNode) {
|
|
74
76
|
let srcNodeType = srcNode.type;
|
|
75
77
|
const parentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type.name;
|
|
76
78
|
const activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.name;
|
|
@@ -94,6 +96,20 @@ export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, destNod
|
|
|
94
96
|
return false;
|
|
95
97
|
}
|
|
96
98
|
}
|
|
99
|
+
|
|
100
|
+
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
101
|
+
const isNestingTablesSupported = fg('platform_editor_use_nested_table_pm_nodes') && editorExperiment('nested-tables-in-tables', true, {
|
|
102
|
+
exposure: true
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// NOTE: this will block drop targets from showing for dragging a table into another table
|
|
106
|
+
// unless nested tables are supported and the nesting depth does not exceed 1
|
|
107
|
+
if ((parentNodeType === 'tableCell' || parentNodeType === 'tableHeader') && activeNodeType === 'table') {
|
|
108
|
+
const nestingDepth = getParentOfTypeCount(srcNode === null || srcNode === void 0 ? void 0 : srcNode.type)($destNodePos);
|
|
109
|
+
if (!isNestingTablesSupported || isNestingTablesSupported && nestingDepth > 1) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
97
113
|
if (isInsideTable(destParent.type) && isExpand(srcNodeType)) {
|
|
98
114
|
if (memoizedTransformExpandToNestedExpand(srcNode)) {
|
|
99
115
|
srcNodeType = srcNodeType.schema.nodes.nestedExpand;
|
|
@@ -181,7 +181,7 @@ export var moveNode = function moveNode(api) {
|
|
|
181
181
|
tr.insert(_mappedTo, fragment).setSelection(Selection.near(tr.doc.resolve(_mappedTo))).scrollIntoView();
|
|
182
182
|
return tr;
|
|
183
183
|
}
|
|
184
|
-
if (!canMoveNodeToIndex(destParent, $to.index(), $from.node().child($from.index()))) {
|
|
184
|
+
if (!canMoveNodeToIndex(destParent, $to.index(), $from.node().child($from.index()), $to)) {
|
|
185
185
|
return tr;
|
|
186
186
|
}
|
|
187
187
|
var convertedNodeSlice = transformSourceSlice(nodeCopy, destType);
|
|
@@ -218,7 +218,7 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
|
|
|
218
218
|
}
|
|
219
219
|
return shouldDescend(node); //skip over, don't consider it a valid depth
|
|
220
220
|
}
|
|
221
|
-
var canDrop = activePMNode && canMoveNodeToIndex(parent, index, activePMNode, node);
|
|
221
|
+
var canDrop = activePMNode && canMoveNodeToIndex(parent, index, activePMNode, $pos, node);
|
|
222
222
|
|
|
223
223
|
//NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
|
|
224
224
|
if (!canDrop && !isBlocksDragTargetDebug()) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import memoizeOne from 'memoize-one';
|
|
2
|
+
import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
2
3
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
6
|
export var isInsideTable = function isInsideTable(nodeType) {
|
|
5
7
|
var _nodeType$schema$node = nodeType.schema.nodes,
|
|
@@ -68,7 +70,7 @@ export var memoizedTransformExpandToNestedExpand = memoizeOne(function (node) {
|
|
|
68
70
|
return null;
|
|
69
71
|
}
|
|
70
72
|
});
|
|
71
|
-
export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, destNode) {
|
|
73
|
+
export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, $destNodePos, destNode) {
|
|
72
74
|
var srcNodeType = srcNode.type;
|
|
73
75
|
var parentNodeType = destParent === null || destParent === void 0 ? void 0 : destParent.type.name;
|
|
74
76
|
var activeNodeType = srcNode === null || srcNode === void 0 ? void 0 : srcNode.type.name;
|
|
@@ -92,6 +94,20 @@ export function canMoveNodeToIndex(destParent, indexIntoParent, srcNode, destNod
|
|
|
92
94
|
return false;
|
|
93
95
|
}
|
|
94
96
|
}
|
|
97
|
+
|
|
98
|
+
// Place experiments here instead of just inside move-node.ts as it stops the drag marker from appearing.
|
|
99
|
+
var isNestingTablesSupported = fg('platform_editor_use_nested_table_pm_nodes') && editorExperiment('nested-tables-in-tables', true, {
|
|
100
|
+
exposure: true
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// NOTE: this will block drop targets from showing for dragging a table into another table
|
|
104
|
+
// unless nested tables are supported and the nesting depth does not exceed 1
|
|
105
|
+
if ((parentNodeType === 'tableCell' || parentNodeType === 'tableHeader') && activeNodeType === 'table') {
|
|
106
|
+
var nestingDepth = getParentOfTypeCount(srcNode === null || srcNode === void 0 ? void 0 : srcNode.type)($destNodePos);
|
|
107
|
+
if (!isNestingTablesSupported || isNestingTablesSupported && nestingDepth > 1) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
95
111
|
if (isInsideTable(destParent.type) && isExpand(srcNodeType)) {
|
|
96
112
|
if (memoizedTransformExpandToNestedExpand(srcNode)) {
|
|
97
113
|
srcNodeType = srcNodeType.schema.nodes.nestedExpand;
|
|
@@ -16,4 +16,4 @@ export declare const isInSameLayout: ($from: ResolvedPos, $to: ResolvedPos) => b
|
|
|
16
16
|
export declare const transformExpandToNestedExpand: (expandNode: PMNode) => PMNode | null;
|
|
17
17
|
export declare const transformSliceExpandToNestedExpand: (slice: Slice) => Slice | null;
|
|
18
18
|
export declare const memoizedTransformExpandToNestedExpand: import("memoize-one").MemoizedFn<(node: PMNode) => PMNode | null>;
|
|
19
|
-
export declare function canMoveNodeToIndex(destParent: PMNode, indexIntoParent: number, srcNode: PMNode, destNode?: PMNode): boolean;
|
|
19
|
+
export declare function canMoveNodeToIndex(destParent: PMNode, indexIntoParent: number, srcNode: PMNode, $destNodePos: ResolvedPos, destNode?: PMNode): boolean;
|
|
@@ -16,4 +16,4 @@ export declare const isInSameLayout: ($from: ResolvedPos, $to: ResolvedPos) => b
|
|
|
16
16
|
export declare const transformExpandToNestedExpand: (expandNode: PMNode) => PMNode | null;
|
|
17
17
|
export declare const transformSliceExpandToNestedExpand: (slice: Slice) => Slice | null;
|
|
18
18
|
export declare const memoizedTransformExpandToNestedExpand: import("memoize-one").MemoizedFn<(node: PMNode) => PMNode | null>;
|
|
19
|
-
export declare function canMoveNodeToIndex(destParent: PMNode, indexIntoParent: number, srcNode: PMNode, destNode?: PMNode): boolean;
|
|
19
|
+
export declare function canMoveNodeToIndex(destParent: PMNode, indexIntoParent: number, srcNode: PMNode, $destNodePos: ResolvedPos, destNode?: PMNode): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.1",
|
|
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": "^46.1.0",
|
|
34
|
-
"@atlaskit/editor-common": "^
|
|
34
|
+
"@atlaskit/editor-common": "^96.0.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",
|
|
@@ -162,6 +162,9 @@
|
|
|
162
162
|
},
|
|
163
163
|
"platform_editor_react18_plugin_portalprovider": {
|
|
164
164
|
"type": "boolean"
|
|
165
|
+
},
|
|
166
|
+
"platform_editor_use_nested_table_pm_nodes": {
|
|
167
|
+
"type": "boolean"
|
|
165
168
|
}
|
|
166
169
|
}
|
|
167
170
|
}
|