@atlaskit/editor-plugin-block-controls 1.5.12 → 1.5.16
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 +33 -0
- package/dist/cjs/plugin.js +9 -8
- package/dist/cjs/pm-plugins/decorations.js +6 -3
- package/dist/cjs/pm-plugins/main.js +61 -19
- package/dist/cjs/ui/drag-handle.js +39 -17
- package/dist/cjs/ui/drag-preview.js +19 -9
- package/dist/cjs/utils/getSelection.js +5 -1
- package/dist/es2019/plugin.js +3 -1
- package/dist/es2019/pm-plugins/decorations.js +6 -3
- package/dist/es2019/pm-plugins/main.js +62 -20
- package/dist/es2019/ui/drag-handle.js +26 -4
- package/dist/es2019/ui/drag-preview.js +21 -11
- package/dist/es2019/utils/getSelection.js +5 -1
- package/dist/esm/plugin.js +9 -8
- package/dist/esm/pm-plugins/decorations.js +6 -3
- package/dist/esm/pm-plugins/main.js +62 -20
- package/dist/esm/ui/drag-handle.js +39 -17
- package/dist/esm/ui/drag-preview.js +21 -11
- package/dist/esm/utils/getSelection.js +5 -1
- package/dist/types/pm-plugins/decorations.d.ts +2 -1
- package/dist/types/pm-plugins/main.d.ts +4 -1
- package/dist/types/types.d.ts +2 -0
- package/dist/types/ui/drag-handle.d.ts +12 -3
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +4 -1
- package/dist/types-ts4.5/types.d.ts +2 -0
- package/dist/types-ts4.5/ui/drag-handle.d.ts +12 -3
- package/package.json +20 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 1.5.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#119383](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/119383)
|
|
8
|
+
[`2db50d6540e1b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2db50d6540e1b) -
|
|
9
|
+
[ux] fix drag handles to respond to viewport narrowing
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 1.5.15
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#118866](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/118866)
|
|
17
|
+
[`77bd34b00632f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/77bd34b00632f) -
|
|
18
|
+
[ux] [ED-23873] Add tooltip to drag handle
|
|
19
|
+
|
|
20
|
+
## 1.5.14
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- [#119010](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/119010)
|
|
25
|
+
[`9853843dd0dc9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9853843dd0dc9) -
|
|
26
|
+
[ux] ED-23189 Update generic preview to match node dimensions
|
|
27
|
+
|
|
28
|
+
## 1.5.13
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- [#118724](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/118724)
|
|
33
|
+
[`6faf03a7723f3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6faf03a7723f3) -
|
|
34
|
+
[ED-23842] When clicking the drag handle, select mediaGroup if there are multiple child nodes
|
|
35
|
+
|
|
3
36
|
## 1.5.12
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -18,16 +18,17 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
18
18
|
pmPlugins: function pmPlugins() {
|
|
19
19
|
return [{
|
|
20
20
|
name: 'blockControlsPmPlugin',
|
|
21
|
-
plugin: function plugin() {
|
|
22
|
-
|
|
21
|
+
plugin: function plugin(_ref2) {
|
|
22
|
+
var getIntl = _ref2.getIntl;
|
|
23
|
+
return (0, _main.createPlugin)(api, getIntl);
|
|
23
24
|
}
|
|
24
25
|
}];
|
|
25
26
|
},
|
|
26
27
|
commands: {
|
|
27
28
|
moveNode: function moveNode(start, to) {
|
|
28
|
-
return function (
|
|
29
|
+
return function (_ref3) {
|
|
29
30
|
var _node$nodeSize, _api$analytics;
|
|
30
|
-
var tr =
|
|
31
|
+
var tr = _ref3.tr;
|
|
31
32
|
var node = tr.doc.nodeAt(start);
|
|
32
33
|
var resolvedNode = tr.doc.resolve(start);
|
|
33
34
|
if (!node) {
|
|
@@ -58,8 +59,8 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
58
59
|
};
|
|
59
60
|
},
|
|
60
61
|
showDragHandleAt: function showDragHandleAt(pos, anchorName, nodeType) {
|
|
61
|
-
return function (
|
|
62
|
-
var tr =
|
|
62
|
+
return function (_ref4) {
|
|
63
|
+
var tr = _ref4.tr;
|
|
63
64
|
tr.setMeta(_main.key, {
|
|
64
65
|
activeNode: {
|
|
65
66
|
pos: pos,
|
|
@@ -71,8 +72,8 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
71
72
|
};
|
|
72
73
|
},
|
|
73
74
|
setNodeDragged: function setNodeDragged(pos, anchorName, nodeType) {
|
|
74
|
-
return function (
|
|
75
|
-
var tr =
|
|
75
|
+
return function (_ref5) {
|
|
76
|
+
var tr = _ref5.tr;
|
|
76
77
|
if (pos === undefined) {
|
|
77
78
|
return tr;
|
|
78
79
|
}
|
|
@@ -8,6 +8,7 @@ exports.nodeDecorations = exports.mouseMoveWrapperDecorations = exports.emptyPar
|
|
|
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 _reactIntlNext = require("react-intl-next");
|
|
11
12
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
12
13
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _dragHandle = require("../ui/drag-handle");
|
|
@@ -135,7 +136,7 @@ var mouseMoveWrapperDecorations = exports.mouseMoveWrapperDecorations = function
|
|
|
135
136
|
});
|
|
136
137
|
return decs;
|
|
137
138
|
};
|
|
138
|
-
var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDecoration(pos, anchorName, nodeType, api) {
|
|
139
|
+
var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDecoration(pos, anchorName, nodeType, api, getIntl) {
|
|
139
140
|
return _view.Decoration.widget(pos, function (view, getPos) {
|
|
140
141
|
var element = document.createElement('div');
|
|
141
142
|
// Need to set it to inline to avoid text being split when merging two paragraphs
|
|
@@ -147,13 +148,15 @@ var dragHandleDecoration = exports.dragHandleDecoration = function dragHandleDec
|
|
|
147
148
|
// due to margins applied to other nodes eg. Headings
|
|
148
149
|
element.style.clear = 'unset';
|
|
149
150
|
}
|
|
150
|
-
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(
|
|
151
|
+
_reactDom.default.render( /*#__PURE__*/(0, _react.createElement)(_reactIntlNext.RawIntlProvider, {
|
|
152
|
+
value: getIntl()
|
|
153
|
+
}, /*#__PURE__*/(0, _react.createElement)(_dragHandle.DragHandle, {
|
|
151
154
|
view: view,
|
|
152
155
|
api: api,
|
|
153
156
|
getPos: getPos,
|
|
154
157
|
anchorName: anchorName,
|
|
155
158
|
nodeType: nodeType
|
|
156
|
-
}), element);
|
|
159
|
+
})), element);
|
|
157
160
|
return element;
|
|
158
161
|
}, {
|
|
159
162
|
side: -1,
|
|
@@ -77,12 +77,14 @@ var initialState = {
|
|
|
77
77
|
isDragging: false,
|
|
78
78
|
isMenuOpen: false,
|
|
79
79
|
editorHeight: 0,
|
|
80
|
+
editorWidthLeft: 0,
|
|
81
|
+
editorWidthRight: 0,
|
|
80
82
|
isResizerResizing: false,
|
|
81
83
|
isDocSizeLimitEnabled: null,
|
|
82
84
|
isPMDragging: false
|
|
83
85
|
};
|
|
84
86
|
var DRAG_AND_DROP_DOC_SIZE_LIMIT = 50;
|
|
85
|
-
var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
87
|
+
var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
86
88
|
return new _safePlugin.SafePlugin({
|
|
87
89
|
key: key,
|
|
88
90
|
state: {
|
|
@@ -90,9 +92,9 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
90
92
|
return initialState;
|
|
91
93
|
},
|
|
92
94
|
apply: function apply(tr, currentState, oldState, newState) {
|
|
93
|
-
var _meta$activeNode, _meta$activeNode2, _meta$isDragging, _meta$editorHeight, _meta$isPMDragging;
|
|
95
|
+
var _meta$activeNode, _meta$activeNode2, _meta$isDragging, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging;
|
|
94
96
|
if (initialState.isDocSizeLimitEnabled === null) {
|
|
95
|
-
if ((0, _platformFeatureFlags.
|
|
97
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-doc-size-limit_7k4vq')) {
|
|
96
98
|
initialState.isDocSizeLimitEnabled = true;
|
|
97
99
|
} else {
|
|
98
100
|
initialState.isDocSizeLimitEnabled = false;
|
|
@@ -106,6 +108,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
106
108
|
isMenuOpen = currentState.isMenuOpen,
|
|
107
109
|
decorationState = currentState.decorationState,
|
|
108
110
|
editorHeight = currentState.editorHeight,
|
|
111
|
+
editorWidthLeft = currentState.editorWidthLeft,
|
|
112
|
+
editorWidthRight = currentState.editorWidthRight,
|
|
109
113
|
isResizerResizing = currentState.isResizerResizing,
|
|
110
114
|
isDragging = currentState.isDragging,
|
|
111
115
|
isPMDragging = currentState.isPMDragging;
|
|
@@ -132,7 +136,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
132
136
|
}
|
|
133
137
|
var isDecsMissing = false;
|
|
134
138
|
var isHandleMissing = false;
|
|
135
|
-
if ((0, _platformFeatureFlags.
|
|
139
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
136
140
|
// Ensure decorations stay in sync when nodes are added or removed from the doc
|
|
137
141
|
isHandleMissing = !(meta !== null && meta !== void 0 && meta.activeNode) && !decorations.find().some(function (_ref6) {
|
|
138
142
|
var spec = _ref6.spec;
|
|
@@ -155,13 +159,13 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
155
159
|
// (when the table node rerenders)
|
|
156
160
|
// The activeNode is from the previous rendering cycle, and verify if they share the same anchor.
|
|
157
161
|
var maybeNodeWidthUpdated = (meta === null || meta === void 0 ? void 0 : meta.activeNode) && (meta === null || meta === void 0 || (_meta$activeNode = meta.activeNode) === null || _meta$activeNode === void 0 ? void 0 : _meta$activeNode.nodeType) === 'table' && meta.activeNode.anchorName === (activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName);
|
|
158
|
-
var redrawDecorations = decorations === _view.DecorationSet.empty || (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== editorHeight || maybeWidthUpdated || nodeCountChanged || maybeNodeWidthUpdated || resizerMeta === false || isDecsMissing || !!(meta !== null && meta !== void 0 && meta.nodeMoved) && tr.docChanged;
|
|
162
|
+
var redrawDecorations = decorations === _view.DecorationSet.empty || (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== editorHeight || (meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== editorWidthLeft || (meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== editorWidthRight || maybeWidthUpdated || nodeCountChanged || maybeNodeWidthUpdated || resizerMeta === false || isDecsMissing || !!(meta !== null && meta !== void 0 && meta.nodeMoved) && tr.docChanged;
|
|
159
163
|
|
|
160
164
|
// Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
|
|
161
165
|
if (redrawDecorations && !isResizerResizing && api) {
|
|
162
166
|
decorations = _view.DecorationSet.create(newState.doc, []);
|
|
163
167
|
var nodeDecs = (0, _decorations.nodeDecorations)(newState);
|
|
164
|
-
if ((0, _platformFeatureFlags.
|
|
168
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
165
169
|
decorations = decorations.add(newState.doc, (0, _toConsumableArray2.default)(nodeDecs));
|
|
166
170
|
} else {
|
|
167
171
|
var mouseWrapperDecs = (0, _decorations.mouseMoveWrapperDecorations)(newState, api);
|
|
@@ -191,7 +195,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
191
195
|
anchorName: anchorName
|
|
192
196
|
};
|
|
193
197
|
}
|
|
194
|
-
var draghandleDec = (0, _decorations.dragHandleDecoration)(activeNode.pos, anchorName, nodeType, api);
|
|
198
|
+
var draghandleDec = (0, _decorations.dragHandleDecoration)(activeNode.pos, anchorName, nodeType, api, getIntl);
|
|
195
199
|
decorations = decorations.add(newState.doc, [draghandleDec]);
|
|
196
200
|
}
|
|
197
201
|
}
|
|
@@ -203,10 +207,10 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
203
207
|
return spec.id === 'drag-handle';
|
|
204
208
|
});
|
|
205
209
|
decorations = decorations.remove(_oldHandle);
|
|
206
|
-
var decs = (0, _decorations.dragHandleDecoration)(meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, api);
|
|
210
|
+
var decs = (0, _decorations.dragHandleDecoration)(meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, api, getIntl);
|
|
207
211
|
decorations = decorations.add(newState.doc, [decs]);
|
|
208
212
|
}
|
|
209
|
-
if ((0, _platformFeatureFlags.
|
|
213
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-ed-23816')) {
|
|
210
214
|
var _activeNodeWithNewNod;
|
|
211
215
|
// Remove previous drag handle widget and draw new drag handle widget when node type changes
|
|
212
216
|
if (activeNodeWithNewNodeType && ((_activeNodeWithNewNod = activeNodeWithNewNodeType) === null || _activeNodeWithNewNod === void 0 ? void 0 : _activeNodeWithNewNod.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) && api) {
|
|
@@ -215,7 +219,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
215
219
|
return spec.id === 'drag-handle';
|
|
216
220
|
});
|
|
217
221
|
decorations = decorations.remove(_oldHandle2);
|
|
218
|
-
var _decs = (0, _decorations.dragHandleDecoration)(activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType, api);
|
|
222
|
+
var _decs = (0, _decorations.dragHandleDecoration)(activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType, api, getIntl);
|
|
219
223
|
decorations = decorations.add(newState.doc, [_decs]);
|
|
220
224
|
}
|
|
221
225
|
}
|
|
@@ -265,7 +269,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
265
269
|
|
|
266
270
|
// Map active node position when the document changes
|
|
267
271
|
var mappedActiveNodePos;
|
|
268
|
-
if ((0, _platformFeatureFlags.
|
|
272
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-ed-23816')) {
|
|
269
273
|
mappedActiveNodePos = tr.docChanged && activeNode ? activeNodeWithNewNodeType || {
|
|
270
274
|
pos: tr.mapping.map(activeNode.pos),
|
|
271
275
|
anchorName: activeNode.anchorName,
|
|
@@ -285,6 +289,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
285
289
|
isDragging: (_meta$isDragging = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging !== void 0 ? _meta$isDragging : isDragging,
|
|
286
290
|
isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
|
|
287
291
|
editorHeight: (_meta$editorHeight = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight !== void 0 ? _meta$editorHeight : currentState.editorHeight,
|
|
292
|
+
editorWidthLeft: (_meta$editorWidthLeft = meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== null && _meta$editorWidthLeft !== void 0 ? _meta$editorWidthLeft : currentState.editorWidthLeft,
|
|
293
|
+
editorWidthRight: (_meta$editorWidthRigh = meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== null && _meta$editorWidthRigh !== void 0 ? _meta$editorWidthRigh : currentState.editorWidthRight,
|
|
288
294
|
isResizerResizing: isResizerResizing,
|
|
289
295
|
isDocSizeLimitEnabled: initialState.isDocSizeLimitEnabled,
|
|
290
296
|
isPMDragging: (_meta$isPMDragging = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging !== void 0 ? _meta$isPMDragging : isPMDragging
|
|
@@ -322,7 +328,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
322
328
|
var draggable = dragging === null || dragging === void 0 ? void 0 : dragging.slice.content.firstChild;
|
|
323
329
|
var activeNode = state.tr.doc.nodeAt(pluginState.activeNode.pos);
|
|
324
330
|
var isSameNode = draggable === activeNode;
|
|
325
|
-
if ((0, _platformFeatureFlags.
|
|
331
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-ed-23892')) {
|
|
326
332
|
var _event$target;
|
|
327
333
|
var nodeElement = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.closest('[data-drag-handler-anchor-name]');
|
|
328
334
|
if (!nodeElement) {
|
|
@@ -354,7 +360,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
354
360
|
}
|
|
355
361
|
},
|
|
356
362
|
mouseover: function mouseover(view, event) {
|
|
357
|
-
if ((0, _platformFeatureFlags.
|
|
363
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
358
364
|
(0, _handleMouseOver.handleMouseOver)(view, event, api);
|
|
359
365
|
}
|
|
360
366
|
return false;
|
|
@@ -379,10 +385,12 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
379
385
|
},
|
|
380
386
|
view: function view(editorView) {
|
|
381
387
|
var dom = editorView.dom;
|
|
382
|
-
var
|
|
383
|
-
|
|
388
|
+
var editorContentArea = editorView.dom.closest('.fabric-editor-popup-scroll-parent');
|
|
389
|
+
var resizeObserverHeight;
|
|
390
|
+
var resizeObserverWidth;
|
|
391
|
+
if (!(0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
384
392
|
// Use ResizeObserver to observe height changes
|
|
385
|
-
|
|
393
|
+
resizeObserverHeight = new ResizeObserver((0, _rafSchd.default)(function (entries) {
|
|
386
394
|
var editorHeight = entries[0].contentBoxSize[0].blockSize;
|
|
387
395
|
|
|
388
396
|
// Update the plugin state when the height changes
|
|
@@ -401,16 +409,50 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
401
409
|
editorView.dispatch(transaction);
|
|
402
410
|
}
|
|
403
411
|
}));
|
|
412
|
+
|
|
404
413
|
// Start observing the editor DOM element
|
|
405
|
-
|
|
414
|
+
resizeObserverHeight.observe(dom);
|
|
415
|
+
}
|
|
416
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
417
|
+
// Use ResizeObserver to observe width changes
|
|
418
|
+
resizeObserverWidth = new ResizeObserver((0, _rafSchd.default)(function (entries) {
|
|
419
|
+
var editorContentArea = entries[0].target;
|
|
420
|
+
var editorWidthRight = editorContentArea.getBoundingClientRect().right;
|
|
421
|
+
var editorWidthLeft = editorContentArea.getBoundingClientRect().left;
|
|
422
|
+
|
|
423
|
+
// Update the plugin state when the height changes
|
|
424
|
+
var pluginState = key.getState(editorView.state);
|
|
425
|
+
if (!(pluginState !== null && pluginState !== void 0 && pluginState.isDragging)) {
|
|
426
|
+
var isResizerResizing = !!dom.querySelector('.is-resizing');
|
|
427
|
+
var transaction = editorView.state.tr;
|
|
428
|
+
if ((pluginState === null || pluginState === void 0 ? void 0 : pluginState.isResizerResizing) !== isResizerResizing) {
|
|
429
|
+
transaction.setMeta('is-resizer-resizing', isResizerResizing);
|
|
430
|
+
}
|
|
431
|
+
if (!isResizerResizing) {
|
|
432
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_elements_drag_and_drop_ed_23394')) {
|
|
433
|
+
transaction.setMeta(key, {
|
|
434
|
+
editorWidthLeft: editorWidthLeft,
|
|
435
|
+
editorWidthRight: editorWidthRight
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
editorView.dispatch(transaction);
|
|
440
|
+
}
|
|
441
|
+
}));
|
|
442
|
+
if (editorContentArea && (0, _platformFeatureFlags.fg)('platform_editor_elements_drag_and_drop_ed_23394')) {
|
|
443
|
+
resizeObserverWidth.observe(editorContentArea);
|
|
444
|
+
}
|
|
406
445
|
}
|
|
407
446
|
|
|
408
447
|
// Start pragmatic monitors
|
|
409
448
|
var pragmaticCleanup = destroyFn(api);
|
|
410
449
|
return {
|
|
411
450
|
destroy: function destroy() {
|
|
412
|
-
if (!(0, _platformFeatureFlags.
|
|
413
|
-
|
|
451
|
+
if (!(0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
452
|
+
resizeObserverHeight.unobserve(dom);
|
|
453
|
+
}
|
|
454
|
+
if (editorContentArea && (0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
455
|
+
(0, _platformFeatureFlags.fg)('platform_editor_elements_drag_and_drop_ed_23394') && resizeObserverWidth.unobserve(editorContentArea);
|
|
414
456
|
}
|
|
415
457
|
pragmaticCleanup();
|
|
416
458
|
}
|
|
@@ -8,13 +8,17 @@ exports.DragHandle = void 0;
|
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
var _react2 = require("@emotion/react");
|
|
11
|
+
var _reactIntlNext = require("react-intl-next");
|
|
11
12
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
13
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
14
|
+
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
15
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
16
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
17
|
var _dragHandler = _interopRequireDefault(require("@atlaskit/icon/glyph/drag-handler"));
|
|
15
18
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
19
|
var _adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
17
20
|
var _setCustomNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview");
|
|
21
|
+
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
18
22
|
var _main = require("../pm-plugins/main");
|
|
19
23
|
var _utils = require("../utils");
|
|
20
24
|
var _dragHandlePositions = require("../utils/drag-handle-positions");
|
|
@@ -55,12 +59,13 @@ var selectedStyles = (0, _react2.css)({
|
|
|
55
59
|
backgroundColor: "var(--ds-background-selected, #E9F2FF)",
|
|
56
60
|
color: "var(--ds-icon-selected, #0C66E4)"
|
|
57
61
|
});
|
|
58
|
-
var
|
|
62
|
+
var DragHandleInternal = function DragHandleInternal(_ref) {
|
|
59
63
|
var view = _ref.view,
|
|
60
64
|
api = _ref.api,
|
|
61
65
|
getPos = _ref.getPos,
|
|
62
66
|
anchorName = _ref.anchorName,
|
|
63
|
-
nodeType = _ref.nodeType
|
|
67
|
+
nodeType = _ref.nodeType,
|
|
68
|
+
formatMessage = _ref.intl.formatMessage;
|
|
64
69
|
var start = getPos();
|
|
65
70
|
var buttonRef = (0, _react.useRef)(null);
|
|
66
71
|
var _useState = (0, _react.useState)(768),
|
|
@@ -255,18 +260,35 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
255
260
|
top: (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_ed_23674') ? (0, _dragHandlePositions.getTopPosition)(dom, nodeType) : (0, _dragHandlePositions.getTopPosition)(dom)
|
|
256
261
|
};
|
|
257
262
|
}, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates]);
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
263
|
+
var helpDescriptors = [{
|
|
264
|
+
description: formatMessage(_messages.blockControlsMessages.dragToMove)
|
|
265
|
+
}, {
|
|
266
|
+
description: formatMessage(_messages.blockControlsMessages.moveUp),
|
|
267
|
+
keymap: _keymaps.dragToMoveUp
|
|
268
|
+
}, {
|
|
269
|
+
description: formatMessage(_messages.blockControlsMessages.moveDown),
|
|
270
|
+
keymap: _keymaps.dragToMoveDown
|
|
271
|
+
}];
|
|
272
|
+
var renderButton = function renderButton() {
|
|
273
|
+
return (0, _react2.jsx)("button", {
|
|
274
|
+
type: "button",
|
|
275
|
+
css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
|
|
276
|
+
ref: buttonRef
|
|
277
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
278
|
+
,
|
|
279
|
+
style: positionStyles,
|
|
280
|
+
onClick: handleOnClick,
|
|
281
|
+
onMouseDown: (0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2') ? handleMouseDownWrapperRemoved : handleMouseDown,
|
|
282
|
+
"data-testid": "block-ctrl-drag-handle"
|
|
283
|
+
}, (0, _react2.jsx)(_dragHandler.default, {
|
|
284
|
+
label: "",
|
|
285
|
+
size: "medium"
|
|
286
|
+
}));
|
|
287
|
+
};
|
|
288
|
+
return (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873') ? (0, _react2.jsx)(_tooltip.default, {
|
|
289
|
+
content: (0, _react2.jsx)(_keymaps.TooltipContentWithMultipleShortcuts, {
|
|
290
|
+
helpDescriptors: helpDescriptors
|
|
291
|
+
})
|
|
292
|
+
}, renderButton()) : renderButton();
|
|
293
|
+
};
|
|
294
|
+
var DragHandle = exports.DragHandle = (0, _reactIntlNext.injectIntl)(DragHandleInternal);
|
|
@@ -7,26 +7,36 @@ exports.dragPreview = void 0;
|
|
|
7
7
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
8
|
var _colors = require("@atlaskit/theme/colors");
|
|
9
9
|
var previewStyle = {
|
|
10
|
-
borderColor: "var(--ds-border-focused, ".concat(_colors.B200, ")"),
|
|
10
|
+
borderColor: (0, _platformFeatureFlags.fg)('platform_editor_elements_drag_and_drop_ed_23189') ? "var(--ds-border, ".concat(_colors.N30, ")") : "var(--ds-border-focused, ".concat(_colors.B200, ")"),
|
|
11
11
|
borderStyle: 'solid',
|
|
12
12
|
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
13
13
|
borderWidth: "var(--ds-border-width-outline, 2px)",
|
|
14
|
-
backgroundColor: "var(--ds-blanket-selected, #388BFF14)"
|
|
14
|
+
backgroundColor: (0, _platformFeatureFlags.fg)('platform_editor_elements_drag_and_drop_ed_23189') ? "var(--ds-skeleton-subtle, ".concat(_colors.N20, ")") : "var(--ds-blanket-selected, #388BFF14)"
|
|
15
15
|
};
|
|
16
16
|
var dragPreview = exports.dragPreview = function dragPreview(container, dom, nodeType) {
|
|
17
|
-
var
|
|
18
|
-
container.style.width = "".concat(rect.width, "px");
|
|
19
|
-
container.style.height = "".concat(rect.height, "px");
|
|
17
|
+
var nodeContainer = dom;
|
|
20
18
|
container.style.pointerEvents = 'none';
|
|
21
19
|
var parent = document.createElement('div');
|
|
22
20
|
// ProseMirror class is required to make sure the cloned dom is styled correctly
|
|
23
21
|
parent.classList.add('ProseMirror');
|
|
24
|
-
if ((0, _platformFeatureFlags.
|
|
22
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
25
23
|
parent.classList.add('block-ctrl-drag-preview');
|
|
26
24
|
}
|
|
27
|
-
var shouldBeGenericPreview = nodeType === 'embedCard' || nodeType === 'extension';
|
|
28
25
|
var embedCard = dom.querySelector('.embedCardView-content-wrap');
|
|
29
|
-
|
|
26
|
+
var shouldBeGenericPreview = nodeType === 'embedCard' || nodeType === 'extension' || !!embedCard;
|
|
27
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_elements_drag_and_drop_ed_23189')) {
|
|
28
|
+
var iframeContainer = dom.querySelector('iframe');
|
|
29
|
+
if (nodeType === 'embedCard') {
|
|
30
|
+
nodeContainer = dom.querySelector('.rich-media-item') || dom;
|
|
31
|
+
} else if (nodeType === 'extension' && iframeContainer) {
|
|
32
|
+
nodeContainer = iframeContainer;
|
|
33
|
+
}
|
|
34
|
+
shouldBeGenericPreview = nodeType === 'embedCard' || !!embedCard || nodeType === 'extension' && !!iframeContainer;
|
|
35
|
+
}
|
|
36
|
+
var nodeContainerRect = nodeContainer.getBoundingClientRect();
|
|
37
|
+
container.style.width = "".concat(nodeContainerRect.width, "px");
|
|
38
|
+
container.style.height = "".concat(nodeContainerRect.height, "px");
|
|
39
|
+
if (shouldBeGenericPreview) {
|
|
30
40
|
parent.style.border = "".concat(previewStyle.borderWidth, " ").concat(previewStyle.borderStyle, " ").concat(previewStyle.borderColor);
|
|
31
41
|
parent.style.borderRadius = previewStyle.borderRadius;
|
|
32
42
|
parent.style.backgroundColor = previewStyle.backgroundColor;
|
|
@@ -41,8 +51,8 @@ var dragPreview = exports.dragPreview = function dragPreview(container, dom, nod
|
|
|
41
51
|
clonedDom.style.marginTop = '0';
|
|
42
52
|
clonedDom.style.marginRight = '0';
|
|
43
53
|
clonedDom.style.marginBottom = '0';
|
|
44
|
-
clonedDom.style.opacity = '0.4';
|
|
45
54
|
clonedDom.style.boxShadow = 'none';
|
|
55
|
+
clonedDom.style.opacity = (0, _platformFeatureFlags.fg)('platform_editor_elements_drag_and_drop_ed_23189') ? '0.31' : '0.4';
|
|
46
56
|
parent.appendChild(clonedDom);
|
|
47
57
|
}
|
|
48
58
|
container.appendChild(parent);
|
|
@@ -16,10 +16,14 @@ var getSelection = exports.getSelection = function getSelection(tr, start) {
|
|
|
16
16
|
// decisionList node is not selectable, but we want to select the whole node not just text
|
|
17
17
|
if (isNodeSelection || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
|
|
18
18
|
return new _state.NodeSelection($startPos);
|
|
19
|
-
// TODO: support multiple nodes selection
|
|
20
19
|
} else if ((node === null || node === void 0 ? void 0 : node.type.name) === 'mediaGroup' && node.childCount === 1) {
|
|
21
20
|
var $mediaStartPos = tr.doc.resolve(start + 1);
|
|
22
21
|
return new _state.NodeSelection($mediaStartPos);
|
|
22
|
+
} else if (
|
|
23
|
+
// Even though mediaGroup is not selectable,
|
|
24
|
+
// we need a quick way to make all child media nodes appear as selected without the need for a custom selection
|
|
25
|
+
(node === null || node === void 0 ? void 0 : node.type.name) === 'mediaGroup' && (0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23842')) {
|
|
26
|
+
return new _state.NodeSelection($startPos);
|
|
23
27
|
} else {
|
|
24
28
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
25
29
|
// Find the first inline node in the node
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
|
+
import { RawIntlProvider } from 'react-intl-next';
|
|
3
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { DragHandle } from '../ui/drag-handle';
|
|
@@ -129,7 +130,7 @@ export const mouseMoveWrapperDecorations = (newState, api) => {
|
|
|
129
130
|
});
|
|
130
131
|
return decs;
|
|
131
132
|
};
|
|
132
|
-
export const dragHandleDecoration = (pos, anchorName, nodeType, api) => {
|
|
133
|
+
export const dragHandleDecoration = (pos, anchorName, nodeType, api, getIntl) => {
|
|
133
134
|
return Decoration.widget(pos, (view, getPos) => {
|
|
134
135
|
const element = document.createElement('div');
|
|
135
136
|
// Need to set it to inline to avoid text being split when merging two paragraphs
|
|
@@ -141,13 +142,15 @@ export const dragHandleDecoration = (pos, anchorName, nodeType, api) => {
|
|
|
141
142
|
// due to margins applied to other nodes eg. Headings
|
|
142
143
|
element.style.clear = 'unset';
|
|
143
144
|
}
|
|
144
|
-
ReactDOM.render( /*#__PURE__*/createElement(
|
|
145
|
+
ReactDOM.render( /*#__PURE__*/createElement(RawIntlProvider, {
|
|
146
|
+
value: getIntl()
|
|
147
|
+
}, /*#__PURE__*/createElement(DragHandle, {
|
|
145
148
|
view,
|
|
146
149
|
api,
|
|
147
150
|
getPos,
|
|
148
151
|
anchorName,
|
|
149
152
|
nodeType
|
|
150
|
-
}), element);
|
|
153
|
+
})), element);
|
|
151
154
|
return element;
|
|
152
155
|
}, {
|
|
153
156
|
side: -1,
|