@atlaskit/editor-plugin-block-controls 2.5.0 → 2.6.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 +30 -0
- package/dist/cjs/commands/move-node.js +7 -6
- package/dist/cjs/commands/show-drag-handle.js +2 -1
- package/dist/cjs/pm-plugins/decorations.js +93 -32
- package/dist/cjs/pm-plugins/keymap.js +5 -2
- package/dist/cjs/pm-plugins/main.js +349 -203
- package/dist/cjs/ui/drag-handle.js +4 -6
- package/dist/cjs/ui/drop-target-v2.js +32 -6
- package/dist/cjs/ui/global-styles.js +1 -7
- package/dist/cjs/utils/transactions.js +63 -0
- package/dist/es2019/commands/move-node.js +7 -6
- package/dist/es2019/commands/show-drag-handle.js +2 -1
- package/dist/es2019/pm-plugins/decorations.js +86 -31
- package/dist/es2019/pm-plugins/keymap.js +5 -2
- package/dist/es2019/pm-plugins/main.js +332 -179
- package/dist/es2019/ui/drag-handle.js +4 -8
- package/dist/es2019/ui/drop-target-v2.js +32 -6
- package/dist/es2019/ui/global-styles.js +1 -7
- package/dist/es2019/utils/transactions.js +57 -0
- package/dist/esm/commands/move-node.js +7 -6
- package/dist/esm/commands/show-drag-handle.js +2 -1
- package/dist/esm/pm-plugins/decorations.js +92 -31
- package/dist/esm/pm-plugins/keymap.js +5 -2
- package/dist/esm/pm-plugins/main.js +350 -204
- package/dist/esm/ui/drag-handle.js +4 -6
- package/dist/esm/ui/drop-target-v2.js +32 -6
- package/dist/esm/ui/global-styles.js +1 -7
- package/dist/esm/utils/transactions.js +57 -0
- package/dist/types/pm-plugins/decorations.d.ts +24 -4
- package/dist/types/pm-plugins/main.d.ts +32 -0
- package/dist/types/ui/drag-handle.d.ts +5 -14
- package/dist/types/ui/drop-target-v2.d.ts +1 -1
- package/dist/types/ui/drop-target.d.ts +2 -0
- package/dist/types/utils/transactions.d.ts +29 -0
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +24 -4
- package/dist/types-ts4.5/pm-plugins/main.d.ts +32 -0
- package/dist/types-ts4.5/ui/drag-handle.d.ts +5 -14
- package/dist/types-ts4.5/ui/drop-target-v2.d.ts +1 -1
- package/dist/types-ts4.5/ui/drop-target.d.ts +2 -0
- package/dist/types-ts4.5/utils/transactions.d.ts +29 -0
- package/package.json +6 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#152510](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/152510)
|
|
8
|
+
[`dcf9edde7ac7b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/dcf9edde7ac7b) -
|
|
9
|
+
bump adf-schema to 42.0.1
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 2.6.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#152056](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/152056)
|
|
17
|
+
[`624da05a0cdab`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/624da05a0cdab) -
|
|
18
|
+
ED-25015 increase drop target to take up empty container
|
|
19
|
+
- [#152099](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/152099)
|
|
20
|
+
[`e7d3d5459e447`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e7d3d5459e447) -
|
|
21
|
+
Update apply to be more performant
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#151127](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/151127)
|
|
26
|
+
[`be27d2b45f725`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/be27d2b45f725) -
|
|
27
|
+
Add `nested-dnd` experiment check on a11y support for nested node
|
|
28
|
+
- [#151127](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/151127)
|
|
29
|
+
[`7e9a2af475546`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7e9a2af475546) -
|
|
30
|
+
ED-25228 Use same selector for setting marginTop for nested-dnd on/off
|
|
31
|
+
- Updated dependencies
|
|
32
|
+
|
|
3
33
|
## 2.5.0
|
|
4
34
|
|
|
5
35
|
### Minor Changes
|
|
@@ -70,7 +70,7 @@ var getCurrentNodePos = function getCurrentNodePos(state, isParentNodeOfTypeLayo
|
|
|
70
70
|
// 2. caret cursor is inside the node
|
|
71
71
|
// 3. the start of the selection is inside the node
|
|
72
72
|
currentNodePos = selection.$from.before(1);
|
|
73
|
-
if (selection.$from.depth > 0 && (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_a11y')) {
|
|
73
|
+
if (selection.$from.depth > 0 && (0, _experiments.editorExperiment)('nested-dnd', true) && (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_a11y')) {
|
|
74
74
|
currentNodePos = (0, _utils4.getNestedNodePosition)(state);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -79,7 +79,8 @@ var getCurrentNodePos = function getCurrentNodePos(state, isParentNodeOfTypeLayo
|
|
|
79
79
|
var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShortcut(api, direction, formatMessage) {
|
|
80
80
|
return function (state) {
|
|
81
81
|
var isParentNodeOfTypeLayout;
|
|
82
|
-
|
|
82
|
+
var shouldEnableNestedDndA11y = (0, _experiments.editorExperiment)('nested-dnd', true) && (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_a11y');
|
|
83
|
+
if (shouldEnableNestedDndA11y) {
|
|
83
84
|
isParentNodeOfTypeLayout = !!(0, _utils2.findParentNodeOfType)([state.schema.nodes.layoutSection])(state.selection);
|
|
84
85
|
}
|
|
85
86
|
var currentNodePos = getCurrentNodePos(state, isParentNodeOfTypeLayout);
|
|
@@ -88,7 +89,7 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
|
|
|
88
89
|
var $pos = state.doc.resolve(currentNodePos);
|
|
89
90
|
var moveToPos = -1;
|
|
90
91
|
var nodeIndex = $pos.index();
|
|
91
|
-
if (direction === _consts.DIRECTION.LEFT &&
|
|
92
|
+
if (direction === _consts.DIRECTION.LEFT && shouldEnableNestedDndA11y) {
|
|
92
93
|
if ($pos.depth < 2 || !isParentNodeOfTypeLayout) {
|
|
93
94
|
return false;
|
|
94
95
|
}
|
|
@@ -98,13 +99,13 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
|
|
|
98
99
|
var grandParent = $pos.node($pos.depth - 1);
|
|
99
100
|
var previousNode = grandParent ? grandParent.maybeChild(index - 1) : null;
|
|
100
101
|
moveToPos = $pos.start() - ((previousNode === null || previousNode === void 0 ? void 0 : previousNode.nodeSize) || 1);
|
|
101
|
-
} else if (direction === _consts.DIRECTION.RIGHT &&
|
|
102
|
+
} else if (direction === _consts.DIRECTION.RIGHT && shouldEnableNestedDndA11y) {
|
|
102
103
|
if ($pos.depth < 2 || !isParentNodeOfTypeLayout) {
|
|
103
104
|
return false;
|
|
104
105
|
}
|
|
105
106
|
moveToPos = $pos.after($pos.depth) + 1;
|
|
106
107
|
} else if (direction === _consts.DIRECTION.UP) {
|
|
107
|
-
var nodeBefore = $pos.depth > 1 && nodeIndex === 0 &&
|
|
108
|
+
var nodeBefore = $pos.depth > 1 && nodeIndex === 0 && shouldEnableNestedDndA11y ? $pos.node($pos.depth) : $pos.nodeBefore;
|
|
108
109
|
if (nodeBefore) {
|
|
109
110
|
moveToPos = currentNodePos - nodeBefore.nodeSize;
|
|
110
111
|
}
|
|
@@ -120,7 +121,7 @@ var moveNodeViaShortcut = exports.moveNodeViaShortcut = function moveNodeViaShor
|
|
|
120
121
|
var nodeType = (_state$doc$nodeAt = state.doc.nodeAt(currentNodePos)) === null || _state$doc$nodeAt === void 0 ? void 0 : _state$doc$nodeAt.type.name;
|
|
121
122
|
|
|
122
123
|
// only move the node if the destination is at the same depth, not support moving a nested node to a parent node
|
|
123
|
-
var shouldMoveNode =
|
|
124
|
+
var shouldMoveNode = shouldEnableNestedDndA11y ? moveToPos > -1 && $pos.depth === state.doc.resolve(moveToPos).depth : moveToPos > -1;
|
|
124
125
|
if (shouldMoveNode) {
|
|
125
126
|
var _api$core;
|
|
126
127
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
|
|
@@ -6,13 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.showDragHandleAtSelection = void 0;
|
|
7
7
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
8
8
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
9
10
|
var _main = require("../pm-plugins/main");
|
|
10
11
|
var _utils2 = require("../utils");
|
|
11
12
|
var showDragHandleAtSelection = exports.showDragHandleAtSelection = function showDragHandleAtSelection(api, shouldFocusParentNode) {
|
|
12
13
|
return function (state, _, view) {
|
|
13
14
|
var $from = state.selection.$from;
|
|
14
15
|
var shouldFocusParentNode;
|
|
15
|
-
if ($from.depth > 1 && (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_a11y')) {
|
|
16
|
+
if ($from.depth > 1 && (0, _experiments.editorExperiment)('nested-dnd', true) && (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_a11y')) {
|
|
16
17
|
var _activeNode$handleOpt, _view$domAtPos;
|
|
17
18
|
var _ref = _main.key.getState(state) || {},
|
|
18
19
|
activeNode = _ref.activeNode;
|
|
@@ -4,14 +4,13 @@ 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.emptyParagraphNodeDecorations = exports.dropTargetDecorations = exports.dragHandleDecoration = exports.createDropTargetDecoration = void 0;
|
|
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;
|
|
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"));
|
|
11
11
|
var _react = require("react");
|
|
12
12
|
var _bindEventListener = require("bind-event-listener");
|
|
13
13
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
14
|
-
var _reactIntlNext = require("react-intl-next");
|
|
15
14
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
16
15
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
17
16
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
@@ -29,6 +28,9 @@ var IGNORE_NODES = ['tableCell', 'tableHeader', 'tableRow', 'layoutColumn', 'lis
|
|
|
29
28
|
var IGNORE_NODE_DESCENDANTS = ['listItem', 'taskList', 'decisionList', 'mediaSingle'];
|
|
30
29
|
var PARENT_WITH_END_DROP_TARGET = ['tableCell', 'tableHeader', 'panel', 'layoutColumn', 'expand', 'nestedExpand', 'bodiedExtension'];
|
|
31
30
|
var DISABLE_CHILD_DROP_TARGET = ['orderedList', 'bulletList'];
|
|
31
|
+
var TYPE_DROP_TARGET_DEC = exports.TYPE_DROP_TARGET_DEC = 'drop-target-decoration';
|
|
32
|
+
var TYPE_HANDLE_DEC = exports.TYPE_HANDLE_DEC = 'drag-handle';
|
|
33
|
+
var TYPE_NODE_DEC = exports.TYPE_NODE_DEC = 'node-decoration';
|
|
32
34
|
var getNestedDepth = function getNestedDepth() {
|
|
33
35
|
return (0, _experiments.editorExperiment)('nested-dnd', true) ? 100 : 0;
|
|
34
36
|
};
|
|
@@ -79,6 +81,54 @@ var shouldDescend = function shouldDescend(node) {
|
|
|
79
81
|
}
|
|
80
82
|
return true;
|
|
81
83
|
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Find drop target decorations in the pos range between from and to
|
|
87
|
+
* @param decorations
|
|
88
|
+
* @param from
|
|
89
|
+
* @param to
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
var findDropTargetDecs = exports.findDropTargetDecs = function findDropTargetDecs(decorations, from, to) {
|
|
93
|
+
return decorations.find(from, to, function (spec) {
|
|
94
|
+
return spec.type === TYPE_DROP_TARGET_DEC;
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
var findHandleDec = exports.findHandleDec = function findHandleDec(decorations, from, to) {
|
|
98
|
+
return decorations.find(from, to, function (spec) {
|
|
99
|
+
return spec.type === TYPE_HANDLE_DEC;
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Find node decorations in the pos range between from and to (non-inclusive)
|
|
105
|
+
* @param decorations
|
|
106
|
+
* @param from
|
|
107
|
+
* @param to
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
110
|
+
var findNodeDecs = exports.findNodeDecs = function findNodeDecs(decorations, from, to) {
|
|
111
|
+
var newfrom = from;
|
|
112
|
+
var newTo = to;
|
|
113
|
+
|
|
114
|
+
// make it non-inclusive
|
|
115
|
+
if (newfrom !== undefined) {
|
|
116
|
+
newfrom++;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// make it non-inclusive
|
|
120
|
+
if (newTo !== undefined) {
|
|
121
|
+
newTo--;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// return empty array if range reversed
|
|
125
|
+
if (newfrom !== undefined && newTo !== undefined && newfrom > newTo) {
|
|
126
|
+
return new Array();
|
|
127
|
+
}
|
|
128
|
+
return decorations.find(newfrom, newTo, function (spec) {
|
|
129
|
+
return spec.type === TYPE_NODE_DEC;
|
|
130
|
+
});
|
|
131
|
+
};
|
|
82
132
|
var createDropTargetDecoration = exports.createDropTargetDecoration = function createDropTargetDecoration(pos, props, side, anchorHeightsCache) {
|
|
83
133
|
return _view.Decoration.widget(pos, function (_, getPos) {
|
|
84
134
|
var element = document.createElement('div');
|
|
@@ -103,13 +153,16 @@ var createDropTargetDecoration = exports.createDropTargetDecoration = function c
|
|
|
103
153
|
}
|
|
104
154
|
return element;
|
|
105
155
|
}, {
|
|
106
|
-
type:
|
|
156
|
+
type: TYPE_DROP_TARGET_DEC,
|
|
107
157
|
side: side
|
|
108
158
|
});
|
|
109
159
|
};
|
|
110
|
-
var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetDecorations(newState, api, formatMessage, activeNode, anchorHeightsCache) {
|
|
111
|
-
var decs = [];
|
|
160
|
+
var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetDecorations(newState, api, formatMessage, activeNode, anchorHeightsCache, from, to) {
|
|
112
161
|
unmountDecorations('data-blocks-drop-target-container');
|
|
162
|
+
var decs = [];
|
|
163
|
+
var POS_END_OF_DOC = newState.doc.nodeSize - 2;
|
|
164
|
+
var docFrom = from === undefined || from < 0 ? 0 : from;
|
|
165
|
+
var docTo = to === undefined || to > POS_END_OF_DOC ? POS_END_OF_DOC : to;
|
|
113
166
|
var prevNode;
|
|
114
167
|
var activeNodePos = activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos;
|
|
115
168
|
var activePMNode = typeof activeNodePos === 'number' && newState.doc.resolve(activeNodePos).nodeAfter;
|
|
@@ -127,7 +180,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
127
180
|
popNodeStack(depth);
|
|
128
181
|
prevNodeStack.push(node);
|
|
129
182
|
};
|
|
130
|
-
newState.doc.
|
|
183
|
+
newState.doc.nodesBetween(docFrom, docTo, function (node, pos, parent, index) {
|
|
131
184
|
var depth = 0;
|
|
132
185
|
// drop target deco at the end position
|
|
133
186
|
var endPos;
|
|
@@ -165,19 +218,27 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
165
218
|
}
|
|
166
219
|
}
|
|
167
220
|
var previousNode = (0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2') ? popNodeStack(depth) : prevNode; // created scoped variable
|
|
221
|
+
|
|
222
|
+
// only table and layout need to render full height drop target
|
|
223
|
+
var isInSupportedContainer = (0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2') && ['tableCell', 'tableHeader', 'layoutColumn'].includes((parent === null || parent === void 0 ? void 0 : parent.type.name) || '');
|
|
224
|
+
|
|
225
|
+
// container with only an empty paragrah
|
|
226
|
+
var shouldShowFullHeight = isInSupportedContainer && (parent === null || parent === void 0 ? void 0 : parent.lastChild) === node && (parent === null || parent === void 0 ? void 0 : parent.childCount) === 1 && (0, _utils.isEmptyParagraph)(node) && (0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2');
|
|
168
227
|
decs.push(createDropTargetDecoration(pos, {
|
|
169
228
|
api: api,
|
|
170
229
|
prevNode: previousNode,
|
|
171
230
|
nextNode: node,
|
|
172
231
|
parentNode: parent || undefined,
|
|
173
|
-
formatMessage: formatMessage
|
|
232
|
+
formatMessage: formatMessage,
|
|
233
|
+
dropTargetStyle: shouldShowFullHeight ? 'fullHeight' : 'default'
|
|
174
234
|
}, -1, anchorHeightsCache));
|
|
175
235
|
if (endPos !== undefined) {
|
|
176
236
|
decs.push(createDropTargetDecoration(endPos, {
|
|
177
237
|
api: api,
|
|
178
238
|
prevNode: (0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2') ? node : undefined,
|
|
179
239
|
parentNode: parent || undefined,
|
|
180
|
-
formatMessage: formatMessage
|
|
240
|
+
formatMessage: formatMessage,
|
|
241
|
+
dropTargetStyle: isInSupportedContainer ? 'fullHeight' : 'default'
|
|
181
242
|
}, -1, anchorHeightsCache));
|
|
182
243
|
}
|
|
183
244
|
if ((0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2')) {
|
|
@@ -187,12 +248,14 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
187
248
|
}
|
|
188
249
|
return depth < getNestedDepth() && shouldDescend(node);
|
|
189
250
|
});
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
251
|
+
if (docTo === POS_END_OF_DOC) {
|
|
252
|
+
decs.push(createDropTargetDecoration(POS_END_OF_DOC, {
|
|
253
|
+
api: api,
|
|
254
|
+
formatMessage: formatMessage,
|
|
255
|
+
prevNode: newState.doc.lastChild || undefined,
|
|
256
|
+
parentNode: newState.doc
|
|
257
|
+
}, undefined, anchorHeightsCache));
|
|
258
|
+
}
|
|
196
259
|
return decs;
|
|
197
260
|
};
|
|
198
261
|
var emptyParagraphNodeDecorations = exports.emptyParagraphNodeDecorations = function emptyParagraphNodeDecorations() {
|
|
@@ -201,7 +264,7 @@ var emptyParagraphNodeDecorations = exports.emptyParagraphNodeDecorations = func
|
|
|
201
264
|
return _view.Decoration.node(0, 2, (0, _defineProperty2.default)({
|
|
202
265
|
style: style
|
|
203
266
|
}, 'data-drag-handler-anchor-name', anchorName), {
|
|
204
|
-
type:
|
|
267
|
+
type: TYPE_NODE_DEC
|
|
205
268
|
});
|
|
206
269
|
};
|
|
207
270
|
var ObjHash = /*#__PURE__*/function () {
|
|
@@ -230,19 +293,17 @@ var shouldIgnoreNode = function shouldIgnoreNode(node) {
|
|
|
230
293
|
}
|
|
231
294
|
return IGNORE_NODES.includes(node.type.name);
|
|
232
295
|
};
|
|
233
|
-
var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newState) {
|
|
296
|
+
var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newState, from, to) {
|
|
234
297
|
var decs = [];
|
|
235
|
-
|
|
298
|
+
var docFrom = from === undefined || from < 0 ? 0 : from;
|
|
299
|
+
var docTo = to === undefined || to > newState.doc.nodeSize - 2 ? newState.doc.nodeSize - 2 : to;
|
|
300
|
+
newState.doc.nodesBetween(docFrom, docTo, function (node, pos, _parent, index) {
|
|
236
301
|
var _Decoration$node2;
|
|
237
302
|
var depth = 0;
|
|
238
303
|
var anchorName;
|
|
239
304
|
var shouldDescend = !IGNORE_NODE_DESCENDANTS.includes(node.type.name);
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}) || (0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
243
|
-
var handleId = ObjHash.getForNode(node);
|
|
244
|
-
anchorName = "--node-anchor-".concat(node.type.name, "-").concat(handleId);
|
|
245
|
-
}
|
|
305
|
+
var handleId = ObjHash.getForNode(node);
|
|
306
|
+
anchorName = "--node-anchor-".concat(node.type.name, "-").concat(handleId);
|
|
246
307
|
if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
247
308
|
var _anchorName;
|
|
248
309
|
// Doesn't descend into a node
|
|
@@ -261,7 +322,7 @@ var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newStat
|
|
|
261
322
|
decs.push(_view.Decoration.node(pos, pos + node.nodeSize, (_Decoration$node2 = {
|
|
262
323
|
style: "anchor-name: ".concat(anchorName, "; ").concat(pos === 0 ? 'margin-top: 0px;' : '', "; position: relative; z-index: 1;")
|
|
263
324
|
}, (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), {
|
|
264
|
-
type:
|
|
325
|
+
type: TYPE_NODE_DEC,
|
|
265
326
|
anchorName: anchorName,
|
|
266
327
|
nodeType: node.type.name
|
|
267
328
|
}));
|
|
@@ -269,7 +330,8 @@ var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newStat
|
|
|
269
330
|
});
|
|
270
331
|
return decs;
|
|
271
332
|
};
|
|
272
|
-
var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDecoration(api,
|
|
333
|
+
var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDecoration(api, formatMessage, pos, anchorName, nodeType, handleOptions) {
|
|
334
|
+
unmountDecorations('data-blocks-drag-handle-container');
|
|
273
335
|
var unbind;
|
|
274
336
|
return _view.Decoration.widget(pos, function (view, getPos) {
|
|
275
337
|
var element = document.createElement('span');
|
|
@@ -283,7 +345,7 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
|
|
|
283
345
|
isTopLevelNode = ($pos === null || $pos === void 0 ? void 0 : $pos.parent.type.name) === 'doc';
|
|
284
346
|
/*
|
|
285
347
|
* We disable mouseover event to fix flickering issue on hover
|
|
286
|
-
* However, the tooltip for nested drag handle is
|
|
348
|
+
* However, the tooltip for nested drag handle is no long working.
|
|
287
349
|
*/
|
|
288
350
|
if (!isTopLevelNode) {
|
|
289
351
|
// This will also hide the tooltip.
|
|
@@ -295,26 +357,25 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
|
|
|
295
357
|
});
|
|
296
358
|
}
|
|
297
359
|
}
|
|
298
|
-
unmountDecorations('data-blocks-drag-handle-container');
|
|
299
360
|
|
|
300
361
|
// There are times when global clear: "both" styles are applied to this decoration causing jumpiness
|
|
301
362
|
// due to margins applied to other nodes eg. Headings
|
|
302
363
|
element.style.clear = 'unset';
|
|
303
|
-
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(
|
|
304
|
-
value: getIntl()
|
|
305
|
-
}, /*#__PURE__*/(0, _react.createElement)(_dragHandle.DragHandle, {
|
|
364
|
+
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dragHandle.DragHandle, {
|
|
306
365
|
view: view,
|
|
307
366
|
api: api,
|
|
367
|
+
formatMessage: formatMessage,
|
|
308
368
|
getPos: getPos,
|
|
309
369
|
anchorName: anchorName,
|
|
310
370
|
nodeType: nodeType,
|
|
311
371
|
handleOptions: handleOptions,
|
|
312
372
|
isTopLevelNode: isTopLevelNode
|
|
313
|
-
})
|
|
373
|
+
}), element);
|
|
314
374
|
return element;
|
|
315
375
|
}, {
|
|
316
376
|
side: -1,
|
|
317
|
-
|
|
377
|
+
type: TYPE_HANDLE_DEC,
|
|
378
|
+
testid: "".concat(TYPE_HANDLE_DEC, "-").concat((0, _uuid.default)()),
|
|
318
379
|
destroy: function destroy() {
|
|
319
380
|
if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
320
381
|
unbind && unbind();
|
|
@@ -7,6 +7,7 @@ exports.boundKeydownHandler = void 0;
|
|
|
7
7
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
8
8
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
9
9
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
10
11
|
var _moveNode = require("../commands/move-node");
|
|
11
12
|
var _showDragHandle = require("../commands/show-drag-handle");
|
|
12
13
|
var _consts = require("../consts");
|
|
@@ -20,8 +21,10 @@ function keymapList(api, formatMessage) {
|
|
|
20
21
|
}, keymapList);
|
|
21
22
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.dragToMoveUp.common, (0, _moveNode.moveNodeViaShortcut)(api, _consts.DIRECTION.UP, formatMessage), keymapList);
|
|
22
23
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.dragToMoveDown.common, (0, _moveNode.moveNodeViaShortcut)(api, _consts.DIRECTION.DOWN, formatMessage), keymapList);
|
|
23
|
-
(0,
|
|
24
|
-
|
|
24
|
+
if ((0, _experiments.editorExperiment)('nested-dnd', true) && (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_a11y')) {
|
|
25
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.dragToMoveLeft.common, (0, _moveNode.moveNodeViaShortcut)(api, _consts.DIRECTION.LEFT, formatMessage), keymapList);
|
|
26
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.dragToMoveRight.common, (0, _moveNode.moveNodeViaShortcut)(api, _consts.DIRECTION.RIGHT, formatMessage), keymapList);
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
29
|
return keymapList;
|
|
27
30
|
}
|