@atlaskit/editor-plugin-block-controls 2.8.0 → 2.9.0
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 +18 -0
- package/dist/cjs/commands/move-to-layout.js +45 -16
- package/dist/cjs/pm-plugins/decorations.js +12 -2
- package/dist/es2019/commands/move-to-layout.js +42 -14
- package/dist/es2019/pm-plugins/decorations.js +11 -1
- package/dist/esm/commands/move-to-layout.js +43 -14
- package/dist/esm/pm-plugins/decorations.js +11 -1
- package/dist/types/pm-plugins/decorations.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +1 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#154648](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/154648)
|
|
8
|
+
[`7224898e37116`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7224898e37116) -
|
|
9
|
+
Don't create node decs within tables if nested dnd not enabled
|
|
10
|
+
- [#154380](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/154380)
|
|
11
|
+
[`e045dd3ba95bd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e045dd3ba95bd) -
|
|
12
|
+
ED-25281 implement DnD API for appending to a layout
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#154186](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/154186)
|
|
17
|
+
[`5c316170d29dd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5c316170d29dd) -
|
|
18
|
+
Bump @atlaskit/adf-schema to 42.3.1
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 2.8.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.moveToLayout = void 0;
|
|
7
7
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
|
-
var _consts = require("../
|
|
8
|
+
var _consts = require("../consts");
|
|
9
|
+
var _consts2 = require("../ui/consts");
|
|
9
10
|
var createNewLayout = function createNewLayout(schema, layoutContents) {
|
|
10
|
-
|
|
11
|
-
if (layoutContents.length === 0 || layoutContents.length > 5) {
|
|
11
|
+
if (layoutContents.length === 0 || layoutContents.length > _consts.MAX_LAYOUT_COLUMN_SUPPORTED) {
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
|
-
var width =
|
|
14
|
+
var width = _consts2.DEFAULT_COLUMN_DISTRIBUTIONS[layoutContents.length];
|
|
15
15
|
if (!width) {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
@@ -19,11 +19,12 @@ var createNewLayout = function createNewLayout(schema, layoutContents) {
|
|
|
19
19
|
layoutSection = _ref.layoutSection,
|
|
20
20
|
layoutColumn = _ref.layoutColumn;
|
|
21
21
|
try {
|
|
22
|
-
var
|
|
22
|
+
var layoutContent = _model.Fragment.fromArray(layoutContents.map(function (layoutContent) {
|
|
23
23
|
return layoutColumn.createChecked({
|
|
24
24
|
width: width
|
|
25
25
|
}, layoutContent);
|
|
26
|
-
}))
|
|
26
|
+
}));
|
|
27
|
+
var layoutSectionNode = layoutSection.createChecked(undefined, layoutContent);
|
|
27
28
|
return layoutSectionNode;
|
|
28
29
|
} catch (error) {
|
|
29
30
|
// TODO analytics
|
|
@@ -34,10 +35,16 @@ var moveToLayout = exports.moveToLayout = function moveToLayout(api) {
|
|
|
34
35
|
return function (from, to, position) {
|
|
35
36
|
return function (_ref2) {
|
|
36
37
|
var tr = _ref2.tr;
|
|
38
|
+
// unable to drag a node to itself.
|
|
39
|
+
if (from === to) {
|
|
40
|
+
return tr;
|
|
41
|
+
}
|
|
37
42
|
var _ref3 = tr.doc.type.schema.nodes || {},
|
|
38
43
|
layoutSection = _ref3.layoutSection,
|
|
39
44
|
layoutColumn = _ref3.layoutColumn,
|
|
40
45
|
doc = _ref3.doc;
|
|
46
|
+
var _ref4 = tr.doc.type.schema.marks || {},
|
|
47
|
+
breakout = _ref4.breakout;
|
|
41
48
|
|
|
42
49
|
// layout plugin does not exist
|
|
43
50
|
if (!layoutSection || !layoutColumn) {
|
|
@@ -51,26 +58,48 @@ var moveToLayout = exports.moveToLayout = function moveToLayout(api) {
|
|
|
51
58
|
}
|
|
52
59
|
var $from = tr.doc.resolve(from);
|
|
53
60
|
|
|
54
|
-
// invalid from position
|
|
55
|
-
if (!$from.nodeAfter) {
|
|
61
|
+
// invalid from position or dragging a layout
|
|
62
|
+
if (!$from.nodeAfter || $from.nodeAfter.type === layoutSection) {
|
|
56
63
|
return tr;
|
|
57
64
|
}
|
|
58
65
|
var toNode = $to.nodeAfter;
|
|
59
66
|
var fromNode = $from.nodeAfter;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if ($
|
|
63
|
-
|
|
67
|
+
|
|
68
|
+
// remove breakout from node;
|
|
69
|
+
if (breakout && $from.nodeAfter && $from.nodeAfter.marks.some(function (m) {
|
|
70
|
+
return m.type === breakout;
|
|
71
|
+
})) {
|
|
72
|
+
tr = tr.removeNodeMark(from, breakout);
|
|
73
|
+
}
|
|
74
|
+
if ($to.nodeAfter.type === layoutSection) {
|
|
75
|
+
var existingLayoutNode = $to.nodeAfter;
|
|
76
|
+
if (existingLayoutNode.childCount < _consts.MAX_LAYOUT_COLUMN_SUPPORTED) {
|
|
77
|
+
var toPos = position === 'left' ? to + 1 : to + existingLayoutNode.nodeSize - 1;
|
|
78
|
+
tr = tr.insert(toPos,
|
|
79
|
+
// resolve again the source node after node updated (remove breakout marks)
|
|
80
|
+
layoutColumn.create(null, tr.doc.resolve(from).nodeAfter));
|
|
81
|
+
var mappedFrom = tr.mapping.map(from);
|
|
82
|
+
var mappedFromEnd = mappedFrom + fromNode.nodeSize;
|
|
83
|
+
tr = tr.delete(mappedFrom, mappedFromEnd);
|
|
84
|
+
return tr;
|
|
85
|
+
}
|
|
86
|
+
return tr;
|
|
87
|
+
} else {
|
|
88
|
+
// resolve again the source node after node updated (remove breakout marks)
|
|
89
|
+
var newFromNode = tr.doc.resolve(from).nodeAfter;
|
|
90
|
+
if (!newFromNode) {
|
|
91
|
+
return tr;
|
|
92
|
+
}
|
|
93
|
+
var layoutContents = position === 'left' ? [newFromNode, toNode] : [toNode, newFromNode];
|
|
64
94
|
var newLayout = createNewLayout(tr.doc.type.schema, layoutContents);
|
|
65
95
|
if (newLayout) {
|
|
66
|
-
tr.delete(from,
|
|
96
|
+
tr = tr.delete(from, from + fromNode.nodeSize);
|
|
67
97
|
var mappedTo = tr.mapping.map(to);
|
|
68
|
-
tr.delete(mappedTo,
|
|
69
|
-
tr.insert(mappedTo, newLayout); // insert the content at the new position
|
|
98
|
+
tr = tr.delete(mappedTo, mappedTo + toNode.nodeSize);
|
|
99
|
+
tr = tr.insert(mappedTo, newLayout); // insert the content at the new position
|
|
70
100
|
}
|
|
71
101
|
return tr;
|
|
72
102
|
}
|
|
73
|
-
return tr;
|
|
74
103
|
};
|
|
75
104
|
};
|
|
76
105
|
};
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.nodeDecorations = exports.getNodeAnchor = exports.findNodeDecs = exports.findHandleDec = exports.findDropTargetDecs = exports.emptyParagraphNodeDecorations = exports.dropTargetDecorations = exports.dragHandleDecoration = exports.createDropTargetDecoration = exports.TYPE_NODE_DEC = exports.TYPE_HANDLE_DEC = exports.TYPE_DROP_TARGET_DEC = void 0;
|
|
7
|
+
exports.shouldDescendIntoNode = exports.nodeDecorations = exports.getNodeAnchor = exports.findNodeDecs = exports.findHandleDec = exports.findDropTargetDecs = exports.emptyParagraphNodeDecorations = exports.dropTargetDecorations = exports.dragHandleDecoration = exports.createDropTargetDecoration = exports.TYPE_NODE_DEC = exports.TYPE_HANDLE_DEC = exports.TYPE_DROP_TARGET_DEC = void 0;
|
|
8
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -296,6 +296,16 @@ var shouldIgnoreNode = function shouldIgnoreNode(node) {
|
|
|
296
296
|
}
|
|
297
297
|
return IGNORE_NODES.includes(node.type.name);
|
|
298
298
|
};
|
|
299
|
+
var shouldDescendIntoNode = exports.shouldDescendIntoNode = function shouldDescendIntoNode(node) {
|
|
300
|
+
// Optimisation to avoid drawing node decorations for empty table cells
|
|
301
|
+
if (['tableCell', 'tableHeader'].includes(node.type.name) && !(0, _experiments.editorExperiment)('table-nested-dnd', true) && (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3')) {
|
|
302
|
+
var _node$firstChild;
|
|
303
|
+
if (node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'paragraph') {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return !IGNORE_NODE_DESCENDANTS.includes(node.type.name);
|
|
308
|
+
};
|
|
299
309
|
var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newState, from, to) {
|
|
300
310
|
var decs = [];
|
|
301
311
|
var docFrom = from === undefined || from < 0 ? 0 : from;
|
|
@@ -304,7 +314,7 @@ var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newStat
|
|
|
304
314
|
var _Decoration$node2;
|
|
305
315
|
var depth = 0;
|
|
306
316
|
var anchorName;
|
|
307
|
-
var shouldDescend =
|
|
317
|
+
var shouldDescend = shouldDescendIntoNode(node);
|
|
308
318
|
var handleId = ObjHash.getForNode(node);
|
|
309
319
|
anchorName = "--node-anchor-".concat(node.type.name, "-").concat(handleId);
|
|
310
320
|
if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { MAX_LAYOUT_COLUMN_SUPPORTED } from '../consts';
|
|
2
3
|
import { DEFAULT_COLUMN_DISTRIBUTIONS } from '../ui/consts';
|
|
3
4
|
const createNewLayout = (schema, layoutContents) => {
|
|
4
|
-
|
|
5
|
-
if (layoutContents.length === 0 || layoutContents.length > 5) {
|
|
5
|
+
if (layoutContents.length === 0 || layoutContents.length > MAX_LAYOUT_COLUMN_SUPPORTED) {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
8
8
|
const width = DEFAULT_COLUMN_DISTRIBUTIONS[layoutContents.length];
|
|
@@ -14,11 +14,12 @@ const createNewLayout = (schema, layoutContents) => {
|
|
|
14
14
|
layoutColumn
|
|
15
15
|
} = schema.nodes || {};
|
|
16
16
|
try {
|
|
17
|
-
const
|
|
17
|
+
const layoutContent = Fragment.fromArray(layoutContents.map(layoutContent => {
|
|
18
18
|
return layoutColumn.createChecked({
|
|
19
19
|
width
|
|
20
20
|
}, layoutContent);
|
|
21
|
-
}))
|
|
21
|
+
}));
|
|
22
|
+
const layoutSectionNode = layoutSection.createChecked(undefined, layoutContent);
|
|
22
23
|
return layoutSectionNode;
|
|
23
24
|
} catch (error) {
|
|
24
25
|
// TODO analytics
|
|
@@ -28,11 +29,18 @@ const createNewLayout = (schema, layoutContents) => {
|
|
|
28
29
|
export const moveToLayout = api => (from, to, position) => ({
|
|
29
30
|
tr
|
|
30
31
|
}) => {
|
|
32
|
+
// unable to drag a node to itself.
|
|
33
|
+
if (from === to) {
|
|
34
|
+
return tr;
|
|
35
|
+
}
|
|
31
36
|
const {
|
|
32
37
|
layoutSection,
|
|
33
38
|
layoutColumn,
|
|
34
39
|
doc
|
|
35
40
|
} = tr.doc.type.schema.nodes || {};
|
|
41
|
+
const {
|
|
42
|
+
breakout
|
|
43
|
+
} = tr.doc.type.schema.marks || {};
|
|
36
44
|
|
|
37
45
|
// layout plugin does not exist
|
|
38
46
|
if (!layoutSection || !layoutColumn) {
|
|
@@ -46,24 +54,44 @@ export const moveToLayout = api => (from, to, position) => ({
|
|
|
46
54
|
}
|
|
47
55
|
const $from = tr.doc.resolve(from);
|
|
48
56
|
|
|
49
|
-
// invalid from position
|
|
50
|
-
if (!$from.nodeAfter) {
|
|
57
|
+
// invalid from position or dragging a layout
|
|
58
|
+
if (!$from.nodeAfter || $from.nodeAfter.type === layoutSection) {
|
|
51
59
|
return tr;
|
|
52
60
|
}
|
|
53
61
|
const toNode = $to.nodeAfter;
|
|
54
62
|
const fromNode = $from.nodeAfter;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if ($
|
|
58
|
-
|
|
63
|
+
|
|
64
|
+
// remove breakout from node;
|
|
65
|
+
if (breakout && $from.nodeAfter && $from.nodeAfter.marks.some(m => m.type === breakout)) {
|
|
66
|
+
tr = tr.removeNodeMark(from, breakout);
|
|
67
|
+
}
|
|
68
|
+
if ($to.nodeAfter.type === layoutSection) {
|
|
69
|
+
const existingLayoutNode = $to.nodeAfter;
|
|
70
|
+
if (existingLayoutNode.childCount < MAX_LAYOUT_COLUMN_SUPPORTED) {
|
|
71
|
+
const toPos = position === 'left' ? to + 1 : to + existingLayoutNode.nodeSize - 1;
|
|
72
|
+
tr = tr.insert(toPos,
|
|
73
|
+
// resolve again the source node after node updated (remove breakout marks)
|
|
74
|
+
layoutColumn.create(null, tr.doc.resolve(from).nodeAfter));
|
|
75
|
+
const mappedFrom = tr.mapping.map(from);
|
|
76
|
+
const mappedFromEnd = mappedFrom + fromNode.nodeSize;
|
|
77
|
+
tr = tr.delete(mappedFrom, mappedFromEnd);
|
|
78
|
+
return tr;
|
|
79
|
+
}
|
|
80
|
+
return tr;
|
|
81
|
+
} else {
|
|
82
|
+
// resolve again the source node after node updated (remove breakout marks)
|
|
83
|
+
const newFromNode = tr.doc.resolve(from).nodeAfter;
|
|
84
|
+
if (!newFromNode) {
|
|
85
|
+
return tr;
|
|
86
|
+
}
|
|
87
|
+
const layoutContents = position === 'left' ? [newFromNode, toNode] : [toNode, newFromNode];
|
|
59
88
|
const newLayout = createNewLayout(tr.doc.type.schema, layoutContents);
|
|
60
89
|
if (newLayout) {
|
|
61
|
-
tr.delete(from,
|
|
90
|
+
tr = tr.delete(from, from + fromNode.nodeSize);
|
|
62
91
|
const mappedTo = tr.mapping.map(to);
|
|
63
|
-
tr.delete(mappedTo,
|
|
64
|
-
tr.insert(mappedTo, newLayout); // insert the content at the new position
|
|
92
|
+
tr = tr.delete(mappedTo, mappedTo + toNode.nodeSize);
|
|
93
|
+
tr = tr.insert(mappedTo, newLayout); // insert the content at the new position
|
|
65
94
|
}
|
|
66
95
|
return tr;
|
|
67
96
|
}
|
|
68
|
-
return tr;
|
|
69
97
|
};
|
|
@@ -274,6 +274,16 @@ const shouldIgnoreNode = node => {
|
|
|
274
274
|
}
|
|
275
275
|
return IGNORE_NODES.includes(node.type.name);
|
|
276
276
|
};
|
|
277
|
+
export const shouldDescendIntoNode = node => {
|
|
278
|
+
// Optimisation to avoid drawing node decorations for empty table cells
|
|
279
|
+
if (['tableCell', 'tableHeader'].includes(node.type.name) && !editorExperiment('table-nested-dnd', true) && fg('platform_editor_element_dnd_nested_fix_patch_3')) {
|
|
280
|
+
var _node$firstChild;
|
|
281
|
+
if (node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'paragraph') {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return !IGNORE_NODE_DESCENDANTS.includes(node.type.name);
|
|
286
|
+
};
|
|
277
287
|
export const nodeDecorations = (newState, from, to) => {
|
|
278
288
|
const decs = [];
|
|
279
289
|
const docFrom = from === undefined || from < 0 ? 0 : from;
|
|
@@ -281,7 +291,7 @@ export const nodeDecorations = (newState, from, to) => {
|
|
|
281
291
|
newState.doc.nodesBetween(docFrom, docTo, (node, pos, _parent, index) => {
|
|
282
292
|
let depth = 0;
|
|
283
293
|
let anchorName;
|
|
284
|
-
const shouldDescend =
|
|
294
|
+
const shouldDescend = shouldDescendIntoNode(node);
|
|
285
295
|
const handleId = ObjHash.getForNode(node);
|
|
286
296
|
anchorName = `--node-anchor-${node.type.name}-${handleId}`;
|
|
287
297
|
if (editorExperiment('nested-dnd', true)) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { MAX_LAYOUT_COLUMN_SUPPORTED } from '../consts';
|
|
2
3
|
import { DEFAULT_COLUMN_DISTRIBUTIONS } from '../ui/consts';
|
|
3
4
|
var createNewLayout = function createNewLayout(schema, layoutContents) {
|
|
4
|
-
|
|
5
|
-
if (layoutContents.length === 0 || layoutContents.length > 5) {
|
|
5
|
+
if (layoutContents.length === 0 || layoutContents.length > MAX_LAYOUT_COLUMN_SUPPORTED) {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
8
8
|
var width = DEFAULT_COLUMN_DISTRIBUTIONS[layoutContents.length];
|
|
@@ -13,11 +13,12 @@ var createNewLayout = function createNewLayout(schema, layoutContents) {
|
|
|
13
13
|
layoutSection = _ref.layoutSection,
|
|
14
14
|
layoutColumn = _ref.layoutColumn;
|
|
15
15
|
try {
|
|
16
|
-
var
|
|
16
|
+
var layoutContent = Fragment.fromArray(layoutContents.map(function (layoutContent) {
|
|
17
17
|
return layoutColumn.createChecked({
|
|
18
18
|
width: width
|
|
19
19
|
}, layoutContent);
|
|
20
|
-
}))
|
|
20
|
+
}));
|
|
21
|
+
var layoutSectionNode = layoutSection.createChecked(undefined, layoutContent);
|
|
21
22
|
return layoutSectionNode;
|
|
22
23
|
} catch (error) {
|
|
23
24
|
// TODO analytics
|
|
@@ -28,10 +29,16 @@ export var moveToLayout = function moveToLayout(api) {
|
|
|
28
29
|
return function (from, to, position) {
|
|
29
30
|
return function (_ref2) {
|
|
30
31
|
var tr = _ref2.tr;
|
|
32
|
+
// unable to drag a node to itself.
|
|
33
|
+
if (from === to) {
|
|
34
|
+
return tr;
|
|
35
|
+
}
|
|
31
36
|
var _ref3 = tr.doc.type.schema.nodes || {},
|
|
32
37
|
layoutSection = _ref3.layoutSection,
|
|
33
38
|
layoutColumn = _ref3.layoutColumn,
|
|
34
39
|
doc = _ref3.doc;
|
|
40
|
+
var _ref4 = tr.doc.type.schema.marks || {},
|
|
41
|
+
breakout = _ref4.breakout;
|
|
35
42
|
|
|
36
43
|
// layout plugin does not exist
|
|
37
44
|
if (!layoutSection || !layoutColumn) {
|
|
@@ -45,26 +52,48 @@ export var moveToLayout = function moveToLayout(api) {
|
|
|
45
52
|
}
|
|
46
53
|
var $from = tr.doc.resolve(from);
|
|
47
54
|
|
|
48
|
-
// invalid from position
|
|
49
|
-
if (!$from.nodeAfter) {
|
|
55
|
+
// invalid from position or dragging a layout
|
|
56
|
+
if (!$from.nodeAfter || $from.nodeAfter.type === layoutSection) {
|
|
50
57
|
return tr;
|
|
51
58
|
}
|
|
52
59
|
var toNode = $to.nodeAfter;
|
|
53
60
|
var fromNode = $from.nodeAfter;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if ($
|
|
57
|
-
|
|
61
|
+
|
|
62
|
+
// remove breakout from node;
|
|
63
|
+
if (breakout && $from.nodeAfter && $from.nodeAfter.marks.some(function (m) {
|
|
64
|
+
return m.type === breakout;
|
|
65
|
+
})) {
|
|
66
|
+
tr = tr.removeNodeMark(from, breakout);
|
|
67
|
+
}
|
|
68
|
+
if ($to.nodeAfter.type === layoutSection) {
|
|
69
|
+
var existingLayoutNode = $to.nodeAfter;
|
|
70
|
+
if (existingLayoutNode.childCount < MAX_LAYOUT_COLUMN_SUPPORTED) {
|
|
71
|
+
var toPos = position === 'left' ? to + 1 : to + existingLayoutNode.nodeSize - 1;
|
|
72
|
+
tr = tr.insert(toPos,
|
|
73
|
+
// resolve again the source node after node updated (remove breakout marks)
|
|
74
|
+
layoutColumn.create(null, tr.doc.resolve(from).nodeAfter));
|
|
75
|
+
var mappedFrom = tr.mapping.map(from);
|
|
76
|
+
var mappedFromEnd = mappedFrom + fromNode.nodeSize;
|
|
77
|
+
tr = tr.delete(mappedFrom, mappedFromEnd);
|
|
78
|
+
return tr;
|
|
79
|
+
}
|
|
80
|
+
return tr;
|
|
81
|
+
} else {
|
|
82
|
+
// resolve again the source node after node updated (remove breakout marks)
|
|
83
|
+
var newFromNode = tr.doc.resolve(from).nodeAfter;
|
|
84
|
+
if (!newFromNode) {
|
|
85
|
+
return tr;
|
|
86
|
+
}
|
|
87
|
+
var layoutContents = position === 'left' ? [newFromNode, toNode] : [toNode, newFromNode];
|
|
58
88
|
var newLayout = createNewLayout(tr.doc.type.schema, layoutContents);
|
|
59
89
|
if (newLayout) {
|
|
60
|
-
tr.delete(from,
|
|
90
|
+
tr = tr.delete(from, from + fromNode.nodeSize);
|
|
61
91
|
var mappedTo = tr.mapping.map(to);
|
|
62
|
-
tr.delete(mappedTo,
|
|
63
|
-
tr.insert(mappedTo, newLayout); // insert the content at the new position
|
|
92
|
+
tr = tr.delete(mappedTo, mappedTo + toNode.nodeSize);
|
|
93
|
+
tr = tr.insert(mappedTo, newLayout); // insert the content at the new position
|
|
64
94
|
}
|
|
65
95
|
return tr;
|
|
66
96
|
}
|
|
67
|
-
return tr;
|
|
68
97
|
};
|
|
69
98
|
};
|
|
70
99
|
};
|
|
@@ -289,6 +289,16 @@ var shouldIgnoreNode = function shouldIgnoreNode(node) {
|
|
|
289
289
|
}
|
|
290
290
|
return IGNORE_NODES.includes(node.type.name);
|
|
291
291
|
};
|
|
292
|
+
export var shouldDescendIntoNode = function shouldDescendIntoNode(node) {
|
|
293
|
+
// Optimisation to avoid drawing node decorations for empty table cells
|
|
294
|
+
if (['tableCell', 'tableHeader'].includes(node.type.name) && !editorExperiment('table-nested-dnd', true) && fg('platform_editor_element_dnd_nested_fix_patch_3')) {
|
|
295
|
+
var _node$firstChild;
|
|
296
|
+
if (node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'paragraph') {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return !IGNORE_NODE_DESCENDANTS.includes(node.type.name);
|
|
301
|
+
};
|
|
292
302
|
export var nodeDecorations = function nodeDecorations(newState, from, to) {
|
|
293
303
|
var decs = [];
|
|
294
304
|
var docFrom = from === undefined || from < 0 ? 0 : from;
|
|
@@ -297,7 +307,7 @@ export var nodeDecorations = function nodeDecorations(newState, from, to) {
|
|
|
297
307
|
var _Decoration$node2;
|
|
298
308
|
var depth = 0;
|
|
299
309
|
var anchorName;
|
|
300
|
-
var shouldDescend =
|
|
310
|
+
var shouldDescend = shouldDescendIntoNode(node);
|
|
301
311
|
var handleId = ObjHash.getForNode(node);
|
|
302
312
|
anchorName = "--node-anchor-".concat(node.type.name, "-").concat(handleId);
|
|
303
313
|
if (editorExperiment('nested-dnd', true)) {
|
|
@@ -30,5 +30,6 @@ export declare const findNodeDecs: (decorations: DecorationSet, from?: number, t
|
|
|
30
30
|
export declare const createDropTargetDecoration: (pos: number, props: Omit<DropTargetProps, 'getPos'>, side?: number, anchorRectCache?: AnchorRectCache) => Decoration;
|
|
31
31
|
export declare const dropTargetDecorations: (newState: EditorState, api: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage: IntlShape['formatMessage'], activeNode?: ActiveNode, anchorRectCache?: AnchorRectCache, from?: number, to?: number) => Decoration[];
|
|
32
32
|
export declare const emptyParagraphNodeDecorations: () => Decoration;
|
|
33
|
+
export declare const shouldDescendIntoNode: (node: PMNode) => boolean;
|
|
33
34
|
export declare const nodeDecorations: (newState: EditorState, from?: number, to?: number) => Decoration[];
|
|
34
35
|
export declare const dragHandleDecoration: (api: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage: IntlShape['formatMessage'], pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => Decoration;
|
|
@@ -30,5 +30,6 @@ export declare const findNodeDecs: (decorations: DecorationSet, from?: number, t
|
|
|
30
30
|
export declare const createDropTargetDecoration: (pos: number, props: Omit<DropTargetProps, 'getPos'>, side?: number, anchorRectCache?: AnchorRectCache) => Decoration;
|
|
31
31
|
export declare const dropTargetDecorations: (newState: EditorState, api: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage: IntlShape['formatMessage'], activeNode?: ActiveNode, anchorRectCache?: AnchorRectCache, from?: number, to?: number) => Decoration[];
|
|
32
32
|
export declare const emptyParagraphNodeDecorations: () => Decoration;
|
|
33
|
+
export declare const shouldDescendIntoNode: (node: PMNode) => boolean;
|
|
33
34
|
export declare const nodeDecorations: (newState: EditorState, from?: number, to?: number) => Decoration[];
|
|
34
35
|
export declare const dragHandleDecoration: (api: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage: IntlShape['formatMessage'], pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => Decoration;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
".": "./src/index.ts"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@atlaskit/adf-schema": "^42.
|
|
34
|
-
"@atlaskit/editor-common": "^
|
|
33
|
+
"@atlaskit/adf-schema": "^42.3.1",
|
|
34
|
+
"@atlaskit/editor-common": "^94.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",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"@atlaskit/editor-prosemirror": "6.0.0",
|
|
42
42
|
"@atlaskit/editor-shared-styles": "^3.0.0",
|
|
43
43
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
44
|
-
"@atlaskit/icon": "^22.
|
|
44
|
+
"@atlaskit/icon": "^22.23.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
46
46
|
"@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
|
|
47
47
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.4.0",
|
|
48
48
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
|
|
49
49
|
"@atlaskit/primitives": "^12.2.0",
|
|
50
50
|
"@atlaskit/theme": "^14.0.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^2.7.0",
|
|
52
52
|
"@atlaskit/tokens": "^2.0.0",
|
|
53
53
|
"@atlaskit/tooltip": "^18.8.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|