@atlaskit/editor-plugin-block-controls 1.10.7 → 1.11.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 +20 -0
- package/dist/cjs/pm-plugins/decorations.js +43 -19
- package/dist/cjs/pm-plugins/main.js +6 -12
- package/dist/cjs/ui/drag-handle.js +1 -1
- package/dist/es2019/pm-plugins/decorations.js +41 -19
- package/dist/es2019/pm-plugins/main.js +5 -11
- package/dist/es2019/ui/drag-handle.js +1 -1
- package/dist/esm/pm-plugins/decorations.js +43 -19
- package/dist/esm/pm-plugins/main.js +6 -12
- package/dist/esm/ui/drag-handle.js +1 -1
- package/dist/types/ui/drop-target.d.ts +6 -9
- package/dist/types-ts4.5/ui/drop-target.d.ts +6 -9
- package/package.json +4 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 1.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#128347](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/128347)
|
|
8
|
+
[`e33566cebd5d1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e33566cebd5d1) -
|
|
9
|
+
[ED-24175] bump @atlaskit/adf-schema to 40.8.1 and @atlassian/adf-schema-json to 1.22.0 to
|
|
10
|
+
promotecodeblocks & media in quotes, and nested expands in expands to full schema, and allow
|
|
11
|
+
quotes in panels and decisions in lists in stage0 schema, and a validator spec change
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#128138](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/128138)
|
|
16
|
+
[`5c7bc23671459`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5c7bc23671459) -
|
|
17
|
+
ED-24471 Clean up feature flags in main.ts apply and long scroll FF
|
|
18
|
+
- [#127946](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/127946)
|
|
19
|
+
[`93f225e326474`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/93f225e326474) -
|
|
20
|
+
ED-24405 fix drop target not showing at last pos
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 1.10.7
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -14,10 +14,26 @@ var _view = require("@atlaskit/editor-prosemirror/view");
|
|
|
14
14
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
15
|
var _dragHandle = require("../ui/drag-handle");
|
|
16
16
|
var _dropTarget = require("../ui/drop-target");
|
|
17
|
+
var _dragTargetDebug = require("../utils/drag-target-debug");
|
|
17
18
|
var _validation = require("../utils/validation");
|
|
18
19
|
var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem'];
|
|
19
20
|
var IGNORE_NODES_AND_DESCENDANTS = ['listItem'];
|
|
20
|
-
var
|
|
21
|
+
var PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand'];
|
|
22
|
+
var getNestedDepth = function getNestedDepth() {
|
|
23
|
+
return (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested') ? 100 : 0;
|
|
24
|
+
};
|
|
25
|
+
var createDropTargetDecoration = function createDropTargetDecoration(pos, dropTargetDec) {
|
|
26
|
+
return _view.Decoration.widget(pos, function () {
|
|
27
|
+
var element = document.createElement('div');
|
|
28
|
+
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
29
|
+
element.style.clear = 'unset';
|
|
30
|
+
_reactDom.default.render(dropTargetDec, element);
|
|
31
|
+
return element;
|
|
32
|
+
}, {
|
|
33
|
+
type: 'drop-target-decoration',
|
|
34
|
+
side: -1
|
|
35
|
+
});
|
|
36
|
+
};
|
|
21
37
|
var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetDecorations(oldState, newState, api, formatMessage, activeNodeType) {
|
|
22
38
|
var decs = [];
|
|
23
39
|
unmountDecorations('data-blocks-drop-target-container');
|
|
@@ -28,49 +44,58 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
28
44
|
newState.doc.nodesBetween(0, newState.doc.nodeSize - 2, function (node, pos, parent, index) {
|
|
29
45
|
var depth = 0;
|
|
30
46
|
var nodeType = newState.doc.type.schema.nodes[activeNodeType];
|
|
47
|
+
var endDec = null;
|
|
31
48
|
if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
|
|
32
49
|
depth = newState.doc.resolve(pos).depth;
|
|
33
|
-
if (node.isInline) {
|
|
50
|
+
if (node.isInline || !parent) {
|
|
34
51
|
return false;
|
|
35
52
|
}
|
|
36
53
|
if (IGNORE_NODES.includes(node.type.name)) {
|
|
37
54
|
return true; //skip over, don't consider it a valid depth
|
|
38
55
|
}
|
|
39
|
-
var canDrop =
|
|
56
|
+
var canDrop = activeNodeType && (0, _validation.canMoveToIndex)(parent, index, nodeType);
|
|
40
57
|
|
|
41
58
|
//NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
|
|
42
|
-
if (!canDrop) {
|
|
59
|
+
if (!canDrop && !(0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
|
|
43
60
|
return false; //not valid pos, so nested not valid either
|
|
44
61
|
}
|
|
45
62
|
decorationState.push({
|
|
46
63
|
id: pos,
|
|
47
64
|
pos: pos
|
|
48
65
|
});
|
|
66
|
+
if (parent.lastChild === node && PARENT_WITH_END_DROP_TARGET.includes(parent.type.name)) {
|
|
67
|
+
var endpos = pos + node.nodeSize;
|
|
68
|
+
endDec = {
|
|
69
|
+
id: endpos,
|
|
70
|
+
pos: endpos
|
|
71
|
+
};
|
|
72
|
+
decorationState.push({
|
|
73
|
+
id: endpos,
|
|
74
|
+
pos: endpos
|
|
75
|
+
});
|
|
76
|
+
}
|
|
49
77
|
} else {
|
|
50
78
|
decorationState.push({
|
|
51
79
|
id: index,
|
|
52
80
|
pos: pos
|
|
53
81
|
});
|
|
54
82
|
}
|
|
55
|
-
|
|
83
|
+
decs.push(createDropTargetDecoration(pos, /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, {
|
|
56
84
|
api: api,
|
|
57
85
|
id: (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested') ? pos : index,
|
|
58
86
|
formatMessage: formatMessage,
|
|
59
87
|
prevNode: prevNode,
|
|
60
88
|
nextNode: node
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
type: 'drop-target-decoration',
|
|
70
|
-
side: -1
|
|
71
|
-
}));
|
|
89
|
+
})));
|
|
90
|
+
if (endDec) {
|
|
91
|
+
decs.push(createDropTargetDecoration(endDec.pos, /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, {
|
|
92
|
+
api: api,
|
|
93
|
+
id: endDec.id,
|
|
94
|
+
formatMessage: formatMessage
|
|
95
|
+
})));
|
|
96
|
+
}
|
|
72
97
|
prevNode = node;
|
|
73
|
-
return depth <
|
|
98
|
+
return depth < getNestedDepth();
|
|
74
99
|
});
|
|
75
100
|
|
|
76
101
|
/**
|
|
@@ -80,7 +105,6 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
80
105
|
* node and not its size.
|
|
81
106
|
*
|
|
82
107
|
*/
|
|
83
|
-
|
|
84
108
|
var lastPos = newState.doc.content.size;
|
|
85
109
|
if ((0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_nested')) {
|
|
86
110
|
decorationState.push({
|
|
@@ -143,7 +167,7 @@ var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newStat
|
|
|
143
167
|
}, (0, _defineProperty2.default)(_Decoration$node2, 'data-drag-handler-anchor-name', anchorName), (0, _defineProperty2.default)(_Decoration$node2, 'data-drag-handler-node-type', node.type.name), (0, _defineProperty2.default)(_Decoration$node2, 'data-drag-handler-anchor-depth', "".concat(depth)), _Decoration$node2), {
|
|
144
168
|
type: 'node-decoration'
|
|
145
169
|
}));
|
|
146
|
-
return depth <
|
|
170
|
+
return depth < getNestedDepth();
|
|
147
171
|
});
|
|
148
172
|
return decs;
|
|
149
173
|
};
|
|
@@ -164,15 +164,11 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
164
164
|
|
|
165
165
|
// Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
|
|
166
166
|
if (redrawDecorations && !isResizerResizing && api) {
|
|
167
|
-
|
|
168
|
-
var
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
decorations = decorations.remove(oldNodeDecs);
|
|
173
|
-
} else {
|
|
174
|
-
decorations = _view.DecorationSet.create(newState.doc, []);
|
|
175
|
-
}
|
|
167
|
+
var oldNodeDecs = decorations.find().filter(function (_ref9) {
|
|
168
|
+
var spec = _ref9.spec;
|
|
169
|
+
return spec.type !== 'drop-target-decoration';
|
|
170
|
+
});
|
|
171
|
+
decorations = decorations.remove(oldNodeDecs);
|
|
176
172
|
var nodeDecs = (0, _decorations.nodeDecorations)(newState);
|
|
177
173
|
decorations = decorations.add(newState.doc, (0, _toConsumableArray2.default)(nodeDecs));
|
|
178
174
|
|
|
@@ -184,9 +180,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
184
180
|
|
|
185
181
|
// When a node type changed to be nested inside another node, the position of the active node is off by 1
|
|
186
182
|
// This is a workaround to fix the position of the active node when it is nested
|
|
187
|
-
|
|
188
|
-
var shouldUpdateNestedPosition = (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24049') ? tr.docChanged && !nodeCountChanged : true;
|
|
189
|
-
if (shouldUpdateNestedPosition && mappedPosisiton === prevMappedPos + 1) {
|
|
183
|
+
if (tr.docChanged && !nodeCountChanged && mappedPosisiton === prevMappedPos + 1) {
|
|
190
184
|
mappedPosisiton = prevMappedPos;
|
|
191
185
|
}
|
|
192
186
|
var newActiveNode = tr.doc.nodeAt(mappedPosisiton);
|
|
@@ -121,7 +121,7 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
|
|
|
121
121
|
});
|
|
122
122
|
var resolvedMovingNode = tr.doc.resolve(startPos);
|
|
123
123
|
var maybeNode = resolvedMovingNode.nodeAfter;
|
|
124
|
-
|
|
124
|
+
tr.setMeta('scrollIntoView', false);
|
|
125
125
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
126
126
|
eventType: _analytics.EVENT_TYPE.UI,
|
|
127
127
|
action: _analytics.ACTION.CLICKED,
|
|
@@ -6,10 +6,24 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import { DragHandle } from '../ui/drag-handle';
|
|
8
8
|
import { DropTarget } from '../ui/drop-target';
|
|
9
|
+
import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
|
|
9
10
|
import { canMoveToIndex } from '../utils/validation';
|
|
10
11
|
const IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem'];
|
|
11
12
|
const IGNORE_NODES_AND_DESCENDANTS = ['listItem'];
|
|
12
|
-
const
|
|
13
|
+
const PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand'];
|
|
14
|
+
const getNestedDepth = () => fg('platform_editor_elements_dnd_nested') ? 100 : 0;
|
|
15
|
+
const createDropTargetDecoration = (pos, dropTargetDec) => {
|
|
16
|
+
return Decoration.widget(pos, () => {
|
|
17
|
+
const element = document.createElement('div');
|
|
18
|
+
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
19
|
+
element.style.clear = 'unset';
|
|
20
|
+
ReactDOM.render(dropTargetDec, element);
|
|
21
|
+
return element;
|
|
22
|
+
}, {
|
|
23
|
+
type: 'drop-target-decoration',
|
|
24
|
+
side: -1
|
|
25
|
+
});
|
|
26
|
+
};
|
|
13
27
|
export const dropTargetDecorations = (oldState, newState, api, formatMessage, activeNodeType) => {
|
|
14
28
|
const decs = [];
|
|
15
29
|
unmountDecorations('data-blocks-drop-target-container');
|
|
@@ -20,49 +34,58 @@ export const dropTargetDecorations = (oldState, newState, api, formatMessage, ac
|
|
|
20
34
|
newState.doc.nodesBetween(0, newState.doc.nodeSize - 2, (node, pos, parent, index) => {
|
|
21
35
|
let depth = 0;
|
|
22
36
|
const nodeType = newState.doc.type.schema.nodes[activeNodeType];
|
|
37
|
+
let endDec = null;
|
|
23
38
|
if (fg('platform_editor_elements_dnd_nested')) {
|
|
24
39
|
depth = newState.doc.resolve(pos).depth;
|
|
25
|
-
if (node.isInline) {
|
|
40
|
+
if (node.isInline || !parent) {
|
|
26
41
|
return false;
|
|
27
42
|
}
|
|
28
43
|
if (IGNORE_NODES.includes(node.type.name)) {
|
|
29
44
|
return true; //skip over, don't consider it a valid depth
|
|
30
45
|
}
|
|
31
|
-
const canDrop =
|
|
46
|
+
const canDrop = activeNodeType && canMoveToIndex(parent, index, nodeType);
|
|
32
47
|
|
|
33
48
|
//NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
|
|
34
|
-
if (!canDrop) {
|
|
49
|
+
if (!canDrop && !isBlocksDragTargetDebug()) {
|
|
35
50
|
return false; //not valid pos, so nested not valid either
|
|
36
51
|
}
|
|
37
52
|
decorationState.push({
|
|
38
53
|
id: pos,
|
|
39
54
|
pos
|
|
40
55
|
});
|
|
56
|
+
if (parent.lastChild === node && PARENT_WITH_END_DROP_TARGET.includes(parent.type.name)) {
|
|
57
|
+
const endpos = pos + node.nodeSize;
|
|
58
|
+
endDec = {
|
|
59
|
+
id: endpos,
|
|
60
|
+
pos: endpos
|
|
61
|
+
};
|
|
62
|
+
decorationState.push({
|
|
63
|
+
id: endpos,
|
|
64
|
+
pos: endpos
|
|
65
|
+
});
|
|
66
|
+
}
|
|
41
67
|
} else {
|
|
42
68
|
decorationState.push({
|
|
43
69
|
id: index,
|
|
44
70
|
pos
|
|
45
71
|
});
|
|
46
72
|
}
|
|
47
|
-
|
|
73
|
+
decs.push(createDropTargetDecoration(pos, /*#__PURE__*/createElement(DropTarget, {
|
|
48
74
|
api,
|
|
49
75
|
id: fg('platform_editor_elements_dnd_nested') ? pos : index,
|
|
50
76
|
formatMessage,
|
|
51
77
|
prevNode,
|
|
52
78
|
nextNode: node
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
type: 'drop-target-decoration',
|
|
62
|
-
side: -1
|
|
63
|
-
}));
|
|
79
|
+
})));
|
|
80
|
+
if (endDec) {
|
|
81
|
+
decs.push(createDropTargetDecoration(endDec.pos, /*#__PURE__*/createElement(DropTarget, {
|
|
82
|
+
api,
|
|
83
|
+
id: endDec.id,
|
|
84
|
+
formatMessage
|
|
85
|
+
})));
|
|
86
|
+
}
|
|
64
87
|
prevNode = node;
|
|
65
|
-
return depth <
|
|
88
|
+
return depth < getNestedDepth();
|
|
66
89
|
});
|
|
67
90
|
|
|
68
91
|
/**
|
|
@@ -72,7 +95,6 @@ export const dropTargetDecorations = (oldState, newState, api, formatMessage, ac
|
|
|
72
95
|
* node and not its size.
|
|
73
96
|
*
|
|
74
97
|
*/
|
|
75
|
-
|
|
76
98
|
const lastPos = newState.doc.content.size;
|
|
77
99
|
if (fg('platform_editor_elements_dnd_nested')) {
|
|
78
100
|
decorationState.push({
|
|
@@ -138,7 +160,7 @@ export const nodeDecorations = newState => {
|
|
|
138
160
|
}, {
|
|
139
161
|
type: 'node-decoration'
|
|
140
162
|
}));
|
|
141
|
-
return depth <
|
|
163
|
+
return depth < getNestedDepth();
|
|
142
164
|
});
|
|
143
165
|
return decs;
|
|
144
166
|
};
|
|
@@ -157,14 +157,10 @@ export const createPlugin = (api, getIntl) => {
|
|
|
157
157
|
|
|
158
158
|
// Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
|
|
159
159
|
if (redrawDecorations && !isResizerResizing && api) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
decorations = decorations.remove(oldNodeDecs);
|
|
165
|
-
} else {
|
|
166
|
-
decorations = DecorationSet.create(newState.doc, []);
|
|
167
|
-
}
|
|
160
|
+
const oldNodeDecs = decorations.find().filter(({
|
|
161
|
+
spec
|
|
162
|
+
}) => spec.type !== 'drop-target-decoration');
|
|
163
|
+
decorations = decorations.remove(oldNodeDecs);
|
|
168
164
|
const nodeDecs = nodeDecorations(newState);
|
|
169
165
|
decorations = decorations.add(newState.doc, [...nodeDecs]);
|
|
170
166
|
|
|
@@ -176,9 +172,7 @@ export const createPlugin = (api, getIntl) => {
|
|
|
176
172
|
|
|
177
173
|
// When a node type changed to be nested inside another node, the position of the active node is off by 1
|
|
178
174
|
// This is a workaround to fix the position of the active node when it is nested
|
|
179
|
-
|
|
180
|
-
const shouldUpdateNestedPosition = fg('platform_editor_element_drag_and_drop_ed_24049') ? tr.docChanged && !nodeCountChanged : true;
|
|
181
|
-
if (shouldUpdateNestedPosition && mappedPosisiton === prevMappedPos + 1) {
|
|
175
|
+
if (tr.docChanged && !nodeCountChanged && mappedPosisiton === prevMappedPos + 1) {
|
|
182
176
|
mappedPosisiton = prevMappedPos;
|
|
183
177
|
}
|
|
184
178
|
const newActiveNode = tr.doc.nodeAt(mappedPosisiton);
|
|
@@ -108,7 +108,7 @@ const DragHandleInternal = ({
|
|
|
108
108
|
});
|
|
109
109
|
const resolvedMovingNode = tr.doc.resolve(startPos);
|
|
110
110
|
const maybeNode = resolvedMovingNode.nodeAfter;
|
|
111
|
-
|
|
111
|
+
tr.setMeta('scrollIntoView', false);
|
|
112
112
|
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
|
|
113
113
|
eventType: EVENT_TYPE.UI,
|
|
114
114
|
action: ACTION.CLICKED,
|
|
@@ -7,10 +7,26 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
8
|
import { DragHandle } from '../ui/drag-handle';
|
|
9
9
|
import { DropTarget } from '../ui/drop-target';
|
|
10
|
+
import { isBlocksDragTargetDebug } from '../utils/drag-target-debug';
|
|
10
11
|
import { canMoveToIndex } from '../utils/validation';
|
|
11
12
|
var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'listItem'];
|
|
12
13
|
var IGNORE_NODES_AND_DESCENDANTS = ['listItem'];
|
|
13
|
-
var
|
|
14
|
+
var PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand'];
|
|
15
|
+
var getNestedDepth = function getNestedDepth() {
|
|
16
|
+
return fg('platform_editor_elements_dnd_nested') ? 100 : 0;
|
|
17
|
+
};
|
|
18
|
+
var createDropTargetDecoration = function createDropTargetDecoration(pos, dropTargetDec) {
|
|
19
|
+
return Decoration.widget(pos, function () {
|
|
20
|
+
var element = document.createElement('div');
|
|
21
|
+
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
22
|
+
element.style.clear = 'unset';
|
|
23
|
+
ReactDOM.render(dropTargetDec, element);
|
|
24
|
+
return element;
|
|
25
|
+
}, {
|
|
26
|
+
type: 'drop-target-decoration',
|
|
27
|
+
side: -1
|
|
28
|
+
});
|
|
29
|
+
};
|
|
14
30
|
export var dropTargetDecorations = function dropTargetDecorations(oldState, newState, api, formatMessage, activeNodeType) {
|
|
15
31
|
var decs = [];
|
|
16
32
|
unmountDecorations('data-blocks-drop-target-container');
|
|
@@ -21,49 +37,58 @@ export var dropTargetDecorations = function dropTargetDecorations(oldState, newS
|
|
|
21
37
|
newState.doc.nodesBetween(0, newState.doc.nodeSize - 2, function (node, pos, parent, index) {
|
|
22
38
|
var depth = 0;
|
|
23
39
|
var nodeType = newState.doc.type.schema.nodes[activeNodeType];
|
|
40
|
+
var endDec = null;
|
|
24
41
|
if (fg('platform_editor_elements_dnd_nested')) {
|
|
25
42
|
depth = newState.doc.resolve(pos).depth;
|
|
26
|
-
if (node.isInline) {
|
|
43
|
+
if (node.isInline || !parent) {
|
|
27
44
|
return false;
|
|
28
45
|
}
|
|
29
46
|
if (IGNORE_NODES.includes(node.type.name)) {
|
|
30
47
|
return true; //skip over, don't consider it a valid depth
|
|
31
48
|
}
|
|
32
|
-
var canDrop =
|
|
49
|
+
var canDrop = activeNodeType && canMoveToIndex(parent, index, nodeType);
|
|
33
50
|
|
|
34
51
|
//NOTE: This will block drop targets showing for nodes that are valid after transformation (i.e. expand -> nestedExpand)
|
|
35
|
-
if (!canDrop) {
|
|
52
|
+
if (!canDrop && !isBlocksDragTargetDebug()) {
|
|
36
53
|
return false; //not valid pos, so nested not valid either
|
|
37
54
|
}
|
|
38
55
|
decorationState.push({
|
|
39
56
|
id: pos,
|
|
40
57
|
pos: pos
|
|
41
58
|
});
|
|
59
|
+
if (parent.lastChild === node && PARENT_WITH_END_DROP_TARGET.includes(parent.type.name)) {
|
|
60
|
+
var endpos = pos + node.nodeSize;
|
|
61
|
+
endDec = {
|
|
62
|
+
id: endpos,
|
|
63
|
+
pos: endpos
|
|
64
|
+
};
|
|
65
|
+
decorationState.push({
|
|
66
|
+
id: endpos,
|
|
67
|
+
pos: endpos
|
|
68
|
+
});
|
|
69
|
+
}
|
|
42
70
|
} else {
|
|
43
71
|
decorationState.push({
|
|
44
72
|
id: index,
|
|
45
73
|
pos: pos
|
|
46
74
|
});
|
|
47
75
|
}
|
|
48
|
-
|
|
76
|
+
decs.push(createDropTargetDecoration(pos, /*#__PURE__*/createElement(DropTarget, {
|
|
49
77
|
api: api,
|
|
50
78
|
id: fg('platform_editor_elements_dnd_nested') ? pos : index,
|
|
51
79
|
formatMessage: formatMessage,
|
|
52
80
|
prevNode: prevNode,
|
|
53
81
|
nextNode: node
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
type: 'drop-target-decoration',
|
|
63
|
-
side: -1
|
|
64
|
-
}));
|
|
82
|
+
})));
|
|
83
|
+
if (endDec) {
|
|
84
|
+
decs.push(createDropTargetDecoration(endDec.pos, /*#__PURE__*/createElement(DropTarget, {
|
|
85
|
+
api: api,
|
|
86
|
+
id: endDec.id,
|
|
87
|
+
formatMessage: formatMessage
|
|
88
|
+
})));
|
|
89
|
+
}
|
|
65
90
|
prevNode = node;
|
|
66
|
-
return depth <
|
|
91
|
+
return depth < getNestedDepth();
|
|
67
92
|
});
|
|
68
93
|
|
|
69
94
|
/**
|
|
@@ -73,7 +98,6 @@ export var dropTargetDecorations = function dropTargetDecorations(oldState, newS
|
|
|
73
98
|
* node and not its size.
|
|
74
99
|
*
|
|
75
100
|
*/
|
|
76
|
-
|
|
77
101
|
var lastPos = newState.doc.content.size;
|
|
78
102
|
if (fg('platform_editor_elements_dnd_nested')) {
|
|
79
103
|
decorationState.push({
|
|
@@ -136,7 +160,7 @@ export var nodeDecorations = function nodeDecorations(newState) {
|
|
|
136
160
|
}, _defineProperty(_Decoration$node2, 'data-drag-handler-anchor-name', anchorName), _defineProperty(_Decoration$node2, 'data-drag-handler-node-type', node.type.name), _defineProperty(_Decoration$node2, 'data-drag-handler-anchor-depth', "".concat(depth)), _Decoration$node2), {
|
|
137
161
|
type: 'node-decoration'
|
|
138
162
|
}));
|
|
139
|
-
return depth <
|
|
163
|
+
return depth < getNestedDepth();
|
|
140
164
|
});
|
|
141
165
|
return decs;
|
|
142
166
|
};
|
|
@@ -157,15 +157,11 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
157
157
|
|
|
158
158
|
// Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
|
|
159
159
|
if (redrawDecorations && !isResizerResizing && api) {
|
|
160
|
-
|
|
161
|
-
var
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
decorations = decorations.remove(oldNodeDecs);
|
|
166
|
-
} else {
|
|
167
|
-
decorations = DecorationSet.create(newState.doc, []);
|
|
168
|
-
}
|
|
160
|
+
var oldNodeDecs = decorations.find().filter(function (_ref9) {
|
|
161
|
+
var spec = _ref9.spec;
|
|
162
|
+
return spec.type !== 'drop-target-decoration';
|
|
163
|
+
});
|
|
164
|
+
decorations = decorations.remove(oldNodeDecs);
|
|
169
165
|
var nodeDecs = nodeDecorations(newState);
|
|
170
166
|
decorations = decorations.add(newState.doc, _toConsumableArray(nodeDecs));
|
|
171
167
|
|
|
@@ -177,9 +173,7 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
177
173
|
|
|
178
174
|
// When a node type changed to be nested inside another node, the position of the active node is off by 1
|
|
179
175
|
// This is a workaround to fix the position of the active node when it is nested
|
|
180
|
-
|
|
181
|
-
var shouldUpdateNestedPosition = fg('platform_editor_element_drag_and_drop_ed_24049') ? tr.docChanged && !nodeCountChanged : true;
|
|
182
|
-
if (shouldUpdateNestedPosition && mappedPosisiton === prevMappedPos + 1) {
|
|
176
|
+
if (tr.docChanged && !nodeCountChanged && mappedPosisiton === prevMappedPos + 1) {
|
|
183
177
|
mappedPosisiton = prevMappedPos;
|
|
184
178
|
}
|
|
185
179
|
var newActiveNode = tr.doc.nodeAt(mappedPosisiton);
|
|
@@ -112,7 +112,7 @@ var DragHandleInternal = function DragHandleInternal(_ref) {
|
|
|
112
112
|
});
|
|
113
113
|
var resolvedMovingNode = tr.doc.resolve(startPos);
|
|
114
114
|
var maybeNode = resolvedMovingNode.nodeAfter;
|
|
115
|
-
|
|
115
|
+
tr.setMeta('scrollIntoView', false);
|
|
116
116
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
117
117
|
eventType: EVENT_TYPE.UI,
|
|
118
118
|
action: ACTION.CLICKED,
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { jsx } from '@emotion/react';
|
|
3
2
|
import { type IntlShape } from 'react-intl-next';
|
|
4
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
5
|
import type { BlockControlsPlugin } from '../types';
|
|
7
|
-
export
|
|
6
|
+
export type DropTargetProps = {
|
|
8
7
|
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
9
8
|
id: number;
|
|
10
|
-
prevNode?: PMNode
|
|
11
|
-
nextNode?: PMNode
|
|
12
|
-
formatMessage?:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} | undefined;
|
|
16
|
-
}) => jsx.JSX.Element;
|
|
9
|
+
prevNode?: PMNode;
|
|
10
|
+
nextNode?: PMNode;
|
|
11
|
+
formatMessage?: IntlShape['formatMessage'];
|
|
12
|
+
};
|
|
13
|
+
export declare const DropTarget: ({ api, id, prevNode, nextNode, formatMessage }: DropTargetProps) => jsx.JSX.Element;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { jsx } from '@emotion/react';
|
|
3
2
|
import { type IntlShape } from 'react-intl-next';
|
|
4
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
5
|
import type { BlockControlsPlugin } from '../types';
|
|
7
|
-
export
|
|
6
|
+
export type DropTargetProps = {
|
|
8
7
|
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
9
8
|
id: number;
|
|
10
|
-
prevNode?: PMNode
|
|
11
|
-
nextNode?: PMNode
|
|
12
|
-
formatMessage?:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} | undefined;
|
|
16
|
-
}) => jsx.JSX.Element;
|
|
9
|
+
prevNode?: PMNode;
|
|
10
|
+
nextNode?: PMNode;
|
|
11
|
+
formatMessage?: IntlShape['formatMessage'];
|
|
12
|
+
};
|
|
13
|
+
export declare const DropTarget: ({ api, id, prevNode, nextNode, formatMessage }: DropTargetProps) => jsx.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/editor-common": "^87.
|
|
34
|
+
"@atlaskit/editor-common": "^87.6.0",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
36
|
-
"@atlaskit/editor-plugin-analytics": "^1.
|
|
36
|
+
"@atlaskit/editor-plugin-analytics": "^1.7.0",
|
|
37
37
|
"@atlaskit/editor-plugin-editor-disabled": "^1.2.0",
|
|
38
38
|
"@atlaskit/editor-plugin-feature-flags": "^1.2.0",
|
|
39
39
|
"@atlaskit/editor-plugin-width": "^1.2.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "5.0.1",
|
|
41
41
|
"@atlaskit/editor-shared-styles": "^2.13.0",
|
|
42
42
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
43
|
-
"@atlaskit/icon": "^22.
|
|
43
|
+
"@atlaskit/icon": "^22.11.0",
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
45
45
|
"@atlaskit/pragmatic-drag-and-drop": "^1.2.0",
|
|
46
46
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.4.0",
|
|
@@ -94,16 +94,10 @@
|
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
"platform-feature-flags": {
|
|
97
|
-
"platform.editor.elements.drag-and-drop-long-node-scroll": {
|
|
98
|
-
"type": "boolean"
|
|
99
|
-
},
|
|
100
97
|
"platform.editor.media.extended-resize-experience": {
|
|
101
98
|
"type": "boolean",
|
|
102
99
|
"referenceOnly": true
|
|
103
100
|
},
|
|
104
|
-
"platform_editor_elements_drag_and_drop_ed_24000": {
|
|
105
|
-
"type": "boolean"
|
|
106
|
-
},
|
|
107
101
|
"platform_editor_elements_drag_and_drop_ed_23189": {
|
|
108
102
|
"type": "boolean"
|
|
109
103
|
},
|
|
@@ -116,9 +110,6 @@
|
|
|
116
110
|
"platform_editor_elements_drag_and_drop_ed_23394": {
|
|
117
111
|
"type": "boolean"
|
|
118
112
|
},
|
|
119
|
-
"platform_editor_element_drag_and_drop_ed_24049": {
|
|
120
|
-
"type": "boolean"
|
|
121
|
-
},
|
|
122
113
|
"platform_editor_element_controls_chrome_input_fix": {
|
|
123
114
|
"type": "boolean"
|
|
124
115
|
},
|