@atlaskit/editor-plugin-block-controls 30.0.1 → 30.1.1
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 +20 -0
- package/dist/cjs/blockControlsPlugin.js +8 -0
- package/dist/cjs/pm-plugins/main.js +4 -68
- package/dist/cjs/ui/block-controls-surface-drag-handle.js +9 -3
- package/dist/cjs/ui/drag-handle.js +23 -10
- package/dist/cjs/ui/use-block-controls-surface-drag-source.js +0 -5
- package/dist/es2019/blockControlsPlugin.js +8 -0
- package/dist/es2019/pm-plugins/main.js +4 -69
- package/dist/es2019/ui/block-controls-surface-drag-handle.js +9 -3
- package/dist/es2019/ui/drag-handle.js +23 -10
- package/dist/es2019/ui/use-block-controls-surface-drag-source.js +0 -5
- package/dist/esm/blockControlsPlugin.js +8 -0
- package/dist/esm/pm-plugins/main.js +4 -68
- package/dist/esm/ui/block-controls-surface-drag-handle.js +9 -3
- package/dist/esm/ui/drag-handle.js +23 -10
- package/dist/esm/ui/use-block-controls-surface-drag-source.js +0 -5
- package/dist/types/blockControlsPluginType.d.ts +9 -0
- package/package.json +7 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 30.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`c02fec2c86f55`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c02fec2c86f55) -
|
|
8
|
+
Clean up experiment `platform_editor_remove_legacy_perf_events`
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 30.1.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [`0352c4e5b3ada`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0352c4e5b3ada) -
|
|
16
|
+
Add an optional onBlockHandleClick callback for drag-handle, including keyboard activation.
|
|
17
|
+
Confluence configures the callback behind the confluence_table_to_database experiment.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 30.0.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -77,6 +77,14 @@ var blockControlsPlugin = exports.blockControlsPlugin = function blockControlsPl
|
|
|
77
77
|
return {
|
|
78
78
|
name: 'blockControls',
|
|
79
79
|
actions: {
|
|
80
|
+
notifyBlockHandleClick: function notifyBlockHandleClick(context) {
|
|
81
|
+
try {
|
|
82
|
+
var _config$onBlockHandle;
|
|
83
|
+
config === null || config === void 0 || (_config$onBlockHandle = config.onBlockHandleClick) === null || _config$onBlockHandle === void 0 || _config$onBlockHandle.call(config, context);
|
|
84
|
+
} catch (_unused) {
|
|
85
|
+
// A host callback must not prevent the block menu from opening.
|
|
86
|
+
}
|
|
87
|
+
},
|
|
80
88
|
getTextInfo: function getTextInfo(editorView) {
|
|
81
89
|
var _api$blockControls, _blockControlsState$m;
|
|
82
90
|
var blockControlsState = api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState();
|
|
@@ -12,7 +12,6 @@ var _browserApis = require("@atlaskit/browser-apis");
|
|
|
12
12
|
var _enums = require("@atlaskit/editor-common/analytics/types/enums");
|
|
13
13
|
var _browser = require("@atlaskit/editor-common/browser");
|
|
14
14
|
var _nodeAnchorProvider = require("@atlaskit/editor-common/node-anchor-provider");
|
|
15
|
-
var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
|
|
16
15
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
17
16
|
var _dragHandle = require("@atlaskit/editor-common/styles/drag-handle");
|
|
18
17
|
var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
@@ -51,17 +50,10 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
51
50
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
52
51
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
53
52
|
var key = exports.key = new _state.PluginKey('blockControls');
|
|
54
|
-
var EDITOR_BLOCKS_DRAG_INIT = 'Editor Blocks Drag Initialization Time';
|
|
55
|
-
var EDITOR_BLOCKS_DROP_INIT = 'Editor Blocks Drop Initialization Time';
|
|
56
|
-
var scheduleCallback = function scheduleCallback(cb, options) {
|
|
57
|
-
return 'requestIdleCallback' in window ? requestIdleCallback(cb, _objectSpread({
|
|
58
|
-
timeout: 5000
|
|
59
|
-
}, options)) : requestAnimationFrame(cb);
|
|
60
|
-
};
|
|
61
53
|
var isHTMLElement = function isHTMLElement(element) {
|
|
62
54
|
return element instanceof HTMLElement;
|
|
63
55
|
};
|
|
64
|
-
var destroyFn = function destroyFn(api
|
|
56
|
+
var destroyFn = function destroyFn(api) {
|
|
65
57
|
var _getDocument$querySel, _getDocument;
|
|
66
58
|
var scrollable = (_getDocument$querySel = (_getDocument = (0, _browserApis.getDocument)()) === null || _getDocument === void 0 ? void 0 : _getDocument.querySelector('.fabric-editor-popup-scroll-parent')) !== null && _getDocument$querySel !== void 0 ? _getDocument$querySel : null;
|
|
67
59
|
var cleanupFn = [];
|
|
@@ -70,37 +62,11 @@ var destroyFn = function destroyFn(api, editorView) {
|
|
|
70
62
|
element: scrollable
|
|
71
63
|
}));
|
|
72
64
|
}
|
|
73
|
-
var dragInitializationDuration = 0;
|
|
74
65
|
cleanupFn.push((0, _elementAdapter.monitorForElements)({
|
|
75
66
|
canMonitor: function canMonitor(_ref) {
|
|
76
67
|
var source = _ref.source;
|
|
77
68
|
return source.data.type === 'element';
|
|
78
69
|
},
|
|
79
|
-
onDrag: function onDrag() {
|
|
80
|
-
if ((0, _fg.fg)('platform_editor_drag_and_drop_perf_analytics')) {
|
|
81
|
-
if ((0, _performanceMeasures.isMeasuring)(EDITOR_BLOCKS_DRAG_INIT)) {
|
|
82
|
-
(0, _performanceMeasures.stopMeasure)(EDITOR_BLOCKS_DRAG_INIT, function (duration) {
|
|
83
|
-
dragInitializationDuration = duration;
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
if ((0, _performanceMeasures.isMeasuring)(EDITOR_BLOCKS_DRAG_INIT)) {
|
|
88
|
-
(0, _performanceMeasures.stopMeasure)(EDITOR_BLOCKS_DRAG_INIT, function (duration, startTime) {
|
|
89
|
-
var _api$analytics;
|
|
90
|
-
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
|
|
91
|
-
action: _enums.ACTION.BLOCKS_DRAG_INIT,
|
|
92
|
-
actionSubject: _enums.ACTION_SUBJECT.EDITOR,
|
|
93
|
-
eventType: _enums.EVENT_TYPE.OPERATIONAL,
|
|
94
|
-
attributes: {
|
|
95
|
-
duration: duration,
|
|
96
|
-
startTime: startTime,
|
|
97
|
-
nodesCount: editorView === null || editorView === void 0 ? void 0 : editorView.state.doc.nodeSize
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
70
|
onDragStart: function onDragStart() {
|
|
105
71
|
if (isHTMLElement(scrollable)) {
|
|
106
72
|
scrollable.style.setProperty('scroll-behavior', 'unset');
|
|
@@ -113,10 +79,6 @@ var destroyFn = function destroyFn(api, editorView) {
|
|
|
113
79
|
if (isHTMLElement(scrollable)) {
|
|
114
80
|
scrollable.style.setProperty('scroll-behavior', null);
|
|
115
81
|
}
|
|
116
|
-
var shouldMeasureDrop = (0, _fg.fg)('platform_editor_drag_and_drop_perf_analytics') && !(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_remove_legacy_perf_events');
|
|
117
|
-
if (shouldMeasureDrop) {
|
|
118
|
-
(0, _performanceMeasures.startMeasure)(EDITOR_BLOCKS_DROP_INIT);
|
|
119
|
-
}
|
|
120
82
|
if (!api) {
|
|
121
83
|
return;
|
|
122
84
|
}
|
|
@@ -148,13 +110,13 @@ var destroyFn = function destroyFn(api, editorView) {
|
|
|
148
110
|
// if no drop targets are rendered, assume that drop is invalid
|
|
149
111
|
var lastDragCancelled = location.current.dropTargets.length === 0;
|
|
150
112
|
if (lastDragCancelled) {
|
|
151
|
-
var _api$
|
|
113
|
+
var _api$analytics;
|
|
152
114
|
var position = (0, _selection.getSelectedSlicePosition)(start, tr, api);
|
|
153
115
|
var attributes = (0, _analytics.getMultiSelectAnalyticsAttributes)(tr, position.from, position.to);
|
|
154
116
|
var nodeTypes = attributes.nodeTypes,
|
|
155
117
|
hasSelectedMultipleNodes = attributes.hasSelectedMultipleNodes;
|
|
156
118
|
var resolvedMovingNode = tr.doc.resolve(start);
|
|
157
|
-
(_api$
|
|
119
|
+
(_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
158
120
|
eventType: _enums.EVENT_TYPE.UI,
|
|
159
121
|
action: _enums.ACTION.CANCELLED,
|
|
160
122
|
actionSubject: _enums.ACTION_SUBJECT.DRAG,
|
|
@@ -181,29 +143,6 @@ var destroyFn = function destroyFn(api, editorView) {
|
|
|
181
143
|
lastDragCancelled: lastDragCancelled
|
|
182
144
|
}));
|
|
183
145
|
});
|
|
184
|
-
if (shouldMeasureDrop) {
|
|
185
|
-
// wait for the idle callback to ensure that the drag operation has completed
|
|
186
|
-
scheduleCallback(function () {
|
|
187
|
-
if ((0, _performanceMeasures.isMeasuring)(EDITOR_BLOCKS_DROP_INIT)) {
|
|
188
|
-
(0, _performanceMeasures.stopMeasure)(EDITOR_BLOCKS_DROP_INIT, function (duration) {
|
|
189
|
-
var _api$analytics3;
|
|
190
|
-
var isCancelled = location.current.dropTargets.length === 0;
|
|
191
|
-
api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.fireAnalyticsEvent({
|
|
192
|
-
action: _enums.ACTION.ENDED,
|
|
193
|
-
eventType: _enums.EVENT_TYPE.TRACK,
|
|
194
|
-
actionSubject: _enums.ACTION_SUBJECT.DRAG,
|
|
195
|
-
actionSubjectId: _enums.ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
|
|
196
|
-
attributes: {
|
|
197
|
-
dragInitializationDuration: dragInitializationDuration,
|
|
198
|
-
dropProcessingDuration: duration,
|
|
199
|
-
isCancelled: isCancelled,
|
|
200
|
-
nodesCount: editorView === null || editorView === void 0 ? void 0 : editorView.state.doc.nodeSize
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
146
|
}
|
|
208
147
|
}));
|
|
209
148
|
return _combine.combine.apply(void 0, cleanupFn);
|
|
@@ -1161,9 +1100,6 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
1161
1100
|
if (api !== null && api !== void 0 && (_api$limitedMode6 = api.limitedMode) !== null && _api$limitedMode6 !== void 0 && (_api$limitedMode6 = _api$limitedMode6.sharedState.currentState()) !== null && _api$limitedMode6 !== void 0 && _api$limitedMode6.enabled) {
|
|
1162
1101
|
return;
|
|
1163
1102
|
}
|
|
1164
|
-
if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_remove_legacy_perf_events')) {
|
|
1165
|
-
(0, _performanceMeasures.startMeasure)(EDITOR_BLOCKS_DRAG_INIT);
|
|
1166
|
-
}
|
|
1167
1103
|
if (isAdvancedLayoutEnabled) {
|
|
1168
1104
|
_activeAnchorTracker.defaultActiveAnchorTracker.reset();
|
|
1169
1105
|
}
|
|
@@ -1305,7 +1241,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
1305
1241
|
}
|
|
1306
1242
|
|
|
1307
1243
|
// Start pragmatic monitors
|
|
1308
|
-
pragmaticCleanup = destroyFn(api
|
|
1244
|
+
pragmaticCleanup = destroyFn(api);
|
|
1309
1245
|
var unbindMouseMove;
|
|
1310
1246
|
|
|
1311
1247
|
// When ignoreRestingPointerHover is false, pointerHasMoved is always true, so we never
|
|
@@ -182,7 +182,7 @@ var BlockControlsSurfaceDragHandle = exports.BlockControlsSurfaceDragHandle = fu
|
|
|
182
182
|
}
|
|
183
183
|
var openedViaKeyboard = event.detail === 0;
|
|
184
184
|
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref4) {
|
|
185
|
-
var _selectionPreservatio, _selectionPreservatio2, _api$analytics, _resolvedStartPos$nod, _api$
|
|
185
|
+
var _selectionPreservatio, _selectionPreservatio2, _api$analytics, _resolvedStartPos$nod, _api$blockControls3, _api$blockControls4, _activeNode$rootPos;
|
|
186
186
|
var tr = _ref4.tr;
|
|
187
187
|
var startPos = getPos();
|
|
188
188
|
if (startPos === undefined) {
|
|
@@ -193,6 +193,12 @@ var BlockControlsSurfaceDragHandle = exports.BlockControlsSurfaceDragHandle = fu
|
|
|
193
193
|
}
|
|
194
194
|
var selection = (_selectionPreservatio = (_selectionPreservatio2 = _pluginKey.selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio2 === void 0 ? void 0 : _selectionPreservatio2.preservedSelection) !== null && _selectionPreservatio !== void 0 ? _selectionPreservatio : tr.selection;
|
|
195
195
|
var resolvedStartPos = tr.doc.resolve(startPos);
|
|
196
|
+
if (resolvedStartPos.nodeAfter) {
|
|
197
|
+
var _api$blockControls2;
|
|
198
|
+
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.actions.notifyBlockHandleClick({
|
|
199
|
+
node: resolvedStartPos.nodeAfter
|
|
200
|
+
});
|
|
201
|
+
}
|
|
196
202
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
197
203
|
action: _enums.ACTION.CLICKED,
|
|
198
204
|
actionSubject: _enums.ACTION_SUBJECT.BUTTON,
|
|
@@ -219,10 +225,10 @@ var BlockControlsSurfaceDragHandle = exports.BlockControlsSurfaceDragHandle = fu
|
|
|
219
225
|
tr: tr
|
|
220
226
|
});
|
|
221
227
|
}
|
|
222
|
-
api === null || api === void 0 || (_api$
|
|
228
|
+
api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.startPreservingSelection()({
|
|
223
229
|
tr: tr
|
|
224
230
|
});
|
|
225
|
-
api === null || api === void 0 || (_api$
|
|
231
|
+
api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || _api$blockControls4.commands.toggleBlockMenu({
|
|
226
232
|
anchorName: getAnchorName(),
|
|
227
233
|
openedViaKeyboard: openedViaKeyboard,
|
|
228
234
|
triggerByNode: {
|
|
@@ -459,7 +459,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
459
459
|
var handleOnClickNew = (0, _react.useCallback)(function (e) {
|
|
460
460
|
var _api$core;
|
|
461
461
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref3) {
|
|
462
|
-
var _selectionPreservatio, _api$analytics, _resolvedStartPos$nod, _api$
|
|
462
|
+
var _selectionPreservatio, _api$analytics, _resolvedStartPos$nod, _api$blockControls2, _api$blockControls3;
|
|
463
463
|
var tr = _ref3.tr;
|
|
464
464
|
var startPos = getPos();
|
|
465
465
|
if (startPos === undefined) {
|
|
@@ -469,6 +469,12 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
469
469
|
tr.setMeta('toggleLayoutColumnMenu', buildToggleLayoutColumnMenuMeta(startPos, false));
|
|
470
470
|
}
|
|
471
471
|
var resolvedStartPos = tr.doc.resolve(startPos);
|
|
472
|
+
if (resolvedStartPos.nodeAfter) {
|
|
473
|
+
var _api$blockControls;
|
|
474
|
+
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.actions.notifyBlockHandleClick({
|
|
475
|
+
node: resolvedStartPos.nodeAfter
|
|
476
|
+
});
|
|
477
|
+
}
|
|
472
478
|
var selection = ((_selectionPreservatio = _pluginKey.selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection) || tr.selection;
|
|
473
479
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
474
480
|
eventType: _enums.EVENT_TYPE.UI,
|
|
@@ -488,10 +494,10 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
488
494
|
nodeType: nodeType,
|
|
489
495
|
api: api
|
|
490
496
|
});
|
|
491
|
-
api === null || api === void 0 || (_api$
|
|
497
|
+
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.startPreservingSelection()({
|
|
492
498
|
tr: tr
|
|
493
499
|
});
|
|
494
|
-
api === null || api === void 0 || (_api$
|
|
500
|
+
api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.toggleBlockMenu({
|
|
495
501
|
anchorName: anchorName,
|
|
496
502
|
openedViaKeyboard: false,
|
|
497
503
|
triggerByNode: {
|
|
@@ -518,11 +524,18 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
518
524
|
e.stopPropagation();
|
|
519
525
|
var startPos = getPos();
|
|
520
526
|
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref4) {
|
|
521
|
-
var _selectionPreservatio2, _api$
|
|
527
|
+
var _selectionPreservatio2, _api$blockControls5, _api$blockControls6, _api$userIntent;
|
|
522
528
|
var tr = _ref4.tr;
|
|
523
529
|
if (startPos === undefined) {
|
|
524
530
|
return tr;
|
|
525
531
|
}
|
|
532
|
+
var node = tr.doc.resolve(startPos).nodeAfter;
|
|
533
|
+
if (node) {
|
|
534
|
+
var _api$blockControls4;
|
|
535
|
+
api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || _api$blockControls4.actions.notifyBlockHandleClick({
|
|
536
|
+
node: node
|
|
537
|
+
});
|
|
538
|
+
}
|
|
526
539
|
var selection = ((_selectionPreservatio2 = _pluginKey.selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio2 === void 0 ? void 0 : _selectionPreservatio2.preservedSelection) || tr.selection;
|
|
527
540
|
(0, _expandAndUpdateSelection.expandAndUpdateSelection)({
|
|
528
541
|
tr: tr,
|
|
@@ -532,7 +545,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
532
545
|
nodeType: nodeType,
|
|
533
546
|
api: api
|
|
534
547
|
});
|
|
535
|
-
api === null || api === void 0 || (_api$
|
|
548
|
+
api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.startPreservingSelection()({
|
|
536
549
|
tr: tr
|
|
537
550
|
});
|
|
538
551
|
if (nodeType === 'layoutColumn') {
|
|
@@ -543,7 +556,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
543
556
|
pos: startPos,
|
|
544
557
|
rootPos: tr.doc.resolve(startPos).before(1)
|
|
545
558
|
};
|
|
546
|
-
api === null || api === void 0 || (_api$
|
|
559
|
+
api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.toggleBlockMenu({
|
|
547
560
|
anchorName: anchorName,
|
|
548
561
|
triggerByNode: triggerByNode,
|
|
549
562
|
openedViaKeyboard: true
|
|
@@ -588,8 +601,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
588
601
|
}
|
|
589
602
|
var newHandlePosCheck = (0, _getSelection.isHandleCorrelatedToSelection)(view.state, tr.selection, handlePos);
|
|
590
603
|
if (!tr.selection.empty && newHandlePosCheck) {
|
|
591
|
-
var _api$
|
|
592
|
-
api === null || api === void 0 || (_api$
|
|
604
|
+
var _api$blockControls7;
|
|
605
|
+
api === null || api === void 0 || (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 || _api$blockControls7.commands.setMultiSelectPositions()({
|
|
593
606
|
tr: tr
|
|
594
607
|
});
|
|
595
608
|
} else {
|
|
@@ -696,7 +709,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
696
709
|
return;
|
|
697
710
|
}
|
|
698
711
|
api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref8) {
|
|
699
|
-
var _api$blockControls$sh2, _api$
|
|
712
|
+
var _api$blockControls$sh2, _api$blockControls8, _api$analytics2;
|
|
700
713
|
var tr = _ref8.tr;
|
|
701
714
|
var nodeTypes, hasSelectedMultipleNodes;
|
|
702
715
|
var resolvedMovingNode = tr.doc.resolve(start);
|
|
@@ -710,7 +723,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
|
|
|
710
723
|
nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
|
|
711
724
|
hasSelectedMultipleNodes = false;
|
|
712
725
|
}
|
|
713
|
-
api === null || api === void 0 || (_api$
|
|
726
|
+
api === null || api === void 0 || (_api$blockControls8 = api.blockControls) === null || _api$blockControls8 === void 0 || _api$blockControls8.commands.setNodeDragged(getPos, anchorName, nodeType)({
|
|
714
727
|
tr: tr
|
|
715
728
|
});
|
|
716
729
|
tr.setMeta('scrollIntoView', false);
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useBlockControlsSurfaceDragSource = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _enums = require("@atlaskit/editor-common/analytics/types/enums");
|
|
9
|
-
var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
|
|
10
9
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
10
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
12
11
|
var _elementAdapter = require("@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter");
|
|
@@ -17,7 +16,6 @@ var _collapsedHeading = require("../pm-plugins/utils/collapsed-heading");
|
|
|
17
16
|
var _getSelection = require("../pm-plugins/utils/getSelection");
|
|
18
17
|
var _blockControlsSurfaceDragHandleUtils = require("./block-controls-surface-drag-handle-utils");
|
|
19
18
|
var _dragPreview = require("./drag-preview");
|
|
20
|
-
var EDITOR_BLOCKS_DRAG_INIT = 'Editor Blocks Drag Initialization Time';
|
|
21
19
|
/**
|
|
22
20
|
* Registry surface drag source. This intentionally duplicates the stable widget handle's drag
|
|
23
21
|
* contract so the legacy implementation remains byte-for-byte unchanged during migration.
|
|
@@ -148,9 +146,6 @@ var useBlockControlsSurfaceDragSource = exports.useBlockControlsSurfaceDragSourc
|
|
|
148
146
|
}
|
|
149
147
|
|
|
150
148
|
// This handle is outside ProseMirror, so it owns the side effects normally started by PM.
|
|
151
|
-
if (!(0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_remove_legacy_perf_events')) {
|
|
152
|
-
(0, _performanceMeasures.startMeasure)(EDITOR_BLOCKS_DRAG_INIT);
|
|
153
|
-
}
|
|
154
149
|
_activeAnchorTracker.defaultActiveAnchorTracker.reset();
|
|
155
150
|
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref5) {
|
|
156
151
|
var _api$blockControls$sh2, _resolvedMovingNode$n, _api$blockControls2, _api$analytics;
|
|
@@ -75,6 +75,14 @@ export const blockControlsPlugin = ({
|
|
|
75
75
|
return {
|
|
76
76
|
name: 'blockControls',
|
|
77
77
|
actions: {
|
|
78
|
+
notifyBlockHandleClick: context => {
|
|
79
|
+
try {
|
|
80
|
+
var _config$onBlockHandle;
|
|
81
|
+
config === null || config === void 0 ? void 0 : (_config$onBlockHandle = config.onBlockHandleClick) === null || _config$onBlockHandle === void 0 ? void 0 : _config$onBlockHandle.call(config, context);
|
|
82
|
+
} catch {
|
|
83
|
+
// A host callback must not prevent the block menu from opening.
|
|
84
|
+
}
|
|
85
|
+
},
|
|
78
86
|
getTextInfo: editorView => {
|
|
79
87
|
var _api$blockControls, _blockControlsState$m;
|
|
80
88
|
const blockControlsState = api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState();
|
|
@@ -4,7 +4,6 @@ import { getDocument } from '@atlaskit/browser-apis';
|
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics/types/enums';
|
|
5
5
|
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
6
6
|
import { getNodeIdProvider } from '@atlaskit/editor-common/node-anchor-provider';
|
|
7
|
-
import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
8
7
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
9
8
|
import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles/drag-handle';
|
|
10
9
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
@@ -38,18 +37,10 @@ import { selectNode } from './utils/getSelection';
|
|
|
38
37
|
import { getSelectedSlicePosition } from './utils/selection';
|
|
39
38
|
import { getTrMetadata } from './utils/transactions';
|
|
40
39
|
export const key = new PluginKey('blockControls');
|
|
41
|
-
const EDITOR_BLOCKS_DRAG_INIT = 'Editor Blocks Drag Initialization Time';
|
|
42
|
-
const EDITOR_BLOCKS_DROP_INIT = 'Editor Blocks Drop Initialization Time';
|
|
43
|
-
const scheduleCallback = (cb, options) => {
|
|
44
|
-
return 'requestIdleCallback' in window ? requestIdleCallback(cb, {
|
|
45
|
-
timeout: 5000,
|
|
46
|
-
...options
|
|
47
|
-
}) : requestAnimationFrame(cb);
|
|
48
|
-
};
|
|
49
40
|
const isHTMLElement = element => {
|
|
50
41
|
return element instanceof HTMLElement;
|
|
51
42
|
};
|
|
52
|
-
const destroyFn =
|
|
43
|
+
const destroyFn = api => {
|
|
53
44
|
var _getDocument$querySel, _getDocument;
|
|
54
45
|
const scrollable = (_getDocument$querySel = (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.querySelector('.fabric-editor-popup-scroll-parent')) !== null && _getDocument$querySel !== void 0 ? _getDocument$querySel : null;
|
|
55
46
|
const cleanupFn = [];
|
|
@@ -58,36 +49,10 @@ const destroyFn = (api, editorView) => {
|
|
|
58
49
|
element: scrollable
|
|
59
50
|
}));
|
|
60
51
|
}
|
|
61
|
-
let dragInitializationDuration = 0;
|
|
62
52
|
cleanupFn.push(monitorForElements({
|
|
63
53
|
canMonitor: ({
|
|
64
54
|
source
|
|
65
55
|
}) => source.data.type === 'element',
|
|
66
|
-
onDrag: () => {
|
|
67
|
-
if (fg('platform_editor_drag_and_drop_perf_analytics')) {
|
|
68
|
-
if (isMeasuring(EDITOR_BLOCKS_DRAG_INIT)) {
|
|
69
|
-
stopMeasure(EDITOR_BLOCKS_DRAG_INIT, duration => {
|
|
70
|
-
dragInitializationDuration = duration;
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
} else {
|
|
74
|
-
if (isMeasuring(EDITOR_BLOCKS_DRAG_INIT)) {
|
|
75
|
-
stopMeasure(EDITOR_BLOCKS_DRAG_INIT, (duration, startTime) => {
|
|
76
|
-
var _api$analytics;
|
|
77
|
-
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent({
|
|
78
|
-
action: ACTION.BLOCKS_DRAG_INIT,
|
|
79
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
80
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
81
|
-
attributes: {
|
|
82
|
-
duration,
|
|
83
|
-
startTime,
|
|
84
|
-
nodesCount: editorView === null || editorView === void 0 ? void 0 : editorView.state.doc.nodeSize
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
56
|
onDragStart: () => {
|
|
92
57
|
if (isHTMLElement(scrollable)) {
|
|
93
58
|
scrollable.style.setProperty('scroll-behavior', 'unset');
|
|
@@ -101,10 +66,6 @@ const destroyFn = (api, editorView) => {
|
|
|
101
66
|
if (isHTMLElement(scrollable)) {
|
|
102
67
|
scrollable.style.setProperty('scroll-behavior', null);
|
|
103
68
|
}
|
|
104
|
-
const shouldMeasureDrop = fg('platform_editor_drag_and_drop_perf_analytics') && !isExperimentEnabled('platform_editor_remove_legacy_perf_events');
|
|
105
|
-
if (shouldMeasureDrop) {
|
|
106
|
-
startMeasure(EDITOR_BLOCKS_DROP_INIT);
|
|
107
|
-
}
|
|
108
69
|
if (!api) {
|
|
109
70
|
return;
|
|
110
71
|
}
|
|
@@ -139,7 +100,7 @@ const destroyFn = (api, editorView) => {
|
|
|
139
100
|
// if no drop targets are rendered, assume that drop is invalid
|
|
140
101
|
const lastDragCancelled = location.current.dropTargets.length === 0;
|
|
141
102
|
if (lastDragCancelled) {
|
|
142
|
-
var _api$
|
|
103
|
+
var _api$analytics;
|
|
143
104
|
const position = getSelectedSlicePosition(start, tr, api);
|
|
144
105
|
const attributes = getMultiSelectAnalyticsAttributes(tr, position.from, position.to);
|
|
145
106
|
const {
|
|
@@ -147,7 +108,7 @@ const destroyFn = (api, editorView) => {
|
|
|
147
108
|
hasSelectedMultipleNodes
|
|
148
109
|
} = attributes;
|
|
149
110
|
const resolvedMovingNode = tr.doc.resolve(start);
|
|
150
|
-
(_api$
|
|
111
|
+
(_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
|
|
151
112
|
eventType: EVENT_TYPE.UI,
|
|
152
113
|
action: ACTION.CANCELLED,
|
|
153
114
|
actionSubject: ACTION_SUBJECT.DRAG,
|
|
@@ -175,29 +136,6 @@ const destroyFn = (api, editorView) => {
|
|
|
175
136
|
lastDragCancelled
|
|
176
137
|
});
|
|
177
138
|
});
|
|
178
|
-
if (shouldMeasureDrop) {
|
|
179
|
-
// wait for the idle callback to ensure that the drag operation has completed
|
|
180
|
-
scheduleCallback(() => {
|
|
181
|
-
if (isMeasuring(EDITOR_BLOCKS_DROP_INIT)) {
|
|
182
|
-
stopMeasure(EDITOR_BLOCKS_DROP_INIT, duration => {
|
|
183
|
-
var _api$analytics3;
|
|
184
|
-
const isCancelled = location.current.dropTargets.length === 0;
|
|
185
|
-
api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.fireAnalyticsEvent({
|
|
186
|
-
action: ACTION.ENDED,
|
|
187
|
-
eventType: EVENT_TYPE.TRACK,
|
|
188
|
-
actionSubject: ACTION_SUBJECT.DRAG,
|
|
189
|
-
actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
|
|
190
|
-
attributes: {
|
|
191
|
-
dragInitializationDuration,
|
|
192
|
-
dropProcessingDuration: duration,
|
|
193
|
-
isCancelled,
|
|
194
|
-
nodesCount: editorView === null || editorView === void 0 ? void 0 : editorView.state.doc.nodeSize
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
139
|
}
|
|
202
140
|
}));
|
|
203
141
|
return combine(...cleanupFn);
|
|
@@ -1065,9 +1003,6 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
1065
1003
|
if (api !== null && api !== void 0 && (_api$limitedMode6 = api.limitedMode) !== null && _api$limitedMode6 !== void 0 && (_api$limitedMode6$sha = _api$limitedMode6.sharedState.currentState()) !== null && _api$limitedMode6$sha !== void 0 && _api$limitedMode6$sha.enabled) {
|
|
1066
1004
|
return;
|
|
1067
1005
|
}
|
|
1068
|
-
if (!isExperimentEnabled('platform_editor_remove_legacy_perf_events')) {
|
|
1069
|
-
startMeasure(EDITOR_BLOCKS_DRAG_INIT);
|
|
1070
|
-
}
|
|
1071
1006
|
if (isAdvancedLayoutEnabled) {
|
|
1072
1007
|
defaultActiveAnchorTracker.reset();
|
|
1073
1008
|
}
|
|
@@ -1216,7 +1151,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
1216
1151
|
}
|
|
1217
1152
|
|
|
1218
1153
|
// Start pragmatic monitors
|
|
1219
|
-
pragmaticCleanup = destroyFn(api
|
|
1154
|
+
pragmaticCleanup = destroyFn(api);
|
|
1220
1155
|
let unbindMouseMove;
|
|
1221
1156
|
|
|
1222
1157
|
// When ignoreRestingPointerHover is false, pointerHasMoved is always true, so we never
|
|
@@ -173,7 +173,7 @@ export const BlockControlsSurfaceDragHandle = ({
|
|
|
173
173
|
api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
|
|
174
174
|
tr
|
|
175
175
|
}) => {
|
|
176
|
-
var _selectionPreservatio, _selectionPreservatio2, _api$analytics, _resolvedStartPos$nod, _api$
|
|
176
|
+
var _selectionPreservatio, _selectionPreservatio2, _api$analytics, _resolvedStartPos$nod, _api$blockControls3, _api$blockControls4, _activeNode$rootPos;
|
|
177
177
|
const startPos = getPos();
|
|
178
178
|
if (startPos === undefined) {
|
|
179
179
|
return tr;
|
|
@@ -183,6 +183,12 @@ export const BlockControlsSurfaceDragHandle = ({
|
|
|
183
183
|
}
|
|
184
184
|
const selection = (_selectionPreservatio = (_selectionPreservatio2 = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio2 === void 0 ? void 0 : _selectionPreservatio2.preservedSelection) !== null && _selectionPreservatio !== void 0 ? _selectionPreservatio : tr.selection;
|
|
185
185
|
const resolvedStartPos = tr.doc.resolve(startPos);
|
|
186
|
+
if (resolvedStartPos.nodeAfter) {
|
|
187
|
+
var _api$blockControls2;
|
|
188
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.actions.notifyBlockHandleClick({
|
|
189
|
+
node: resolvedStartPos.nodeAfter
|
|
190
|
+
});
|
|
191
|
+
}
|
|
186
192
|
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
|
|
187
193
|
action: ACTION.CLICKED,
|
|
188
194
|
actionSubject: ACTION_SUBJECT.BUTTON,
|
|
@@ -209,10 +215,10 @@ export const BlockControlsSurfaceDragHandle = ({
|
|
|
209
215
|
tr
|
|
210
216
|
});
|
|
211
217
|
}
|
|
212
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
218
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.startPreservingSelection()({
|
|
213
219
|
tr
|
|
214
220
|
});
|
|
215
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
221
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands.toggleBlockMenu({
|
|
216
222
|
anchorName: getAnchorName(),
|
|
217
223
|
openedViaKeyboard,
|
|
218
224
|
triggerByNode: {
|
|
@@ -438,7 +438,7 @@ export const DragHandle = ({
|
|
|
438
438
|
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
|
|
439
439
|
tr
|
|
440
440
|
}) => {
|
|
441
|
-
var _selectionPreservatio, _api$analytics, _resolvedStartPos$nod, _api$
|
|
441
|
+
var _selectionPreservatio, _api$analytics, _resolvedStartPos$nod, _api$blockControls2, _api$blockControls3;
|
|
442
442
|
const startPos = getPos();
|
|
443
443
|
if (startPos === undefined) {
|
|
444
444
|
return tr;
|
|
@@ -447,6 +447,12 @@ export const DragHandle = ({
|
|
|
447
447
|
tr.setMeta('toggleLayoutColumnMenu', buildToggleLayoutColumnMenuMeta(startPos, false));
|
|
448
448
|
}
|
|
449
449
|
const resolvedStartPos = tr.doc.resolve(startPos);
|
|
450
|
+
if (resolvedStartPos.nodeAfter) {
|
|
451
|
+
var _api$blockControls;
|
|
452
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.actions.notifyBlockHandleClick({
|
|
453
|
+
node: resolvedStartPos.nodeAfter
|
|
454
|
+
});
|
|
455
|
+
}
|
|
450
456
|
const selection = ((_selectionPreservatio = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection) || tr.selection;
|
|
451
457
|
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
|
|
452
458
|
eventType: EVENT_TYPE.UI,
|
|
@@ -466,10 +472,10 @@ export const DragHandle = ({
|
|
|
466
472
|
nodeType,
|
|
467
473
|
api
|
|
468
474
|
});
|
|
469
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
475
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.startPreservingSelection()({
|
|
470
476
|
tr
|
|
471
477
|
});
|
|
472
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
478
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 ? void 0 : _api$blockControls3.commands.toggleBlockMenu({
|
|
473
479
|
anchorName,
|
|
474
480
|
openedViaKeyboard: false,
|
|
475
481
|
triggerByNode: {
|
|
@@ -498,10 +504,17 @@ export const DragHandle = ({
|
|
|
498
504
|
api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
|
|
499
505
|
tr
|
|
500
506
|
}) => {
|
|
501
|
-
var _selectionPreservatio2, _api$
|
|
507
|
+
var _selectionPreservatio2, _api$blockControls5, _api$blockControls6, _api$userIntent;
|
|
502
508
|
if (startPos === undefined) {
|
|
503
509
|
return tr;
|
|
504
510
|
}
|
|
511
|
+
const node = tr.doc.resolve(startPos).nodeAfter;
|
|
512
|
+
if (node) {
|
|
513
|
+
var _api$blockControls4;
|
|
514
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.actions.notifyBlockHandleClick({
|
|
515
|
+
node
|
|
516
|
+
});
|
|
517
|
+
}
|
|
505
518
|
const selection = ((_selectionPreservatio2 = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio2 === void 0 ? void 0 : _selectionPreservatio2.preservedSelection) || tr.selection;
|
|
506
519
|
expandAndUpdateSelection({
|
|
507
520
|
tr,
|
|
@@ -511,7 +524,7 @@ export const DragHandle = ({
|
|
|
511
524
|
nodeType,
|
|
512
525
|
api
|
|
513
526
|
});
|
|
514
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
527
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 ? void 0 : _api$blockControls5.commands.startPreservingSelection()({
|
|
515
528
|
tr
|
|
516
529
|
});
|
|
517
530
|
if (nodeType === 'layoutColumn') {
|
|
@@ -522,7 +535,7 @@ export const DragHandle = ({
|
|
|
522
535
|
pos: startPos,
|
|
523
536
|
rootPos: tr.doc.resolve(startPos).before(1)
|
|
524
537
|
};
|
|
525
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
538
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 ? void 0 : _api$blockControls6.commands.toggleBlockMenu({
|
|
526
539
|
anchorName,
|
|
527
540
|
triggerByNode,
|
|
528
541
|
openedViaKeyboard: true
|
|
@@ -565,8 +578,8 @@ export const DragHandle = ({
|
|
|
565
578
|
}
|
|
566
579
|
const newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
|
|
567
580
|
if (!tr.selection.empty && newHandlePosCheck) {
|
|
568
|
-
var _api$
|
|
569
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
581
|
+
var _api$blockControls7;
|
|
582
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 ? void 0 : _api$blockControls7.commands.setMultiSelectPositions()({
|
|
570
583
|
tr
|
|
571
584
|
});
|
|
572
585
|
} else {
|
|
@@ -680,7 +693,7 @@ export const DragHandle = ({
|
|
|
680
693
|
api === null || api === void 0 ? void 0 : (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions.execute(({
|
|
681
694
|
tr
|
|
682
695
|
}) => {
|
|
683
|
-
var _api$blockControls$sh2, _api$
|
|
696
|
+
var _api$blockControls$sh2, _api$blockControls8, _api$analytics2;
|
|
684
697
|
let nodeTypes, hasSelectedMultipleNodes;
|
|
685
698
|
const resolvedMovingNode = tr.doc.resolve(start);
|
|
686
699
|
const maybeNode = resolvedMovingNode.nodeAfter;
|
|
@@ -693,7 +706,7 @@ export const DragHandle = ({
|
|
|
693
706
|
nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
|
|
694
707
|
hasSelectedMultipleNodes = false;
|
|
695
708
|
}
|
|
696
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
709
|
+
api === null || api === void 0 ? void 0 : (_api$blockControls8 = api.blockControls) === null || _api$blockControls8 === void 0 ? void 0 : _api$blockControls8.commands.setNodeDragged(getPos, anchorName, nodeType)({
|
|
697
710
|
tr
|
|
698
711
|
});
|
|
699
712
|
tr.setMeta('scrollIntoView', false);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics/types/enums';
|
|
3
|
-
import { startMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
4
3
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
4
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
6
5
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter';
|
|
@@ -11,7 +10,6 @@ import { isCollapsedHeading, prepareCollapsedHeadingSelection } from '../pm-plug
|
|
|
11
10
|
import { isHandleCorrelatedToSelection, selectNode } from '../pm-plugins/utils/getSelection';
|
|
12
11
|
import { getNodeMarginsForDragPreview, getNodeSpacingForDragPreview } from './block-controls-surface-drag-handle-utils';
|
|
13
12
|
import { dragPreview } from './drag-preview';
|
|
14
|
-
const EDITOR_BLOCKS_DRAG_INIT = 'Editor Blocks Drag Initialization Time';
|
|
15
13
|
/**
|
|
16
14
|
* Registry surface drag source. This intentionally duplicates the stable widget handle's drag
|
|
17
15
|
* contract so the legacy implementation remains byte-for-byte unchanged during migration.
|
|
@@ -145,9 +143,6 @@ export const useBlockControlsSurfaceDragSource = ({
|
|
|
145
143
|
}
|
|
146
144
|
|
|
147
145
|
// This handle is outside ProseMirror, so it owns the side effects normally started by PM.
|
|
148
|
-
if (!isExperimentEnabled('platform_editor_remove_legacy_perf_events')) {
|
|
149
|
-
startMeasure(EDITOR_BLOCKS_DRAG_INIT);
|
|
150
|
-
}
|
|
151
146
|
defaultActiveAnchorTracker.reset();
|
|
152
147
|
api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
|
|
153
148
|
tr
|
|
@@ -70,6 +70,14 @@ export var blockControlsPlugin = function blockControlsPlugin(_ref) {
|
|
|
70
70
|
return {
|
|
71
71
|
name: 'blockControls',
|
|
72
72
|
actions: {
|
|
73
|
+
notifyBlockHandleClick: function notifyBlockHandleClick(context) {
|
|
74
|
+
try {
|
|
75
|
+
var _config$onBlockHandle;
|
|
76
|
+
config === null || config === void 0 || (_config$onBlockHandle = config.onBlockHandleClick) === null || _config$onBlockHandle === void 0 || _config$onBlockHandle.call(config, context);
|
|
77
|
+
} catch (_unused) {
|
|
78
|
+
// A host callback must not prevent the block menu from opening.
|
|
79
|
+
}
|
|
80
|
+
},
|
|
73
81
|
getTextInfo: function getTextInfo(editorView) {
|
|
74
82
|
var _api$blockControls, _blockControlsState$m;
|
|
75
83
|
var blockControlsState = api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState();
|
|
@@ -10,7 +10,6 @@ import { getDocument } from '@atlaskit/browser-apis';
|
|
|
10
10
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics/types/enums';
|
|
11
11
|
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
12
12
|
import { getNodeIdProvider } from '@atlaskit/editor-common/node-anchor-provider';
|
|
13
|
-
import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
14
13
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
15
14
|
import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles/drag-handle';
|
|
16
15
|
import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
|
|
@@ -44,17 +43,10 @@ import { selectNode } from './utils/getSelection';
|
|
|
44
43
|
import { getSelectedSlicePosition } from './utils/selection';
|
|
45
44
|
import { getTrMetadata } from './utils/transactions';
|
|
46
45
|
export var key = new PluginKey('blockControls');
|
|
47
|
-
var EDITOR_BLOCKS_DRAG_INIT = 'Editor Blocks Drag Initialization Time';
|
|
48
|
-
var EDITOR_BLOCKS_DROP_INIT = 'Editor Blocks Drop Initialization Time';
|
|
49
|
-
var scheduleCallback = function scheduleCallback(cb, options) {
|
|
50
|
-
return 'requestIdleCallback' in window ? requestIdleCallback(cb, _objectSpread({
|
|
51
|
-
timeout: 5000
|
|
52
|
-
}, options)) : requestAnimationFrame(cb);
|
|
53
|
-
};
|
|
54
46
|
var isHTMLElement = function isHTMLElement(element) {
|
|
55
47
|
return element instanceof HTMLElement;
|
|
56
48
|
};
|
|
57
|
-
var destroyFn = function destroyFn(api
|
|
49
|
+
var destroyFn = function destroyFn(api) {
|
|
58
50
|
var _getDocument$querySel, _getDocument;
|
|
59
51
|
var scrollable = (_getDocument$querySel = (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.querySelector('.fabric-editor-popup-scroll-parent')) !== null && _getDocument$querySel !== void 0 ? _getDocument$querySel : null;
|
|
60
52
|
var cleanupFn = [];
|
|
@@ -63,37 +55,11 @@ var destroyFn = function destroyFn(api, editorView) {
|
|
|
63
55
|
element: scrollable
|
|
64
56
|
}));
|
|
65
57
|
}
|
|
66
|
-
var dragInitializationDuration = 0;
|
|
67
58
|
cleanupFn.push(monitorForElements({
|
|
68
59
|
canMonitor: function canMonitor(_ref) {
|
|
69
60
|
var source = _ref.source;
|
|
70
61
|
return source.data.type === 'element';
|
|
71
62
|
},
|
|
72
|
-
onDrag: function onDrag() {
|
|
73
|
-
if (fg('platform_editor_drag_and_drop_perf_analytics')) {
|
|
74
|
-
if (isMeasuring(EDITOR_BLOCKS_DRAG_INIT)) {
|
|
75
|
-
stopMeasure(EDITOR_BLOCKS_DRAG_INIT, function (duration) {
|
|
76
|
-
dragInitializationDuration = duration;
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
} else {
|
|
80
|
-
if (isMeasuring(EDITOR_BLOCKS_DRAG_INIT)) {
|
|
81
|
-
stopMeasure(EDITOR_BLOCKS_DRAG_INIT, function (duration, startTime) {
|
|
82
|
-
var _api$analytics;
|
|
83
|
-
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
|
|
84
|
-
action: ACTION.BLOCKS_DRAG_INIT,
|
|
85
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
86
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
87
|
-
attributes: {
|
|
88
|
-
duration: duration,
|
|
89
|
-
startTime: startTime,
|
|
90
|
-
nodesCount: editorView === null || editorView === void 0 ? void 0 : editorView.state.doc.nodeSize
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
63
|
onDragStart: function onDragStart() {
|
|
98
64
|
if (isHTMLElement(scrollable)) {
|
|
99
65
|
scrollable.style.setProperty('scroll-behavior', 'unset');
|
|
@@ -106,10 +72,6 @@ var destroyFn = function destroyFn(api, editorView) {
|
|
|
106
72
|
if (isHTMLElement(scrollable)) {
|
|
107
73
|
scrollable.style.setProperty('scroll-behavior', null);
|
|
108
74
|
}
|
|
109
|
-
var shouldMeasureDrop = fg('platform_editor_drag_and_drop_perf_analytics') && !isExperimentEnabled('platform_editor_remove_legacy_perf_events');
|
|
110
|
-
if (shouldMeasureDrop) {
|
|
111
|
-
startMeasure(EDITOR_BLOCKS_DROP_INIT);
|
|
112
|
-
}
|
|
113
75
|
if (!api) {
|
|
114
76
|
return;
|
|
115
77
|
}
|
|
@@ -141,13 +103,13 @@ var destroyFn = function destroyFn(api, editorView) {
|
|
|
141
103
|
// if no drop targets are rendered, assume that drop is invalid
|
|
142
104
|
var lastDragCancelled = location.current.dropTargets.length === 0;
|
|
143
105
|
if (lastDragCancelled) {
|
|
144
|
-
var _api$
|
|
106
|
+
var _api$analytics;
|
|
145
107
|
var position = getSelectedSlicePosition(start, tr, api);
|
|
146
108
|
var attributes = getMultiSelectAnalyticsAttributes(tr, position.from, position.to);
|
|
147
109
|
var nodeTypes = attributes.nodeTypes,
|
|
148
110
|
hasSelectedMultipleNodes = attributes.hasSelectedMultipleNodes;
|
|
149
111
|
var resolvedMovingNode = tr.doc.resolve(start);
|
|
150
|
-
(_api$
|
|
112
|
+
(_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
151
113
|
eventType: EVENT_TYPE.UI,
|
|
152
114
|
action: ACTION.CANCELLED,
|
|
153
115
|
actionSubject: ACTION_SUBJECT.DRAG,
|
|
@@ -174,29 +136,6 @@ var destroyFn = function destroyFn(api, editorView) {
|
|
|
174
136
|
lastDragCancelled: lastDragCancelled
|
|
175
137
|
}));
|
|
176
138
|
});
|
|
177
|
-
if (shouldMeasureDrop) {
|
|
178
|
-
// wait for the idle callback to ensure that the drag operation has completed
|
|
179
|
-
scheduleCallback(function () {
|
|
180
|
-
if (isMeasuring(EDITOR_BLOCKS_DROP_INIT)) {
|
|
181
|
-
stopMeasure(EDITOR_BLOCKS_DROP_INIT, function (duration) {
|
|
182
|
-
var _api$analytics3;
|
|
183
|
-
var isCancelled = location.current.dropTargets.length === 0;
|
|
184
|
-
api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.fireAnalyticsEvent({
|
|
185
|
-
action: ACTION.ENDED,
|
|
186
|
-
eventType: EVENT_TYPE.TRACK,
|
|
187
|
-
actionSubject: ACTION_SUBJECT.DRAG,
|
|
188
|
-
actionSubjectId: ACTION_SUBJECT_ID.ELEMENT_DRAG_HANDLE,
|
|
189
|
-
attributes: {
|
|
190
|
-
dragInitializationDuration: dragInitializationDuration,
|
|
191
|
-
dropProcessingDuration: duration,
|
|
192
|
-
isCancelled: isCancelled,
|
|
193
|
-
nodesCount: editorView === null || editorView === void 0 ? void 0 : editorView.state.doc.nodeSize
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
139
|
}
|
|
201
140
|
}));
|
|
202
141
|
return combine.apply(void 0, cleanupFn);
|
|
@@ -1155,9 +1094,6 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
1155
1094
|
if (api !== null && api !== void 0 && (_api$limitedMode6 = api.limitedMode) !== null && _api$limitedMode6 !== void 0 && (_api$limitedMode6 = _api$limitedMode6.sharedState.currentState()) !== null && _api$limitedMode6 !== void 0 && _api$limitedMode6.enabled) {
|
|
1156
1095
|
return;
|
|
1157
1096
|
}
|
|
1158
|
-
if (!isExperimentEnabled('platform_editor_remove_legacy_perf_events')) {
|
|
1159
|
-
startMeasure(EDITOR_BLOCKS_DRAG_INIT);
|
|
1160
|
-
}
|
|
1161
1097
|
if (isAdvancedLayoutEnabled) {
|
|
1162
1098
|
defaultActiveAnchorTracker.reset();
|
|
1163
1099
|
}
|
|
@@ -1299,7 +1235,7 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
1299
1235
|
}
|
|
1300
1236
|
|
|
1301
1237
|
// Start pragmatic monitors
|
|
1302
|
-
pragmaticCleanup = destroyFn(api
|
|
1238
|
+
pragmaticCleanup = destroyFn(api);
|
|
1303
1239
|
var unbindMouseMove;
|
|
1304
1240
|
|
|
1305
1241
|
// When ignoreRestingPointerHover is false, pointerHasMoved is always true, so we never
|
|
@@ -176,7 +176,7 @@ export var BlockControlsSurfaceDragHandle = function BlockControlsSurfaceDragHan
|
|
|
176
176
|
}
|
|
177
177
|
var openedViaKeyboard = event.detail === 0;
|
|
178
178
|
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref4) {
|
|
179
|
-
var _selectionPreservatio, _selectionPreservatio2, _api$analytics, _resolvedStartPos$nod, _api$
|
|
179
|
+
var _selectionPreservatio, _selectionPreservatio2, _api$analytics, _resolvedStartPos$nod, _api$blockControls3, _api$blockControls4, _activeNode$rootPos;
|
|
180
180
|
var tr = _ref4.tr;
|
|
181
181
|
var startPos = getPos();
|
|
182
182
|
if (startPos === undefined) {
|
|
@@ -187,6 +187,12 @@ export var BlockControlsSurfaceDragHandle = function BlockControlsSurfaceDragHan
|
|
|
187
187
|
}
|
|
188
188
|
var selection = (_selectionPreservatio = (_selectionPreservatio2 = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio2 === void 0 ? void 0 : _selectionPreservatio2.preservedSelection) !== null && _selectionPreservatio !== void 0 ? _selectionPreservatio : tr.selection;
|
|
189
189
|
var resolvedStartPos = tr.doc.resolve(startPos);
|
|
190
|
+
if (resolvedStartPos.nodeAfter) {
|
|
191
|
+
var _api$blockControls2;
|
|
192
|
+
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.actions.notifyBlockHandleClick({
|
|
193
|
+
node: resolvedStartPos.nodeAfter
|
|
194
|
+
});
|
|
195
|
+
}
|
|
190
196
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
191
197
|
action: ACTION.CLICKED,
|
|
192
198
|
actionSubject: ACTION_SUBJECT.BUTTON,
|
|
@@ -213,10 +219,10 @@ export var BlockControlsSurfaceDragHandle = function BlockControlsSurfaceDragHan
|
|
|
213
219
|
tr: tr
|
|
214
220
|
});
|
|
215
221
|
}
|
|
216
|
-
api === null || api === void 0 || (_api$
|
|
222
|
+
api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.startPreservingSelection()({
|
|
217
223
|
tr: tr
|
|
218
224
|
});
|
|
219
|
-
api === null || api === void 0 || (_api$
|
|
225
|
+
api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || _api$blockControls4.commands.toggleBlockMenu({
|
|
220
226
|
anchorName: getAnchorName(),
|
|
221
227
|
openedViaKeyboard: openedViaKeyboard,
|
|
222
228
|
triggerByNode: {
|
|
@@ -455,7 +455,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
455
455
|
var handleOnClickNew = useCallback(function (e) {
|
|
456
456
|
var _api$core;
|
|
457
457
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref3) {
|
|
458
|
-
var _selectionPreservatio, _api$analytics, _resolvedStartPos$nod, _api$
|
|
458
|
+
var _selectionPreservatio, _api$analytics, _resolvedStartPos$nod, _api$blockControls2, _api$blockControls3;
|
|
459
459
|
var tr = _ref3.tr;
|
|
460
460
|
var startPos = getPos();
|
|
461
461
|
if (startPos === undefined) {
|
|
@@ -465,6 +465,12 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
465
465
|
tr.setMeta('toggleLayoutColumnMenu', buildToggleLayoutColumnMenuMeta(startPos, false));
|
|
466
466
|
}
|
|
467
467
|
var resolvedStartPos = tr.doc.resolve(startPos);
|
|
468
|
+
if (resolvedStartPos.nodeAfter) {
|
|
469
|
+
var _api$blockControls;
|
|
470
|
+
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.actions.notifyBlockHandleClick({
|
|
471
|
+
node: resolvedStartPos.nodeAfter
|
|
472
|
+
});
|
|
473
|
+
}
|
|
468
474
|
var selection = ((_selectionPreservatio = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio === void 0 ? void 0 : _selectionPreservatio.preservedSelection) || tr.selection;
|
|
469
475
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
470
476
|
eventType: EVENT_TYPE.UI,
|
|
@@ -484,10 +490,10 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
484
490
|
nodeType: nodeType,
|
|
485
491
|
api: api
|
|
486
492
|
});
|
|
487
|
-
api === null || api === void 0 || (_api$
|
|
493
|
+
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.startPreservingSelection()({
|
|
488
494
|
tr: tr
|
|
489
495
|
});
|
|
490
|
-
api === null || api === void 0 || (_api$
|
|
496
|
+
api === null || api === void 0 || (_api$blockControls3 = api.blockControls) === null || _api$blockControls3 === void 0 || _api$blockControls3.commands.toggleBlockMenu({
|
|
491
497
|
anchorName: anchorName,
|
|
492
498
|
openedViaKeyboard: false,
|
|
493
499
|
triggerByNode: {
|
|
@@ -514,11 +520,18 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
514
520
|
e.stopPropagation();
|
|
515
521
|
var startPos = getPos();
|
|
516
522
|
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref4) {
|
|
517
|
-
var _selectionPreservatio2, _api$
|
|
523
|
+
var _selectionPreservatio2, _api$blockControls5, _api$blockControls6, _api$userIntent;
|
|
518
524
|
var tr = _ref4.tr;
|
|
519
525
|
if (startPos === undefined) {
|
|
520
526
|
return tr;
|
|
521
527
|
}
|
|
528
|
+
var node = tr.doc.resolve(startPos).nodeAfter;
|
|
529
|
+
if (node) {
|
|
530
|
+
var _api$blockControls4;
|
|
531
|
+
api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || _api$blockControls4.actions.notifyBlockHandleClick({
|
|
532
|
+
node: node
|
|
533
|
+
});
|
|
534
|
+
}
|
|
522
535
|
var selection = ((_selectionPreservatio2 = selectionPreservationPluginKey.getState(view.state)) === null || _selectionPreservatio2 === void 0 ? void 0 : _selectionPreservatio2.preservedSelection) || tr.selection;
|
|
523
536
|
expandAndUpdateSelection({
|
|
524
537
|
tr: tr,
|
|
@@ -528,7 +541,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
528
541
|
nodeType: nodeType,
|
|
529
542
|
api: api
|
|
530
543
|
});
|
|
531
|
-
api === null || api === void 0 || (_api$
|
|
544
|
+
api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.startPreservingSelection()({
|
|
532
545
|
tr: tr
|
|
533
546
|
});
|
|
534
547
|
if (nodeType === 'layoutColumn') {
|
|
@@ -539,7 +552,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
539
552
|
pos: startPos,
|
|
540
553
|
rootPos: tr.doc.resolve(startPos).before(1)
|
|
541
554
|
};
|
|
542
|
-
api === null || api === void 0 || (_api$
|
|
555
|
+
api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.toggleBlockMenu({
|
|
543
556
|
anchorName: anchorName,
|
|
544
557
|
triggerByNode: triggerByNode,
|
|
545
558
|
openedViaKeyboard: true
|
|
@@ -584,8 +597,8 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
584
597
|
}
|
|
585
598
|
var newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
|
|
586
599
|
if (!tr.selection.empty && newHandlePosCheck) {
|
|
587
|
-
var _api$
|
|
588
|
-
api === null || api === void 0 || (_api$
|
|
600
|
+
var _api$blockControls7;
|
|
601
|
+
api === null || api === void 0 || (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 || _api$blockControls7.commands.setMultiSelectPositions()({
|
|
589
602
|
tr: tr
|
|
590
603
|
});
|
|
591
604
|
} else {
|
|
@@ -692,7 +705,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
692
705
|
return;
|
|
693
706
|
}
|
|
694
707
|
api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref8) {
|
|
695
|
-
var _api$blockControls$sh2, _api$
|
|
708
|
+
var _api$blockControls$sh2, _api$blockControls8, _api$analytics2;
|
|
696
709
|
var tr = _ref8.tr;
|
|
697
710
|
var nodeTypes, hasSelectedMultipleNodes;
|
|
698
711
|
var resolvedMovingNode = tr.doc.resolve(start);
|
|
@@ -706,7 +719,7 @@ export var DragHandle = function DragHandle(_ref2) {
|
|
|
706
719
|
nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
|
|
707
720
|
hasSelectedMultipleNodes = false;
|
|
708
721
|
}
|
|
709
|
-
api === null || api === void 0 || (_api$
|
|
722
|
+
api === null || api === void 0 || (_api$blockControls8 = api.blockControls) === null || _api$blockControls8 === void 0 || _api$blockControls8.commands.setNodeDragged(getPos, anchorName, nodeType)({
|
|
710
723
|
tr: tr
|
|
711
724
|
});
|
|
712
725
|
tr.setMeta('scrollIntoView', false);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics/types/enums';
|
|
3
|
-
import { startMeasure } from '@atlaskit/editor-common/performance-measures';
|
|
4
3
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
4
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
6
5
|
import { draggable } from '@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter';
|
|
@@ -11,7 +10,6 @@ import { isCollapsedHeading, prepareCollapsedHeadingSelection } from '../pm-plug
|
|
|
11
10
|
import { isHandleCorrelatedToSelection, selectNode } from '../pm-plugins/utils/getSelection';
|
|
12
11
|
import { getNodeMarginsForDragPreview, getNodeSpacingForDragPreview } from './block-controls-surface-drag-handle-utils';
|
|
13
12
|
import { dragPreview } from './drag-preview';
|
|
14
|
-
var EDITOR_BLOCKS_DRAG_INIT = 'Editor Blocks Drag Initialization Time';
|
|
15
13
|
/**
|
|
16
14
|
* Registry surface drag source. This intentionally duplicates the stable widget handle's drag
|
|
17
15
|
* contract so the legacy implementation remains byte-for-byte unchanged during migration.
|
|
@@ -142,9 +140,6 @@ export var useBlockControlsSurfaceDragSource = function useBlockControlsSurfaceD
|
|
|
142
140
|
}
|
|
143
141
|
|
|
144
142
|
// This handle is outside ProseMirror, so it owns the side effects normally started by PM.
|
|
145
|
-
if (!isExperimentEnabled('platform_editor_remove_legacy_perf_events')) {
|
|
146
|
-
startMeasure(EDITOR_BLOCKS_DRAG_INIT);
|
|
147
|
-
}
|
|
148
143
|
defaultActiveAnchorTracker.reset();
|
|
149
144
|
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref5) {
|
|
150
145
|
var _api$blockControls$sh2, _resolvedMovingNode$n, _api$blockControls2, _api$analytics;
|
|
@@ -21,6 +21,7 @@ import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead/type-ah
|
|
|
21
21
|
import type { UiControlRegistryPlugin } from '@atlaskit/editor-plugin-ui-control-registry/ui-control-registry-plugin-type';
|
|
22
22
|
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent/user-intent-plugin-type';
|
|
23
23
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width/width-plugin-type';
|
|
24
|
+
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
24
25
|
import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
25
26
|
import type { Mapping } from '@atlaskit/editor-prosemirror/transform';
|
|
26
27
|
import type { Decoration, DecorationSet, EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -85,6 +86,10 @@ export interface PluginState {
|
|
|
85
86
|
}
|
|
86
87
|
export type ReleaseHiddenDecoration = () => boolean | undefined;
|
|
87
88
|
export type BlockControlsPluginConfig = {
|
|
89
|
+
/** Called with the clicked block from either drag-handle implementation. */
|
|
90
|
+
onBlockHandleClick?: (context: {
|
|
91
|
+
node: Node;
|
|
92
|
+
}) => void;
|
|
88
93
|
/**
|
|
89
94
|
* Enable the quick insert plus button icon on the left of the drag handle.
|
|
90
95
|
*
|
|
@@ -192,6 +197,10 @@ export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
|
|
|
192
197
|
textContent: string;
|
|
193
198
|
textLength: number;
|
|
194
199
|
} | null;
|
|
200
|
+
/** Notifies the host about a drag-handle click. */
|
|
201
|
+
notifyBlockHandleClick: (context: {
|
|
202
|
+
node: Node;
|
|
203
|
+
}) => void;
|
|
195
204
|
registerNodeDecoration: (factory: NodeDecorationFactory) => void;
|
|
196
205
|
unregisterNodeDecoration: (type: string) => void;
|
|
197
206
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "30.
|
|
3
|
+
"version": "30.1.1",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"atlaskit:src": "src/index.ts",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@atlaskit/browser-apis": "^1.2.0",
|
|
29
|
-
"@atlaskit/button": "^25.
|
|
29
|
+
"@atlaskit/button": "^25.6.0",
|
|
30
30
|
"@atlaskit/css": "^1.1.0",
|
|
31
31
|
"@atlaskit/docs": "^12.3.0",
|
|
32
32
|
"@atlaskit/editor-plugin-accessibility-utils": "^29.0.0",
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"@atlaskit/editor-plugin-metrics": "^30.0.0",
|
|
41
41
|
"@atlaskit/editor-plugin-quick-insert": "^29.0.0",
|
|
42
42
|
"@atlaskit/editor-plugin-selection": "^29.0.0",
|
|
43
|
-
"@atlaskit/editor-plugin-show-diff": "^27.
|
|
43
|
+
"@atlaskit/editor-plugin-show-diff": "^27.1.0",
|
|
44
44
|
"@atlaskit/editor-plugin-toolbar": "^26.0.0",
|
|
45
45
|
"@atlaskit/editor-plugin-type-ahead": "^30.0.0",
|
|
46
46
|
"@atlaskit/editor-plugin-ui-control-registry": "^23.0.0",
|
|
47
47
|
"@atlaskit/editor-plugin-user-intent": "^27.0.0",
|
|
48
48
|
"@atlaskit/editor-plugin-width": "^30.0.0",
|
|
49
49
|
"@atlaskit/editor-prosemirror": "^9.0.0",
|
|
50
|
-
"@atlaskit/editor-shared-styles": "^4.
|
|
50
|
+
"@atlaskit/editor-shared-styles": "^4.6.0",
|
|
51
51
|
"@atlaskit/editor-tables": "^3.2.0",
|
|
52
52
|
"@atlaskit/editor-ui-control-model": "^2.10.0",
|
|
53
53
|
"@atlaskit/icon": "^38.0.0",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"@atlaskit/primitives": "^22.6.0",
|
|
62
62
|
"@atlaskit/section-message": "^10.2.0",
|
|
63
63
|
"@atlaskit/theme": "^28.2.0",
|
|
64
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
65
|
-
"@atlaskit/tokens": "^20.
|
|
64
|
+
"@atlaskit/tmp-editor-statsig": "^245.0.0",
|
|
65
|
+
"@atlaskit/tokens": "^20.7.0",
|
|
66
66
|
"@atlaskit/tooltip": "^24.4.0",
|
|
67
67
|
"@babel/runtime": "^7.0.0",
|
|
68
68
|
"@compiled/react": "^1.0.2",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"uuid": "^11.1.1"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@atlaskit/editor-common": "^133.
|
|
76
|
+
"@atlaskit/editor-common": "^133.5.0",
|
|
77
77
|
"react": "^18.2.0 || ^19.2.0",
|
|
78
78
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
79
79
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
@@ -82,9 +82,6 @@
|
|
|
82
82
|
"platform_editor_ease_of_use_metrics": {
|
|
83
83
|
"type": "boolean"
|
|
84
84
|
},
|
|
85
|
-
"platform_editor_drag_and_drop_perf_analytics": {
|
|
86
|
-
"type": "boolean"
|
|
87
|
-
},
|
|
88
85
|
"platform_editor_content_mode_button_mvp": {
|
|
89
86
|
"type": "boolean"
|
|
90
87
|
},
|