@atlaskit/editor-plugin-block-controls 2.13.22 → 2.13.24

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.
Files changed (28) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/plugin.js +3 -2
  3. package/dist/cjs/pm-plugins/decorations-common.js +10 -2
  4. package/dist/cjs/pm-plugins/decorations-drag-handle.js +29 -12
  5. package/dist/cjs/pm-plugins/decorations-drop-target.js +52 -20
  6. package/dist/cjs/pm-plugins/main.js +14 -14
  7. package/dist/cjs/ui/drag-handle.js +15 -7
  8. package/dist/es2019/plugin.js +3 -2
  9. package/dist/es2019/pm-plugins/decorations-common.js +10 -2
  10. package/dist/es2019/pm-plugins/decorations-drag-handle.js +27 -12
  11. package/dist/es2019/pm-plugins/decorations-drop-target.js +52 -23
  12. package/dist/es2019/pm-plugins/main.js +14 -14
  13. package/dist/es2019/ui/drag-handle.js +16 -8
  14. package/dist/esm/plugin.js +3 -2
  15. package/dist/esm/pm-plugins/decorations-common.js +10 -2
  16. package/dist/esm/pm-plugins/decorations-drag-handle.js +29 -12
  17. package/dist/esm/pm-plugins/decorations-drop-target.js +52 -20
  18. package/dist/esm/pm-plugins/main.js +14 -14
  19. package/dist/esm/ui/drag-handle.js +16 -8
  20. package/dist/types/pm-plugins/decorations-common.d.ts +2 -1
  21. package/dist/types/pm-plugins/decorations-drag-handle.d.ts +2 -1
  22. package/dist/types/pm-plugins/decorations-drop-target.d.ts +4 -3
  23. package/dist/types/pm-plugins/main.d.ts +4 -3
  24. package/dist/types-ts4.5/pm-plugins/decorations-common.d.ts +2 -1
  25. package/dist/types-ts4.5/pm-plugins/decorations-drag-handle.d.ts +2 -1
  26. package/dist/types-ts4.5/pm-plugins/decorations-drop-target.d.ts +4 -3
  27. package/dist/types-ts4.5/pm-plugins/main.d.ts +4 -3
  28. package/package.json +7 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 2.13.24
4
+
5
+ ### Patch Changes
6
+
7
+ - [#168183](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/168183)
8
+ [`5d8ee46d0ab46`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5d8ee46d0ab46) -
9
+ Fix dragging issue of a layout column while layout is selected
10
+
11
+ ## 2.13.23
12
+
13
+ ### Patch Changes
14
+
15
+ - [#164073](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/164073)
16
+ [`74421f65186ac`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/74421f65186ac) -
17
+ ED-25607: replace usages of ReactDOM.render with portal provider
18
+
3
19
  ## 2.13.22
4
20
 
5
21
  ### Patch Changes
@@ -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
- return (0, _main.createPlugin)(api, getIntl);
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
- _reactDom.default.unmountComponentAtNode(el);
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
- _reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dragHandle.DragHandle, {
68
- view: view,
69
- api: api,
70
- formatMessage: formatMessage,
71
- getPos: getPos,
72
- anchorName: anchorName,
73
- nodeType: nodeType,
74
- handleOptions: handleOptions,
75
- isTopLevelNode: isTopLevelNode
76
- }), element);
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
- _reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTargetV.DropTargetV2, _objectSpread(_objectSpread({}, props), {}, {
104
- getPos: getPos,
105
- anchorRectCache: anchorRectCache,
106
- isSameLayout: isSameLayout
107
- })), element);
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
- _reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTarget.DropTarget, _objectSpread(_objectSpread({}, props), {}, {
110
- getPos: getPos
111
- })), element);
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
- _reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_dropTargetLayout.DropTargetLayout, _objectSpread(_objectSpread({}, props), {}, {
125
- getPos: getPos,
126
- anchorRectCache: anchorRectCache
127
- })), element);
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: {
@@ -95,6 +95,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
95
95
  setDragHandleSelected = _useState4[1];
96
96
  var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['featureFlags']),
97
97
  featureFlagsState = _useSharedPluginState.featureFlagsState;
