@atlaskit/editor-plugin-block-controls 30.1.0 → 30.1.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 +21 -0
- package/dist/cjs/pm-plugins/main.js +4 -68
- package/dist/cjs/ui/block-controls-surface-components.js +42 -6
- package/dist/cjs/ui/use-block-controls-surface-drag-source.js +0 -5
- package/dist/es2019/pm-plugins/main.js +4 -69
- package/dist/es2019/ui/block-controls-surface-components.js +30 -5
- package/dist/es2019/ui/use-block-controls-surface-drag-source.js +0 -5
- package/dist/esm/pm-plugins/main.js +4 -68
- package/dist/esm/ui/block-controls-surface-components.js +42 -6
- package/dist/esm/ui/use-block-controls-surface-drag-source.js +0 -5
- package/package.json +7 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 30.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`0aef8124fd34f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0aef8124fd34f) -
|
|
8
|
+
Add an optional controlVisibility map to the block-control surface context. Visibility predicates
|
|
9
|
+
receive earlier controls' isHidden results in registry rank order, keyed by registered control
|
|
10
|
+
key. Behind the platform_editor_remix_control_priority experiment on the
|
|
11
|
+
platform_editor_block_control_migration path, use this context to let Remix yield to earlier
|
|
12
|
+
eligible controls on the same block without coupling it to suggestions. With the experiment
|
|
13
|
+
disabled, retain the original context and Remix rank and visibility.
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 30.1.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [`c02fec2c86f55`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c02fec2c86f55) -
|
|
21
|
+
Clean up experiment `platform_editor_remove_legacy_perf_events`
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 30.1.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
|
@@ -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
|
|
@@ -10,12 +10,18 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _blockControlUiContext = require("@atlaskit/editor-common/block-controls/block-control-ui-context");
|
|
13
14
|
var _surfaceKeys = require("@atlaskit/editor-common/block-controls/surface-keys");
|
|
15
|
+
var _createSurfaceContext = require("@atlaskit/editor-ui-control-model/create-surface-context");
|
|
14
16
|
var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-renderer");
|
|
17
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
15
18
|
var _partitionComponentsByPersistence = require("./utils/partition-components-by-persistence");
|
|
16
19
|
var _visibilityContainer = require("./visibility-container");
|
|
17
20
|
var _excluded = ["isHidden"];
|
|
18
21
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
22
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
23
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
24
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
19
25
|
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; }
|
|
20
26
|
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; }
|
|
21
27
|
var BlockControlsVisibilityContext = /*#__PURE__*/(0, _react.createContext)({
|
|
@@ -66,6 +72,21 @@ var withoutVisibilityPredicate = function withoutVisibilityPredicate(component)
|
|
|
66
72
|
visibleComponent = (0, _objectWithoutProperties2.default)(component, _excluded);
|
|
67
73
|
return visibleComponent;
|
|
68
74
|
};
|
|
75
|
+
var withControlVisibility = function withControlVisibility(surfaceContext, controlVisibility) {
|
|
76
|
+
var context = surfaceContext.get(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT);
|
|
77
|
+
if (!context) {
|
|
78
|
+
return surfaceContext;
|
|
79
|
+
}
|
|
80
|
+
var controlContext = (0, _createSurfaceContext.createSurfaceContext)(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT, _objectSpread(_objectSpread({}, context), {}, {
|
|
81
|
+
controlVisibility: new Map(controlVisibility)
|
|
82
|
+
}));
|
|
83
|
+
return {
|
|
84
|
+
get: function get(token) {
|
|
85
|
+
var _controlContext$get;
|
|
86
|
+
return (_controlContext$get = controlContext.get(token)) !== null && _controlContext$get !== void 0 ? _controlContext$get : surfaceContext.get(token);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
};
|
|
69
90
|
|
|
70
91
|
/**
|
|
71
92
|
* Replaces the shared surface group with one stable wrapper group per visible control. The wrappers
|
|
@@ -80,12 +101,27 @@ var getBlockControlsSurfaceComponents = function getBlockControlsSurfaceComponen
|
|
|
80
101
|
var resolvedSurface = (0, _surfaceRenderer.resolveSurface)(components, surface);
|
|
81
102
|
var groupIdentity = (0, _surfaceRenderer.getComponentIdentity)(group);
|
|
82
103
|
var controls = (_resolvedSurface$chil = resolvedSurface.childrenMap.get(groupIdentity)) !== null && _resolvedSurface$chil !== void 0 ? _resolvedSurface$chil : [];
|
|
83
|
-
var visibleControls =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
104
|
+
var visibleControls = [];
|
|
105
|
+
var controlVisibility = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_remix_control_priority') ? new Map() : undefined;
|
|
106
|
+
var _iterator = _createForOfIteratorHelper(controls),
|
|
107
|
+
_step;
|
|
108
|
+
try {
|
|
109
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
110
|
+
var _control$isHidden, _control$isHidden2;
|
|
111
|
+
var control = _step.value;
|
|
112
|
+
var isHidden = (_control$isHidden = (_control$isHidden2 = control.isHidden) === null || _control$isHidden2 === void 0 ? void 0 : _control$isHidden2.call(control, {
|
|
113
|
+
surfaceContext: controlVisibility ? withControlVisibility(surfaceContext, controlVisibility) : surfaceContext
|
|
114
|
+
})) !== null && _control$isHidden !== void 0 ? _control$isHidden : false;
|
|
115
|
+
controlVisibility === null || controlVisibility === void 0 || controlVisibility.set(control.key, isHidden);
|
|
116
|
+
if (!isHidden) {
|
|
117
|
+
visibleControls.push(control);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
} catch (err) {
|
|
121
|
+
_iterator.e(err);
|
|
122
|
+
} finally {
|
|
123
|
+
_iterator.f();
|
|
124
|
+
}
|
|
89
125
|
if (!resolvedSurface.root || visibleControls.length === 0) {
|
|
90
126
|
return undefined;
|
|
91
127
|
}
|
|
@@ -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;
|
|
@@ -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
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React, { createContext, useContext, useMemo } from 'react';
|
|
2
|
+
import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
|
|
2
3
|
import { BLOCK_CONTROLS_LEFT_GROUP, BLOCK_CONTROLS_LEFT_SECTION, BLOCK_CONTROLS_LEFT_SURFACE, BLOCK_CONTROLS_RIGHT_GROUP, BLOCK_CONTROLS_RIGHT_SECTION, BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
4
|
+
import { createSurfaceContext } from '@atlaskit/editor-ui-control-model/create-surface-context';
|
|
3
5
|
import { getComponentIdentity, resolveSurface } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
6
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
4
7
|
import { partitionComponentsByPersistence } from './utils/partition-components-by-persistence';
|
|
5
8
|
import { VisibilityWrapper } from './visibility-container';
|
|
6
9
|
const BlockControlsVisibilityContext = /*#__PURE__*/createContext({
|
|
@@ -55,6 +58,22 @@ const withoutVisibilityPredicate = component => {
|
|
|
55
58
|
} = component;
|
|
56
59
|
return visibleComponent;
|
|
57
60
|
};
|
|
61
|
+
const withControlVisibility = (surfaceContext, controlVisibility) => {
|
|
62
|
+
const context = surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
|
|
63
|
+
if (!context) {
|
|
64
|
+
return surfaceContext;
|
|
65
|
+
}
|
|
66
|
+
const controlContext = createSurfaceContext(BLOCK_CONTROL_UI_CONTEXT, {
|
|
67
|
+
...context,
|
|
68
|
+
controlVisibility: new Map(controlVisibility)
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
get: token => {
|
|
72
|
+
var _controlContext$get;
|
|
73
|
+
return (_controlContext$get = controlContext.get(token)) !== null && _controlContext$get !== void 0 ? _controlContext$get : surfaceContext.get(token);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
};
|
|
58
77
|
|
|
59
78
|
/**
|
|
60
79
|
* Replaces the shared surface group with one stable wrapper group per visible control. The wrappers
|
|
@@ -70,12 +89,18 @@ const getBlockControlsSurfaceComponents = (components, {
|
|
|
70
89
|
const resolvedSurface = resolveSurface(components, surface);
|
|
71
90
|
const groupIdentity = getComponentIdentity(group);
|
|
72
91
|
const controls = (_resolvedSurface$chil = resolvedSurface.childrenMap.get(groupIdentity)) !== null && _resolvedSurface$chil !== void 0 ? _resolvedSurface$chil : [];
|
|
73
|
-
const visibleControls =
|
|
92
|
+
const visibleControls = [];
|
|
93
|
+
const controlVisibility = isExperimentEnabled('platform_editor_remix_control_priority') ? new Map() : undefined;
|
|
94
|
+
for (const control of controls) {
|
|
74
95
|
var _control$isHidden, _control$isHidden2;
|
|
75
|
-
|
|
76
|
-
surfaceContext
|
|
77
|
-
})) !== null && _control$isHidden !== void 0 ? _control$isHidden : false
|
|
78
|
-
|
|
96
|
+
const isHidden = (_control$isHidden = (_control$isHidden2 = control.isHidden) === null || _control$isHidden2 === void 0 ? void 0 : _control$isHidden2.call(control, {
|
|
97
|
+
surfaceContext: controlVisibility ? withControlVisibility(surfaceContext, controlVisibility) : surfaceContext
|
|
98
|
+
})) !== null && _control$isHidden !== void 0 ? _control$isHidden : false;
|
|
99
|
+
controlVisibility === null || controlVisibility === void 0 ? void 0 : controlVisibility.set(control.key, isHidden);
|
|
100
|
+
if (!isHidden) {
|
|
101
|
+
visibleControls.push(control);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
79
104
|
if (!resolvedSurface.root || visibleControls.length === 0) {
|
|
80
105
|
return undefined;
|
|
81
106
|
}
|
|
@@ -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
|
|
@@ -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
|
|
@@ -2,11 +2,17 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
4
|
var _excluded = ["isHidden"];
|
|
5
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
6
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
7
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
8
|
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; }
|
|
6
9
|
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) { _defineProperty(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; }
|
|
7
10
|
import React, { createContext, useContext, useMemo } from 'react';
|
|
11
|
+
import { BLOCK_CONTROL_UI_CONTEXT } from '@atlaskit/editor-common/block-controls/block-control-ui-context';
|
|
8
12
|
import { BLOCK_CONTROLS_LEFT_GROUP, BLOCK_CONTROLS_LEFT_SECTION, BLOCK_CONTROLS_LEFT_SURFACE, BLOCK_CONTROLS_RIGHT_GROUP, BLOCK_CONTROLS_RIGHT_SECTION, BLOCK_CONTROLS_RIGHT_SURFACE } from '@atlaskit/editor-common/block-controls/surface-keys';
|
|
13
|
+
import { createSurfaceContext } from '@atlaskit/editor-ui-control-model/create-surface-context';
|
|
9
14
|
import { getComponentIdentity, resolveSurface } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
15
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
10
16
|
import { partitionComponentsByPersistence } from './utils/partition-components-by-persistence';
|
|
11
17
|
import { VisibilityWrapper } from './visibility-container';
|
|
12
18
|
var BlockControlsVisibilityContext = /*#__PURE__*/createContext({
|
|
@@ -57,6 +63,21 @@ var withoutVisibilityPredicate = function withoutVisibilityPredicate(component)
|
|
|
57
63
|
visibleComponent = _objectWithoutProperties(component, _excluded);
|
|
58
64
|
return visibleComponent;
|
|
59
65
|
};
|
|
66
|
+
var withControlVisibility = function withControlVisibility(surfaceContext, controlVisibility) {
|
|
67
|
+
var context = surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT);
|
|
68
|
+
if (!context) {
|
|
69
|
+
return surfaceContext;
|
|
70
|
+
}
|
|
71
|
+
var controlContext = createSurfaceContext(BLOCK_CONTROL_UI_CONTEXT, _objectSpread(_objectSpread({}, context), {}, {
|
|
72
|
+
controlVisibility: new Map(controlVisibility)
|
|
73
|
+
}));
|
|
74
|
+
return {
|
|
75
|
+
get: function get(token) {
|
|
76
|
+
var _controlContext$get;
|
|
77
|
+
return (_controlContext$get = controlContext.get(token)) !== null && _controlContext$get !== void 0 ? _controlContext$get : surfaceContext.get(token);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
};
|
|
60
81
|
|
|
61
82
|
/**
|
|
62
83
|
* Replaces the shared surface group with one stable wrapper group per visible control. The wrappers
|
|
@@ -71,12 +92,27 @@ var getBlockControlsSurfaceComponents = function getBlockControlsSurfaceComponen
|
|
|
71
92
|
var resolvedSurface = resolveSurface(components, surface);
|
|
72
93
|
var groupIdentity = getComponentIdentity(group);
|
|
73
94
|
var controls = (_resolvedSurface$chil = resolvedSurface.childrenMap.get(groupIdentity)) !== null && _resolvedSurface$chil !== void 0 ? _resolvedSurface$chil : [];
|
|
74
|
-
var visibleControls =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
95
|
+
var visibleControls = [];
|
|
96
|
+
var controlVisibility = isExperimentEnabled('platform_editor_remix_control_priority') ? new Map() : undefined;
|
|
97
|
+
var _iterator = _createForOfIteratorHelper(controls),
|
|
98
|
+
_step;
|
|
99
|
+
try {
|
|
100
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
101
|
+
var _control$isHidden, _control$isHidden2;
|
|
102
|
+
var control = _step.value;
|
|
103
|
+
var isHidden = (_control$isHidden = (_control$isHidden2 = control.isHidden) === null || _control$isHidden2 === void 0 ? void 0 : _control$isHidden2.call(control, {
|
|
104
|
+
surfaceContext: controlVisibility ? withControlVisibility(surfaceContext, controlVisibility) : surfaceContext
|
|
105
|
+
})) !== null && _control$isHidden !== void 0 ? _control$isHidden : false;
|
|
106
|
+
controlVisibility === null || controlVisibility === void 0 || controlVisibility.set(control.key, isHidden);
|
|
107
|
+
if (!isHidden) {
|
|
108
|
+
visibleControls.push(control);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
} catch (err) {
|
|
112
|
+
_iterator.e(err);
|
|
113
|
+
} finally {
|
|
114
|
+
_iterator.f();
|
|
115
|
+
}
|
|
80
116
|
if (!resolvedSurface.root || visibleControls.length === 0) {
|
|
81
117
|
return undefined;
|
|
82
118
|
}
|
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "30.1.
|
|
3
|
+
"version": "30.1.2",
|
|
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.6.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
|
},
|