@atlaskit/editor-plugin-block-controls 1.5.12 → 1.5.15
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 +24 -0
- package/dist/cjs/plugin.js +9 -8
- package/dist/cjs/pm-plugins/decorations.js +6 -3
- package/dist/cjs/pm-plugins/main.js +13 -13
- 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 +14 -14
- 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 +14 -14
- 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 +2 -1
- 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 +2 -1
- package/dist/types-ts4.5/ui/drag-handle.d.ts +12 -3
- package/package.json +16 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 1.5.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#118866](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/118866)
|
|
8
|
+
[`77bd34b00632f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/77bd34b00632f) -
|
|
9
|
+
[ux] [ED-23873] Add tooltip to drag handle
|
|
10
|
+
|
|
11
|
+
## 1.5.14
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#119010](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/119010)
|
|
16
|
+
[`9853843dd0dc9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9853843dd0dc9) -
|
|
17
|
+
[ux] ED-23189 Update generic preview to match node dimensions
|
|
18
|
+
|
|
19
|
+
## 1.5.13
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#118724](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/118724)
|
|
24
|
+
[`6faf03a7723f3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6faf03a7723f3) -
|
|
25
|
+
[ED-23842] When clicking the drag handle, select mediaGroup if there are multiple child nodes
|
|
26
|
+
|
|
3
27
|
## 1.5.12
|
|
4
28
|
|
|
5
29
|
### 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,
|
|
@@ -82,7 +82,7 @@ var initialState = {
|
|
|
82
82
|
isPMDragging: false
|
|
83
83
|
};
|
|
84
84
|
var DRAG_AND_DROP_DOC_SIZE_LIMIT = 50;
|
|
85
|
-
var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
85
|
+
var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
86
86
|
return new _safePlugin.SafePlugin({
|
|
87
87
|
key: key,
|
|
88
88
|
state: {
|
|
@@ -92,7 +92,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
92
92
|
apply: function apply(tr, currentState, oldState, newState) {
|
|
93
93
|
var _meta$activeNode, _meta$activeNode2, _meta$isDragging, _meta$editorHeight, _meta$isPMDragging;
|
|
94
94
|
if (initialState.isDocSizeLimitEnabled === null) {
|
|
95
|
-
if ((0, _platformFeatureFlags.
|
|
95
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-doc-size-limit_7k4vq')) {
|
|
96
96
|
initialState.isDocSizeLimitEnabled = true;
|
|
97
97
|
} else {
|
|
98
98
|
initialState.isDocSizeLimitEnabled = false;
|
|
@@ -132,7 +132,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
132
132
|
}
|
|
133
133
|
var isDecsMissing = false;
|
|
134
134
|
var isHandleMissing = false;
|
|
135
|
-
if ((0, _platformFeatureFlags.
|
|
135
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
136
136
|
// Ensure decorations stay in sync when nodes are added or removed from the doc
|
|
137
137
|
isHandleMissing = !(meta !== null && meta !== void 0 && meta.activeNode) && !decorations.find().some(function (_ref6) {
|
|
138
138
|
var spec = _ref6.spec;
|
|
@@ -161,7 +161,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
161
161
|
if (redrawDecorations && !isResizerResizing && api) {
|
|
162
162
|
decorations = _view.DecorationSet.create(newState.doc, []);
|
|
163
163
|
var nodeDecs = (0, _decorations.nodeDecorations)(newState);
|
|
164
|
-
if ((0, _platformFeatureFlags.
|
|
164
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
165
165
|
decorations = decorations.add(newState.doc, (0, _toConsumableArray2.default)(nodeDecs));
|
|
166
166
|
} else {
|
|
167
167
|
var mouseWrapperDecs = (0, _decorations.mouseMoveWrapperDecorations)(newState, api);
|
|
@@ -191,7 +191,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
191
191
|
anchorName: anchorName
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
|
-
var draghandleDec = (0, _decorations.dragHandleDecoration)(activeNode.pos, anchorName, nodeType, api);
|
|
194
|
+
var draghandleDec = (0, _decorations.dragHandleDecoration)(activeNode.pos, anchorName, nodeType, api, getIntl);
|
|
195
195
|
decorations = decorations.add(newState.doc, [draghandleDec]);
|
|
196
196
|
}
|
|
197
197
|
}
|
|
@@ -203,10 +203,10 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
203
203
|
return spec.id === 'drag-handle';
|
|
204
204
|
});
|
|
205
205
|
decorations = decorations.remove(_oldHandle);
|
|
206
|
-
var decs = (0, _decorations.dragHandleDecoration)(meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, api);
|
|
206
|
+
var decs = (0, _decorations.dragHandleDecoration)(meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, api, getIntl);
|
|
207
207
|
decorations = decorations.add(newState.doc, [decs]);
|
|
208
208
|
}
|
|
209
|
-
if ((0, _platformFeatureFlags.
|
|
209
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-ed-23816')) {
|
|
210
210
|
var _activeNodeWithNewNod;
|
|
211
211
|
// Remove previous drag handle widget and draw new drag handle widget when node type changes
|
|
212
212
|
if (activeNodeWithNewNodeType && ((_activeNodeWithNewNod = activeNodeWithNewNodeType) === null || _activeNodeWithNewNod === void 0 ? void 0 : _activeNodeWithNewNod.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) && api) {
|
|
@@ -215,7 +215,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
215
215
|
return spec.id === 'drag-handle';
|
|
216
216
|
});
|
|
217
217
|
decorations = decorations.remove(_oldHandle2);
|
|
218
|
-
var _decs = (0, _decorations.dragHandleDecoration)(activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType, api);
|
|
218
|
+
var _decs = (0, _decorations.dragHandleDecoration)(activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType, api, getIntl);
|
|
219
219
|
decorations = decorations.add(newState.doc, [_decs]);
|
|
220
220
|
}
|
|
221
221
|
}
|
|
@@ -265,7 +265,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
265
265
|
|
|
266
266
|
// Map active node position when the document changes
|
|
267
267
|
var mappedActiveNodePos;
|
|
268
|
-
if ((0, _platformFeatureFlags.
|
|
268
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-ed-23816')) {
|
|
269
269
|
mappedActiveNodePos = tr.docChanged && activeNode ? activeNodeWithNewNodeType || {
|
|
270
270
|
pos: tr.mapping.map(activeNode.pos),
|
|
271
271
|
anchorName: activeNode.anchorName,
|
|
@@ -322,7 +322,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
322
322
|
var draggable = dragging === null || dragging === void 0 ? void 0 : dragging.slice.content.firstChild;
|
|
323
323
|
var activeNode = state.tr.doc.nodeAt(pluginState.activeNode.pos);
|
|
324
324
|
var isSameNode = draggable === activeNode;
|
|
325
|
-
if ((0, _platformFeatureFlags.
|
|
325
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-ed-23892')) {
|
|
326
326
|
var _event$target;
|
|
327
327
|
var nodeElement = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.closest('[data-drag-handler-anchor-name]');
|
|
328
328
|
if (!nodeElement) {
|
|
@@ -354,7 +354,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
354
354
|
}
|
|
355
355
|
},
|
|
356
356
|
mouseover: function mouseover(view, event) {
|
|
357
|
-
if ((0, _platformFeatureFlags.
|
|
357
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
358
358
|
(0, _handleMouseOver.handleMouseOver)(view, event, api);
|
|
359
359
|
}
|
|
360
360
|
return false;
|
|
@@ -380,7 +380,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
380
380
|
view: function view(editorView) {
|
|
381
381
|
var dom = editorView.dom;
|
|
382
382
|
var resizeObserver;
|
|
383
|
-
if (!(0, _platformFeatureFlags.
|
|
383
|
+
if (!(0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
384
384
|
// Use ResizeObserver to observe height changes
|
|
385
385
|
resizeObserver = new ResizeObserver((0, _rafSchd.default)(function (entries) {
|
|
386
386
|
var editorHeight = entries[0].contentBoxSize[0].blockSize;
|
|
@@ -409,7 +409,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
409
409
|
var pragmaticCleanup = destroyFn(api);
|
|
410
410
|
return {
|
|
411
411
|
destroy: function destroy() {
|
|
412
|
-
if (!(0, _platformFeatureFlags.
|
|
412
|
+
if (!(0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
413
413
|
resizeObserver.unobserve(dom);
|
|
414
414
|
}
|
|
415
415
|
pragmaticCleanup();
|
|
@@ -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,
|
|
@@ -5,7 +5,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
5
5
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
-
import {
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
|
|
10
10
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
11
11
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
@@ -76,7 +76,7 @@ const initialState = {
|
|
|
76
76
|
isPMDragging: false
|
|
77
77
|
};
|
|
78
78
|
const DRAG_AND_DROP_DOC_SIZE_LIMIT = 50;
|
|
79
|
-
export const createPlugin = api => {
|
|
79
|
+
export const createPlugin = (api, getIntl) => {
|
|
80
80
|
return new SafePlugin({
|
|
81
81
|
key,
|
|
82
82
|
state: {
|
|
@@ -86,7 +86,7 @@ export const createPlugin = api => {
|
|
|
86
86
|
apply(tr, currentState, oldState, newState) {
|
|
87
87
|
var _meta$activeNode, _meta$activeNode2, _meta$isDragging, _meta$editorHeight, _meta$isPMDragging;
|
|
88
88
|
if (initialState.isDocSizeLimitEnabled === null) {
|
|
89
|
-
if (
|
|
89
|
+
if (fg('platform.editor.elements.drag-and-drop-doc-size-limit_7k4vq')) {
|
|
90
90
|
initialState.isDocSizeLimitEnabled = true;
|
|
91
91
|
} else {
|
|
92
92
|
initialState.isDocSizeLimitEnabled = false;
|
|
@@ -125,7 +125,7 @@ export const createPlugin = api => {
|
|
|
125
125
|
}
|
|
126
126
|
let isDecsMissing = false;
|
|
127
127
|
let isHandleMissing = false;
|
|
128
|
-
if (
|
|
128
|
+
if (fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
129
129
|
// Ensure decorations stay in sync when nodes are added or removed from the doc
|
|
130
130
|
isHandleMissing = !(meta !== null && meta !== void 0 && meta.activeNode) && !decorations.find().some(({
|
|
131
131
|
spec
|
|
@@ -152,7 +152,7 @@ export const createPlugin = api => {
|
|
|
152
152
|
if (redrawDecorations && !isResizerResizing && api) {
|
|
153
153
|
decorations = DecorationSet.create(newState.doc, []);
|
|
154
154
|
const nodeDecs = nodeDecorations(newState);
|
|
155
|
-
if (
|
|
155
|
+
if (fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
156
156
|
decorations = decorations.add(newState.doc, [...nodeDecs]);
|
|
157
157
|
} else {
|
|
158
158
|
const mouseWrapperDecs = mouseMoveWrapperDecorations(newState, api);
|
|
@@ -182,7 +182,7 @@ export const createPlugin = api => {
|
|
|
182
182
|
anchorName
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
|
-
const draghandleDec = dragHandleDecoration(activeNode.pos, anchorName, nodeType, api);
|
|
185
|
+
const draghandleDec = dragHandleDecoration(activeNode.pos, anchorName, nodeType, api, getIntl);
|
|
186
186
|
decorations = decorations.add(newState.doc, [draghandleDec]);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
@@ -193,10 +193,10 @@ export const createPlugin = api => {
|
|
|
193
193
|
spec
|
|
194
194
|
}) => spec.id === 'drag-handle');
|
|
195
195
|
decorations = decorations.remove(oldHandle);
|
|
196
|
-
const decs = dragHandleDecoration(meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, api);
|
|
196
|
+
const decs = dragHandleDecoration(meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, api, getIntl);
|
|
197
197
|
decorations = decorations.add(newState.doc, [decs]);
|
|
198
198
|
}
|
|
199
|
-
if (
|
|
199
|
+
if (fg('platform.editor.elements.drag-and-drop-ed-23816')) {
|
|
200
200
|
var _activeNodeWithNewNod;
|
|
201
201
|
// Remove previous drag handle widget and draw new drag handle widget when node type changes
|
|
202
202
|
if (activeNodeWithNewNodeType && ((_activeNodeWithNewNod = activeNodeWithNewNodeType) === null || _activeNodeWithNewNod === void 0 ? void 0 : _activeNodeWithNewNod.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) && api) {
|
|
@@ -204,7 +204,7 @@ export const createPlugin = api => {
|
|
|
204
204
|
spec
|
|
205
205
|
}) => spec.id === 'drag-handle');
|
|
206
206
|
decorations = decorations.remove(oldHandle);
|
|
207
|
-
const decs = dragHandleDecoration(activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType, api);
|
|
207
|
+
const decs = dragHandleDecoration(activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType, api, getIntl);
|
|
208
208
|
decorations = decorations.add(newState.doc, [decs]);
|
|
209
209
|
}
|
|
210
210
|
}
|
|
@@ -254,7 +254,7 @@ export const createPlugin = api => {
|
|
|
254
254
|
|
|
255
255
|
// Map active node position when the document changes
|
|
256
256
|
let mappedActiveNodePos;
|
|
257
|
-
if (
|
|
257
|
+
if (fg('platform.editor.elements.drag-and-drop-ed-23816')) {
|
|
258
258
|
mappedActiveNodePos = tr.docChanged && activeNode ? activeNodeWithNewNodeType || {
|
|
259
259
|
pos: tr.mapping.map(activeNode.pos),
|
|
260
260
|
anchorName: activeNode.anchorName,
|
|
@@ -313,7 +313,7 @@ export const createPlugin = api => {
|
|
|
313
313
|
const draggable = dragging === null || dragging === void 0 ? void 0 : dragging.slice.content.firstChild;
|
|
314
314
|
const activeNode = state.tr.doc.nodeAt(pluginState.activeNode.pos);
|
|
315
315
|
let isSameNode = draggable === activeNode;
|
|
316
|
-
if (
|
|
316
|
+
if (fg('platform.editor.elements.drag-and-drop-ed-23892')) {
|
|
317
317
|
var _event$target;
|
|
318
318
|
const nodeElement = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.closest('[data-drag-handler-anchor-name]');
|
|
319
319
|
if (!nodeElement) {
|
|
@@ -347,7 +347,7 @@ export const createPlugin = api => {
|
|
|
347
347
|
}
|
|
348
348
|
},
|
|
349
349
|
mouseover: (view, event) => {
|
|
350
|
-
if (
|
|
350
|
+
if (fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
351
351
|
handleMouseOver(view, event, api);
|
|
352
352
|
}
|
|
353
353
|
return false;
|
|
@@ -374,7 +374,7 @@ export const createPlugin = api => {
|
|
|
374
374
|
view: editorView => {
|
|
375
375
|
const dom = editorView.dom;
|
|
376
376
|
let resizeObserver;
|
|
377
|
-
if (!
|
|
377
|
+
if (!fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
378
378
|
// Use ResizeObserver to observe height changes
|
|
379
379
|
resizeObserver = new ResizeObserver(rafSchedule(entries => {
|
|
380
380
|
const editorHeight = entries[0].contentBoxSize[0].blockSize;
|
|
@@ -403,7 +403,7 @@ export const createPlugin = api => {
|
|
|
403
403
|
const pragmaticCleanup = destroyFn(api);
|
|
404
404
|
return {
|
|
405
405
|
destroy() {
|
|
406
|
-
if (!
|
|
406
|
+
if (!fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
407
407
|
resizeObserver.unobserve(dom);
|
|
408
408
|
}
|
|
409
409
|
pragmaticCleanup();
|
|
@@ -3,13 +3,17 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
3
3
|
|
|
4
4
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
5
5
|
import { css, jsx } from '@emotion/react';
|
|
6
|
+
import { injectIntl } from 'react-intl-next';
|
|
6
7
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
7
8
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
9
|
+
import { dragToMoveDown, dragToMoveUp, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
|
|
10
|
+
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
8
11
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
12
|
import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
|
|
10
13
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
14
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
12
15
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
|
|
16
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
13
17
|
import { key } from '../pm-plugins/main';
|
|
14
18
|
import { selectNode } from '../utils';
|
|
15
19
|
import { getLeftPosition, getTopPosition } from '../utils/drag-handle-positions';
|
|
@@ -46,12 +50,15 @@ const selectedStyles = css({
|
|
|
46
50
|
backgroundColor: "var(--ds-background-selected, #E9F2FF)",
|
|
47
51
|
color: "var(--ds-icon-selected, #0C66E4)"
|
|
48
52
|
});
|
|
49
|
-
|
|
53
|
+
const DragHandleInternal = ({
|
|
50
54
|
view,
|
|
51
55
|
api,
|
|
52
56
|
getPos,
|
|
53
57
|
anchorName,
|
|
54
|
-
nodeType
|
|
58
|
+
nodeType,
|
|
59
|
+
intl: {
|
|
60
|
+
formatMessage
|
|
61
|
+
}
|
|
55
62
|
}) => {
|
|
56
63
|
const start = getPos();
|
|
57
64
|
const buttonRef = useRef(null);
|
|
@@ -244,7 +251,16 @@ export const DragHandle = ({
|
|
|
244
251
|
top: fg('platform_editor_elements_dnd_ed_23674') ? getTopPosition(dom, nodeType) : getTopPosition(dom)
|
|
245
252
|
};
|
|
246
253
|
}, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates]);
|
|
247
|
-
|
|
254
|
+
const helpDescriptors = [{
|
|
255
|
+
description: formatMessage(blockControlsMessages.dragToMove)
|
|
256
|
+
}, {
|
|
257
|
+
description: formatMessage(blockControlsMessages.moveUp),
|
|
258
|
+
keymap: dragToMoveUp
|
|
259
|
+
}, {
|
|
260
|
+
description: formatMessage(blockControlsMessages.moveDown),
|
|
261
|
+
keymap: dragToMoveDown
|
|
262
|
+
}];
|
|
263
|
+
const renderButton = () => jsx("button", {
|
|
248
264
|
type: "button",
|
|
249
265
|
css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
|
|
250
266
|
ref: buttonRef
|
|
@@ -258,4 +274,10 @@ export const DragHandle = ({
|
|
|
258
274
|
label: "",
|
|
259
275
|
size: "medium"
|
|
260
276
|
}));
|
|
261
|
-
|
|
277
|
+
return fg('platform_editor_element_drag_and_drop_ed_23873') ? jsx(Tooltip, {
|
|
278
|
+
content: jsx(TooltipContentWithMultipleShortcuts, {
|
|
279
|
+
helpDescriptors: helpDescriptors
|
|
280
|
+
})
|
|
281
|
+
}, renderButton()) : renderButton();
|
|
282
|
+
};
|
|
283
|
+
export const DragHandle = injectIntl(DragHandleInternal);
|
|
@@ -1,26 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B200 } from '@atlaskit/theme/colors';
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
import { B200, N20, N30 } from '@atlaskit/theme/colors';
|
|
3
3
|
const previewStyle = {
|
|
4
|
-
borderColor: `var(--ds-border-focused, ${B200})`,
|
|
4
|
+
borderColor: fg('platform_editor_elements_drag_and_drop_ed_23189') ? `var(--ds-border, ${N30})` : `var(--ds-border-focused, ${B200})`,
|
|
5
5
|
borderStyle: 'solid',
|
|
6
6
|
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
7
7
|
borderWidth: "var(--ds-border-width-outline, 2px)",
|
|
8
|
-
backgroundColor: "var(--ds-blanket-selected, #388BFF14)"
|
|
8
|
+
backgroundColor: fg('platform_editor_elements_drag_and_drop_ed_23189') ? `var(--ds-skeleton-subtle, ${N20})` : "var(--ds-blanket-selected, #388BFF14)"
|
|
9
9
|
};
|
|
10
10
|
export const dragPreview = (container, dom, nodeType) => {
|
|
11
|
-
|
|
12
|
-
container.style.width = `${rect.width}px`;
|
|
13
|
-
container.style.height = `${rect.height}px`;
|
|
11
|
+
let nodeContainer = dom;
|
|
14
12
|
container.style.pointerEvents = 'none';
|
|
15
13
|
const parent = document.createElement('div');
|
|
16
14
|
// ProseMirror class is required to make sure the cloned dom is styled correctly
|
|
17
15
|
parent.classList.add('ProseMirror');
|
|
18
|
-
if (
|
|
16
|
+
if (fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
19
17
|
parent.classList.add('block-ctrl-drag-preview');
|
|
20
18
|
}
|
|
21
|
-
const shouldBeGenericPreview = nodeType === 'embedCard' || nodeType === 'extension';
|
|
22
19
|
const embedCard = dom.querySelector('.embedCardView-content-wrap');
|
|
23
|
-
|
|
20
|
+
let shouldBeGenericPreview = nodeType === 'embedCard' || nodeType === 'extension' || !!embedCard;
|
|
21
|
+
if (fg('platform_editor_elements_drag_and_drop_ed_23189')) {
|
|
22
|
+
const iframeContainer = dom.querySelector('iframe');
|
|
23
|
+
if (nodeType === 'embedCard') {
|
|
24
|
+
nodeContainer = dom.querySelector('.rich-media-item') || dom;
|
|
25
|
+
} else if (nodeType === 'extension' && iframeContainer) {
|
|
26
|
+
nodeContainer = iframeContainer;
|
|
27
|
+
}
|
|
28
|
+
shouldBeGenericPreview = nodeType === 'embedCard' || !!embedCard || nodeType === 'extension' && !!iframeContainer;
|
|
29
|
+
}
|
|
30
|
+
const nodeContainerRect = nodeContainer.getBoundingClientRect();
|
|
31
|
+
container.style.width = `${nodeContainerRect.width}px`;
|
|
32
|
+
container.style.height = `${nodeContainerRect.height}px`;
|
|
33
|
+
if (shouldBeGenericPreview) {
|
|
24
34
|
parent.style.border = `${previewStyle.borderWidth} ${previewStyle.borderStyle} ${previewStyle.borderColor}`;
|
|
25
35
|
parent.style.borderRadius = previewStyle.borderRadius;
|
|
26
36
|
parent.style.backgroundColor = previewStyle.backgroundColor;
|
|
@@ -35,8 +45,8 @@ export const dragPreview = (container, dom, nodeType) => {
|
|
|
35
45
|
clonedDom.style.marginTop = '0';
|
|
36
46
|
clonedDom.style.marginRight = '0';
|
|
37
47
|
clonedDom.style.marginBottom = '0';
|
|
38
|
-
clonedDom.style.opacity = '0.4';
|
|
39
48
|
clonedDom.style.boxShadow = 'none';
|
|
49
|
+
clonedDom.style.opacity = fg('platform_editor_elements_drag_and_drop_ed_23189') ? '0.31' : '0.4';
|
|
40
50
|
parent.appendChild(clonedDom);
|
|
41
51
|
}
|
|
42
52
|
container.appendChild(parent);
|
|
@@ -10,10 +10,14 @@ export const getSelection = (tr, start) => {
|
|
|
10
10
|
// decisionList node is not selectable, but we want to select the whole node not just text
|
|
11
11
|
if (isNodeSelection || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
|
|
12
12
|
return new NodeSelection($startPos);
|
|
13
|
-
// TODO: support multiple nodes selection
|
|
14
13
|
} else if ((node === null || node === void 0 ? void 0 : node.type.name) === 'mediaGroup' && node.childCount === 1) {
|
|
15
14
|
const $mediaStartPos = tr.doc.resolve(start + 1);
|
|
16
15
|
return new NodeSelection($mediaStartPos);
|
|
16
|
+
} else if (
|
|
17
|
+
// Even though mediaGroup is not selectable,
|
|
18
|
+
// we need a quick way to make all child media nodes appear as selected without the need for a custom selection
|
|
19
|
+
(node === null || node === void 0 ? void 0 : node.type.name) === 'mediaGroup' && fg('platform_editor_element_drag_and_drop_ed_23842')) {
|
|
20
|
+
return new NodeSelection($startPos);
|
|
17
21
|
} else {
|
|
18
22
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
19
23
|
// Find the first inline node in the node
|
package/dist/esm/plugin.js
CHANGED
|
@@ -11,16 +11,17 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
11
11
|
pmPlugins: function pmPlugins() {
|
|
12
12
|
return [{
|
|
13
13
|
name: 'blockControlsPmPlugin',
|
|
14
|
-
plugin: function plugin() {
|
|
15
|
-
|
|
14
|
+
plugin: function plugin(_ref2) {
|
|
15
|
+
var getIntl = _ref2.getIntl;
|
|
16
|
+
return createPlugin(api, getIntl);
|
|
16
17
|
}
|
|
17
18
|
}];
|
|
18
19
|
},
|
|
19
20
|
commands: {
|
|
20
21
|
moveNode: function moveNode(start, to) {
|
|
21
|
-
return function (
|
|
22
|
+
return function (_ref3) {
|
|
22
23
|
var _node$nodeSize, _api$analytics;
|
|
23
|
-
var tr =
|
|
24
|
+
var tr = _ref3.tr;
|
|
24
25
|
var node = tr.doc.nodeAt(start);
|
|
25
26
|
var resolvedNode = tr.doc.resolve(start);
|
|
26
27
|
if (!node) {
|
|
@@ -51,8 +52,8 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
51
52
|
};
|
|
52
53
|
},
|
|
53
54
|
showDragHandleAt: function showDragHandleAt(pos, anchorName, nodeType) {
|
|
54
|
-
return function (
|
|
55
|
-
var tr =
|
|
55
|
+
return function (_ref4) {
|
|
56
|
+
var tr = _ref4.tr;
|
|
56
57
|
tr.setMeta(key, {
|
|
57
58
|
activeNode: {
|
|
58
59
|
pos: pos,
|
|
@@ -64,8 +65,8 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
64
65
|
};
|
|
65
66
|
},
|
|
66
67
|
setNodeDragged: function setNodeDragged(pos, anchorName, nodeType) {
|
|
67
|
-
return function (
|
|
68
|
-
var tr =
|
|
68
|
+
return function (_ref5) {
|
|
69
|
+
var tr = _ref5.tr;
|
|
69
70
|
if (pos === undefined) {
|
|
70
71
|
return tr;
|
|
71
72
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { createElement } from 'react';
|
|
3
3
|
import ReactDOM from 'react-dom';
|
|
4
|
+
import { RawIntlProvider } from 'react-intl-next';
|
|
4
5
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { DragHandle } from '../ui/drag-handle';
|
|
@@ -128,7 +129,7 @@ export var mouseMoveWrapperDecorations = function mouseMoveWrapperDecorations(ne
|
|
|
128
129
|
});
|
|
129
130
|
return decs;
|
|
130
131
|
};
|
|
131
|
-
export var dragHandleDecoration = function dragHandleDecoration(pos, anchorName, nodeType, api) {
|
|
132
|
+
export var dragHandleDecoration = function dragHandleDecoration(pos, anchorName, nodeType, api, getIntl) {
|
|
132
133
|
return Decoration.widget(pos, function (view, getPos) {
|
|
133
134
|
var element = document.createElement('div');
|
|
134
135
|
// Need to set it to inline to avoid text being split when merging two paragraphs
|
|
@@ -140,13 +141,15 @@ export var dragHandleDecoration = function dragHandleDecoration(pos, anchorName,
|
|
|
140
141
|
// due to margins applied to other nodes eg. Headings
|
|
141
142
|
element.style.clear = 'unset';
|
|
142
143
|
}
|
|
143
|
-
ReactDOM.render( /*#__PURE__*/createElement(
|
|
144
|
+
ReactDOM.render( /*#__PURE__*/createElement(RawIntlProvider, {
|
|
145
|
+
value: getIntl()
|
|
146
|
+
}, /*#__PURE__*/createElement(DragHandle, {
|
|
144
147
|
view: view,
|
|
145
148
|
api: api,
|
|
146
149
|
getPos: getPos,
|
|
147
150
|
anchorName: anchorName,
|
|
148
151
|
nodeType: nodeType
|
|
149
|
-
}), element);
|
|
152
|
+
})), element);
|
|
150
153
|
return element;
|
|
151
154
|
}, {
|
|
152
155
|
side: -1,
|
|
@@ -6,7 +6,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
6
6
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
8
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
9
|
-
import {
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
|
|
11
11
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
12
12
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
@@ -75,7 +75,7 @@ var initialState = {
|
|
|
75
75
|
isPMDragging: false
|
|
76
76
|
};
|
|
77
77
|
var DRAG_AND_DROP_DOC_SIZE_LIMIT = 50;
|
|
78
|
-
export var createPlugin = function createPlugin(api) {
|
|
78
|
+
export var createPlugin = function createPlugin(api, getIntl) {
|
|
79
79
|
return new SafePlugin({
|
|
80
80
|
key: key,
|
|
81
81
|
state: {
|
|
@@ -85,7 +85,7 @@ export var createPlugin = function createPlugin(api) {
|
|
|
85
85
|
apply: function apply(tr, currentState, oldState, newState) {
|
|
86
86
|
var _meta$activeNode, _meta$activeNode2, _meta$isDragging, _meta$editorHeight, _meta$isPMDragging;
|
|
87
87
|
if (initialState.isDocSizeLimitEnabled === null) {
|
|
88
|
-
if (
|
|
88
|
+
if (fg('platform.editor.elements.drag-and-drop-doc-size-limit_7k4vq')) {
|
|
89
89
|
initialState.isDocSizeLimitEnabled = true;
|
|
90
90
|
} else {
|
|
91
91
|
initialState.isDocSizeLimitEnabled = false;
|
|
@@ -125,7 +125,7 @@ export var createPlugin = function createPlugin(api) {
|
|
|
125
125
|
}
|
|
126
126
|
var isDecsMissing = false;
|
|
127
127
|
var isHandleMissing = false;
|
|
128
|
-
if (
|
|
128
|
+
if (fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
129
129
|
// Ensure decorations stay in sync when nodes are added or removed from the doc
|
|
130
130
|
isHandleMissing = !(meta !== null && meta !== void 0 && meta.activeNode) && !decorations.find().some(function (_ref6) {
|
|
131
131
|
var spec = _ref6.spec;
|
|
@@ -154,7 +154,7 @@ export var createPlugin = function createPlugin(api) {
|
|
|
154
154
|
if (redrawDecorations && !isResizerResizing && api) {
|
|
155
155
|
decorations = DecorationSet.create(newState.doc, []);
|
|
156
156
|
var nodeDecs = nodeDecorations(newState);
|
|
157
|
-
if (
|
|
157
|
+
if (fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
158
158
|
decorations = decorations.add(newState.doc, _toConsumableArray(nodeDecs));
|
|
159
159
|
} else {
|
|
160
160
|
var mouseWrapperDecs = mouseMoveWrapperDecorations(newState, api);
|
|
@@ -184,7 +184,7 @@ export var createPlugin = function createPlugin(api) {
|
|
|
184
184
|
anchorName: anchorName
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
|
-
var draghandleDec = dragHandleDecoration(activeNode.pos, anchorName, nodeType, api);
|
|
187
|
+
var draghandleDec = dragHandleDecoration(activeNode.pos, anchorName, nodeType, api, getIntl);
|
|
188
188
|
decorations = decorations.add(newState.doc, [draghandleDec]);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
@@ -196,10 +196,10 @@ export var createPlugin = function createPlugin(api) {
|
|
|
196
196
|
return spec.id === 'drag-handle';
|
|
197
197
|
});
|
|
198
198
|
decorations = decorations.remove(_oldHandle);
|
|
199
|
-
var decs = dragHandleDecoration(meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, api);
|
|
199
|
+
var decs = dragHandleDecoration(meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, api, getIntl);
|
|
200
200
|
decorations = decorations.add(newState.doc, [decs]);
|
|
201
201
|
}
|
|
202
|
-
if (
|
|
202
|
+
if (fg('platform.editor.elements.drag-and-drop-ed-23816')) {
|
|
203
203
|
var _activeNodeWithNewNod;
|
|
204
204
|
// Remove previous drag handle widget and draw new drag handle widget when node type changes
|
|
205
205
|
if (activeNodeWithNewNodeType && ((_activeNodeWithNewNod = activeNodeWithNewNodeType) === null || _activeNodeWithNewNod === void 0 ? void 0 : _activeNodeWithNewNod.nodeType) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) && api) {
|
|
@@ -208,7 +208,7 @@ export var createPlugin = function createPlugin(api) {
|
|
|
208
208
|
return spec.id === 'drag-handle';
|
|
209
209
|
});
|
|
210
210
|
decorations = decorations.remove(_oldHandle2);
|
|
211
|
-
var _decs = dragHandleDecoration(activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType, api);
|
|
211
|
+
var _decs = dragHandleDecoration(activeNodeWithNewNodeType.pos, activeNodeWithNewNodeType.anchorName, activeNodeWithNewNodeType.nodeType, api, getIntl);
|
|
212
212
|
decorations = decorations.add(newState.doc, [_decs]);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
@@ -258,7 +258,7 @@ export var createPlugin = function createPlugin(api) {
|
|
|
258
258
|
|
|
259
259
|
// Map active node position when the document changes
|
|
260
260
|
var mappedActiveNodePos;
|
|
261
|
-
if (
|
|
261
|
+
if (fg('platform.editor.elements.drag-and-drop-ed-23816')) {
|
|
262
262
|
mappedActiveNodePos = tr.docChanged && activeNode ? activeNodeWithNewNodeType || {
|
|
263
263
|
pos: tr.mapping.map(activeNode.pos),
|
|
264
264
|
anchorName: activeNode.anchorName,
|
|
@@ -315,7 +315,7 @@ export var createPlugin = function createPlugin(api) {
|
|
|
315
315
|
var draggable = dragging === null || dragging === void 0 ? void 0 : dragging.slice.content.firstChild;
|
|
316
316
|
var activeNode = state.tr.doc.nodeAt(pluginState.activeNode.pos);
|
|
317
317
|
var isSameNode = draggable === activeNode;
|
|
318
|
-
if (
|
|
318
|
+
if (fg('platform.editor.elements.drag-and-drop-ed-23892')) {
|
|
319
319
|
var _event$target;
|
|
320
320
|
var nodeElement = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.closest('[data-drag-handler-anchor-name]');
|
|
321
321
|
if (!nodeElement) {
|
|
@@ -347,7 +347,7 @@ export var createPlugin = function createPlugin(api) {
|
|
|
347
347
|
}
|
|
348
348
|
},
|
|
349
349
|
mouseover: function mouseover(view, event) {
|
|
350
|
-
if (
|
|
350
|
+
if (fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
351
351
|
handleMouseOver(view, event, api);
|
|
352
352
|
}
|
|
353
353
|
return false;
|
|
@@ -373,7 +373,7 @@ export var createPlugin = function createPlugin(api) {
|
|
|
373
373
|
view: function view(editorView) {
|
|
374
374
|
var dom = editorView.dom;
|
|
375
375
|
var resizeObserver;
|
|
376
|
-
if (!
|
|
376
|
+
if (!fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
377
377
|
// Use ResizeObserver to observe height changes
|
|
378
378
|
resizeObserver = new ResizeObserver(rafSchedule(function (entries) {
|
|
379
379
|
var editorHeight = entries[0].contentBoxSize[0].blockSize;
|
|
@@ -402,7 +402,7 @@ export var createPlugin = function createPlugin(api) {
|
|
|
402
402
|
var pragmaticCleanup = destroyFn(api);
|
|
403
403
|
return {
|
|
404
404
|
destroy: function destroy() {
|
|
405
|
-
if (!
|
|
405
|
+
if (!fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
406
406
|
resizeObserver.unobserve(dom);
|
|
407
407
|
}
|
|
408
408
|
pragmaticCleanup();
|
|
@@ -4,13 +4,17 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
4
4
|
|
|
5
5
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
6
|
import { css, jsx } from '@emotion/react';
|
|
7
|
+
import { injectIntl } from 'react-intl-next';
|
|
7
8
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
8
9
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
10
|
+
import { dragToMoveDown, dragToMoveUp, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
|
|
11
|
+
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
9
12
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
13
|
import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
|
|
11
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
15
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
13
16
|
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
|
|
17
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
14
18
|
import { key } from '../pm-plugins/main';
|
|
15
19
|
import { selectNode } from '../utils';
|
|
16
20
|
import { getLeftPosition, getTopPosition } from '../utils/drag-handle-positions';
|
|
@@ -47,12 +51,13 @@ var selectedStyles = css({
|
|
|
47
51
|
backgroundColor: "var(--ds-background-selected, #E9F2FF)",
|
|
48
52
|
color: "var(--ds-icon-selected, #0C66E4)"
|
|
49
53
|
});
|
|
50
|
-
|
|
54
|
+
var DragHandleInternal = function DragHandleInternal(_ref) {
|
|
51
55
|
var view = _ref.view,
|
|
52
56
|
api = _ref.api,
|
|
53
57
|
getPos = _ref.getPos,
|
|
54
58
|
anchorName = _ref.anchorName,
|
|
55
|
-
nodeType = _ref.nodeType
|
|
59
|
+
nodeType = _ref.nodeType,
|
|
60
|
+
formatMessage = _ref.intl.formatMessage;
|
|
56
61
|
var start = getPos();
|
|
57
62
|
var buttonRef = useRef(null);
|
|
58
63
|
var _useState = useState(768),
|
|
@@ -247,18 +252,35 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
247
252
|
top: fg('platform_editor_elements_dnd_ed_23674') ? getTopPosition(dom, nodeType) : getTopPosition(dom)
|
|
248
253
|
};
|
|
249
254
|
}, [anchorName, nodeType, view, blockCardWidth, macroInteractionUpdates]);
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
255
|
+
var helpDescriptors = [{
|
|
256
|
+
description: formatMessage(blockControlsMessages.dragToMove)
|
|
257
|
+
}, {
|
|
258
|
+
description: formatMessage(blockControlsMessages.moveUp),
|
|
259
|
+
keymap: dragToMoveUp
|
|
260
|
+
}, {
|
|
261
|
+
description: formatMessage(blockControlsMessages.moveDown),
|
|
262
|
+
keymap: dragToMoveDown
|
|
263
|
+
}];
|
|
264
|
+
var renderButton = function renderButton() {
|
|
265
|
+
return jsx("button", {
|
|
266
|
+
type: "button",
|
|
267
|
+
css: [dragHandleButtonStyles, dragHandleSelected && selectedStyles],
|
|
268
|
+
ref: buttonRef
|
|
269
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
270
|
+
,
|
|
271
|
+
style: positionStyles,
|
|
272
|
+
onClick: handleOnClick,
|
|
273
|
+
onMouseDown: fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2') ? handleMouseDownWrapperRemoved : handleMouseDown,
|
|
274
|
+
"data-testid": "block-ctrl-drag-handle"
|
|
275
|
+
}, jsx(DragHandlerIcon, {
|
|
276
|
+
label: "",
|
|
277
|
+
size: "medium"
|
|
278
|
+
}));
|
|
279
|
+
};
|
|
280
|
+
return fg('platform_editor_element_drag_and_drop_ed_23873') ? jsx(Tooltip, {
|
|
281
|
+
content: jsx(TooltipContentWithMultipleShortcuts, {
|
|
282
|
+
helpDescriptors: helpDescriptors
|
|
283
|
+
})
|
|
284
|
+
}, renderButton()) : renderButton();
|
|
285
|
+
};
|
|
286
|
+
export var DragHandle = injectIntl(DragHandleInternal);
|
|
@@ -1,26 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B200 } from '@atlaskit/theme/colors';
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
import { B200, N20, N30 } from '@atlaskit/theme/colors';
|
|
3
3
|
var previewStyle = {
|
|
4
|
-
borderColor: "var(--ds-border-focused, ".concat(B200, ")"),
|
|
4
|
+
borderColor: fg('platform_editor_elements_drag_and_drop_ed_23189') ? "var(--ds-border, ".concat(N30, ")") : "var(--ds-border-focused, ".concat(B200, ")"),
|
|
5
5
|
borderStyle: 'solid',
|
|
6
6
|
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
7
7
|
borderWidth: "var(--ds-border-width-outline, 2px)",
|
|
8
|
-
backgroundColor: "var(--ds-blanket-selected, #388BFF14)"
|
|
8
|
+
backgroundColor: fg('platform_editor_elements_drag_and_drop_ed_23189') ? "var(--ds-skeleton-subtle, ".concat(N20, ")") : "var(--ds-blanket-selected, #388BFF14)"
|
|
9
9
|
};
|
|
10
10
|
export var dragPreview = function dragPreview(container, dom, nodeType) {
|
|
11
|
-
var
|
|
12
|
-
container.style.width = "".concat(rect.width, "px");
|
|
13
|
-
container.style.height = "".concat(rect.height, "px");
|
|
11
|
+
var nodeContainer = dom;
|
|
14
12
|
container.style.pointerEvents = 'none';
|
|
15
13
|
var parent = document.createElement('div');
|
|
16
14
|
// ProseMirror class is required to make sure the cloned dom is styled correctly
|
|
17
15
|
parent.classList.add('ProseMirror');
|
|
18
|
-
if (
|
|
16
|
+
if (fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
19
17
|
parent.classList.add('block-ctrl-drag-preview');
|
|
20
18
|
}
|
|
21
|
-
var shouldBeGenericPreview = nodeType === 'embedCard' || nodeType === 'extension';
|
|
22
19
|
var embedCard = dom.querySelector('.embedCardView-content-wrap');
|
|
23
|
-
|
|
20
|
+
var shouldBeGenericPreview = nodeType === 'embedCard' || nodeType === 'extension' || !!embedCard;
|
|
21
|
+
if (fg('platform_editor_elements_drag_and_drop_ed_23189')) {
|
|
22
|
+
var iframeContainer = dom.querySelector('iframe');
|
|
23
|
+
if (nodeType === 'embedCard') {
|
|
24
|
+
nodeContainer = dom.querySelector('.rich-media-item') || dom;
|
|
25
|
+
} else if (nodeType === 'extension' && iframeContainer) {
|
|
26
|
+
nodeContainer = iframeContainer;
|
|
27
|
+
}
|
|
28
|
+
shouldBeGenericPreview = nodeType === 'embedCard' || !!embedCard || nodeType === 'extension' && !!iframeContainer;
|
|
29
|
+
}
|
|
30
|
+
var nodeContainerRect = nodeContainer.getBoundingClientRect();
|
|
31
|
+
container.style.width = "".concat(nodeContainerRect.width, "px");
|
|
32
|
+
container.style.height = "".concat(nodeContainerRect.height, "px");
|
|
33
|
+
if (shouldBeGenericPreview) {
|
|
24
34
|
parent.style.border = "".concat(previewStyle.borderWidth, " ").concat(previewStyle.borderStyle, " ").concat(previewStyle.borderColor);
|
|
25
35
|
parent.style.borderRadius = previewStyle.borderRadius;
|
|
26
36
|
parent.style.backgroundColor = previewStyle.backgroundColor;
|
|
@@ -35,8 +45,8 @@ export var dragPreview = function dragPreview(container, dom, nodeType) {
|
|
|
35
45
|
clonedDom.style.marginTop = '0';
|
|
36
46
|
clonedDom.style.marginRight = '0';
|
|
37
47
|
clonedDom.style.marginBottom = '0';
|
|
38
|
-
clonedDom.style.opacity = '0.4';
|
|
39
48
|
clonedDom.style.boxShadow = 'none';
|
|
49
|
+
clonedDom.style.opacity = fg('platform_editor_elements_drag_and_drop_ed_23189') ? '0.31' : '0.4';
|
|
40
50
|
parent.appendChild(clonedDom);
|
|
41
51
|
}
|
|
42
52
|
container.appendChild(parent);
|
|
@@ -10,10 +10,14 @@ export var getSelection = function getSelection(tr, start) {
|
|
|
10
10
|
// decisionList node is not selectable, but we want to select the whole node not just text
|
|
11
11
|
if (isNodeSelection || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
|
|
12
12
|
return new NodeSelection($startPos);
|
|
13
|
-
// TODO: support multiple nodes selection
|
|
14
13
|
} else if ((node === null || node === void 0 ? void 0 : node.type.name) === 'mediaGroup' && node.childCount === 1) {
|
|
15
14
|
var $mediaStartPos = tr.doc.resolve(start + 1);
|
|
16
15
|
return new NodeSelection($mediaStartPos);
|
|
16
|
+
} else if (
|
|
17
|
+
// Even though mediaGroup is not selectable,
|
|
18
|
+
// we need a quick way to make all child media nodes appear as selected without the need for a custom selection
|
|
19
|
+
(node === null || node === void 0 ? void 0 : node.type.name) === 'mediaGroup' && fg('platform_editor_element_drag_and_drop_ed_23842')) {
|
|
20
|
+
return new NodeSelection($startPos);
|
|
17
21
|
} else {
|
|
18
22
|
// To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
|
|
19
23
|
// Find the first inline node in the node
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type IntlShape } from 'react-intl-next';
|
|
1
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -17,4 +18,4 @@ export declare const nodeDecorations: (newState: EditorState) => Decoration[];
|
|
|
17
18
|
* And show the drag handle
|
|
18
19
|
*/
|
|
19
20
|
export declare const mouseMoveWrapperDecorations: (newState: EditorState, api: ExtractInjectionAPI<BlockControlsPlugin>) => Decoration[];
|
|
20
|
-
export declare const dragHandleDecoration: (pos: number, anchorName: string, nodeType: string, api: ExtractInjectionAPI<BlockControlsPlugin
|
|
21
|
+
export declare const dragHandleDecoration: (pos: number, anchorName: string, nodeType: string, api: ExtractInjectionAPI<BlockControlsPlugin>, getIntl: () => IntlShape) => Decoration;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { type IntlShape } from 'react-intl-next';
|
|
1
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
5
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
5
6
|
import type { BlockControlsPlugin, PluginState } from '../types';
|
|
6
7
|
export declare const key: PluginKey<PluginState>;
|
|
7
|
-
export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined) => SafePlugin<PluginState | {
|
|
8
|
+
export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape) => SafePlugin<PluginState | {
|
|
8
9
|
decorations: DecorationSet;
|
|
9
10
|
decorationState: import("../types").DecorationState;
|
|
10
11
|
activeNode: any;
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type WrappedComponentProps } from 'react-intl-next';
|
|
2
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
5
|
import type { BlockControlsPlugin } from '../types';
|
|
5
|
-
export declare const DragHandle: ({
|
|
6
|
+
export declare const DragHandle: import("react").FC<import("react-intl-next").WithIntlProps<{
|
|
6
7
|
view: EditorView;
|
|
7
8
|
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
8
9
|
getPos: () => number | undefined;
|
|
9
10
|
anchorName: string;
|
|
10
11
|
nodeType: string;
|
|
11
|
-
}
|
|
12
|
+
} & WrappedComponentProps>> & {
|
|
13
|
+
WrappedComponent: import("react").ComponentType<{
|
|
14
|
+
view: EditorView;
|
|
15
|
+
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
16
|
+
getPos: () => number | undefined;
|
|
17
|
+
anchorName: string;
|
|
18
|
+
nodeType: string;
|
|
19
|
+
} & WrappedComponentProps>;
|
|
20
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type IntlShape } from 'react-intl-next';
|
|
1
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -17,4 +18,4 @@ export declare const nodeDecorations: (newState: EditorState) => Decoration[];
|
|
|
17
18
|
* And show the drag handle
|
|
18
19
|
*/
|
|
19
20
|
export declare const mouseMoveWrapperDecorations: (newState: EditorState, api: ExtractInjectionAPI<BlockControlsPlugin>) => Decoration[];
|
|
20
|
-
export declare const dragHandleDecoration: (pos: number, anchorName: string, nodeType: string, api: ExtractInjectionAPI<BlockControlsPlugin
|
|
21
|
+
export declare const dragHandleDecoration: (pos: number, anchorName: string, nodeType: string, api: ExtractInjectionAPI<BlockControlsPlugin>, getIntl: () => IntlShape) => Decoration;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { type IntlShape } from 'react-intl-next';
|
|
1
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
5
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
5
6
|
import type { BlockControlsPlugin, PluginState } from '../types';
|
|
6
7
|
export declare const key: PluginKey<PluginState>;
|
|
7
|
-
export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined) => SafePlugin<PluginState | {
|
|
8
|
+
export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape) => SafePlugin<PluginState | {
|
|
8
9
|
decorations: DecorationSet;
|
|
9
10
|
decorationState: import("../types").DecorationState;
|
|
10
11
|
activeNode: any;
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type WrappedComponentProps } from 'react-intl-next';
|
|
2
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
5
|
import type { BlockControlsPlugin } from '../types';
|
|
5
|
-
export declare const DragHandle: ({
|
|
6
|
+
export declare const DragHandle: import("react").FC<import("react-intl-next").WithIntlProps<{
|
|
6
7
|
view: EditorView;
|
|
7
8
|
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
8
9
|
getPos: () => number | undefined;
|
|
9
10
|
anchorName: string;
|
|
10
11
|
nodeType: string;
|
|
11
|
-
}
|
|
12
|
+
} & WrappedComponentProps>> & {
|
|
13
|
+
WrappedComponent: import("react").ComponentType<{
|
|
14
|
+
view: EditorView;
|
|
15
|
+
api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
|
|
16
|
+
getPos: () => number | undefined;
|
|
17
|
+
anchorName: string;
|
|
18
|
+
nodeType: string;
|
|
19
|
+
} & WrappedComponentProps>;
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.15",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,21 +32,22 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^39.0.3",
|
|
35
|
-
"@atlaskit/editor-common": "^84.
|
|
35
|
+
"@atlaskit/editor-common": "^84.4.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.4.0",
|
|
37
37
|
"@atlaskit/editor-plugin-editor-disabled": "^1.1.5",
|
|
38
38
|
"@atlaskit/editor-plugin-feature-flags": "^1.1.0",
|
|
39
39
|
"@atlaskit/editor-plugin-width": "^1.1.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "4.0.1",
|
|
41
|
-
"@atlaskit/editor-shared-styles": "^2.
|
|
41
|
+
"@atlaskit/editor-shared-styles": "^2.13.0",
|
|
42
42
|
"@atlaskit/editor-tables": "^2.7.0",
|
|
43
|
-
"@atlaskit/icon": "^22.
|
|
43
|
+
"@atlaskit/icon": "^22.6.0",
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
45
45
|
"@atlaskit/pragmatic-drag-and-drop": "^1.2.0",
|
|
46
46
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.4.0",
|
|
47
47
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
|
|
48
48
|
"@atlaskit/theme": "^12.11.0",
|
|
49
49
|
"@atlaskit/tokens": "^1.53.0",
|
|
50
|
+
"@atlaskit/tooltip": "^18.5.0",
|
|
50
51
|
"@babel/runtime": "^7.0.0",
|
|
51
52
|
"@emotion/react": "^11.7.1",
|
|
52
53
|
"bind-event-listener": "^3.0.0",
|
|
@@ -54,7 +55,8 @@
|
|
|
54
55
|
},
|
|
55
56
|
"peerDependencies": {
|
|
56
57
|
"react": "^16.8.0",
|
|
57
|
-
"react-dom": "^16.8.0"
|
|
58
|
+
"react-dom": "^16.8.0",
|
|
59
|
+
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
58
60
|
},
|
|
59
61
|
"techstack": {
|
|
60
62
|
"@atlassian/frontend": {
|
|
@@ -117,11 +119,20 @@
|
|
|
117
119
|
"platform.editor.elements.drag-and-drop-ed-23905": {
|
|
118
120
|
"type": "boolean"
|
|
119
121
|
},
|
|
122
|
+
"platform_editor_elements_drag_and_drop_ed_23189": {
|
|
123
|
+
"type": "boolean"
|
|
124
|
+
},
|
|
120
125
|
"platform.editor.elements.drag-and-drop-ed-23932": {
|
|
121
126
|
"type": "boolean"
|
|
122
127
|
},
|
|
123
128
|
"platform_editor_elements_dnd_ed_23674": {
|
|
124
129
|
"type": "boolean"
|
|
130
|
+
},
|
|
131
|
+
"platform_editor_element_drag_and_drop_ed_23873": {
|
|
132
|
+
"type": "boolean"
|
|
133
|
+
},
|
|
134
|
+
"platform_editor_element_drag_and_drop_ed_23842": {
|
|
135
|
+
"type": "boolean"
|
|
125
136
|
}
|
|
126
137
|
}
|
|
127
138
|
}
|