98
+ var isLayoutColumn = nodeType === 'layoutColumn';
98
99
  (0, _react.useEffect)(function () {
99
100
  // blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
100
101
  if (nodeType === 'blockCard') {
@@ -146,6 +147,9 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
146
147
  // but ensures the preview is generated correctly.
147
148
  var handleMouseDown = (0, _react.useCallback)(function () {
148
149
  var _api$core3;
150
+ if (!(isLayoutColumn && (0, _advancedLayoutsFlags.isPreRelease2)()) && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24885')) {
151
+ return undefined;
152
+ }
149
153
  api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
150
154
  var tr = _ref3.tr;
151
155
  var startPos = getPos();
@@ -156,12 +160,17 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
156
160
  if (!node) {
157
161
  return tr;
158
162
  }
159
- var $startPos = tr.doc.resolve(startPos + node.nodeSize);
160
- var selection = new _state.TextSelection($startPos);
163
+ var selection;
164
+ if (isLayoutColumn && (0, _advancedLayoutsFlags.isPreRelease2)()) {
165
+ selection = new _state.NodeSelection(tr.doc.resolve(startPos));
166
+ } else {
167
+ var $startPos = tr.doc.resolve(startPos + node.nodeSize);
168
+ selection = new _state.TextSelection($startPos);
169
+ }
161
170
  tr.setSelection(selection);
162
171
  return tr;
163
172
  });
164
- }, [api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, getPos]);
173
+ }, [api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, getPos, isLayoutColumn]);
165
174
  var handleKeyDown = (0, _react.useCallback)(function (e) {
166
175
  if ((0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
167
176
  // allow user to use spacebar to select the node
@@ -282,7 +291,6 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
282
291
  }
283
292
  }
284
293
  var isEdgeCase = (hasResizer || isExtension || isEmbedCard || isBlockCard) && innerContainer;
285
- var isLayoutColumn = nodeType === 'layoutColumn';
286
294
  if (supportsAnchor) {
287
295
  return {
288
296
  left: isEdgeCase ? "calc(anchor(".concat(anchorName, " start) + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType), ")") : (0, _advancedLayoutsFlags.isPreRelease2)() && isLayoutColumn ? "calc((anchor(".concat(anchorName, " right) + anchor(").concat(anchorName, " left))/2 - ").concat(_consts.DRAG_HANDLE_HEIGHT / 2, "px)") : "calc(anchor(".concat(anchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType, parentNodeType), "px)"),
@@ -293,7 +301,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
293
301
  left: isEdgeCase ? "calc(".concat((dom === null || dom === void 0 ? void 0 : dom.offsetLeft) || 0, "px + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType), ")") : (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates, parentNodeType),
294
302
  top: (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_ed_23674') ? (0, _dragHandlePositions.getTopPosition)(dom, nodeType) : (0, _dragHandlePositions.getTopPosition)(dom)
295
303
  };
296
- }, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates, getPos]);
304
+ }, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates, getPos, isLayoutColumn]);
297
305
  var _useState5 = (0, _react.useState)({
298
306
  display: 'none'
299
307
  }),
@@ -409,13 +417,13 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
409
417
  // eslint-disable-next-line @atlaskit/design-system/no-html-button
410
418
  (0, _react2.jsx)("button", {
411
419
  type: "button",
412
- css: [dragHandleButtonStyles, (0, _advancedLayoutsFlags.isPreRelease2)() && nodeType === 'layoutColumn' && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
420
+ css: [dragHandleButtonStyles, (0, _advancedLayoutsFlags.isPreRelease2)() && isLayoutColumn && layoutColumnDragHandleStyles, dragHandleSelected && selectedStyles],
413
421
  ref: buttonRef
414
422
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
415
423
  ,
416
424
  style: positionStyles,
417
425
  onClick: handleOnClick,
418
- onMouseDown: (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24885') ? undefined : handleMouseDown,
426
+ onMouseDown: handleMouseDown,
419
427
  onKeyDown: handleKeyDown,
420
428
  "data-testid": "block-ctrl-drag-handle"
421
429
  }, (0, _react2.jsx)(_dragHandler.default, {
@@ -14,8 +14,9 @@ export const blockControlsPlugin = ({
14
14
  return [{
15
15
  name: 'blockControlsPmPlugin',
16
16
  plugin: ({
17
- getIntl
18
- }) => createPlugin(api, getIntl)
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
- ReactDOM.unmountComponentAtNode(el);
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
- ReactDOM.render( /*#__PURE__*/createElement(DragHandle, {
59
- view,
60
- api,
61
- formatMessage,
62
- getPos,
63
- anchorName,
64
- nodeType,
65
- handleOptions,
66
- isTopLevelNode
67
- }), element);
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,