@atlaskit/editor-plugin-block-controls 2.13.22 → 2.13.23
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 +8 -0
- package/dist/cjs/plugin.js +3 -2
- package/dist/cjs/pm-plugins/decorations-common.js +10 -2
- package/dist/cjs/pm-plugins/decorations-drag-handle.js +29 -12
- package/dist/cjs/pm-plugins/decorations-drop-target.js +52 -20
- package/dist/cjs/pm-plugins/main.js +14 -14
- package/dist/es2019/plugin.js +3 -2
- package/dist/es2019/pm-plugins/decorations-common.js +10 -2
- package/dist/es2019/pm-plugins/decorations-drag-handle.js +27 -12
- package/dist/es2019/pm-plugins/decorations-drop-target.js +52 -23
- package/dist/es2019/pm-plugins/main.js +14 -14
- package/dist/esm/plugin.js +3 -2
- package/dist/esm/pm-plugins/decorations-common.js +10 -2
- package/dist/esm/pm-plugins/decorations-drag-handle.js +29 -12
- package/dist/esm/pm-plugins/decorations-drop-target.js +52 -20
- package/dist/esm/pm-plugins/main.js +14 -14
- package/dist/types/pm-plugins/decorations-common.d.ts +2 -1
- package/dist/types/pm-plugins/decorations-drag-handle.d.ts +2 -1
- package/dist/types/pm-plugins/decorations-drop-target.d.ts +4 -3
- package/dist/types/pm-plugins/main.d.ts +4 -3
- package/dist/types-ts4.5/pm-plugins/decorations-common.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/decorations-drag-handle.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/decorations-drop-target.d.ts +4 -3
- package/dist/types-ts4.5/pm-plugins/main.d.ts +4 -3
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.13.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#164073](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/164073)
|
|
8
|
+
[`74421f65186ac`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/74421f65186ac) -
|
|
9
|
+
ED-25607: replace usages of ReactDOM.render with portal provider
|
|
10
|
+
|
|
3
11
|
## 2.13.22
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -21,8 +21,9 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
21
21
|
return [{
|
|
22
22
|
name: 'blockControlsPmPlugin',
|
|
23
23
|
plugin: function plugin(_ref2) {
|
|
24
|
-
var getIntl = _ref2.getIntl
|
|
25
|
-
|
|
24
|
+
var getIntl = _ref2.getIntl,
|
|
25
|
+
nodeViewPortalProviderAPI = _ref2.nodeViewPortalProviderAPI;
|
|
26
|
+
return (0, _main.createPlugin)(api, getIntl, nodeViewPortalProviderAPI);
|
|
26
27
|
}
|
|
27
28
|
}];
|
|
28
29
|
},
|
|
@@ -10,6 +10,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
12
12
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
14
15
|
var TYPE_DROP_TARGET_DEC = exports.TYPE_DROP_TARGET_DEC = 'drop-target-decoration';
|
|
15
16
|
var TYPE_HANDLE_DEC = exports.TYPE_HANDLE_DEC = 'drag-handle';
|
|
@@ -39,11 +40,18 @@ var ObjHash = /*#__PURE__*/function () {
|
|
|
39
40
|
return ObjHash;
|
|
40
41
|
}();
|
|
41
42
|
(0, _defineProperty2.default)(ObjHash, "caching", new WeakMap());
|
|
42
|
-
var unmountDecorations = exports.unmountDecorations = function unmountDecorations(selector) {
|
|
43
|
+
var unmountDecorations = exports.unmountDecorations = function unmountDecorations(nodeViewPortalProviderAPI, selector, key) {
|
|
43
44
|
// Removing decorations manually instead of using native destroy function in prosemirror API
|
|
44
45
|
// as it was more responsive and causes less re-rendering
|
|
45
46
|
var decorationsToRemove = document.querySelectorAll("[".concat(selector, "=\"true\"]"));
|
|
46
47
|
decorationsToRemove.forEach(function (el) {
|
|
47
|
-
|
|
48
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
|
|
49
|
+
var nodeKey = el.getAttribute(key);
|
|
50
|
+
if (nodeKey) {
|
|
51
|
+
nodeViewPortalProviderAPI.remove(nodeKey);
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
_reactDom.default.unmountComponentAtNode(el);
|
|
55
|
+
}
|
|
48
56
|
});
|
|
49
57
|
};
|
|
@@ -29,9 +29,10 @@ var findHandleDec = exports.findHandleDec = function findHandleDec(decorations,
|
|
|
29
29
|
return spec.type === _decorationsCommon.TYPE_HANDLE_DEC;
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
|
-
var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDecoration(api, formatMessage, pos, anchorName, nodeType, handleOptions) {
|
|
33
|
-
(0, _decorationsCommon.unmountDecorations)('data-blocks-drag-handle-container');
|
|
32
|
+
var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDecoration(api, formatMessage, pos, anchorName, nodeType, nodeViewPortalProviderAPI, handleOptions) {
|
|
33
|
+
(0, _decorationsCommon.unmountDecorations)(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
|
|
34
34
|
var unbind;
|
|
35
|
+
var key = (0, _uuid.default)();
|
|
35
36
|
return _view.Decoration.widget(pos, function (view, getPos) {
|
|
36
37
|
var element = document.createElement('span');
|
|
37
38
|
// Need to set it to inline to avoid text being split when merging two paragraphs
|
|
@@ -39,6 +40,7 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
|
|
|
39
40
|
element.style.display = (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_2') ? 'block' : 'inline';
|
|
40
41
|
element.setAttribute('data-testid', 'block-ctrl-decorator-widget');
|
|
41
42
|
element.setAttribute('data-blocks-drag-handle-container', 'true');
|
|
43
|
+
element.setAttribute('data-blocks-drag-handle-key', key);
|
|
42
44
|
var isTopLevelNode = true;
|
|
43
45
|
if ((0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
44
46
|
var newPos = (0, _platformFeatureFlags.fg)('platform_editor_element_dnd_nested_fix_patch_3') ? getPos() : pos;
|
|
@@ -64,16 +66,31 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
|
|
|
64
66
|
// There are times when global clear: "both" styles are applied to this decoration causing jumpiness
|
|
65
67
|
// due to margins applied to other nodes eg. Headings
|
|
66
68
|
element.style.clear = 'unset';
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
|
|
70
|
+
nodeViewPortalProviderAPI.render(function () {
|
|
71
|
+
return /*#__PURE__*/(0, _react.createElement)(_dragHandle.DragHandle, {
|
|
72
|
+
view: view,
|
|
73
|
+
api: api,
|
|
74
|
+
formatMessage: formatMessage,
|
|
75
|
+
getPos: getPos,
|
|
76
|
+
anchorName: anchorName,
|
|
77
|
+
nodeType: nodeType,
|
|
78
|
+
handleOptions: handleOptions,
|
|
79
|
+
isTopLevelNode: isTopLevelNode
|
|
80
|
+
});
|
|
81
|
+
}, element, key);
|
|
82
|
+
} else {
|
|
83
|
+
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dragHandle.DragHandle, {
|
|
84
|
+
view: view,
|
|
85
|
+
api: api,
|
|
86
|
+
formatMessage: formatMessage,
|
|
87
|
+
getPos: getPos,
|
|
88
|
+
anchorName: anchorName,
|
|
89
|
+
nodeType: nodeType,
|
|
90
|
+
handleOptions: handleOptions,
|
|
91
|
+
isTopLevelNode: isTopLevelNode
|
|
92
|
+
}), element);
|
|
93
|
+
}
|
|
77
94
|
return element;
|
|
78
95
|
}, {
|
|
79
96
|
side: -1,
|
|
@@ -8,6 +8,7 @@ exports.findDropTargetDecs = exports.dropTargetDecorations = exports.createLayou
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
11
|
+
var _uuid = _interopRequireDefault(require("uuid"));
|
|
11
12
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
12
13
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
13
14
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
@@ -88,10 +89,12 @@ var findDropTargetDecs = exports.findDropTargetDecs = function findDropTargetDec
|
|
|
88
89
|
return spec.type === _decorationsCommon.TYPE_DROP_TARGET_DEC;
|
|
89
90
|
});
|
|
90
91
|
};
|
|
91
|
-
var createDropTargetDecoration = exports.createDropTargetDecoration = function createDropTargetDecoration(pos, props, side, anchorRectCache, isSameLayout) {
|
|
92
|
+
var createDropTargetDecoration = exports.createDropTargetDecoration = function createDropTargetDecoration(pos, props, nodeViewPortalProviderAPI, side, anchorRectCache, isSameLayout) {
|
|
93
|
+
var key = (0, _uuid.default)();
|
|
92
94
|
return _view.Decoration.widget(pos, function (_, getPos) {
|
|
93
95
|
var element = document.createElement('div');
|
|
94
96
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
97
|
+
element.setAttribute('data-blocks-drop-target-key', key);
|
|
95
98
|
element.style.clear = 'unset';
|
|
96
99
|
if ((0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2')) {
|
|
97
100
|
var _getGapAndOffset = getGapAndOffset(props.prevNode, props.nextNode, props.parentNode),
|
|
@@ -100,15 +103,33 @@ var createDropTargetDecoration = exports.createDropTargetDecoration = function c
|
|
|
100
103
|
element.style.setProperty(_dropTargetV.EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET, "".concat(offset, "px"));
|
|
101
104
|
element.style.setProperty(_dropTargetV.EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, "".concat(gap, "px"));
|
|
102
105
|
element.style.setProperty('display', 'block');
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
|
|
107
|
+
nodeViewPortalProviderAPI.render(function () {
|
|
108
|
+
return /*#__PURE__*/(0, _react.createElement)(_dropTargetV.DropTargetV2, _objectSpread(_objectSpread({}, props), {}, {
|
|
109
|
+
getPos: getPos,
|
|
110
|
+
anchorRectCache: anchorRectCache,
|
|
111
|
+
isSameLayout: isSameLayout
|
|
112
|
+
}));
|
|
113
|
+
}, element, key);
|
|
114
|
+
} else {
|
|
115
|
+
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTargetV.DropTargetV2, _objectSpread(_objectSpread({}, props), {}, {
|
|
116
|
+
getPos: getPos,
|
|
117
|
+
anchorRectCache: anchorRectCache,
|
|
118
|
+
isSameLayout: isSameLayout
|
|
119
|
+
})), element);
|
|
120
|
+
}
|
|
108
121
|
} else {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
122
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
|
|
123
|
+
nodeViewPortalProviderAPI.render(function () {
|
|
124
|
+
return /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, _objectSpread(_objectSpread({}, props), {}, {
|
|
125
|
+
getPos: getPos
|
|
126
|
+
}));
|
|
127
|
+
}, element, key);
|
|
128
|
+
} else {
|
|
129
|
+
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, _objectSpread(_objectSpread({}, props), {}, {
|
|
130
|
+
getPos: getPos
|
|
131
|
+
})), element);
|
|
132
|
+
}
|
|
112
133
|
}
|
|
113
134
|
return element;
|
|
114
135
|
}, {
|
|
@@ -116,22 +137,33 @@ var createDropTargetDecoration = exports.createDropTargetDecoration = function c
|
|
|
116
137
|
side: side
|
|
117
138
|
});
|
|
118
139
|
};
|
|
119
|
-
var createLayoutDropTargetDecoration = exports.createLayoutDropTargetDecoration = function createLayoutDropTargetDecoration(pos, props, anchorRectCache) {
|
|
140
|
+
var createLayoutDropTargetDecoration = exports.createLayoutDropTargetDecoration = function createLayoutDropTargetDecoration(pos, props, nodeViewPortalProviderAPI, anchorRectCache) {
|
|
141
|
+
var key = (0, _uuid.default)();
|
|
120
142
|
return _view.Decoration.widget(pos, function (_, getPos) {
|
|
121
143
|
var element = document.createElement('div');
|
|
122
144
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
145
|
+
element.setAttribute('data-blocks-drop-target-key', key);
|
|
123
146
|
element.style.clear = 'unset';
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
147
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_react18_plugin_portalprovider')) {
|
|
148
|
+
nodeViewPortalProviderAPI.render(function () {
|
|
149
|
+
return /*#__PURE__*/(0, _react.createElement)(_dropTargetLayout.DropTargetLayout, _objectSpread(_objectSpread({}, props), {}, {
|
|
150
|
+
getPos: getPos,
|
|
151
|
+
anchorRectCache: anchorRectCache
|
|
152
|
+
}));
|
|
153
|
+
}, element, key);
|
|
154
|
+
} else {
|
|
155
|
+
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTargetLayout.DropTargetLayout, _objectSpread(_objectSpread({}, props), {}, {
|
|
156
|
+
getPos: getPos,
|
|
157
|
+
anchorRectCache: anchorRectCache
|
|
158
|
+
})), element);
|
|
159
|
+
}
|
|
128
160
|
return element;
|
|
129
161
|
}, {
|
|
130
162
|
type: _decorationsCommon.TYPE_DROP_TARGET_DEC
|
|
131
163
|
});
|
|
132
164
|
};
|
|
133
|
-
var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetDecorations(newState, api, formatMessage, activeNode, anchorRectCache, from, to) {
|
|
134
|
-
(0, _decorationsCommon.unmountDecorations)('data-blocks-drop-target-container');
|
|
165
|
+
var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetDecorations(newState, api, formatMessage, nodeViewPortalProviderAPI, activeNode, anchorRectCache, from, to) {
|
|
166
|
+
(0, _decorationsCommon.unmountDecorations)(nodeViewPortalProviderAPI, 'data-blocks-drop-target-container', 'data-blocks-drop-target-key');
|
|
135
167
|
var decs = [];
|
|
136
168
|
var POS_END_OF_DOC = newState.doc.nodeSize - 2;
|
|
137
169
|
var docFrom = from === undefined || from < 0 ? 0 : from;
|
|
@@ -175,7 +207,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
175
207
|
api: api,
|
|
176
208
|
parent: parent,
|
|
177
209
|
formatMessage: formatMessage
|
|
178
|
-
}, anchorRectCache));
|
|
210
|
+
}, nodeViewPortalProviderAPI, anchorRectCache));
|
|
179
211
|
}
|
|
180
212
|
}
|
|
181
213
|
if (node.isInline || !parent || DISABLE_CHILD_DROP_TARGET.includes(parent.type.name)) {
|
|
@@ -221,7 +253,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
221
253
|
parentNode: parent || undefined,
|
|
222
254
|
formatMessage: formatMessage,
|
|
223
255
|
dropTargetStyle: shouldShowFullHeight ? 'remainingHeight' : 'default'
|
|
224
|
-
}, -1, anchorRectCache, isSameLayout));
|
|
256
|
+
}, nodeViewPortalProviderAPI, -1, anchorRectCache, isSameLayout));
|
|
225
257
|
if (endPos !== undefined) {
|
|
226
258
|
decs.push(createDropTargetDecoration(endPos, {
|
|
227
259
|
api: api,
|
|
@@ -229,7 +261,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
229
261
|
parentNode: parent || undefined,
|
|
230
262
|
formatMessage: formatMessage,
|
|
231
263
|
dropTargetStyle: 'remainingHeight'
|
|
232
|
-
}, -1, anchorRectCache));
|
|
264
|
+
}, nodeViewPortalProviderAPI, -1, anchorRectCache));
|
|
233
265
|
}
|
|
234
266
|
if ((0, _platformFeatureFlags.fg)('platform_editor_drag_and_drop_target_v2')) {
|
|
235
267
|
pushNodeStack(node, depth);
|
|
@@ -244,7 +276,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
244
276
|
formatMessage: formatMessage,
|
|
245
277
|
prevNode: newState.doc.lastChild || undefined,
|
|
246
278
|
parentNode: newState.doc
|
|
247
|
-
}, undefined, anchorRectCache));
|
|
279
|
+
}, nodeViewPortalProviderAPI, undefined, anchorRectCache));
|
|
248
280
|
}
|
|
249
281
|
return decs;
|
|
250
282
|
};
|
|
@@ -99,7 +99,7 @@ var initialState = {
|
|
|
99
99
|
isDocSizeLimitEnabled: null,
|
|
100
100
|
isPMDragging: false
|
|
101
101
|
};
|
|
102
|
-
var newApply = exports.newApply = function newApply(api, formatMessage, tr, currentState, newState, flags, anchorRectCache) {
|
|
102
|
+
var newApply = exports.newApply = function newApply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) {
|
|
103
103
|
var _meta$activeNode, _activeNode, _activeNode2, _meta$activeNode$hand, _meta$isDragging, _meta$isDragging2, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging;
|
|
104
104
|
var activeNode = currentState.activeNode,
|
|
105
105
|
decorations = currentState.decorations,
|
|
@@ -189,7 +189,7 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
|
|
|
189
189
|
var _activeNode5, _activeNode6;
|
|
190
190
|
var _oldHandle = (0, _decorationsDragHandle.findHandleDec)(decorations, (_activeNode5 = activeNode) === null || _activeNode5 === void 0 ? void 0 : _activeNode5.pos, (_activeNode6 = activeNode) === null || _activeNode6 === void 0 ? void 0 : _activeNode6.pos);
|
|
191
191
|
decorations = decorations.remove(_oldHandle);
|
|
192
|
-
var handleDec = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.pos, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.anchorName, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.nodeType, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.handleOptions);
|
|
192
|
+
var handleDec = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.pos, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.anchorName, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.nodeType, nodeViewPortalProviderAPI, latestActiveNode === null || latestActiveNode === void 0 ? void 0 : latestActiveNode.handleOptions);
|
|
193
193
|
decorations = decorations.add(newState.doc, [handleDec]);
|
|
194
194
|
}
|
|
195
195
|
|
|
@@ -197,7 +197,7 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
|
|
|
197
197
|
var isDropTargetsMissing = ((_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging) && maybeNodeCountChanged && !(meta !== null && meta !== void 0 && meta.nodeMoved);
|
|
198
198
|
|
|
199
199
|
// Remove drop target decorations when dragging stops or they need to be redrawn
|
|
200
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
|
|
200
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing || (0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
|
|
201
201
|
var dropTargetDecs = (0, _decorationsDropTarget.findDropTargetDecs)(decorations);
|
|
202
202
|
decorations = decorations.remove(dropTargetDecs);
|
|
203
203
|
}
|
|
@@ -205,7 +205,7 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
|
|
|
205
205
|
// Add drop targets when dragging starts or some are missing
|
|
206
206
|
if (api) {
|
|
207
207
|
if (meta !== null && meta !== void 0 && meta.isDragging || isDropTargetsMissing || (0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
|
|
208
|
-
var decs = (0, _decorationsDropTarget.dropTargetDecorations)(newState, api, formatMessage, latestActiveNode, anchorRectCache);
|
|
208
|
+
var decs = (0, _decorationsDropTarget.dropTargetDecorations)(newState, api, formatMessage, nodeViewPortalProviderAPI, latestActiveNode, anchorRectCache);
|
|
209
209
|
decorations = decorations.add(newState.doc, decs);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
@@ -230,7 +230,7 @@ var newApply = exports.newApply = function newApply(api, formatMessage, tr, curr
|
|
|
230
230
|
isPMDragging: (_meta$isPMDragging = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging !== void 0 ? _meta$isPMDragging : isPMDragging
|
|
231
231
|
};
|
|
232
232
|
};
|
|
233
|
-
var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, currentState, oldState, newState, flags, anchorRectCache) {
|
|
233
|
+
var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, currentState, oldState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) {
|
|
234
234
|
var _meta$activeNode2, _meta$activeNode$hand2, _activeNodeWithNewNod, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2;
|
|
235
235
|
var isNestedEnabled = flags.isNestedEnabled;
|
|
236
236
|
var activeNode = currentState.activeNode,
|
|
@@ -335,7 +335,7 @@ var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, curr
|
|
|
335
335
|
var decAtPos = newNodeDecs.find(function (dec) {
|
|
336
336
|
return dec.from === mappedPosisiton;
|
|
337
337
|
});
|
|
338
|
-
draghandleDec = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, (_meta$activeNode$pos = meta === null || meta === void 0 || (_meta$activeNode3 = meta.activeNode) === null || _meta$activeNode3 === void 0 ? void 0 : _meta$activeNode3.pos) !== null && _meta$activeNode$pos !== void 0 ? _meta$activeNode$pos : mappedPosisiton, (_ref6 = (_meta$activeNode$anch = meta === null || meta === void 0 || (_meta$activeNode4 = meta.activeNode) === null || _meta$activeNode4 === void 0 ? void 0 : _meta$activeNode4.anchorName) !== null && _meta$activeNode$anch !== void 0 ? _meta$activeNode$anch : decAtPos === null || decAtPos === void 0 || (_decAtPos$spec = decAtPos.spec) === null || _decAtPos$spec === void 0 ? void 0 : _decAtPos$spec.anchorName) !== null && _ref6 !== void 0 ? _ref6 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName, (_ref7 = (_meta$activeNode$node = meta === null || meta === void 0 || (_meta$activeNode5 = meta.activeNode) === null || _meta$activeNode5 === void 0 ? void 0 : _meta$activeNode5.nodeType) !== null && _meta$activeNode$node !== void 0 ? _meta$activeNode$node : decAtPos === null || decAtPos === void 0 || (_decAtPos$spec2 = decAtPos.spec) === null || _decAtPos$spec2 === void 0 ? void 0 : _decAtPos$spec2.nodeType) !== null && _ref7 !== void 0 ? _ref7 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType, meta === null || meta === void 0 || (_meta$activeNode6 = meta.activeNode) === null || _meta$activeNode6 === void 0 ? void 0 : _meta$activeNode6.handleOptions);
|
|
338
|
+
draghandleDec = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, (_meta$activeNode$pos = meta === null || meta === void 0 || (_meta$activeNode3 = meta.activeNode) === null || _meta$activeNode3 === void 0 ? void 0 : _meta$activeNode3.pos) !== null && _meta$activeNode$pos !== void 0 ? _meta$activeNode$pos : mappedPosisiton, (_ref6 = (_meta$activeNode$anch = meta === null || meta === void 0 || (_meta$activeNode4 = meta.activeNode) === null || _meta$activeNode4 === void 0 ? void 0 : _meta$activeNode4.anchorName) !== null && _meta$activeNode$anch !== void 0 ? _meta$activeNode$anch : decAtPos === null || decAtPos === void 0 || (_decAtPos$spec = decAtPos.spec) === null || _decAtPos$spec === void 0 ? void 0 : _decAtPos$spec.anchorName) !== null && _ref6 !== void 0 ? _ref6 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName, (_ref7 = (_meta$activeNode$node = meta === null || meta === void 0 || (_meta$activeNode5 = meta.activeNode) === null || _meta$activeNode5 === void 0 ? void 0 : _meta$activeNode5.nodeType) !== null && _meta$activeNode$node !== void 0 ? _meta$activeNode$node : decAtPos === null || decAtPos === void 0 || (_decAtPos$spec2 = decAtPos.spec) === null || _decAtPos$spec2 === void 0 ? void 0 : _decAtPos$spec2.nodeType) !== null && _ref7 !== void 0 ? _ref7 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType, nodeViewPortalProviderAPI, meta === null || meta === void 0 || (_meta$activeNode6 = meta.activeNode) === null || _meta$activeNode6 === void 0 ? void 0 : _meta$activeNode6.handleOptions);
|
|
339
339
|
} else {
|
|
340
340
|
var nodeType = activeNode.nodeType;
|
|
341
341
|
var anchorName = activeNode.anchorName;
|
|
@@ -348,7 +348,7 @@ var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, curr
|
|
|
348
348
|
anchorName: anchorName
|
|
349
349
|
};
|
|
350
350
|
}
|
|
351
|
-
draghandleDec = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, activeNode.pos, anchorName, nodeType);
|
|
351
|
+
draghandleDec = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, activeNode.pos, anchorName, nodeType, nodeViewPortalProviderAPI);
|
|
352
352
|
}
|
|
353
353
|
decorations = decorations.add(newState.doc, [draghandleDec]);
|
|
354
354
|
}
|
|
@@ -360,7 +360,7 @@ var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, curr
|
|
|
360
360
|
return spec.type === 'drag-handle';
|
|
361
361
|
});
|
|
362
362
|
decorations = decorations.remove(_oldHandle3);
|
|
363
|
-
var decs = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, meta.activeNode.handleOptions);
|
|
363
|
+
var decs = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, nodeViewPortalProviderAPI, meta.activeNode.handleOptions);
|
|
364
364
|
decorations = decorations.add(newState.doc, [decs]);
|
|
365
365
|
}
|
|
366
366
|
|
|
@@ -370,10 +370,10 @@ var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, curr
|
|
|
370
370
|
return spec.type === 'drag-handle';
|
|
371
371
|
});
|
|
372
372
|
decorations = decorations.remove(_oldHandle4);
|
|
373
|
-
var _decs = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType);
|
|
373
|
+
var _decs = (0, _decorationsDragHandle.dragHandleDecoration)(api, formatMessage, activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType, nodeViewPortalProviderAPI);
|
|
374
374
|
decorations = decorations.add(newState.doc, [_decs]);
|
|
375
375
|
}
|
|
376
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
|
|
376
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing || (0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
|
|
377
377
|
// Remove drop target decoration when dragging stops
|
|
378
378
|
var dropTargetDecs = decorations.find(undefined, undefined, function (spec) {
|
|
379
379
|
return spec.type === 'drop-target-decoration';
|
|
@@ -393,7 +393,7 @@ var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, curr
|
|
|
393
393
|
// if the transaction is only for analytics and user is dragging, continue to draw drop targets
|
|
394
394
|
if (shouldCreateDropTargets || (0, _dragTargetDebug.isBlocksDragTargetDebug)()) {
|
|
395
395
|
var _meta$activeNode7;
|
|
396
|
-
var _decs2 = (0, _decorationsDropTarget.dropTargetDecorations)(newState, api, formatMessage, isNestedEnabled ? (_meta$activeNode7 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode7 !== void 0 ? _meta$activeNode7 : mappedActiveNodePos : meta === null || meta === void 0 ? void 0 : meta.activeNode, anchorRectCache);
|
|
396
|
+
var _decs2 = (0, _decorationsDropTarget.dropTargetDecorations)(newState, api, formatMessage, nodeViewPortalProviderAPI, isNestedEnabled ? (_meta$activeNode7 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode7 !== void 0 ? _meta$activeNode7 : mappedActiveNodePos : meta === null || meta === void 0 ? void 0 : meta.activeNode, anchorRectCache);
|
|
397
397
|
decorations = decorations.add(newState.doc, _decs2);
|
|
398
398
|
}
|
|
399
399
|
}
|
|
@@ -422,7 +422,7 @@ var oldApply = exports.oldApply = function oldApply(api, formatMessage, tr, curr
|
|
|
422
422
|
isPMDragging: (_meta$isPMDragging2 = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging2 !== void 0 ? _meta$isPMDragging2 : isPMDragging
|
|
423
423
|
};
|
|
424
424
|
};
|
|
425
|
-
var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
425
|
+
var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, nodeViewPortalProviderAPI) {
|
|
426
426
|
var _getIntl = getIntl(),
|
|
427
427
|
formatMessage = _getIntl.formatMessage;
|
|
428
428
|
var isNestedEnabled = (0, _experiments.editorExperiment)('nested-dnd', true, {
|
|
@@ -450,9 +450,9 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
450
450
|
},
|
|
451
451
|
apply: function apply(tr, currentState, oldState, newState) {
|
|
452
452
|
if (isOptimisedApply) {
|
|
453
|
-
return newApply(api, formatMessage, tr, currentState, newState, flags, anchorRectCache);
|
|
453
|
+
return newApply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
|
|
454
454
|
}
|
|
455
|
-
return oldApply(api, formatMessage, tr, currentState, oldState, newState, flags, anchorRectCache);
|
|
455
|
+
return oldApply(api, formatMessage, tr, currentState, oldState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
|
|
456
456
|
}
|
|
457
457
|
},
|
|
458
458
|
props: {
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -14,8 +14,9 @@ export const blockControlsPlugin = ({
|
|
|
14
14
|
return [{
|
|
15
15
|
name: 'blockControlsPmPlugin',
|
|
16
16
|
plugin: ({
|
|
17
|
-
getIntl
|
|
18
|
-
|
|
17
|
+
getIntl,
|
|
18
|
+
nodeViewPortalProviderAPI
|
|
19
|
+
}) => createPlugin(api, getIntl, nodeViewPortalProviderAPI)
|
|
19
20
|
}];
|
|
20
21
|
},
|
|
21
22
|
commands: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import uuid from 'uuid';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
6
|
export const TYPE_DROP_TARGET_DEC = 'drop-target-decoration';
|
|
6
7
|
export const TYPE_HANDLE_DEC = 'drag-handle';
|
|
@@ -21,11 +22,18 @@ class ObjHash {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
_defineProperty(ObjHash, "caching", new WeakMap());
|
|
24
|
-
export const unmountDecorations = selector => {
|
|
25
|
+
export const unmountDecorations = (nodeViewPortalProviderAPI, selector, key) => {
|
|
25
26
|
// Removing decorations manually instead of using native destroy function in prosemirror API
|
|
26
27
|
// as it was more responsive and causes less re-rendering
|
|
27
28
|
const decorationsToRemove = document.querySelectorAll(`[${selector}="true"]`);
|
|
28
29
|
decorationsToRemove.forEach(el => {
|
|
29
|
-
|
|
30
|
+
if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
31
|
+
const nodeKey = el.getAttribute(key);
|
|
32
|
+
if (nodeKey) {
|
|
33
|
+
nodeViewPortalProviderAPI.remove(nodeKey);
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
ReactDOM.unmountComponentAtNode(el);
|
|
37
|
+
}
|
|
30
38
|
});
|
|
31
39
|
};
|
|
@@ -20,9 +20,10 @@ export const emptyParagraphNodeDecorations = () => {
|
|
|
20
20
|
export const findHandleDec = (decorations, from, to) => {
|
|
21
21
|
return decorations.find(from, to, spec => spec.type === TYPE_HANDLE_DEC);
|
|
22
22
|
};
|
|
23
|
-
export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeType, handleOptions) => {
|
|
24
|
-
unmountDecorations('data-blocks-drag-handle-container');
|
|
23
|
+
export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeType, nodeViewPortalProviderAPI, handleOptions) => {
|
|
24
|
+
unmountDecorations(nodeViewPortalProviderAPI, 'data-blocks-drag-handle-container', 'data-blocks-drag-handle-key');
|
|
25
25
|
let unbind;
|
|
26
|
+
const key = uuid();
|
|
26
27
|
return Decoration.widget(pos, (view, getPos) => {
|
|
27
28
|
const element = document.createElement('span');
|
|
28
29
|
// Need to set it to inline to avoid text being split when merging two paragraphs
|
|
@@ -30,6 +31,7 @@ export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeTy
|
|
|
30
31
|
element.style.display = fg('platform_editor_element_dnd_nested_fix_patch_2') ? 'block' : 'inline';
|
|
31
32
|
element.setAttribute('data-testid', 'block-ctrl-decorator-widget');
|
|
32
33
|
element.setAttribute('data-blocks-drag-handle-container', 'true');
|
|
34
|
+
element.setAttribute('data-blocks-drag-handle-key', key);
|
|
33
35
|
let isTopLevelNode = true;
|
|
34
36
|
if (editorExperiment('nested-dnd', true)) {
|
|
35
37
|
const newPos = fg('platform_editor_element_dnd_nested_fix_patch_3') ? getPos() : pos;
|
|
@@ -55,16 +57,29 @@ export const dragHandleDecoration = (api, formatMessage, pos, anchorName, nodeTy
|
|
|
55
57
|
// There are times when global clear: "both" styles are applied to this decoration causing jumpiness
|
|
56
58
|
// due to margins applied to other nodes eg. Headings
|
|
57
59
|
element.style.clear = 'unset';
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
61
|
+
nodeViewPortalProviderAPI.render(() => /*#__PURE__*/createElement(DragHandle, {
|
|
62
|
+
view,
|
|
63
|
+
api,
|
|
64
|
+
formatMessage,
|
|
65
|
+
getPos,
|
|
66
|
+
anchorName,
|
|
67
|
+
nodeType,
|
|
68
|
+
handleOptions,
|
|
69
|
+
isTopLevelNode
|
|
70
|
+
}), element, key);
|
|
71
|
+
} else {
|
|
72
|
+
ReactDOM.render( /*#__PURE__*/createElement(DragHandle, {
|
|
73
|
+
view,
|
|
74
|
+
api,
|
|
75
|
+
formatMessage,
|
|
76
|
+
getPos,
|
|
77
|
+
anchorName,
|
|
78
|
+
nodeType,
|
|
79
|
+
handleOptions,
|
|
80
|
+
isTopLevelNode
|
|
81
|
+
}), element);
|
|
82
|
+
}
|
|
68
83
|
return element;
|
|
69
84
|
}, {
|
|
70
85
|
side: -1,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
|
+
import uuid from 'uuid';
|
|
3
4
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
4
5
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -76,10 +77,12 @@ const getGapAndOffset = (prevNode, nextNode, parentNode) => {
|
|
|
76
77
|
export const findDropTargetDecs = (decorations, from, to) => {
|
|
77
78
|
return decorations.find(from, to, spec => spec.type === TYPE_DROP_TARGET_DEC);
|
|
78
79
|
};
|
|
79
|
-
export const createDropTargetDecoration = (pos, props, side, anchorRectCache, isSameLayout) => {
|
|
80
|
+
export const createDropTargetDecoration = (pos, props, nodeViewPortalProviderAPI, side, anchorRectCache, isSameLayout) => {
|
|
81
|
+
const key = uuid();
|
|
80
82
|
return Decoration.widget(pos, (_, getPos) => {
|
|
81
83
|
const element = document.createElement('div');
|
|
82
84
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
85
|
+
element.setAttribute('data-blocks-drop-target-key', key);
|
|
83
86
|
element.style.clear = 'unset';
|
|
84
87
|
if (fg('platform_editor_drag_and_drop_target_v2')) {
|
|
85
88
|
const {
|
|
@@ -89,17 +92,33 @@ export const createDropTargetDecoration = (pos, props, side, anchorRectCache, is
|
|
|
89
92
|
element.style.setProperty(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_OFFSET, `${offset}px`);
|
|
90
93
|
element.style.setProperty(EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_GAP, `${gap}px`);
|
|
91
94
|
element.style.setProperty('display', 'block');
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
96
|
+
nodeViewPortalProviderAPI.render(() => /*#__PURE__*/createElement(DropTargetV2, {
|
|
97
|
+
...props,
|
|
98
|
+
getPos,
|
|
99
|
+
anchorRectCache,
|
|
100
|
+
isSameLayout
|
|
101
|
+
}), element, key);
|
|
102
|
+
} else {
|
|
103
|
+
ReactDOM.render( /*#__PURE__*/createElement(DropTargetV2, {
|
|
104
|
+
...props,
|
|
105
|
+
getPos,
|
|
106
|
+
anchorRectCache,
|
|
107
|
+
isSameLayout
|
|
108
|
+
}), element);
|
|
109
|
+
}
|
|
98
110
|
} else {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
111
|
+
if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
112
|
+
nodeViewPortalProviderAPI.render(() => /*#__PURE__*/createElement(DropTarget, {
|
|
113
|
+
...props,
|
|
114
|
+
getPos
|
|
115
|
+
}), element, key);
|
|
116
|
+
} else {
|
|
117
|
+
ReactDOM.render( /*#__PURE__*/createElement(DropTarget, {
|
|
118
|
+
...props,
|
|
119
|
+
getPos
|
|
120
|
+
}), element);
|
|
121
|
+
}
|
|
103
122
|
}
|
|
104
123
|
return element;
|
|
105
124
|
}, {
|
|
@@ -107,23 +126,33 @@ export const createDropTargetDecoration = (pos, props, side, anchorRectCache, is
|
|
|
107
126
|
side
|
|
108
127
|
});
|
|
109
128
|
};
|
|
110
|
-
export const createLayoutDropTargetDecoration = (pos, props, anchorRectCache) => {
|
|
129
|
+
export const createLayoutDropTargetDecoration = (pos, props, nodeViewPortalProviderAPI, anchorRectCache) => {
|
|
130
|
+
const key = uuid();
|
|
111
131
|
return Decoration.widget(pos, (_, getPos) => {
|
|
112
132
|
const element = document.createElement('div');
|
|
113
133
|
element.setAttribute('data-blocks-drop-target-container', 'true');
|
|
134
|
+
element.setAttribute('data-blocks-drop-target-key', key);
|
|
114
135
|
element.style.clear = 'unset';
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
136
|
+
if (fg('platform_editor_react18_plugin_portalprovider')) {
|
|
137
|
+
nodeViewPortalProviderAPI.render(() => /*#__PURE__*/createElement(DropTargetLayout, {
|
|
138
|
+
...props,
|
|
139
|
+
getPos,
|
|
140
|
+
anchorRectCache
|
|
141
|
+
}), element, key);
|
|
142
|
+
} else {
|
|
143
|
+
ReactDOM.render( /*#__PURE__*/createElement(DropTargetLayout, {
|
|
144
|
+
...props,
|
|
145
|
+
getPos,
|
|
146
|
+
anchorRectCache
|
|
147
|
+
}), element);
|
|
148
|
+
}
|
|
120
149
|
return element;
|
|
121
150
|
}, {
|
|
122
151
|
type: TYPE_DROP_TARGET_DEC
|
|
123
152
|
});
|
|
124
153
|
};
|
|
125
|
-
export const dropTargetDecorations = (newState, api, formatMessage, activeNode, anchorRectCache, from, to) => {
|
|
126
|
-
unmountDecorations('data-blocks-drop-target-container');
|
|
154
|
+
export const dropTargetDecorations = (newState, api, formatMessage, nodeViewPortalProviderAPI, activeNode, anchorRectCache, from, to) => {
|
|
155
|
+
unmountDecorations(nodeViewPortalProviderAPI, 'data-blocks-drop-target-container', 'data-blocks-drop-target-key');
|
|
127
156
|
const decs = [];
|
|
128
157
|
const POS_END_OF_DOC = newState.doc.nodeSize - 2;
|
|
129
158
|
const docFrom = from === undefined || from < 0 ? 0 : from;
|
|
@@ -167,7 +196,7 @@ export const dropTargetDecorations = (newState, api, formatMessage, activeNode,
|
|
|
167
196
|
api,
|
|
168
197
|
parent,
|
|
169
198
|
formatMessage
|
|
170
|
-
}, anchorRectCache));
|
|
199
|
+
}, nodeViewPortalProviderAPI, anchorRectCache));
|
|
171
200
|
}
|
|
172
201
|
}
|
|
173
202
|
if (node.isInline || !parent || DISABLE_CHILD_DROP_TARGET.includes(parent.type.name)) {
|
|
@@ -213,7 +242,7 @@ export const dropTargetDecorations = (newState, api, formatMessage, activeNode,
|
|
|
213
242
|
parentNode: parent || undefined,
|
|
214
243
|
formatMessage,
|
|
215
244
|
dropTargetStyle: shouldShowFullHeight ? 'remainingHeight' : 'default'
|
|
216
|
-
}, -1, anchorRectCache, isSameLayout));
|
|
245
|
+
}, nodeViewPortalProviderAPI, -1, anchorRectCache, isSameLayout));
|
|
217
246
|
if (endPos !== undefined) {
|
|
218
247
|
decs.push(createDropTargetDecoration(endPos, {
|
|
219
248
|
api,
|
|
@@ -221,7 +250,7 @@ export const dropTargetDecorations = (newState, api, formatMessage, activeNode,
|
|
|
221
250
|
parentNode: parent || undefined,
|
|
222
251
|
formatMessage,
|
|
223
252
|
dropTargetStyle: 'remainingHeight'
|
|
224
|
-
}, -1, anchorRectCache));
|
|
253
|
+
}, nodeViewPortalProviderAPI, -1, anchorRectCache));
|
|
225
254
|
}
|
|
226
255
|
if (fg('platform_editor_drag_and_drop_target_v2')) {
|
|
227
256
|
pushNodeStack(node, depth);
|
|
@@ -236,7 +265,7 @@ export const dropTargetDecorations = (newState, api, formatMessage, activeNode,
|
|
|
236
265
|
formatMessage,
|
|
237
266
|
prevNode: newState.doc.lastChild || undefined,
|
|
238
267
|
parentNode: newState.doc
|
|
239
|
-
}, undefined, anchorRectCache));
|
|
268
|
+
}, nodeViewPortalProviderAPI, undefined, anchorRectCache));
|
|
240
269
|
}
|
|
241
270
|
return decs;
|
|
242
271
|
};
|