@atlaskit/editor-plugin-block-controls 18.0.0 → 18.1.0
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 +36 -0
- package/dist/cjs/pm-plugins/main.js +89 -34
- package/dist/es2019/pm-plugins/main.js +87 -32
- package/dist/esm/pm-plugins/main.js +89 -34
- package/dist/types/pm-plugins/main.d.ts +3 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 18.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`aec3fcfe13ff9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/aec3fcfe13ff9) -
|
|
8
|
+
EDITOR-8303 Add runtime input-latency trigger for limited mode behind
|
|
9
|
+
platform_editor_dynamic_limited_mode. Limited mode can now latch mid-session when sustained slow
|
|
10
|
+
input or repeated browser freezes indicate the device is struggling, in addition to the existing
|
|
11
|
+
document-size decision. The latch is one-way. Nothing is constructed when the experiment is off.
|
|
12
|
+
|
|
13
|
+
How much evidence is needed is a single tunable, `requiredConfirmations`: that many qualifying
|
|
14
|
+
windows, each separated from the last by `confirmationGapMs`. The hardware no longer feeds into
|
|
15
|
+
the decision — `navigator.hardwareConcurrency` and `navigator.deviceMemory` are reported with the
|
|
16
|
+
`limitedModeLatched` event instead, so which devices latch can be answered from the data rather
|
|
17
|
+
than assumed up front.
|
|
18
|
+
|
|
19
|
+
`LimitedModePluginState` gains a derived `enabled` flag, which is now the single thing consumers
|
|
20
|
+
should branch on — the individual reasons (`documentSizeBreachesThreshold`, `latchPolicyBreached`)
|
|
21
|
+
no longer need to be combined at each call site, so a future reason needs no change outside this
|
|
22
|
+
plugin. `sharedState.enabled` reads from it.
|
|
23
|
+
|
|
24
|
+
Under the experiment the document decision is also evaluated on load and on document replacement
|
|
25
|
+
only, rather than on every transaction that changes the document. That check walks the whole
|
|
26
|
+
document, so it was a full-document scan per keystroke on exactly the pages least able to afford
|
|
27
|
+
one. The trade-off is that a document editing its way past the thresholds is not re-judged until
|
|
28
|
+
it next loads.
|
|
29
|
+
|
|
30
|
+
Consumers updated to react to a mid-session change: table sticky headers now subscribe instead of
|
|
31
|
+
reading once at construction, block-controls resets rather than freezes its state on entry, and
|
|
32
|
+
the expand, media and table nodeviews read the derived flag so they no longer miss a runtime
|
|
33
|
+
latch.
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies
|
|
38
|
+
|
|
3
39
|
## 18.0.0
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
|
@@ -21,6 +21,7 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
21
21
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
22
22
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
23
23
|
var _surfaceRenderer = require("@atlaskit/editor-ui-control-model/surface-renderer");
|
|
24
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
24
25
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
25
26
|
var _element = require("@atlaskit/pragmatic-drag-and-drop-auto-scroll/element");
|
|
26
27
|
var _combine = require("@atlaskit/pragmatic-drag-and-drop/utils/combine");
|
|
@@ -240,13 +241,14 @@ var getDecorationAtPos = function getDecorationAtPos(state, decorations, pos, to
|
|
|
240
241
|
return nodeDecAtActivePos;
|
|
241
242
|
};
|
|
242
243
|
var _apply = exports.apply = function apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry) {
|
|
243
|
-
var
|
|
244
|
+
var _meta$multiSelectDnD, _api$editorViewMode, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _meta$isDragging3, _meta$toggleMenu, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$toggleMenu6, _meta$toggleMenu7, _meta$toggleMenu8, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
|
|
244
245
|
var rightSideControlsEnabled = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
|
|
245
246
|
var quickInsertButtonEnabled = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : true;
|
|
246
247
|
var anchorRectCache = arguments.length > 10 ? arguments[10] : undefined;
|
|
247
248
|
var resizeObserverWidth = arguments.length > 11 ? arguments[11] : undefined;
|
|
248
249
|
var pragmaticCleanup = arguments.length > 12 ? arguments[12] : undefined;
|
|
249
250
|
var resolvedSurfaces = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : [];
|
|
251
|
+
var limitedModeTeardown = arguments.length > 14 ? arguments[14] : undefined;
|
|
250
252
|
var activeNode = currentState.activeNode,
|
|
251
253
|
decorations = currentState.decorations,
|
|
252
254
|
isResizerResizing = currentState.isResizerResizing,
|
|
@@ -273,18 +275,67 @@ var _apply = exports.apply = function apply(api, formatMessage, tr, currentState
|
|
|
273
275
|
isAllText = _getTrMetadata.isAllText,
|
|
274
276
|
isReplacedWithSameSize = _getTrMetadata.isReplacedWithSameSize;
|
|
275
277
|
var meta = tr.getMeta(key);
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
278
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_dynamic_limited_mode')) {
|
|
279
|
+
var _api$limitedMode;
|
|
280
|
+
// Both arms read `newState` — the state this transaction is producing. Deriving `enabled` from
|
|
281
|
+
// `sharedState.currentState()` instead would resolve against `view.state`, which during `apply` is
|
|
282
|
+
// still the *previous* state, delaying the limited-mode teardown by one transaction.
|
|
283
|
+
//
|
|
284
|
+
// Limited mode can now also be latched at runtime by the performance detector, so the treatment
|
|
285
|
+
// arm considers both reasons rather than just the document one. Identical in the control arm, where
|
|
286
|
+
// the runtime latch can never be set.
|
|
287
|
+
var limitedModeState = api === null || api === void 0 || (_api$limitedMode = api.limitedMode) === null || _api$limitedMode === void 0 || (_api$limitedMode = _api$limitedMode.sharedState.currentState()) === null || _api$limitedMode === void 0 ? void 0 : _api$limitedMode.limitedModePluginKey.getState(newState);
|
|
288
|
+
if (!!(limitedModeState !== null && limitedModeState !== void 0 && limitedModeState.enabled)) {
|
|
289
|
+
/**
|
|
290
|
+
* INFO: This is a duplicate of the logic in destroy(). When we enter limited mode we want to
|
|
291
|
+
* trigger the cleanup logic in destroy().
|
|
292
|
+
*/
|
|
293
|
+
if (!limitedModeTeardown || !limitedModeTeardown.done) {
|
|
294
|
+
var _getDocument$querySel2, _getDocument2;
|
|
295
|
+
/**
|
|
296
|
+
* Edge-triggered under the experiment: limited mode is a latch, so without this guard the
|
|
297
|
+
* teardown re-runs on every subsequent transaction for the rest of the session — and would
|
|
298
|
+
* re-register the pragmatic monitors if `pragmaticCleanup` ever became re-entrant.
|
|
299
|
+
*/
|
|
300
|
+
if (limitedModeTeardown) {
|
|
301
|
+
limitedModeTeardown.done = true;
|
|
302
|
+
}
|
|
303
|
+
var editorContentArea = (_getDocument$querySel2 = (_getDocument2 = (0, _browserApis.getDocument)()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.querySelector('.fabric-editor-popup-scroll-parent')) !== null && _getDocument$querySel2 !== void 0 ? _getDocument$querySel2 : null;
|
|
304
|
+
if (editorContentArea && resizeObserverWidth) {
|
|
305
|
+
resizeObserverWidth.unobserve(editorContentArea);
|
|
306
|
+
}
|
|
307
|
+
pragmaticCleanup === null || pragmaticCleanup === void 0 || pragmaticCleanup();
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Reset rather than freeze. Returning `currentState` here would keep `decorations`,
|
|
312
|
+
* `activeNode` and the multi-select positions from before the latch, while skipping the
|
|
313
|
+
* `tr.mapping` remapping below — so they would silently drift out of sync with the document on
|
|
314
|
+
* every subsequent edit. Nothing renders them in limited mode (`props.decorations` returns
|
|
315
|
+
* early), but stale positions are a latent source of incorrect offsets for anything that reads
|
|
316
|
+
* them, so the safe state is empty.
|
|
317
|
+
*/
|
|
318
|
+
return _objectSpread(_objectSpread({}, currentState), {}, {
|
|
319
|
+
activeNode: undefined,
|
|
320
|
+
decorations: _view.DecorationSet.empty,
|
|
321
|
+
multiSelectDnD: undefined
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
} else {
|
|
325
|
+
var _api$limitedMode2;
|
|
326
|
+
var hasDocumentSizeBreachedThreshold = api === null || api === void 0 || (_api$limitedMode2 = api.limitedMode) === null || _api$limitedMode2 === void 0 || (_api$limitedMode2 = _api$limitedMode2.sharedState.currentState()) === null || _api$limitedMode2 === void 0 || (_api$limitedMode2 = _api$limitedMode2.limitedModePluginKey.getState(newState)) === null || _api$limitedMode2 === void 0 ? void 0 : _api$limitedMode2.documentSizeBreachesThreshold;
|
|
327
|
+
if (hasDocumentSizeBreachedThreshold) {
|
|
328
|
+
var _getDocument$querySel3, _getDocument3;
|
|
329
|
+
/**
|
|
330
|
+
* INFO: This if statement is a duplicate of the logic in destroy(). When the threshold is breached and we enter limited mode, we want to trigger the cleanup logic in destroy().
|
|
331
|
+
*/
|
|
332
|
+
var _editorContentArea = (_getDocument$querySel3 = (_getDocument3 = (0, _browserApis.getDocument)()) === null || _getDocument3 === void 0 ? void 0 : _getDocument3.querySelector('.fabric-editor-popup-scroll-parent')) !== null && _getDocument$querySel3 !== void 0 ? _getDocument$querySel3 : null;
|
|
333
|
+
if (_editorContentArea && resizeObserverWidth) {
|
|
334
|
+
resizeObserverWidth.unobserve(_editorContentArea);
|
|
335
|
+
}
|
|
336
|
+
pragmaticCleanup === null || pragmaticCleanup === void 0 || pragmaticCleanup();
|
|
337
|
+
return currentState;
|
|
285
338
|
}
|
|
286
|
-
pragmaticCleanup === null || pragmaticCleanup === void 0 || pragmaticCleanup();
|
|
287
|
-
return currentState;
|
|
288
339
|
}
|
|
289
340
|
|
|
290
341
|
// When steps exist, remap existing decorations, activeNode and multi select positions
|
|
@@ -912,6 +963,10 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
912
963
|
}
|
|
913
964
|
var resizeObserverWidth;
|
|
914
965
|
var pragmaticCleanup = null;
|
|
966
|
+
// Limited mode is a one-way latch, so its teardown must only run on the transition.
|
|
967
|
+
var limitedModeTeardown = {
|
|
968
|
+
done: false
|
|
969
|
+
};
|
|
915
970
|
return new _safePlugin.SafePlugin({
|
|
916
971
|
key: key,
|
|
917
972
|
state: {
|
|
@@ -921,13 +976,13 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
921
976
|
});
|
|
922
977
|
},
|
|
923
978
|
apply: function apply(tr, currentState, _, newState) {
|
|
924
|
-
return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, resolvedSurfaces);
|
|
979
|
+
return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, resolvedSurfaces, limitedModeTeardown);
|
|
925
980
|
}
|
|
926
981
|
},
|
|
927
982
|
props: {
|
|
928
983
|
decorations: function decorations(state) {
|
|
929
|
-
var _api$
|
|
930
|
-
if (api !== null && api !== void 0 && (_api$
|
|
984
|
+
var _api$limitedMode3, _api$editorDisabled, _key$getState2, _api$editorViewMode3;
|
|
985
|
+
if (api !== null && api !== void 0 && (_api$limitedMode3 = api.limitedMode) !== null && _api$limitedMode3 !== void 0 && (_api$limitedMode3 = _api$limitedMode3.sharedState.currentState()) !== null && _api$limitedMode3 !== void 0 && _api$limitedMode3.enabled) {
|
|
931
986
|
return;
|
|
932
987
|
}
|
|
933
988
|
var isDisabled = api === null || api === void 0 || (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 || (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled === void 0 ? void 0 : _api$editorDisabled.editorDisabled;
|
|
@@ -1000,8 +1055,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
1000
1055
|
return false;
|
|
1001
1056
|
},
|
|
1002
1057
|
dragenter: function dragenter(view, event) {
|
|
1003
|
-
var _api$
|
|
1004
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1058
|
+
var _api$limitedMode4, _key$getState3;
|
|
1059
|
+
if (api !== null && api !== void 0 && (_api$limitedMode4 = api.limitedMode) !== null && _api$limitedMode4 !== void 0 && (_api$limitedMode4 = _api$limitedMode4.sharedState.currentState()) !== null && _api$limitedMode4 !== void 0 && _api$limitedMode4.enabled) {
|
|
1005
1060
|
return;
|
|
1006
1061
|
}
|
|
1007
1062
|
|
|
@@ -1041,8 +1096,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
1041
1096
|
}
|
|
1042
1097
|
},
|
|
1043
1098
|
dragstart: function dragstart(view) {
|
|
1044
|
-
var _api$
|
|
1045
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1099
|
+
var _api$limitedMode5, _anchorRectCache2;
|
|
1100
|
+
if (api !== null && api !== void 0 && (_api$limitedMode5 = api.limitedMode) !== null && _api$limitedMode5 !== void 0 && (_api$limitedMode5 = _api$limitedMode5.sharedState.currentState()) !== null && _api$limitedMode5 !== void 0 && _api$limitedMode5.enabled) {
|
|
1046
1101
|
return;
|
|
1047
1102
|
}
|
|
1048
1103
|
(0, _performanceMeasures.startMeasure)(EDITOR_BLOCKS_DRAG_INIT);
|
|
@@ -1059,8 +1114,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
1059
1114
|
})));
|
|
1060
1115
|
},
|
|
1061
1116
|
dragend: function dragend(view) {
|
|
1062
|
-
var _api$
|
|
1063
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1117
|
+
var _api$limitedMode6, _key$getState4;
|
|
1118
|
+
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) {
|
|
1064
1119
|
return;
|
|
1065
1120
|
}
|
|
1066
1121
|
var state = view.state,
|
|
@@ -1080,8 +1135,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
1080
1135
|
}
|
|
1081
1136
|
},
|
|
1082
1137
|
mouseover: function mouseover(view, event) {
|
|
1083
|
-
var _api$
|
|
1084
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1138
|
+
var _api$limitedMode7, _getNodeIdProvider;
|
|
1139
|
+
if (api !== null && api !== void 0 && (_api$limitedMode7 = api.limitedMode) !== null && _api$limitedMode7 !== void 0 && (_api$limitedMode7 = _api$limitedMode7.sharedState.currentState()) !== null && _api$limitedMode7 !== void 0 && _api$limitedMode7.enabled) {
|
|
1085
1140
|
return;
|
|
1086
1141
|
}
|
|
1087
1142
|
|
|
@@ -1095,15 +1150,15 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
1095
1150
|
return false;
|
|
1096
1151
|
},
|
|
1097
1152
|
mousedown: function mousedown(view, event) {
|
|
1098
|
-
var _api$
|
|
1099
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1153
|
+
var _api$limitedMode8;
|
|
1154
|
+
if (api !== null && api !== void 0 && (_api$limitedMode8 = api.limitedMode) !== null && _api$limitedMode8 !== void 0 && (_api$limitedMode8 = _api$limitedMode8.sharedState.currentState()) !== null && _api$limitedMode8 !== void 0 && _api$limitedMode8.enabled) {
|
|
1100
1155
|
return;
|
|
1101
1156
|
}
|
|
1102
1157
|
return (0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1') ? (0, _handleMouseDown.handleMouseDown)(api)(view, event) : undefined;
|
|
1103
1158
|
},
|
|
1104
1159
|
keydown: function keydown(view, event) {
|
|
1105
|
-
var _api$
|
|
1106
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1160
|
+
var _api$limitedMode9;
|
|
1161
|
+
if (api !== null && api !== void 0 && (_api$limitedMode9 = api.limitedMode) !== null && _api$limitedMode9 !== void 0 && (_api$limitedMode9 = _api$limitedMode9.sharedState.currentState()) !== null && _api$limitedMode9 !== void 0 && _api$limitedMode9.enabled) {
|
|
1107
1162
|
return;
|
|
1108
1163
|
}
|
|
1109
1164
|
if (event.shiftKey && event.ctrlKey) {
|
|
@@ -1134,8 +1189,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
1134
1189
|
return false;
|
|
1135
1190
|
},
|
|
1136
1191
|
keyup: function keyup(view, event) {
|
|
1137
|
-
var _api$
|
|
1138
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1192
|
+
var _api$limitedMode0;
|
|
1193
|
+
if (api !== null && api !== void 0 && (_api$limitedMode0 = api.limitedMode) !== null && _api$limitedMode0 !== void 0 && (_api$limitedMode0 = _api$limitedMode0.sharedState.currentState()) !== null && _api$limitedMode0 !== void 0 && _api$limitedMode0.enabled) {
|
|
1139
1194
|
return;
|
|
1140
1195
|
}
|
|
1141
1196
|
if (!event.repeat && event.key === 'Shift') {
|
|
@@ -1145,8 +1200,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
1145
1200
|
}
|
|
1146
1201
|
},
|
|
1147
1202
|
blur: function blur(view, event) {
|
|
1148
|
-
var _api$
|
|
1149
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1203
|
+
var _api$limitedMode1;
|
|
1204
|
+
if (api !== null && api !== void 0 && (_api$limitedMode1 = api.limitedMode) !== null && _api$limitedMode1 !== void 0 && (_api$limitedMode1 = _api$limitedMode1.sharedState.currentState()) !== null && _api$limitedMode1 !== void 0 && _api$limitedMode1.enabled) {
|
|
1150
1205
|
return;
|
|
1151
1206
|
}
|
|
1152
1207
|
if ((0, _editorExperiment.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
@@ -1193,13 +1248,13 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl, no
|
|
|
1193
1248
|
// Registry surfaces have their own ResizeObservers and absolute placement.
|
|
1194
1249
|
// Width metadata only drives legacy widget recreation.
|
|
1195
1250
|
if (legacyDragHandleEnabled && !isResizerResizing) {
|
|
1196
|
-
var
|
|
1251
|
+
var _editorContentArea2 = entries[0].target;
|
|
1197
1252
|
// Ignored via go/ees005
|
|
1198
1253
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1199
|
-
var editorWidthRight =
|
|
1254
|
+
var editorWidthRight = _editorContentArea2.getBoundingClientRect().right;
|
|
1200
1255
|
// Ignored via go/ees005
|
|
1201
1256
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1202
|
-
var editorWidthLeft =
|
|
1257
|
+
var editorWidthLeft = _editorContentArea2.getBoundingClientRect().left;
|
|
1203
1258
|
transaction.setMeta(key, _objectSpread(_objectSpread({}, transaction.getMeta(key)), {}, {
|
|
1204
1259
|
editorWidthLeft: editorWidthLeft,
|
|
1205
1260
|
editorWidthRight: editorWidthRight
|
|
@@ -13,6 +13,7 @@ import { isEmptyDocument } from '@atlaskit/editor-common/utils';
|
|
|
13
13
|
import { PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
14
14
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
15
15
|
import { resolveSurface } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
16
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
16
17
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
17
18
|
import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
|
|
18
19
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/utils/combine';
|
|
@@ -231,8 +232,8 @@ const getDecorationAtPos = (state, decorations, pos, to) => {
|
|
|
231
232
|
const nodeDecAtActivePos = nodeDecsAtActivePos.pop();
|
|
232
233
|
return nodeDecAtActivePos;
|
|
233
234
|
};
|
|
234
|
-
export const apply = (api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled = false, quickInsertButtonEnabled = true, anchorRectCache, resizeObserverWidth, pragmaticCleanup, resolvedSurfaces = []) => {
|
|
235
|
-
var
|
|
235
|
+
export const apply = (api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled = false, quickInsertButtonEnabled = true, anchorRectCache, resizeObserverWidth, pragmaticCleanup, resolvedSurfaces = [], limitedModeTeardown) => {
|
|
236
|
+
var _meta$multiSelectDnD, _api$editorViewMode, _api$editorViewMode$s, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _meta$isDragging3, _meta$toggleMenu, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$toggleMenu6, _meta$toggleMenu7, _meta$toggleMenu8, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
|
|
236
237
|
let {
|
|
237
238
|
activeNode,
|
|
238
239
|
decorations,
|
|
@@ -264,18 +265,68 @@ export const apply = (api, formatMessage, tr, currentState, newState, flags, nod
|
|
|
264
265
|
isReplacedWithSameSize
|
|
265
266
|
} = getTrMetadata(tr, flags);
|
|
266
267
|
const meta = tr.getMeta(key);
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
268
|
+
if (isExperimentEnabled('platform_editor_dynamic_limited_mode')) {
|
|
269
|
+
var _api$limitedMode, _api$limitedMode$shar;
|
|
270
|
+
// Both arms read `newState` — the state this transaction is producing. Deriving `enabled` from
|
|
271
|
+
// `sharedState.currentState()` instead would resolve against `view.state`, which during `apply` is
|
|
272
|
+
// still the *previous* state, delaying the limited-mode teardown by one transaction.
|
|
273
|
+
//
|
|
274
|
+
// Limited mode can now also be latched at runtime by the performance detector, so the treatment
|
|
275
|
+
// arm considers both reasons rather than just the document one. Identical in the control arm, where
|
|
276
|
+
// the runtime latch can never be set.
|
|
277
|
+
const limitedModeState = api === null || api === void 0 ? void 0 : (_api$limitedMode = api.limitedMode) === null || _api$limitedMode === void 0 ? void 0 : (_api$limitedMode$shar = _api$limitedMode.sharedState.currentState()) === null || _api$limitedMode$shar === void 0 ? void 0 : _api$limitedMode$shar.limitedModePluginKey.getState(newState);
|
|
278
|
+
if (!!(limitedModeState !== null && limitedModeState !== void 0 && limitedModeState.enabled)) {
|
|
279
|
+
/**
|
|
280
|
+
* INFO: This is a duplicate of the logic in destroy(). When we enter limited mode we want to
|
|
281
|
+
* trigger the cleanup logic in destroy().
|
|
282
|
+
*/
|
|
283
|
+
if (!limitedModeTeardown || !limitedModeTeardown.done) {
|
|
284
|
+
var _getDocument$querySel2, _getDocument2;
|
|
285
|
+
/**
|
|
286
|
+
* Edge-triggered under the experiment: limited mode is a latch, so without this guard the
|
|
287
|
+
* teardown re-runs on every subsequent transaction for the rest of the session — and would
|
|
288
|
+
* re-register the pragmatic monitors if `pragmaticCleanup` ever became re-entrant.
|
|
289
|
+
*/
|
|
290
|
+
if (limitedModeTeardown) {
|
|
291
|
+
limitedModeTeardown.done = true;
|
|
292
|
+
}
|
|
293
|
+
const editorContentArea = (_getDocument$querySel2 = (_getDocument2 = getDocument()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.querySelector('.fabric-editor-popup-scroll-parent')) !== null && _getDocument$querySel2 !== void 0 ? _getDocument$querySel2 : null;
|
|
294
|
+
if (editorContentArea && resizeObserverWidth) {
|
|
295
|
+
resizeObserverWidth.unobserve(editorContentArea);
|
|
296
|
+
}
|
|
297
|
+
pragmaticCleanup === null || pragmaticCleanup === void 0 ? void 0 : pragmaticCleanup();
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Reset rather than freeze. Returning `currentState` here would keep `decorations`,
|
|
302
|
+
* `activeNode` and the multi-select positions from before the latch, while skipping the
|
|
303
|
+
* `tr.mapping` remapping below — so they would silently drift out of sync with the document on
|
|
304
|
+
* every subsequent edit. Nothing renders them in limited mode (`props.decorations` returns
|
|
305
|
+
* early), but stale positions are a latent source of incorrect offsets for anything that reads
|
|
306
|
+
* them, so the safe state is empty.
|
|
307
|
+
*/
|
|
308
|
+
return {
|
|
309
|
+
...currentState,
|
|
310
|
+
activeNode: undefined,
|
|
311
|
+
decorations: DecorationSet.empty,
|
|
312
|
+
multiSelectDnD: undefined
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
} else {
|
|
316
|
+
var _api$limitedMode2, _api$limitedMode2$sha, _api$limitedMode2$sha2;
|
|
317
|
+
const hasDocumentSizeBreachedThreshold = api === null || api === void 0 ? void 0 : (_api$limitedMode2 = api.limitedMode) === null || _api$limitedMode2 === void 0 ? void 0 : (_api$limitedMode2$sha = _api$limitedMode2.sharedState.currentState()) === null || _api$limitedMode2$sha === void 0 ? void 0 : (_api$limitedMode2$sha2 = _api$limitedMode2$sha.limitedModePluginKey.getState(newState)) === null || _api$limitedMode2$sha2 === void 0 ? void 0 : _api$limitedMode2$sha2.documentSizeBreachesThreshold;
|
|
318
|
+
if (hasDocumentSizeBreachedThreshold) {
|
|
319
|
+
var _getDocument$querySel3, _getDocument3;
|
|
320
|
+
/**
|
|
321
|
+
* INFO: This if statement is a duplicate of the logic in destroy(). When the threshold is breached and we enter limited mode, we want to trigger the cleanup logic in destroy().
|
|
322
|
+
*/
|
|
323
|
+
const editorContentArea = (_getDocument$querySel3 = (_getDocument3 = getDocument()) === null || _getDocument3 === void 0 ? void 0 : _getDocument3.querySelector('.fabric-editor-popup-scroll-parent')) !== null && _getDocument$querySel3 !== void 0 ? _getDocument$querySel3 : null;
|
|
324
|
+
if (editorContentArea && resizeObserverWidth) {
|
|
325
|
+
resizeObserverWidth.unobserve(editorContentArea);
|
|
326
|
+
}
|
|
327
|
+
pragmaticCleanup === null || pragmaticCleanup === void 0 ? void 0 : pragmaticCleanup();
|
|
328
|
+
return currentState;
|
|
276
329
|
}
|
|
277
|
-
pragmaticCleanup === null || pragmaticCleanup === void 0 ? void 0 : pragmaticCleanup();
|
|
278
|
-
return currentState;
|
|
279
330
|
}
|
|
280
331
|
|
|
281
332
|
// When steps exist, remap existing decorations, activeNode and multi select positions
|
|
@@ -810,6 +861,10 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
810
861
|
}
|
|
811
862
|
let resizeObserverWidth;
|
|
812
863
|
let pragmaticCleanup = null;
|
|
864
|
+
// Limited mode is a one-way latch, so its teardown must only run on the transition.
|
|
865
|
+
const limitedModeTeardown = {
|
|
866
|
+
done: false
|
|
867
|
+
};
|
|
813
868
|
return new SafePlugin({
|
|
814
869
|
key,
|
|
815
870
|
state: {
|
|
@@ -819,12 +874,12 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
819
874
|
surfaceNodePositions: resolvedSurfaces.length > 0 ? getSurfaceNodePositions(editorState, resolvedSurfaces) : []
|
|
820
875
|
};
|
|
821
876
|
},
|
|
822
|
-
apply: (tr, currentState, _, newState) => apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, resolvedSurfaces)
|
|
877
|
+
apply: (tr, currentState, _, newState) => apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, resolvedSurfaces, limitedModeTeardown)
|
|
823
878
|
},
|
|
824
879
|
props: {
|
|
825
880
|
decorations: state => {
|
|
826
|
-
var _api$
|
|
827
|
-
if (api !== null && api !== void 0 && (_api$
|
|
881
|
+
var _api$limitedMode3, _api$limitedMode3$sha, _api$editorDisabled, _api$editorDisabled$s, _key$getState2, _api$editorViewMode3, _api$editorViewMode3$;
|
|
882
|
+
if (api !== null && api !== void 0 && (_api$limitedMode3 = api.limitedMode) !== null && _api$limitedMode3 !== void 0 && (_api$limitedMode3$sha = _api$limitedMode3.sharedState.currentState()) !== null && _api$limitedMode3$sha !== void 0 && _api$limitedMode3$sha.enabled) {
|
|
828
883
|
return;
|
|
829
884
|
}
|
|
830
885
|
const isDisabled = api === null || api === void 0 ? void 0 : (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 ? void 0 : (_api$editorDisabled$s = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled$s === void 0 ? void 0 : _api$editorDisabled$s.editorDisabled;
|
|
@@ -900,8 +955,8 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
900
955
|
return false;
|
|
901
956
|
},
|
|
902
957
|
dragenter(view, event) {
|
|
903
|
-
var _api$
|
|
904
|
-
if (api !== null && api !== void 0 && (_api$
|
|
958
|
+
var _api$limitedMode4, _api$limitedMode4$sha, _key$getState3;
|
|
959
|
+
if (api !== null && api !== void 0 && (_api$limitedMode4 = api.limitedMode) !== null && _api$limitedMode4 !== void 0 && (_api$limitedMode4$sha = _api$limitedMode4.sharedState.currentState()) !== null && _api$limitedMode4$sha !== void 0 && _api$limitedMode4$sha.enabled) {
|
|
905
960
|
return;
|
|
906
961
|
}
|
|
907
962
|
|
|
@@ -941,8 +996,8 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
941
996
|
}
|
|
942
997
|
},
|
|
943
998
|
dragstart(view) {
|
|
944
|
-
var _api$
|
|
945
|
-
if (api !== null && api !== void 0 && (_api$
|
|
999
|
+
var _api$limitedMode5, _api$limitedMode5$sha, _anchorRectCache2;
|
|
1000
|
+
if (api !== null && api !== void 0 && (_api$limitedMode5 = api.limitedMode) !== null && _api$limitedMode5 !== void 0 && (_api$limitedMode5$sha = _api$limitedMode5.sharedState.currentState()) !== null && _api$limitedMode5$sha !== void 0 && _api$limitedMode5$sha.enabled) {
|
|
946
1001
|
return;
|
|
947
1002
|
}
|
|
948
1003
|
startMeasure(EDITOR_BLOCKS_DRAG_INIT);
|
|
@@ -960,8 +1015,8 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
960
1015
|
}));
|
|
961
1016
|
},
|
|
962
1017
|
dragend(view) {
|
|
963
|
-
var _api$
|
|
964
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1018
|
+
var _api$limitedMode6, _api$limitedMode6$sha, _key$getState4;
|
|
1019
|
+
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) {
|
|
965
1020
|
return;
|
|
966
1021
|
}
|
|
967
1022
|
const {
|
|
@@ -984,8 +1039,8 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
984
1039
|
}
|
|
985
1040
|
},
|
|
986
1041
|
mouseover: (view, event) => {
|
|
987
|
-
var _api$
|
|
988
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1042
|
+
var _api$limitedMode7, _api$limitedMode7$sha, _getNodeIdProvider;
|
|
1043
|
+
if (api !== null && api !== void 0 && (_api$limitedMode7 = api.limitedMode) !== null && _api$limitedMode7 !== void 0 && (_api$limitedMode7$sha = _api$limitedMode7.sharedState.currentState()) !== null && _api$limitedMode7$sha !== void 0 && _api$limitedMode7$sha.enabled) {
|
|
989
1044
|
return;
|
|
990
1045
|
}
|
|
991
1046
|
|
|
@@ -999,15 +1054,15 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
999
1054
|
return false;
|
|
1000
1055
|
},
|
|
1001
1056
|
mousedown: (view, event) => {
|
|
1002
|
-
var _api$
|
|
1003
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1057
|
+
var _api$limitedMode8, _api$limitedMode8$sha;
|
|
1058
|
+
if (api !== null && api !== void 0 && (_api$limitedMode8 = api.limitedMode) !== null && _api$limitedMode8 !== void 0 && (_api$limitedMode8$sha = _api$limitedMode8.sharedState.currentState()) !== null && _api$limitedMode8$sha !== void 0 && _api$limitedMode8$sha.enabled) {
|
|
1004
1059
|
return;
|
|
1005
1060
|
}
|
|
1006
1061
|
return editorExperiment('platform_editor_controls', 'variant1') ? handleMouseDown(api)(view, event) : undefined;
|
|
1007
1062
|
},
|
|
1008
1063
|
keydown(view, event) {
|
|
1009
|
-
var _api$
|
|
1010
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1064
|
+
var _api$limitedMode9, _api$limitedMode9$sha;
|
|
1065
|
+
if (api !== null && api !== void 0 && (_api$limitedMode9 = api.limitedMode) !== null && _api$limitedMode9 !== void 0 && (_api$limitedMode9$sha = _api$limitedMode9.sharedState.currentState()) !== null && _api$limitedMode9$sha !== void 0 && _api$limitedMode9$sha.enabled) {
|
|
1011
1066
|
return;
|
|
1012
1067
|
}
|
|
1013
1068
|
if (event.shiftKey && event.ctrlKey) {
|
|
@@ -1039,8 +1094,8 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
1039
1094
|
return false;
|
|
1040
1095
|
},
|
|
1041
1096
|
keyup(view, event) {
|
|
1042
|
-
var _api$
|
|
1043
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1097
|
+
var _api$limitedMode0, _api$limitedMode0$sha;
|
|
1098
|
+
if (api !== null && api !== void 0 && (_api$limitedMode0 = api.limitedMode) !== null && _api$limitedMode0 !== void 0 && (_api$limitedMode0$sha = _api$limitedMode0.sharedState.currentState()) !== null && _api$limitedMode0$sha !== void 0 && _api$limitedMode0$sha.enabled) {
|
|
1044
1099
|
return;
|
|
1045
1100
|
}
|
|
1046
1101
|
if (!event.repeat && event.key === 'Shift') {
|
|
@@ -1051,8 +1106,8 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI, nodeDecora
|
|
|
1051
1106
|
}
|
|
1052
1107
|
},
|
|
1053
1108
|
blur(view, event) {
|
|
1054
|
-
var _api$
|
|
1055
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1109
|
+
var _api$limitedMode1, _api$limitedMode1$sha;
|
|
1110
|
+
if (api !== null && api !== void 0 && (_api$limitedMode1 = api.limitedMode) !== null && _api$limitedMode1 !== void 0 && (_api$limitedMode1$sha = _api$limitedMode1.sharedState.currentState()) !== null && _api$limitedMode1$sha !== void 0 && _api$limitedMode1$sha.enabled) {
|
|
1056
1111
|
return;
|
|
1057
1112
|
}
|
|
1058
1113
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
@@ -19,6 +19,7 @@ import { isEmptyDocument } from '@atlaskit/editor-common/utils';
|
|
|
19
19
|
import { PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
20
20
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
21
21
|
import { resolveSurface } from '@atlaskit/editor-ui-control-model/surface-renderer';
|
|
22
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
22
23
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
23
24
|
import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
|
|
24
25
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/utils/combine';
|
|
@@ -233,13 +234,14 @@ var getDecorationAtPos = function getDecorationAtPos(state, decorations, pos, to
|
|
|
233
234
|
return nodeDecAtActivePos;
|
|
234
235
|
};
|
|
235
236
|
var _apply = function apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry) {
|
|
236
|
-
var
|
|
237
|
+
var _meta$multiSelectDnD, _api$editorViewMode, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging2, _meta$isDragging3, _meta$toggleMenu, _meta$toggleMenu2, _meta$toggleMenu3, _meta$toggleMenu4, _meta$toggleMenu5, _meta$toggleMenu6, _meta$toggleMenu7, _meta$toggleMenu8, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
|
|
237
238
|
var rightSideControlsEnabled = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
|
|
238
239
|
var quickInsertButtonEnabled = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : true;
|
|
239
240
|
var anchorRectCache = arguments.length > 10 ? arguments[10] : undefined;
|
|
240
241
|
var resizeObserverWidth = arguments.length > 11 ? arguments[11] : undefined;
|
|
241
242
|
var pragmaticCleanup = arguments.length > 12 ? arguments[12] : undefined;
|
|
242
243
|
var resolvedSurfaces = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : [];
|
|
244
|
+
var limitedModeTeardown = arguments.length > 14 ? arguments[14] : undefined;
|
|
243
245
|
var activeNode = currentState.activeNode,
|
|
244
246
|
decorations = currentState.decorations,
|
|
245
247
|
isResizerResizing = currentState.isResizerResizing,
|
|
@@ -266,18 +268,67 @@ var _apply = function apply(api, formatMessage, tr, currentState, newState, flag
|
|
|
266
268
|
isAllText = _getTrMetadata.isAllText,
|
|
267
269
|
isReplacedWithSameSize = _getTrMetadata.isReplacedWithSameSize;
|
|
268
270
|
var meta = tr.getMeta(key);
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
271
|
+
if (isExperimentEnabled('platform_editor_dynamic_limited_mode')) {
|
|
272
|
+
var _api$limitedMode;
|
|
273
|
+
// Both arms read `newState` — the state this transaction is producing. Deriving `enabled` from
|
|
274
|
+
// `sharedState.currentState()` instead would resolve against `view.state`, which during `apply` is
|
|
275
|
+
// still the *previous* state, delaying the limited-mode teardown by one transaction.
|
|
276
|
+
//
|
|
277
|
+
// Limited mode can now also be latched at runtime by the performance detector, so the treatment
|
|
278
|
+
// arm considers both reasons rather than just the document one. Identical in the control arm, where
|
|
279
|
+
// the runtime latch can never be set.
|
|
280
|
+
var limitedModeState = api === null || api === void 0 || (_api$limitedMode = api.limitedMode) === null || _api$limitedMode === void 0 || (_api$limitedMode = _api$limitedMode.sharedState.currentState()) === null || _api$limitedMode === void 0 ? void 0 : _api$limitedMode.limitedModePluginKey.getState(newState);
|
|
281
|
+
if (!!(limitedModeState !== null && limitedModeState !== void 0 && limitedModeState.enabled)) {
|
|
282
|
+
/**
|
|
283
|
+
* INFO: This is a duplicate of the logic in destroy(). When we enter limited mode we want to
|
|
284
|
+
* trigger the cleanup logic in destroy().
|
|
285
|
+
*/
|
|
286
|
+
if (!limitedModeTeardown || !limitedModeTeardown.done) {
|
|
287
|
+
var _getDocument$querySel2, _getDocument2;
|
|
288
|
+
/**
|
|
289
|
+
* Edge-triggered under the experiment: limited mode is a latch, so without this guard the
|
|
290
|
+
* teardown re-runs on every subsequent transaction for the rest of the session — and would
|
|
291
|
+
* re-register the pragmatic monitors if `pragmaticCleanup` ever became re-entrant.
|
|
292
|
+
*/
|
|
293
|
+
if (limitedModeTeardown) {
|
|
294
|
+
limitedModeTeardown.done = true;
|
|
295
|
+
}
|
|
296
|
+
var editorContentArea = (_getDocument$querySel2 = (_getDocument2 = getDocument()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.querySelector('.fabric-editor-popup-scroll-parent')) !== null && _getDocument$querySel2 !== void 0 ? _getDocument$querySel2 : null;
|
|
297
|
+
if (editorContentArea && resizeObserverWidth) {
|
|
298
|
+
resizeObserverWidth.unobserve(editorContentArea);
|
|
299
|
+
}
|
|
300
|
+
pragmaticCleanup === null || pragmaticCleanup === void 0 || pragmaticCleanup();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Reset rather than freeze. Returning `currentState` here would keep `decorations`,
|
|
305
|
+
* `activeNode` and the multi-select positions from before the latch, while skipping the
|
|
306
|
+
* `tr.mapping` remapping below — so they would silently drift out of sync with the document on
|
|
307
|
+
* every subsequent edit. Nothing renders them in limited mode (`props.decorations` returns
|
|
308
|
+
* early), but stale positions are a latent source of incorrect offsets for anything that reads
|
|
309
|
+
* them, so the safe state is empty.
|
|
310
|
+
*/
|
|
311
|
+
return _objectSpread(_objectSpread({}, currentState), {}, {
|
|
312
|
+
activeNode: undefined,
|
|
313
|
+
decorations: DecorationSet.empty,
|
|
314
|
+
multiSelectDnD: undefined
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
} else {
|
|
318
|
+
var _api$limitedMode2;
|
|
319
|
+
var hasDocumentSizeBreachedThreshold = api === null || api === void 0 || (_api$limitedMode2 = api.limitedMode) === null || _api$limitedMode2 === void 0 || (_api$limitedMode2 = _api$limitedMode2.sharedState.currentState()) === null || _api$limitedMode2 === void 0 || (_api$limitedMode2 = _api$limitedMode2.limitedModePluginKey.getState(newState)) === null || _api$limitedMode2 === void 0 ? void 0 : _api$limitedMode2.documentSizeBreachesThreshold;
|
|
320
|
+
if (hasDocumentSizeBreachedThreshold) {
|
|
321
|
+
var _getDocument$querySel3, _getDocument3;
|
|
322
|
+
/**
|
|
323
|
+
* INFO: This if statement is a duplicate of the logic in destroy(). When the threshold is breached and we enter limited mode, we want to trigger the cleanup logic in destroy().
|
|
324
|
+
*/
|
|
325
|
+
var _editorContentArea = (_getDocument$querySel3 = (_getDocument3 = getDocument()) === null || _getDocument3 === void 0 ? void 0 : _getDocument3.querySelector('.fabric-editor-popup-scroll-parent')) !== null && _getDocument$querySel3 !== void 0 ? _getDocument$querySel3 : null;
|
|
326
|
+
if (_editorContentArea && resizeObserverWidth) {
|
|
327
|
+
resizeObserverWidth.unobserve(_editorContentArea);
|
|
328
|
+
}
|
|
329
|
+
pragmaticCleanup === null || pragmaticCleanup === void 0 || pragmaticCleanup();
|
|
330
|
+
return currentState;
|
|
278
331
|
}
|
|
279
|
-
pragmaticCleanup === null || pragmaticCleanup === void 0 || pragmaticCleanup();
|
|
280
|
-
return currentState;
|
|
281
332
|
}
|
|
282
333
|
|
|
283
334
|
// When steps exist, remap existing decorations, activeNode and multi select positions
|
|
@@ -906,6 +957,10 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
906
957
|
}
|
|
907
958
|
var resizeObserverWidth;
|
|
908
959
|
var pragmaticCleanup = null;
|
|
960
|
+
// Limited mode is a one-way latch, so its teardown must only run on the transition.
|
|
961
|
+
var limitedModeTeardown = {
|
|
962
|
+
done: false
|
|
963
|
+
};
|
|
909
964
|
return new SafePlugin({
|
|
910
965
|
key: key,
|
|
911
966
|
state: {
|
|
@@ -915,13 +970,13 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
915
970
|
});
|
|
916
971
|
},
|
|
917
972
|
apply: function apply(tr, currentState, _, newState) {
|
|
918
|
-
return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, resolvedSurfaces);
|
|
973
|
+
return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, nodeDecorationRegistry, rightSideControlsEnabled, quickInsertButtonEnabled, anchorRectCache, resizeObserverWidth, pragmaticCleanup, resolvedSurfaces, limitedModeTeardown);
|
|
919
974
|
}
|
|
920
975
|
},
|
|
921
976
|
props: {
|
|
922
977
|
decorations: function decorations(state) {
|
|
923
|
-
var _api$
|
|
924
|
-
if (api !== null && api !== void 0 && (_api$
|
|
978
|
+
var _api$limitedMode3, _api$editorDisabled, _key$getState2, _api$editorViewMode3;
|
|
979
|
+
if (api !== null && api !== void 0 && (_api$limitedMode3 = api.limitedMode) !== null && _api$limitedMode3 !== void 0 && (_api$limitedMode3 = _api$limitedMode3.sharedState.currentState()) !== null && _api$limitedMode3 !== void 0 && _api$limitedMode3.enabled) {
|
|
925
980
|
return;
|
|
926
981
|
}
|
|
927
982
|
var isDisabled = api === null || api === void 0 || (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 || (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled === void 0 ? void 0 : _api$editorDisabled.editorDisabled;
|
|
@@ -994,8 +1049,8 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
994
1049
|
return false;
|
|
995
1050
|
},
|
|
996
1051
|
dragenter: function dragenter(view, event) {
|
|
997
|
-
var _api$
|
|
998
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1052
|
+
var _api$limitedMode4, _key$getState3;
|
|
1053
|
+
if (api !== null && api !== void 0 && (_api$limitedMode4 = api.limitedMode) !== null && _api$limitedMode4 !== void 0 && (_api$limitedMode4 = _api$limitedMode4.sharedState.currentState()) !== null && _api$limitedMode4 !== void 0 && _api$limitedMode4.enabled) {
|
|
999
1054
|
return;
|
|
1000
1055
|
}
|
|
1001
1056
|
|
|
@@ -1035,8 +1090,8 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
1035
1090
|
}
|
|
1036
1091
|
},
|
|
1037
1092
|
dragstart: function dragstart(view) {
|
|
1038
|
-
var _api$
|
|
1039
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1093
|
+
var _api$limitedMode5, _anchorRectCache2;
|
|
1094
|
+
if (api !== null && api !== void 0 && (_api$limitedMode5 = api.limitedMode) !== null && _api$limitedMode5 !== void 0 && (_api$limitedMode5 = _api$limitedMode5.sharedState.currentState()) !== null && _api$limitedMode5 !== void 0 && _api$limitedMode5.enabled) {
|
|
1040
1095
|
return;
|
|
1041
1096
|
}
|
|
1042
1097
|
startMeasure(EDITOR_BLOCKS_DRAG_INIT);
|
|
@@ -1053,8 +1108,8 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
1053
1108
|
})));
|
|
1054
1109
|
},
|
|
1055
1110
|
dragend: function dragend(view) {
|
|
1056
|
-
var _api$
|
|
1057
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1111
|
+
var _api$limitedMode6, _key$getState4;
|
|
1112
|
+
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) {
|
|
1058
1113
|
return;
|
|
1059
1114
|
}
|
|
1060
1115
|
var state = view.state,
|
|
@@ -1074,8 +1129,8 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
1074
1129
|
}
|
|
1075
1130
|
},
|
|
1076
1131
|
mouseover: function mouseover(view, event) {
|
|
1077
|
-
var _api$
|
|
1078
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1132
|
+
var _api$limitedMode7, _getNodeIdProvider;
|
|
1133
|
+
if (api !== null && api !== void 0 && (_api$limitedMode7 = api.limitedMode) !== null && _api$limitedMode7 !== void 0 && (_api$limitedMode7 = _api$limitedMode7.sharedState.currentState()) !== null && _api$limitedMode7 !== void 0 && _api$limitedMode7.enabled) {
|
|
1079
1134
|
return;
|
|
1080
1135
|
}
|
|
1081
1136
|
|
|
@@ -1089,15 +1144,15 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
1089
1144
|
return false;
|
|
1090
1145
|
},
|
|
1091
1146
|
mousedown: function mousedown(view, event) {
|
|
1092
|
-
var _api$
|
|
1093
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1147
|
+
var _api$limitedMode8;
|
|
1148
|
+
if (api !== null && api !== void 0 && (_api$limitedMode8 = api.limitedMode) !== null && _api$limitedMode8 !== void 0 && (_api$limitedMode8 = _api$limitedMode8.sharedState.currentState()) !== null && _api$limitedMode8 !== void 0 && _api$limitedMode8.enabled) {
|
|
1094
1149
|
return;
|
|
1095
1150
|
}
|
|
1096
1151
|
return editorExperiment('platform_editor_controls', 'variant1') ? handleMouseDown(api)(view, event) : undefined;
|
|
1097
1152
|
},
|
|
1098
1153
|
keydown: function keydown(view, event) {
|
|
1099
|
-
var _api$
|
|
1100
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1154
|
+
var _api$limitedMode9;
|
|
1155
|
+
if (api !== null && api !== void 0 && (_api$limitedMode9 = api.limitedMode) !== null && _api$limitedMode9 !== void 0 && (_api$limitedMode9 = _api$limitedMode9.sharedState.currentState()) !== null && _api$limitedMode9 !== void 0 && _api$limitedMode9.enabled) {
|
|
1101
1156
|
return;
|
|
1102
1157
|
}
|
|
1103
1158
|
if (event.shiftKey && event.ctrlKey) {
|
|
@@ -1128,8 +1183,8 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
1128
1183
|
return false;
|
|
1129
1184
|
},
|
|
1130
1185
|
keyup: function keyup(view, event) {
|
|
1131
|
-
var _api$
|
|
1132
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1186
|
+
var _api$limitedMode0;
|
|
1187
|
+
if (api !== null && api !== void 0 && (_api$limitedMode0 = api.limitedMode) !== null && _api$limitedMode0 !== void 0 && (_api$limitedMode0 = _api$limitedMode0.sharedState.currentState()) !== null && _api$limitedMode0 !== void 0 && _api$limitedMode0.enabled) {
|
|
1133
1188
|
return;
|
|
1134
1189
|
}
|
|
1135
1190
|
if (!event.repeat && event.key === 'Shift') {
|
|
@@ -1139,8 +1194,8 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
1139
1194
|
}
|
|
1140
1195
|
},
|
|
1141
1196
|
blur: function blur(view, event) {
|
|
1142
|
-
var _api$
|
|
1143
|
-
if (api !== null && api !== void 0 && (_api$
|
|
1197
|
+
var _api$limitedMode1;
|
|
1198
|
+
if (api !== null && api !== void 0 && (_api$limitedMode1 = api.limitedMode) !== null && _api$limitedMode1 !== void 0 && (_api$limitedMode1 = _api$limitedMode1.sharedState.currentState()) !== null && _api$limitedMode1 !== void 0 && _api$limitedMode1.enabled) {
|
|
1144
1199
|
return;
|
|
1145
1200
|
}
|
|
1146
1201
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
@@ -1187,13 +1242,13 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
|
|
|
1187
1242
|
// Registry surfaces have their own ResizeObservers and absolute placement.
|
|
1188
1243
|
// Width metadata only drives legacy widget recreation.
|
|
1189
1244
|
if (legacyDragHandleEnabled && !isResizerResizing) {
|
|
1190
|
-
var
|
|
1245
|
+
var _editorContentArea2 = entries[0].target;
|
|
1191
1246
|
// Ignored via go/ees005
|
|
1192
1247
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1193
|
-
var editorWidthRight =
|
|
1248
|
+
var editorWidthRight = _editorContentArea2.getBoundingClientRect().right;
|
|
1194
1249
|
// Ignored via go/ees005
|
|
1195
1250
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1196
|
-
var editorWidthLeft =
|
|
1251
|
+
var editorWidthLeft = _editorContentArea2.getBoundingClientRect().left;
|
|
1197
1252
|
transaction.setMeta(key, _objectSpread(_objectSpread({}, transaction.getMeta(key)), {}, {
|
|
1198
1253
|
editorWidthLeft: editorWidthLeft,
|
|
1199
1254
|
editorWidthRight: editorWidthRight
|
|
@@ -19,7 +19,9 @@ export interface FlagType {
|
|
|
19
19
|
toolbarFlagsEnabled: boolean;
|
|
20
20
|
}
|
|
21
21
|
export declare const getDecorations: (state: EditorState) => DecorationSet | undefined;
|
|
22
|
-
export declare const apply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, nodeDecorationRegistry: NodeDecorationFactory[], rightSideControlsEnabled?: boolean, quickInsertButtonEnabled?: boolean, anchorRectCache?: AnchorRectCache, resizeObserverWidth?: ResizeObserver, pragmaticCleanup?: (() => void) | null, resolvedSurfaces?: readonly ResolvedSurface[]
|
|
22
|
+
export declare const apply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, nodeDecorationRegistry: NodeDecorationFactory[], rightSideControlsEnabled?: boolean, quickInsertButtonEnabled?: boolean, anchorRectCache?: AnchorRectCache, resizeObserverWidth?: ResizeObserver, pragmaticCleanup?: (() => void) | null, resolvedSurfaces?: readonly ResolvedSurface[], limitedModeTeardown?: {
|
|
23
|
+
done: boolean;
|
|
24
|
+
}) => PluginState | {
|
|
23
25
|
activeDropTargetNode: ActiveDropTargetNode | undefined;
|
|
24
26
|
activeNode: any;
|
|
25
27
|
blockMenuOptions: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.1.0",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@atlaskit/editor-plugin-editor-viewmode": "^19.0.0",
|
|
31
31
|
"@atlaskit/editor-plugin-feature-flags": "^16.0.0",
|
|
32
32
|
"@atlaskit/editor-plugin-interaction": "^28.0.0",
|
|
33
|
-
"@atlaskit/editor-plugin-limited-mode": "^14.
|
|
33
|
+
"@atlaskit/editor-plugin-limited-mode": "^14.1.0",
|
|
34
34
|
"@atlaskit/editor-plugin-metrics": "^18.0.0",
|
|
35
35
|
"@atlaskit/editor-plugin-quick-insert": "^17.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-selection": "^17.0.0",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"uuid": "^11.1.1"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"@atlaskit/editor-common": "^121.
|
|
70
|
+
"@atlaskit/editor-common": "^121.1.0",
|
|
71
71
|
"react": "^18.2.0 || ^19.2.0",
|
|
72
72
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
73
73
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|