@atlaskit/editor-plugin-block-controls 1.5.11 → 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 +33 -0
- package/dist/cjs/plugin.js +9 -8
- package/dist/cjs/pm-plugins/decorations.js +8 -5
- package/dist/cjs/pm-plugins/main.js +13 -13
- package/dist/cjs/ui/consts.js +13 -1
- package/dist/cjs/ui/drag-handle.js +44 -22
- package/dist/cjs/ui/drag-preview.js +19 -9
- package/dist/cjs/ui/global-styles.js +19 -11
- package/dist/cjs/utils/drag-handle-positions.js +3 -1
- package/dist/cjs/utils/getSelection.js +5 -1
- package/dist/es2019/plugin.js +3 -1
- package/dist/es2019/pm-plugins/decorations.js +9 -6
- package/dist/es2019/pm-plugins/main.js +14 -14
- package/dist/es2019/ui/consts.js +12 -0
- package/dist/es2019/ui/drag-handle.js +34 -12
- package/dist/es2019/ui/drag-preview.js +21 -11
- package/dist/es2019/ui/global-styles.js +19 -11
- package/dist/es2019/utils/drag-handle-positions.js +4 -2
- package/dist/es2019/utils/getSelection.js +5 -1
- package/dist/esm/plugin.js +9 -8
- package/dist/esm/pm-plugins/decorations.js +9 -6
- package/dist/esm/pm-plugins/main.js +14 -14
- package/dist/esm/ui/consts.js +12 -0
- package/dist/esm/ui/drag-handle.js +46 -24
- package/dist/esm/ui/drag-preview.js +21 -11
- package/dist/esm/ui/global-styles.js +19 -11
- package/dist/esm/utils/drag-handle-positions.js +4 -2
- 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/consts.d.ts +2 -0
- package/dist/types/ui/drag-handle.d.ts +12 -3
- package/dist/types/utils/drag-handle-positions.d.ts +1 -1
- 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/consts.d.ts +2 -0
- package/dist/types-ts4.5/ui/drag-handle.d.ts +12 -3
- package/dist/types-ts4.5/utils/drag-handle-positions.d.ts +1 -1
- package/package.json +19 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
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
|
+
|
|
27
|
+
## 1.5.12
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- [#117568](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/117568)
|
|
32
|
+
[`b07c3e0b8dbf8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b07c3e0b8dbf8) -
|
|
33
|
+
Update drag handle position on divider node
|
|
34
|
+
- Updated dependencies
|
|
35
|
+
|
|
3
36
|
## 1.5.11
|
|
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");
|
|
@@ -82,7 +83,7 @@ var nodeDecorations = exports.nodeDecorations = function nodeDecorations(newStat
|
|
|
82
83
|
var _Decoration$node2;
|
|
83
84
|
var anchorName = "--node-anchor-".concat(node.type.name, "-").concat(index);
|
|
84
85
|
var style;
|
|
85
|
-
if ((0, _platformFeatureFlags.
|
|
86
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
86
87
|
style = "anchor-name: ".concat(anchorName, "; ").concat(pos === 0 ? 'margin-top: 0px;' : '', "; position: relative; z-index: 1;");
|
|
87
88
|
} else {
|
|
88
89
|
style = "anchor-name: ".concat(anchorName, "; ").concat(pos === 0 ? 'margin-top: 0px;' : '');
|
|
@@ -135,25 +136,27 @@ 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
|
|
142
143
|
element.style.display = 'inline';
|
|
143
144
|
element.setAttribute('data-testid', 'block-ctrl-decorator-widget');
|
|
144
145
|
element.setAttribute('data-blocks-drag-handle-container', 'true');
|
|
145
|
-
if ((0, _platformFeatureFlags.
|
|
146
|
+
if ((0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
146
147
|
// There are times when global clear: "both" styles are applied to this decoration causing jumpiness
|
|
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();
|
package/dist/cjs/ui/consts.js
CHANGED
|
@@ -3,17 +3,29 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.dragHandleGap = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
|
|
6
|
+
exports.topPositionAdjustment = exports.dragHandleGap = exports.DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_BORDER_RADIUS = void 0;
|
|
7
7
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
8
8
|
var DRAG_HANDLE_HEIGHT = exports.DRAG_HANDLE_HEIGHT = 24;
|
|
9
9
|
var DRAG_HANDLE_WIDTH = exports.DRAG_HANDLE_WIDTH = 12;
|
|
10
10
|
var DRAG_HANDLE_BORDER_RADIUS = exports.DRAG_HANDLE_BORDER_RADIUS = 4;
|
|
11
11
|
var DRAG_HANDLE_ZINDEX = exports.DRAG_HANDLE_ZINDEX = _editorSharedStyles.akRichMediaResizeZIndex + _editorSharedStyles.akEditorUnitZIndex; //place above legacy resizer
|
|
12
12
|
|
|
13
|
+
var DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = exports.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT = 4 + 2; // 4px for the divider vertical padding and 2px for the divider height
|
|
14
|
+
|
|
13
15
|
var nodeTypeExcludeList = ['embedCard', 'mediaSingle', 'table'];
|
|
14
16
|
var dragHandleGap = exports.dragHandleGap = function dragHandleGap(nodeType) {
|
|
15
17
|
if (nodeTypeExcludeList.includes(nodeType)) {
|
|
16
18
|
return 12;
|
|
17
19
|
}
|
|
18
20
|
return 8;
|
|
21
|
+
};
|
|
22
|
+
var topPositionAdjustment = exports.topPositionAdjustment = function topPositionAdjustment(nodeType) {
|
|
23
|
+
switch (nodeType) {
|
|
24
|
+
case 'rule':
|
|
25
|
+
return -DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT;
|
|
26
|
+
case 'table':
|
|
27
|
+
return DRAG_HANDLE_HEIGHT;
|
|
28
|
+
default:
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
19
31
|
};
|
|
@@ -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),
|
|
@@ -105,7 +110,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
105
110
|
});
|
|
106
111
|
var resolvedMovingNode = tr.doc.resolve(start);
|
|
107
112
|
var maybeNode = resolvedMovingNode.nodeAfter;
|
|
108
|
-
(0, _platformFeatureFlags.
|
|
113
|
+
(0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-long-node-scroll') && tr.setMeta('scrollIntoView', false);
|
|
109
114
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
110
115
|
eventType: _analytics.EVENT_TYPE.UI,
|
|
111
116
|
action: _analytics.ACTION.CLICKED,
|
|
@@ -242,31 +247,48 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
242
247
|
}
|
|
243
248
|
}
|
|
244
249
|
if (supportsAnchor) {
|
|
245
|
-
return (0, _platformFeatureFlags.
|
|
250
|
+
return (0, _platformFeatureFlags.fg)('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2') ? {
|
|
246
251
|
left: hasResizer || isExtension || isEmbedCard ? "calc(anchor(".concat(anchorName, " start) + ").concat((0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates), ")") : "calc(anchor(".concat(anchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType), "px)"),
|
|
247
|
-
top: anchorName.includes('table') ? "calc(anchor(".concat(anchorName, " start) + ").concat(_consts.DRAG_HANDLE_HEIGHT, "px)") : "anchor(".concat(anchorName, " start)")
|
|
252
|
+
top: (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_ed_23674') ? "calc(anchor(".concat(anchorName, " start) + ").concat((0, _consts.topPositionAdjustment)(nodeType), "px)") : anchorName.includes('table') ? "calc(anchor(".concat(anchorName, " start) + ").concat(_consts.DRAG_HANDLE_HEIGHT, "px)") : "anchor(".concat(anchorName, " start)")
|
|
248
253
|
} : {
|
|
249
254
|
left: hasResizer || isExtension || isBlockCard || isEmbedCard ? (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates) : "calc(anchor(".concat(anchorName, " start) - ").concat(_consts.DRAG_HANDLE_WIDTH, "px - ").concat((0, _consts.dragHandleGap)(nodeType), "px)"),
|
|
250
|
-
top: anchorName.includes('table') ? "calc(anchor(".concat(anchorName, " start) + ").concat(_consts.DRAG_HANDLE_HEIGHT, "px)") : "anchor(".concat(anchorName, " start)")
|
|
255
|
+
top: (0, _platformFeatureFlags.fg)('platform_editor_elements_dnd_ed_23674') ? "calc(anchor(".concat(anchorName, " start) + ").concat((0, _consts.topPositionAdjustment)(nodeType), "px)") : anchorName.includes('table') ? "calc(anchor(".concat(anchorName, " start) + ").concat(_consts.DRAG_HANDLE_HEIGHT, "px)") : "anchor(".concat(anchorName, " start)")
|
|
251
256
|
};
|
|
252
257
|
}
|
|
253
258
|
return {
|
|
254
259
|
left: (0, _dragHandlePositions.getLeftPosition)(dom, nodeType, innerContainer, macroInteractionUpdates),
|
|
255
|
-
top: (0, _dragHandlePositions.getTopPosition)(dom)
|
|
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);
|
|
@@ -18,19 +18,27 @@ var extendedHoverZone = (0, _react.css)({
|
|
|
18
18
|
display: 'none !important'
|
|
19
19
|
},
|
|
20
20
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
21
|
-
'
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
'.ProseMirror': {
|
|
22
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
|
|
23
|
+
'&& [data-drag-handler-anchor-name]::after': {
|
|
24
|
+
content: '""',
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
top: 0,
|
|
27
|
+
left: '-100%',
|
|
28
|
+
width: '100%',
|
|
29
|
+
height: '100%',
|
|
30
|
+
background: 'transparent',
|
|
31
|
+
cursor: 'default',
|
|
32
|
+
zIndex: -1
|
|
33
|
+
}
|
|
31
34
|
},
|
|
35
|
+
// TODO - ED-23995 this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
|
|
32
36
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
33
|
-
'[data-
|
|
37
|
+
'hr[data-drag-handler-anchor-name]': {
|
|
38
|
+
overflow: 'visible'
|
|
39
|
+
},
|
|
40
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
41
|
+
'[data-blocks-drag-handle-container="true"] + *::after': {
|
|
34
42
|
display: 'none'
|
|
35
43
|
}
|
|
36
44
|
});
|
|
@@ -5,13 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getTopPosition = exports.getLeftPosition = void 0;
|
|
7
7
|
var _consts = require("../ui/consts");
|
|
8
|
-
var getTopPosition = exports.getTopPosition = function getTopPosition(dom) {
|
|
8
|
+
var getTopPosition = exports.getTopPosition = function getTopPosition(dom, type) {
|
|
9
9
|
if (!dom) {
|
|
10
10
|
return 'auto';
|
|
11
11
|
}
|
|
12
12
|
var table = dom.querySelector('table');
|
|
13
13
|
if (table) {
|
|
14
14
|
return "".concat(dom.offsetTop + ((table === null || table === void 0 ? void 0 : table.offsetTop) || 0), "px");
|
|
15
|
+
} else if (type === 'rule') {
|
|
16
|
+
return "".concat(dom.offsetTop - _consts.DRAG_HANDLE_DIVIDER_TOP_ADJUSTMENT, "px");
|
|
15
17
|
} else {
|
|
16
18
|
return "".concat(dom.offsetTop, "px");
|
|
17
19
|
}
|
|
@@ -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,7 +1,8 @@
|
|
|
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
|
-
import {
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { DragHandle } from '../ui/drag-handle';
|
|
6
7
|
import { DropTarget } from '../ui/drop-target';
|
|
7
8
|
import { MouseMoveWrapper } from '../ui/mouse-move-wrapper';
|
|
@@ -74,7 +75,7 @@ export const nodeDecorations = newState => {
|
|
|
74
75
|
newState.doc.descendants((node, pos, _parent, index) => {
|
|
75
76
|
const anchorName = `--node-anchor-${node.type.name}-${index}`;
|
|
76
77
|
let style;
|
|
77
|
-
if (
|
|
78
|
+
if (fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
78
79
|
style = `anchor-name: ${anchorName}; ${pos === 0 ? 'margin-top: 0px;' : ''}; position: relative; z-index: 1;`;
|
|
79
80
|
} else {
|
|
80
81
|
style = `anchor-name: ${anchorName}; ${pos === 0 ? 'margin-top: 0px;' : ''}`;
|
|
@@ -129,25 +130,27 @@ 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
|
|
136
137
|
element.style.display = 'inline';
|
|
137
138
|
element.setAttribute('data-testid', 'block-ctrl-decorator-widget');
|
|
138
139
|
element.setAttribute('data-blocks-drag-handle-container', 'true');
|
|
139
|
-
if (
|
|
140
|
+
if (fg('platform.editor.elements.drag-and-drop-remove-wrapper_fyqr2')) {
|
|
140
141
|
// There are times when global clear: "both" styles are applied to this decoration causing jumpiness
|
|
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,
|