@atlaskit/editor-plugin-block-controls 2.19.0 → 2.19.2
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 +17 -0
- package/dist/cjs/blockControlsPlugin.js +0 -5
- package/dist/cjs/pm-plugins/decorations-anchor.js +1 -1
- package/dist/cjs/pm-plugins/handle-mouse-over.js +2 -6
- package/dist/cjs/ui/drag-handle.js +13 -37
- package/dist/cjs/ui/global-styles.js +2 -2
- package/dist/es2019/blockControlsPlugin.js +0 -5
- package/dist/es2019/pm-plugins/decorations-anchor.js +1 -1
- package/dist/es2019/pm-plugins/handle-mouse-over.js +2 -6
- package/dist/es2019/ui/drag-handle.js +8 -33
- package/dist/es2019/ui/global-styles.js +2 -2
- package/dist/esm/blockControlsPlugin.js +0 -5
- package/dist/esm/pm-plugins/decorations-anchor.js +1 -1
- package/dist/esm/pm-plugins/handle-mouse-over.js +2 -6
- package/dist/esm/ui/drag-handle.js +14 -38
- package/dist/esm/ui/global-styles.js +2 -2
- package/dist/types/blockControlsPluginType.d.ts +15 -13
- package/dist/types/pm-plugins/keymap.d.ts +2 -1
- package/dist/types-ts4.5/blockControlsPluginType.d.ts +15 -13
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -1
- package/package.json +2 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.19.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#102237](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102237)
|
|
8
|
+
[`ff4d14b55fec9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ff4d14b55fec9) -
|
|
9
|
+
[ED-26244] clean up platform_editor_element_drag_and_drop_ed_24885
|
|
10
|
+
|
|
11
|
+
## 2.19.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#102045](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102045)
|
|
16
|
+
[`44f96aff22dd9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/44f96aff22dd9) -
|
|
17
|
+
[ED-26179] clean up platform_editor_elements_dnd_nested_table
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 2.19.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
|
@@ -6,11 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.blockControlsPlugin = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
9
|
var _moveNode = require("./editor-commands/move-node");
|
|
11
10
|
var _moveToLayout = require("./editor-commands/move-to-layout");
|
|
12
11
|
var _main = require("./pm-plugins/main");
|
|
13
|
-
var _getSelection = require("./pm-plugins/utils/getSelection");
|
|
14
12
|
var _dragHandleMenu = require("./ui/drag-handle-menu");
|
|
15
13
|
var _globalStyles = require("./ui/global-styles");
|
|
16
14
|
var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
@@ -53,9 +51,6 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
53
51
|
if (pos === undefined) {
|
|
54
52
|
return tr;
|
|
55
53
|
}
|
|
56
|
-
if (!(0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_24885')) {
|
|
57
|
-
tr = (0, _getSelection.selectNode)(tr, pos, nodeType);
|
|
58
|
-
}
|
|
59
54
|
tr.setMeta(_main.key, {
|
|
60
55
|
isDragging: true,
|
|
61
56
|
activeNode: {
|
|
@@ -15,7 +15,7 @@ var IGNORE_NODE_DESCENDANTS = ['listItem', 'taskList', 'decisionList', 'mediaSin
|
|
|
15
15
|
var IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT = ['listItem', 'taskList', 'decisionList'];
|
|
16
16
|
var shouldDescendIntoNode = exports.shouldDescendIntoNode = function shouldDescendIntoNode(node) {
|
|
17
17
|
// Optimisation to avoid drawing node decorations for empty table cells
|
|
18
|
-
if (['tableCell', 'tableHeader'].includes(node.type.name)
|
|
18
|
+
if (['tableCell', 'tableHeader'].includes(node.type.name)) {
|
|
19
19
|
var _node$firstChild;
|
|
20
20
|
if (node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'paragraph') {
|
|
21
21
|
return false;
|
|
@@ -48,16 +48,12 @@ var handleMouseOver = exports.handleMouseOver = function handleMouseOver(view, e
|
|
|
48
48
|
var parentElementType = parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute('data-drag-handler-node-type');
|
|
49
49
|
if ((0, _experiments.editorExperiment)('advanced_layouts', true) && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
50
50
|
// We want to exclude handles from showing for direct descendant of table nodes (i.e. nodes in cells)
|
|
51
|
-
if (parentElement && (parentElementType === 'table' || parentElementType === 'tableRow') && (0, _experiments.editorExperiment)('nested-dnd', true)
|
|
52
|
-
exposure: true
|
|
53
|
-
})) {
|
|
51
|
+
if (parentElement && (parentElementType === 'table' || parentElementType === 'tableRow') && (0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
54
52
|
rootElement = parentElement;
|
|
55
53
|
}
|
|
56
54
|
} else {
|
|
57
55
|
// We want to exclude handles from showing for direct descendant of table nodes (i.e. nodes in cells)
|
|
58
|
-
if (parentElement && parentElementType === 'table' && (0, _experiments.editorExperiment)('nested-dnd', true)
|
|
59
|
-
exposure: true
|
|
60
|
-
})) {
|
|
56
|
+
if (parentElement && parentElementType === 'table' && (0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
61
57
|
rootElement = parentElement;
|
|
62
58
|
}
|
|
63
59
|
}
|
|
@@ -73,7 +73,7 @@ var selectedStyles = (0, _react2.css)({
|
|
|
73
73
|
color: "var(--ds-icon-selected, #0C66E4)"
|
|
74
74
|
});
|
|
75
75
|
var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
76
|
-
var _api$core2, _api$analytics2, _api$core4
|
|
76
|
+
var _api$core2, _api$analytics2, _api$core4;
|
|
77
77
|
var view = _ref.view,
|
|
78
78
|
api = _ref.api,
|
|
79
79
|
formatMessage = _ref.formatMessage,
|
|
@@ -146,7 +146,6 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
146
146
|
// as expected with a node selection. This workaround sets the selection to the node on mouseDown,
|
|
147
147
|
// but ensures the preview is generated correctly.
|
|
148
148
|
var handleMouseDown = (0, _react.useCallback)(function () {
|
|
149
|
-
var _api$core3;
|
|
150
149
|
if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
151
150
|
// prevent native drag and drop.
|
|
152
151
|
if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
@@ -157,39 +156,16 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
157
156
|
return undefined;
|
|
158
157
|
}
|
|
159
158
|
}
|
|
160
|
-
|
|
161
|
-
return undefined;
|
|
162
|
-
}
|
|
163
|
-
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
|
|
164
|
-
var tr = _ref3.tr;
|
|
165
|
-
var startPos = getPos();
|
|
166
|
-
if (startPos === undefined) {
|
|
167
|
-
return tr;
|
|
168
|
-
}
|
|
169
|
-
var node = tr.doc.nodeAt(startPos);
|
|
170
|
-
if (!node) {
|
|
171
|
-
return tr;
|
|
172
|
-
}
|
|
173
|
-
var selection;
|
|
174
|
-
if (isLayoutColumn && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
175
|
-
selection = new _state.NodeSelection(tr.doc.resolve(startPos));
|
|
176
|
-
} else {
|
|
177
|
-
var $startPos = tr.doc.resolve(startPos + node.nodeSize);
|
|
178
|
-
selection = new _state.TextSelection($startPos);
|
|
179
|
-
}
|
|
180
|
-
tr.setSelection(selection);
|
|
181
|
-
return tr;
|
|
182
|
-
});
|
|
183
|
-
}, [api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, getPos, isLayoutColumn]);
|
|
159
|
+
}, [isLayoutColumn]);
|
|
184
160
|
var handleKeyDown = (0, _react.useCallback)(function (e) {
|
|
185
161
|
if ((0, _platformFeatureFlags.fg)('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
186
162
|
// allow user to use spacebar to select the node
|
|
187
163
|
|
|
188
164
|
if (!e.repeat && e.key === ' ') {
|
|
189
|
-
var _api$
|
|
165
|
+
var _api$core3;
|
|
190
166
|
var startPos = getPos();
|
|
191
|
-
api === null || api === void 0 || (_api$
|
|
192
|
-
var tr =
|
|
167
|
+
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
|
|
168
|
+
var tr = _ref3.tr;
|
|
193
169
|
if (startPos === undefined) {
|
|
194
170
|
return tr;
|
|
195
171
|
}
|
|
@@ -213,7 +189,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
213
189
|
view.focus();
|
|
214
190
|
}
|
|
215
191
|
}
|
|
216
|
-
}, [getPos, api === null || api === void 0 || (_api$
|
|
192
|
+
}, [getPos, api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, view]);
|
|
217
193
|
(0, _react.useEffect)(function () {
|
|
218
194
|
var element = buttonRef.current;
|
|
219
195
|
if (!element) {
|
|
@@ -227,11 +203,11 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
227
203
|
start: start
|
|
228
204
|
};
|
|
229
205
|
},
|
|
230
|
-
onGenerateDragPreview: function onGenerateDragPreview(
|
|
231
|
-
var nativeSetDragImage =
|
|
206
|
+
onGenerateDragPreview: function onGenerateDragPreview(_ref4) {
|
|
207
|
+
var nativeSetDragImage = _ref4.nativeSetDragImage;
|
|
232
208
|
(0, _setCustomNativeDragPreview.setCustomNativeDragPreview)({
|
|
233
|
-
render: function render(
|
|
234
|
-
var container =
|
|
209
|
+
render: function render(_ref5) {
|
|
210
|
+
var container = _ref5.container;
|
|
235
211
|
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
|
|
236
212
|
if (!dom) {
|
|
237
213
|
return;
|
|
@@ -242,13 +218,13 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
242
218
|
});
|
|
243
219
|
},
|
|
244
220
|
onDragStart: function onDragStart() {
|
|
245
|
-
var _api$
|
|
221
|
+
var _api$core5;
|
|
246
222
|
if (start === undefined) {
|
|
247
223
|
return;
|
|
248
224
|
}
|
|
249
|
-
api === null || api === void 0 || (_api$
|
|
225
|
+
api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref6) {
|
|
250
226
|
var _api$blockControls, _api$analytics3;
|
|
251
|
-
var tr =
|
|
227
|
+
var tr = _ref6.tr;
|
|
252
228
|
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.setNodeDragged(getPos, anchorName, nodeType)({
|
|
253
229
|
tr: tr
|
|
254
230
|
});
|
|
@@ -73,9 +73,9 @@ var extendedHoverZoneNested = function extendedHoverZoneNested() {
|
|
|
73
73
|
position: 'absolute',
|
|
74
74
|
top: 0,
|
|
75
75
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
76
|
-
left:
|
|
76
|
+
left: 0,
|
|
77
77
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
78
|
-
width:
|
|
78
|
+
width: 0,
|
|
79
79
|
height: '100%',
|
|
80
80
|
cursor: 'default',
|
|
81
81
|
zIndex: 1
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
2
|
import { moveNode } from './editor-commands/move-node';
|
|
4
3
|
import { moveToLayout } from './editor-commands/move-to-layout';
|
|
5
4
|
import { createPlugin, key } from './pm-plugins/main';
|
|
6
|
-
import { selectNode } from './pm-plugins/utils/getSelection';
|
|
7
5
|
import { DragHandleMenu } from './ui/drag-handle-menu';
|
|
8
6
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
9
7
|
export const blockControlsPlugin = ({
|
|
@@ -44,9 +42,6 @@ export const blockControlsPlugin = ({
|
|
|
44
42
|
if (pos === undefined) {
|
|
45
43
|
return tr;
|
|
46
44
|
}
|
|
47
|
-
if (!fg('platform_editor_element_drag_and_drop_ed_24885')) {
|
|
48
|
-
tr = selectNode(tr, pos, nodeType);
|
|
49
|
-
}
|
|
50
45
|
tr.setMeta(key, {
|
|
51
46
|
isDragging: true,
|
|
52
47
|
activeNode: {
|
|
@@ -7,7 +7,7 @@ const IGNORE_NODE_DESCENDANTS = ['listItem', 'taskList', 'decisionList', 'mediaS
|
|
|
7
7
|
const IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT = ['listItem', 'taskList', 'decisionList'];
|
|
8
8
|
export const shouldDescendIntoNode = node => {
|
|
9
9
|
// Optimisation to avoid drawing node decorations for empty table cells
|
|
10
|
-
if (['tableCell', 'tableHeader'].includes(node.type.name)
|
|
10
|
+
if (['tableCell', 'tableHeader'].includes(node.type.name)) {
|
|
11
11
|
var _node$firstChild;
|
|
12
12
|
if (node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'paragraph') {
|
|
13
13
|
return false;
|
|
@@ -43,16 +43,12 @@ export const handleMouseOver = (view, event, api) => {
|
|
|
43
43
|
const parentElementType = parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute('data-drag-handler-node-type');
|
|
44
44
|
if (editorExperiment('advanced_layouts', true) && fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
45
45
|
// We want to exclude handles from showing for direct descendant of table nodes (i.e. nodes in cells)
|
|
46
|
-
if (parentElement && (parentElementType === 'table' || parentElementType === 'tableRow') && editorExperiment('nested-dnd', true)
|
|
47
|
-
exposure: true
|
|
48
|
-
})) {
|
|
46
|
+
if (parentElement && (parentElementType === 'table' || parentElementType === 'tableRow') && editorExperiment('nested-dnd', true)) {
|
|
49
47
|
rootElement = parentElement;
|
|
50
48
|
}
|
|
51
49
|
} else {
|
|
52
50
|
// We want to exclude handles from showing for direct descendant of table nodes (i.e. nodes in cells)
|
|
53
|
-
if (parentElement && parentElementType === 'table' && editorExperiment('nested-dnd', true)
|
|
54
|
-
exposure: true
|
|
55
|
-
})) {
|
|
51
|
+
if (parentElement && parentElementType === 'table' && editorExperiment('nested-dnd', true)) {
|
|
56
52
|
rootElement = parentElement;
|
|
57
53
|
}
|
|
58
54
|
}
|
|
@@ -10,7 +10,7 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
|
|
|
10
10
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
11
11
|
import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, getAriaKeyshortcuts, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
|
|
12
12
|
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
13
|
-
import {
|
|
13
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
14
14
|
import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
|
|
15
15
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
16
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
@@ -71,7 +71,7 @@ export const DragHandle = ({
|
|
|
71
71
|
handleOptions,
|
|
72
72
|
isTopLevelNode = true
|
|
73
73
|
}) => {
|
|
74
|
-
var _api$core2, _api$analytics2, _api$core4
|
|
74
|
+
var _api$core2, _api$analytics2, _api$core4;
|
|
75
75
|
const start = getPos();
|
|
76
76
|
const buttonRef = useRef(null);
|
|
77
77
|
const [blockCardWidth, setBlockCardWidth] = useState(768);
|
|
@@ -129,7 +129,6 @@ export const DragHandle = ({
|
|
|
129
129
|
// as expected with a node selection. This workaround sets the selection to the node on mouseDown,
|
|
130
130
|
// but ensures the preview is generated correctly.
|
|
131
131
|
const handleMouseDown = useCallback(() => {
|
|
132
|
-
var _api$core3;
|
|
133
132
|
if (editorExperiment('advanced_layouts', true)) {
|
|
134
133
|
// prevent native drag and drop.
|
|
135
134
|
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
@@ -140,39 +139,15 @@ export const DragHandle = ({
|
|
|
140
139
|
return undefined;
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
|
-
|
|
144
|
-
return undefined;
|
|
145
|
-
}
|
|
146
|
-
api === null || api === void 0 ? void 0 : (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(({
|
|
147
|
-
tr
|
|
148
|
-
}) => {
|
|
149
|
-
const startPos = getPos();
|
|
150
|
-
if (startPos === undefined) {
|
|
151
|
-
return tr;
|
|
152
|
-
}
|
|
153
|
-
const node = tr.doc.nodeAt(startPos);
|
|
154
|
-
if (!node) {
|
|
155
|
-
return tr;
|
|
156
|
-
}
|
|
157
|
-
let selection;
|
|
158
|
-
if (isLayoutColumn && editorExperiment('advanced_layouts', true)) {
|
|
159
|
-
selection = new NodeSelection(tr.doc.resolve(startPos));
|
|
160
|
-
} else {
|
|
161
|
-
const $startPos = tr.doc.resolve(startPos + node.nodeSize);
|
|
162
|
-
selection = new TextSelection($startPos);
|
|
163
|
-
}
|
|
164
|
-
tr.setSelection(selection);
|
|
165
|
-
return tr;
|
|
166
|
-
});
|
|
167
|
-
}, [api === null || api === void 0 ? void 0 : (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, getPos, isLayoutColumn]);
|
|
142
|
+
}, [isLayoutColumn]);
|
|
168
143
|
const handleKeyDown = useCallback(e => {
|
|
169
144
|
if (fg('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
170
145
|
// allow user to use spacebar to select the node
|
|
171
146
|
|
|
172
147
|
if (!e.repeat && e.key === ' ') {
|
|
173
|
-
var _api$
|
|
148
|
+
var _api$core3;
|
|
174
149
|
const startPos = getPos();
|
|
175
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
150
|
+
api === null || api === void 0 ? void 0 : (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(({
|
|
176
151
|
tr
|
|
177
152
|
}) => {
|
|
178
153
|
if (startPos === undefined) {
|
|
@@ -196,7 +171,7 @@ export const DragHandle = ({
|
|
|
196
171
|
view.focus();
|
|
197
172
|
}
|
|
198
173
|
}
|
|
199
|
-
}, [getPos, api === null || api === void 0 ? void 0 : (_api$
|
|
174
|
+
}, [getPos, api === null || api === void 0 ? void 0 : (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, view]);
|
|
200
175
|
useEffect(() => {
|
|
201
176
|
const element = buttonRef.current;
|
|
202
177
|
if (!element) {
|
|
@@ -225,11 +200,11 @@ export const DragHandle = ({
|
|
|
225
200
|
});
|
|
226
201
|
},
|
|
227
202
|
onDragStart() {
|
|
228
|
-
var _api$
|
|
203
|
+
var _api$core5;
|
|
229
204
|
if (start === undefined) {
|
|
230
205
|
return;
|
|
231
206
|
}
|
|
232
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
207
|
+
api === null || api === void 0 ? void 0 : (_api$core5 = api.core) === null || _api$core5 === void 0 ? void 0 : _api$core5.actions.execute(({
|
|
233
208
|
tr
|
|
234
209
|
}) => {
|
|
235
210
|
var _api$blockControls, _api$analytics3;
|
|
@@ -85,9 +85,9 @@ const extendedHoverZoneNested = () => css({
|
|
|
85
85
|
position: 'absolute',
|
|
86
86
|
top: 0,
|
|
87
87
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
88
|
-
left:
|
|
88
|
+
left: 0,
|
|
89
89
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
90
|
-
width:
|
|
90
|
+
width: 0,
|
|
91
91
|
height: '100%',
|
|
92
92
|
cursor: 'default',
|
|
93
93
|
zIndex: 1
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
2
|
import { moveNode } from './editor-commands/move-node';
|
|
4
3
|
import { moveToLayout } from './editor-commands/move-to-layout';
|
|
5
4
|
import { createPlugin, key } from './pm-plugins/main';
|
|
6
|
-
import { selectNode } from './pm-plugins/utils/getSelection';
|
|
7
5
|
import { DragHandleMenu } from './ui/drag-handle-menu';
|
|
8
6
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
9
7
|
export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
@@ -46,9 +44,6 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
46
44
|
if (pos === undefined) {
|
|
47
45
|
return tr;
|
|
48
46
|
}
|
|
49
|
-
if (!fg('platform_editor_element_drag_and_drop_ed_24885')) {
|
|
50
|
-
tr = selectNode(tr, pos, nodeType);
|
|
51
|
-
}
|
|
52
47
|
tr.setMeta(key, {
|
|
53
48
|
isDragging: true,
|
|
54
49
|
activeNode: {
|
|
@@ -8,7 +8,7 @@ var IGNORE_NODE_DESCENDANTS = ['listItem', 'taskList', 'decisionList', 'mediaSin
|
|
|
8
8
|
var IGNORE_NODE_DESCENDANTS_ADVANCED_LAYOUT = ['listItem', 'taskList', 'decisionList'];
|
|
9
9
|
export var shouldDescendIntoNode = function shouldDescendIntoNode(node) {
|
|
10
10
|
// Optimisation to avoid drawing node decorations for empty table cells
|
|
11
|
-
if (['tableCell', 'tableHeader'].includes(node.type.name)
|
|
11
|
+
if (['tableCell', 'tableHeader'].includes(node.type.name)) {
|
|
12
12
|
var _node$firstChild;
|
|
13
13
|
if (node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.type.name) === 'paragraph') {
|
|
14
14
|
return false;
|
|
@@ -42,16 +42,12 @@ export var handleMouseOver = function handleMouseOver(view, event, api) {
|
|
|
42
42
|
var parentElementType = parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute('data-drag-handler-node-type');
|
|
43
43
|
if (editorExperiment('advanced_layouts', true) && fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
44
44
|
// We want to exclude handles from showing for direct descendant of table nodes (i.e. nodes in cells)
|
|
45
|
-
if (parentElement && (parentElementType === 'table' || parentElementType === 'tableRow') && editorExperiment('nested-dnd', true)
|
|
46
|
-
exposure: true
|
|
47
|
-
})) {
|
|
45
|
+
if (parentElement && (parentElementType === 'table' || parentElementType === 'tableRow') && editorExperiment('nested-dnd', true)) {
|
|
48
46
|
rootElement = parentElement;
|
|
49
47
|
}
|
|
50
48
|
} else {
|
|
51
49
|
// We want to exclude handles from showing for direct descendant of table nodes (i.e. nodes in cells)
|
|
52
|
-
if (parentElement && parentElementType === 'table' && editorExperiment('nested-dnd', true)
|
|
53
|
-
exposure: true
|
|
54
|
-
})) {
|
|
50
|
+
if (parentElement && parentElementType === 'table' && editorExperiment('nested-dnd', true)) {
|
|
55
51
|
rootElement = parentElement;
|
|
56
52
|
}
|
|
57
53
|
}
|
|
@@ -12,7 +12,7 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
|
|
|
12
12
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
13
13
|
import { dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, getAriaKeyshortcuts, TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
|
|
14
14
|
import { blockControlsMessages } from '@atlaskit/editor-common/messages';
|
|
15
|
-
import {
|
|
15
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
16
16
|
import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
|
|
17
17
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
18
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
@@ -64,7 +64,7 @@ var selectedStyles = css({
|
|
|
64
64
|
color: "var(--ds-icon-selected, #0C66E4)"
|
|
65
65
|
});
|
|
66
66
|
export var DragHandle = function DragHandle(_ref) {
|
|
67
|
-
var _api$core2, _api$analytics2, _api$core4
|
|
67
|
+
var _api$core2, _api$analytics2, _api$core4;
|
|
68
68
|
var view = _ref.view,
|
|
69
69
|
api = _ref.api,
|
|
70
70
|
formatMessage = _ref.formatMessage,
|
|
@@ -137,7 +137,6 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
137
137
|
// as expected with a node selection. This workaround sets the selection to the node on mouseDown,
|
|
138
138
|
// but ensures the preview is generated correctly.
|
|
139
139
|
var handleMouseDown = useCallback(function () {
|
|
140
|
-
var _api$core3;
|
|
141
140
|
if (editorExperiment('advanced_layouts', true)) {
|
|
142
141
|
// prevent native drag and drop.
|
|
143
142
|
if (fg('platform_editor_advanced_layouts_post_fix_patch_1')) {
|
|
@@ -148,39 +147,16 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
148
147
|
return undefined;
|
|
149
148
|
}
|
|
150
149
|
}
|
|
151
|
-
|
|
152
|
-
return undefined;
|
|
153
|
-
}
|
|
154
|
-
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
|
|
155
|
-
var tr = _ref3.tr;
|
|
156
|
-
var startPos = getPos();
|
|
157
|
-
if (startPos === undefined) {
|
|
158
|
-
return tr;
|
|
159
|
-
}
|
|
160
|
-
var node = tr.doc.nodeAt(startPos);
|
|
161
|
-
if (!node) {
|
|
162
|
-
return tr;
|
|
163
|
-
}
|
|
164
|
-
var selection;
|
|
165
|
-
if (isLayoutColumn && editorExperiment('advanced_layouts', true)) {
|
|
166
|
-
selection = new NodeSelection(tr.doc.resolve(startPos));
|
|
167
|
-
} else {
|
|
168
|
-
var $startPos = tr.doc.resolve(startPos + node.nodeSize);
|
|
169
|
-
selection = new TextSelection($startPos);
|
|
170
|
-
}
|
|
171
|
-
tr.setSelection(selection);
|
|
172
|
-
return tr;
|
|
173
|
-
});
|
|
174
|
-
}, [api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, getPos, isLayoutColumn]);
|
|
150
|
+
}, [isLayoutColumn]);
|
|
175
151
|
var handleKeyDown = useCallback(function (e) {
|
|
176
152
|
if (fg('platform_editor_element_drag_and_drop_ed_23873')) {
|
|
177
153
|
// allow user to use spacebar to select the node
|
|
178
154
|
|
|
179
155
|
if (!e.repeat && e.key === ' ') {
|
|
180
|
-
var _api$
|
|
156
|
+
var _api$core3;
|
|
181
157
|
var startPos = getPos();
|
|
182
|
-
api === null || api === void 0 || (_api$
|
|
183
|
-
var tr =
|
|
158
|
+
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
|
|
159
|
+
var tr = _ref3.tr;
|
|
184
160
|
if (startPos === undefined) {
|
|
185
161
|
return tr;
|
|
186
162
|
}
|
|
@@ -204,7 +180,7 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
204
180
|
view.focus();
|
|
205
181
|
}
|
|
206
182
|
}
|
|
207
|
-
}, [getPos, api === null || api === void 0 || (_api$
|
|
183
|
+
}, [getPos, api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, view]);
|
|
208
184
|
useEffect(function () {
|
|
209
185
|
var element = buttonRef.current;
|
|
210
186
|
if (!element) {
|
|
@@ -218,11 +194,11 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
218
194
|
start: start
|
|
219
195
|
};
|
|
220
196
|
},
|
|
221
|
-
onGenerateDragPreview: function onGenerateDragPreview(
|
|
222
|
-
var nativeSetDragImage =
|
|
197
|
+
onGenerateDragPreview: function onGenerateDragPreview(_ref4) {
|
|
198
|
+
var nativeSetDragImage = _ref4.nativeSetDragImage;
|
|
223
199
|
setCustomNativeDragPreview({
|
|
224
|
-
render: function render(
|
|
225
|
-
var container =
|
|
200
|
+
render: function render(_ref5) {
|
|
201
|
+
var container = _ref5.container;
|
|
226
202
|
var dom = view.dom.querySelector("[data-drag-handler-anchor-name=\"".concat(anchorName, "\"]"));
|
|
227
203
|
if (!dom) {
|
|
228
204
|
return;
|
|
@@ -233,13 +209,13 @@ export var DragHandle = function DragHandle(_ref) {
|
|
|
233
209
|
});
|
|
234
210
|
},
|
|
235
211
|
onDragStart: function onDragStart() {
|
|
236
|
-
var _api$
|
|
212
|
+
var _api$core5;
|
|
237
213
|
if (start === undefined) {
|
|
238
214
|
return;
|
|
239
215
|
}
|
|
240
|
-
api === null || api === void 0 || (_api$
|
|
216
|
+
api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref6) {
|
|
241
217
|
var _api$blockControls, _api$analytics3;
|
|
242
|
-
var tr =
|
|
218
|
+
var tr = _ref6.tr;
|
|
243
219
|
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.setNodeDragged(getPos, anchorName, nodeType)({
|
|
244
220
|
tr: tr
|
|
245
221
|
});
|
|
@@ -66,9 +66,9 @@ var extendedHoverZoneNested = function extendedHoverZoneNested() {
|
|
|
66
66
|
position: 'absolute',
|
|
67
67
|
top: 0,
|
|
68
68
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
69
|
-
left:
|
|
69
|
+
left: 0,
|
|
70
70
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values
|
|
71
|
-
width:
|
|
71
|
+
width: 0,
|
|
72
72
|
height: '100%',
|
|
73
73
|
cursor: 'default',
|
|
74
74
|
zIndex: 1
|
|
@@ -43,19 +43,21 @@ export type BlockControlsSharedState = {
|
|
|
43
43
|
export type HandleOptions = {
|
|
44
44
|
isFocused: boolean;
|
|
45
45
|
} | undefined;
|
|
46
|
+
export type MoveNode = (start: number, to: number, inputMethod?: MoveNodeMethod, formatMessage?: IntlShape['formatMessage']) => EditorCommand;
|
|
47
|
+
export type BlockControlsPluginDependencies = [
|
|
48
|
+
OptionalPlugin<EditorDisabledPlugin>,
|
|
49
|
+
OptionalPlugin<WidthPlugin>,
|
|
50
|
+
OptionalPlugin<FeatureFlagsPlugin>,
|
|
51
|
+
OptionalPlugin<AnalyticsPlugin>,
|
|
52
|
+
OptionalPlugin<AccessibilityUtilsPlugin>,
|
|
53
|
+
/**
|
|
54
|
+
* For Typeahead - Empty line prompt experiment
|
|
55
|
+
* Clean up ticket ED-24824
|
|
56
|
+
*/
|
|
57
|
+
OptionalPlugin<QuickInsertPlugin>
|
|
58
|
+
];
|
|
46
59
|
export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
47
|
-
dependencies:
|
|
48
|
-
OptionalPlugin<EditorDisabledPlugin>,
|
|
49
|
-
OptionalPlugin<WidthPlugin>,
|
|
50
|
-
OptionalPlugin<FeatureFlagsPlugin>,
|
|
51
|
-
OptionalPlugin<AnalyticsPlugin>,
|
|
52
|
-
OptionalPlugin<AccessibilityUtilsPlugin>,
|
|
53
|
-
/**
|
|
54
|
-
* For Typeahead - Empty line prompt experiment
|
|
55
|
-
* Clean up ticket ED-24824
|
|
56
|
-
*/
|
|
57
|
-
OptionalPlugin<QuickInsertPlugin>
|
|
58
|
-
];
|
|
60
|
+
dependencies: BlockControlsPluginDependencies;
|
|
59
61
|
sharedState: BlockControlsSharedState;
|
|
60
62
|
commands: {
|
|
61
63
|
/**
|
|
@@ -67,7 +69,7 @@ export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
|
67
69
|
moveToLayout: (start: number, to: number, options?: {
|
|
68
70
|
moveToEnd?: boolean;
|
|
69
71
|
}) => EditorCommand;
|
|
70
|
-
moveNode:
|
|
72
|
+
moveNode: MoveNode;
|
|
71
73
|
showDragHandleAt: (pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => EditorCommand;
|
|
72
74
|
setNodeDragged: (getPos: () => number | undefined, anchorName: string, nodeType: string) => EditorCommand;
|
|
73
75
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type IntlShape } from 'react-intl-next';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
4
|
import type { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
4
|
-
export declare const boundKeydownHandler: (api?: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage?: IntlShape['formatMessage']) => (view:
|
|
5
|
+
export declare const boundKeydownHandler: (api?: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage?: IntlShape['formatMessage']) => (view: EditorView, event: KeyboardEvent) => boolean;
|
|
@@ -43,19 +43,21 @@ export type BlockControlsSharedState = {
|
|
|
43
43
|
export type HandleOptions = {
|
|
44
44
|
isFocused: boolean;
|
|
45
45
|
} | undefined;
|
|
46
|
+
export type MoveNode = (start: number, to: number, inputMethod?: MoveNodeMethod, formatMessage?: IntlShape['formatMessage']) => EditorCommand;
|
|
47
|
+
export type BlockControlsPluginDependencies = [
|
|
48
|
+
OptionalPlugin<EditorDisabledPlugin>,
|
|
49
|
+
OptionalPlugin<WidthPlugin>,
|
|
50
|
+
OptionalPlugin<FeatureFlagsPlugin>,
|
|
51
|
+
OptionalPlugin<AnalyticsPlugin>,
|
|
52
|
+
OptionalPlugin<AccessibilityUtilsPlugin>,
|
|
53
|
+
/**
|
|
54
|
+
* For Typeahead - Empty line prompt experiment
|
|
55
|
+
* Clean up ticket ED-24824
|
|
56
|
+
*/
|
|
57
|
+
OptionalPlugin<QuickInsertPlugin>
|
|
58
|
+
];
|
|
46
59
|
export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
47
|
-
dependencies:
|
|
48
|
-
OptionalPlugin<EditorDisabledPlugin>,
|
|
49
|
-
OptionalPlugin<WidthPlugin>,
|
|
50
|
-
OptionalPlugin<FeatureFlagsPlugin>,
|
|
51
|
-
OptionalPlugin<AnalyticsPlugin>,
|
|
52
|
-
OptionalPlugin<AccessibilityUtilsPlugin>,
|
|
53
|
-
/**
|
|
54
|
-
* For Typeahead - Empty line prompt experiment
|
|
55
|
-
* Clean up ticket ED-24824
|
|
56
|
-
*/
|
|
57
|
-
OptionalPlugin<QuickInsertPlugin>
|
|
58
|
-
];
|
|
60
|
+
dependencies: BlockControlsPluginDependencies;
|
|
59
61
|
sharedState: BlockControlsSharedState;
|
|
60
62
|
commands: {
|
|
61
63
|
/**
|
|
@@ -67,7 +69,7 @@ export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
|
67
69
|
moveToLayout: (start: number, to: number, options?: {
|
|
68
70
|
moveToEnd?: boolean;
|
|
69
71
|
}) => EditorCommand;
|
|
70
|
-
moveNode:
|
|
72
|
+
moveNode: MoveNode;
|
|
71
73
|
showDragHandleAt: (pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => EditorCommand;
|
|
72
74
|
setNodeDragged: (getPos: () => number | undefined, anchorName: string, nodeType: string) => EditorCommand;
|
|
73
75
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type IntlShape } from 'react-intl-next';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
4
|
import type { BlockControlsPlugin } from '../blockControlsPluginType';
|
|
4
|
-
export declare const boundKeydownHandler: (api?: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage?: IntlShape['formatMessage']) => (view:
|
|
5
|
+
export declare const boundKeydownHandler: (api?: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage?: IntlShape['formatMessage']) => (view: EditorView, event: KeyboardEvent) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.2",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
|
|
49
49
|
"@atlaskit/primitives": "^13.3.0",
|
|
50
50
|
"@atlaskit/theme": "^14.0.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^2.34.0",
|
|
52
52
|
"@atlaskit/tokens": "^3.0.0",
|
|
53
53
|
"@atlaskit/tooltip": "^19.0.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
@@ -118,9 +118,6 @@
|
|
|
118
118
|
"platform_editor_element_drag_and_drop_debug": {
|
|
119
119
|
"type": "boolean"
|
|
120
120
|
},
|
|
121
|
-
"platform_editor_element_drag_and_drop_ed_24885": {
|
|
122
|
-
"type": "boolean"
|
|
123
|
-
},
|
|
124
121
|
"platform_editor_element_dnd_nested_fix_patch_6": {
|
|
125
122
|
"type": "boolean"
|
|
126
123
|
},
|