@atlaskit/editor-plugin-block-controls 18.0.0 → 18.2.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 +51 -0
- package/dist/cjs/editor-commands/move-node.js +11 -0
- package/dist/cjs/editor-commands/move-to-layout.js +8 -0
- package/dist/cjs/pm-plugins/main.js +89 -34
- package/dist/cjs/pm-plugins/utils/collapsed-heading.js +69 -0
- package/dist/cjs/ui/block-controls-left-surface.js +5 -4
- package/dist/cjs/ui/block-controls-surface-drag-handle.js +10 -0
- package/dist/cjs/ui/use-block-controls-surface-drag-source.js +11 -0
- package/dist/es2019/editor-commands/move-node.js +11 -0
- package/dist/es2019/editor-commands/move-to-layout.js +8 -0
- package/dist/es2019/pm-plugins/main.js +87 -32
- package/dist/es2019/pm-plugins/utils/collapsed-heading.js +65 -0
- package/dist/es2019/ui/block-controls-left-surface.js +5 -4
- package/dist/es2019/ui/block-controls-surface-drag-handle.js +10 -0
- package/dist/es2019/ui/use-block-controls-surface-drag-source.js +11 -0
- package/dist/esm/editor-commands/move-node.js +11 -0
- package/dist/esm/editor-commands/move-to-layout.js +8 -0
- package/dist/esm/pm-plugins/main.js +89 -34
- package/dist/esm/pm-plugins/utils/collapsed-heading.js +63 -0
- package/dist/esm/ui/block-controls-left-surface.js +5 -4
- package/dist/esm/ui/block-controls-surface-drag-handle.js +10 -0
- package/dist/esm/ui/use-block-controls-surface-drag-source.js +11 -0
- package/dist/types/blockControlsPluginType.d.ts +2 -0
- package/dist/types/pm-plugins/main.d.ts +3 -1
- package/dist/types/pm-plugins/utils/collapsed-heading.d.ts +27 -0
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 18.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`00fc2f11bb42e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/00fc2f11bb42e) -
|
|
8
|
+
[ux] Support dragging and changing the format of complete collapsed heading sections under
|
|
9
|
+
`platform_editor_collapsible_headings`.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`834dc6bee730b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/834dc6bee730b) -
|
|
14
|
+
[ux] Keep collapsed heading controls visible under `platform_editor_collapsible_headings` when
|
|
15
|
+
another editor node is active.
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
18
|
+
## 18.1.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- [`aec3fcfe13ff9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/aec3fcfe13ff9) -
|
|
23
|
+
EDITOR-8303 Add runtime input-latency trigger for limited mode behind
|
|
24
|
+
platform_editor_dynamic_limited_mode. Limited mode can now latch mid-session when sustained slow
|
|
25
|
+
input or repeated browser freezes indicate the device is struggling, in addition to the existing
|
|
26
|
+
document-size decision. The latch is one-way. Nothing is constructed when the experiment is off.
|
|
27
|
+
|
|
28
|
+
How much evidence is needed is a single tunable, `requiredConfirmations`: that many qualifying
|
|
29
|
+
windows, each separated from the last by `confirmationGapMs`. The hardware no longer feeds into
|
|
30
|
+
the decision — `navigator.hardwareConcurrency` and `navigator.deviceMemory` are reported with the
|
|
31
|
+
`limitedModeLatched` event instead, so which devices latch can be answered from the data rather
|
|
32
|
+
than assumed up front.
|
|
33
|
+
|
|
34
|
+
`LimitedModePluginState` gains a derived `enabled` flag, which is now the single thing consumers
|
|
35
|
+
should branch on — the individual reasons (`documentSizeBreachesThreshold`, `latchPolicyBreached`)
|
|
36
|
+
no longer need to be combined at each call site, so a future reason needs no change outside this
|
|
37
|
+
plugin. `sharedState.enabled` reads from it.
|
|
38
|
+
|
|
39
|
+
Under the experiment the document decision is also evaluated on load and on document replacement
|
|
40
|
+
only, rather than on every transaction that changes the document. That check walks the whole
|
|
41
|
+
document, so it was a full-document scan per keystroke on exactly the pages least able to afford
|
|
42
|
+
one. The trade-off is that a document editing its way past the thresholds is not re-judged until
|
|
43
|
+
it next loads.
|
|
44
|
+
|
|
45
|
+
Consumers updated to react to a mid-session change: table sticky headers now subscribe instead of
|
|
46
|
+
reading once at construction, block-controls resets rather than freezes its state on entry, and
|
|
47
|
+
the expand, media and table nodeviews read the derived flag so they no longer miss a runtime
|
|
48
|
+
latch.
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- Updated dependencies
|
|
53
|
+
|
|
3
54
|
## 18.0.0
|
|
4
55
|
|
|
5
56
|
### Patch Changes
|
|
@@ -25,6 +25,7 @@ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
|
25
25
|
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
26
26
|
var _main = require("../pm-plugins/main");
|
|
27
27
|
var _analytics2 = require("../pm-plugins/utils/analytics");
|
|
28
|
+
var _collapsedHeading = require("../pm-plugins/utils/collapsed-heading");
|
|
28
29
|
var _getNestedNodePosition = require("../pm-plugins/utils/getNestedNodePosition");
|
|
29
30
|
var _getSelection = require("../pm-plugins/utils/getSelection");
|
|
30
31
|
var _removeFromSource = require("../pm-plugins/utils/remove-from-source");
|
|
@@ -369,6 +370,7 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
369
370
|
if (!handleNode) {
|
|
370
371
|
return tr;
|
|
371
372
|
}
|
|
373
|
+
var wasCollapsedHeading = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_collapsible_headings') && (0, _collapsedHeading.isCollapsedHeading)(api, start);
|
|
372
374
|
var sliceFrom = start;
|
|
373
375
|
var sliceTo;
|
|
374
376
|
var sourceNodeTypes, hasSelectedMultipleNodes;
|
|
@@ -486,6 +488,15 @@ var moveNode = exports.moveNode = function moveNode(api) {
|
|
|
486
488
|
api === null || api === void 0 || api.core.actions.focus();
|
|
487
489
|
}
|
|
488
490
|
var $mappedTo = tr.doc.resolve(mappedTo);
|
|
491
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_collapsible_headings')) {
|
|
492
|
+
(0, _collapsedHeading.updateCollapsedHeadingAfterMove)({
|
|
493
|
+
api: api,
|
|
494
|
+
destinationPos: mappedTo,
|
|
495
|
+
isNested: $mappedTo.parent.type.name !== 'doc',
|
|
496
|
+
tr: tr,
|
|
497
|
+
wasCollapsed: wasCollapsedHeading
|
|
498
|
+
});
|
|
499
|
+
}
|
|
489
500
|
var expandAncestor = (0, _utils2.findParentNodeOfTypeClosestToPos)($to, [expand, nestedExpand]);
|
|
490
501
|
if (expandAncestor) {
|
|
491
502
|
var wasExpandExpanded = _expand.expandedState.get(expandAncestor.node);
|
|
@@ -8,10 +8,12 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
8
8
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
9
9
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
11
12
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
12
13
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
13
14
|
var _analytics2 = require("../pm-plugins/utils/analytics");
|
|
14
15
|
var _checkFragment = require("../pm-plugins/utils/check-fragment");
|
|
16
|
+
var _collapsedHeading = require("../pm-plugins/utils/collapsed-heading");
|
|
15
17
|
var _consts = require("../pm-plugins/utils/consts");
|
|
16
18
|
var _removeFromSource = require("../pm-plugins/utils/remove-from-source");
|
|
17
19
|
var _selection = require("../pm-plugins/utils/selection");
|
|
@@ -243,6 +245,12 @@ var moveToLayout = exports.moveToLayout = function moveToLayout(api) {
|
|
|
243
245
|
if (!canMove) {
|
|
244
246
|
return tr;
|
|
245
247
|
}
|
|
248
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_collapsible_headings') && (0, _collapsedHeading.isCollapsedHeading)(api, from)) {
|
|
249
|
+
var _api$blockCollapse;
|
|
250
|
+
(_api$blockCollapse = api.blockCollapse) === null || _api$blockCollapse === void 0 || _api$blockCollapse.commands.expandHeading(from)({
|
|
251
|
+
tr: tr
|
|
252
|
+
});
|
|
253
|
+
}
|
|
246
254
|
var toNode = canMove.toNode,
|
|
247
255
|
$to = canMove.$to,
|
|
248
256
|
sourceContent = canMove.sourceContent,
|
|
@@ -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
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.updateCollapsedHeadingAfterMove = exports.prepareCollapsedHeadingSelection = exports.isCollapsedHeading = exports.getCollapsedHeadingRange = void 0;
|
|
7
|
+
/** Document range containing a heading and all content in its section. */
|
|
8
|
+
|
|
9
|
+
/** Returns the full section range when the heading at this position is collapsed. */
|
|
10
|
+
var getCollapsedHeadingRange = exports.getCollapsedHeadingRange = function getCollapsedHeadingRange(api, headingPos) {
|
|
11
|
+
var _api$blockCollapse;
|
|
12
|
+
var sectionEnd = api === null || api === void 0 || (_api$blockCollapse = api.blockCollapse) === null || _api$blockCollapse === void 0 || (_api$blockCollapse = _api$blockCollapse.sharedState.currentState()) === null || _api$blockCollapse === void 0 ? void 0 : _api$blockCollapse.collapsedSectionEnds.get(headingPos);
|
|
13
|
+
return sectionEnd === undefined ? undefined : {
|
|
14
|
+
from: headingPos,
|
|
15
|
+
to: sectionEnd
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Returns whether the heading at this position has a collapsed section. */
|
|
20
|
+
var isCollapsedHeading = exports.isCollapsedHeading = function isCollapsedHeading(api, headingPos) {
|
|
21
|
+
var _api$blockCollapse$sh, _api$blockCollapse2;
|
|
22
|
+
return (_api$blockCollapse$sh = api === null || api === void 0 || (_api$blockCollapse2 = api.blockCollapse) === null || _api$blockCollapse2 === void 0 || (_api$blockCollapse2 = _api$blockCollapse2.sharedState.currentState()) === null || _api$blockCollapse2 === void 0 ? void 0 : _api$blockCollapse2.collapsedSectionEnds.has(headingPos)) !== null && _api$blockCollapse$sh !== void 0 ? _api$blockCollapse$sh : false;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** Selects a collapsed section for drag or block-menu operations, optionally expanding it. */
|
|
26
|
+
var prepareCollapsedHeadingSelection = exports.prepareCollapsedHeadingSelection = function prepareCollapsedHeadingSelection(_ref) {
|
|
27
|
+
var _api$blockControls;
|
|
28
|
+
var api = _ref.api,
|
|
29
|
+
expand = _ref.expand,
|
|
30
|
+
headingPos = _ref.headingPos,
|
|
31
|
+
tr = _ref.tr;
|
|
32
|
+
var range = getCollapsedHeadingRange(api, headingPos);
|
|
33
|
+
if (!range) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (expand) {
|
|
37
|
+
var _api$blockCollapse3;
|
|
38
|
+
api === null || api === void 0 || (_api$blockCollapse3 = api.blockCollapse) === null || _api$blockCollapse3 === void 0 || _api$blockCollapse3.commands.expandHeading(headingPos)({
|
|
39
|
+
tr: tr
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.setMultiSelectPositions(range.from, range.to)({
|
|
43
|
+
tr: tr
|
|
44
|
+
});
|
|
45
|
+
return true;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Preserves collapse for root moves and expands headings moved into nested containers. */
|
|
49
|
+
var updateCollapsedHeadingAfterMove = exports.updateCollapsedHeadingAfterMove = function updateCollapsedHeadingAfterMove(_ref2) {
|
|
50
|
+
var _api$blockCollapse5;
|
|
51
|
+
var api = _ref2.api,
|
|
52
|
+
destinationPos = _ref2.destinationPos,
|
|
53
|
+
isNested = _ref2.isNested,
|
|
54
|
+
tr = _ref2.tr,
|
|
55
|
+
wasCollapsed = _ref2.wasCollapsed;
|
|
56
|
+
if (!wasCollapsed) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (isNested) {
|
|
60
|
+
var _api$blockCollapse4;
|
|
61
|
+
api === null || api === void 0 || (_api$blockCollapse4 = api.blockCollapse) === null || _api$blockCollapse4 === void 0 || _api$blockCollapse4.commands.expandHeading(destinationPos)({
|
|
62
|
+
tr: tr
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
api === null || api === void 0 || (_api$blockCollapse5 = api.blockCollapse) === null || _api$blockCollapse5 === void 0 || _api$blockCollapse5.commands.collapseHeadingsAtPositions([destinationPos])({
|
|
67
|
+
tr: tr
|
|
68
|
+
});
|
|
69
|
+
};
|
|
@@ -51,22 +51,23 @@ var BlockControlsLeftSurface = exports.BlockControlsLeftSurface = function Block
|
|
|
51
51
|
className: (0, _runtime.ax)(["_kqswstnw _1pbyb4wl"])
|
|
52
52
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
53
53
|
className: (0, _runtime.ax)(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc"])
|
|
54
|
-
},
|
|
54
|
+
}, willRenderHoverOnly && /*#__PURE__*/_react.default.createElement(_visibilityContainer.VisibilityContainer, {
|
|
55
55
|
api: api,
|
|
56
56
|
controlSide: (0, _blockControlsSurfaceContext.getBlockControlsSurfaceControlSide)(surfaceContext.get(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT), (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_controls_reliable_anchor')),
|
|
57
57
|
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
58
58
|
shouldUseDisplayContents: true
|
|
59
59
|
}, /*#__PURE__*/_react.default.createElement(_surfaceRenderer.SurfaceRenderer, {
|
|
60
|
-
components:
|
|
60
|
+
components: hoverOnlyComponents,
|
|
61
61
|
surface: _surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE,
|
|
62
62
|
surfaceContext: surfaceContext
|
|
63
|
-
})),
|
|
63
|
+
})), willRenderPersistent && /*#__PURE__*/_react.default.createElement(_visibilityContainer.VisibilityContainer, {
|
|
64
64
|
api: api,
|
|
65
65
|
controlSide: (0, _blockControlsSurfaceContext.getBlockControlsSurfaceControlSide)(surfaceContext.get(_blockControlUiContext.BLOCK_CONTROL_UI_CONTEXT), (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_controls_reliable_anchor')),
|
|
66
66
|
forceVisibleOnMouseOut: forceVisibleOnMouseOut,
|
|
67
|
+
isPersistent: true,
|
|
67
68
|
shouldUseDisplayContents: true
|
|
68
69
|
}, /*#__PURE__*/_react.default.createElement(_surfaceRenderer.SurfaceRenderer, {
|
|
69
|
-
components:
|
|
70
|
+
components: persistentComponents,
|
|
70
71
|
surface: _surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE,
|
|
71
72
|
surfaceContext: surfaceContext
|
|
72
73
|
}))));
|
|
@@ -21,10 +21,12 @@ var _hooks = require("@atlaskit/editor-common/hooks");
|
|
|
21
21
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
22
22
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
23
23
|
var _dragHandleVertical = _interopRequireDefault(require("@atlaskit/icon/core/drag-handle-vertical"));
|
|
24
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
24
25
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
25
26
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
26
27
|
var _Tooltip = _interopRequireDefault(require("@atlaskit/tooltip/Tooltip"));
|
|
27
28
|
var _pluginKey = require("../pm-plugins/selection-preservation/plugin-key");
|
|
29
|
+
var _collapsedHeading = require("../pm-plugins/utils/collapsed-heading");
|
|
28
30
|
var _expandAndUpdateSelection = require("../pm-plugins/utils/expand-and-update-selection");
|
|
29
31
|
var _getSelection = require("../pm-plugins/utils/getSelection");
|
|
30
32
|
var _blockControlsSurfaceDragHandleUtils = require("./block-controls-surface-drag-handle-utils");
|
|
@@ -221,6 +223,14 @@ var BlockControlsSurfaceDragHandle = exports.BlockControlsSurfaceDragHandle = fu
|
|
|
221
223
|
startPos: startPos,
|
|
222
224
|
tr: tr
|
|
223
225
|
});
|
|
226
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_collapsible_headings')) {
|
|
227
|
+
(0, _collapsedHeading.prepareCollapsedHeadingSelection)({
|
|
228
|
+
api: api,
|
|
229
|
+
expand: true,
|
|
230
|
+
headingPos: startPos,
|
|
231
|
+
tr: tr
|
|
232
|
+
});
|
|
233
|
+
}
|
|
224
234
|
api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.startPreservingSelection()({
|
|
225
235
|
tr: tr
|
|
226
236
|
});
|
|
@@ -8,10 +8,12 @@ var _react = require("react");
|
|
|
8
8
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
9
9
|
var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
|
|
10
10
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
11
12
|
var _elementAdapter = require("@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter");
|
|
12
13
|
var _setCustomNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/utils/set-custom-native-drag-preview");
|
|
13
14
|
var _activeAnchorTracker = require("../pm-plugins/utils/active-anchor-tracker");
|
|
14
15
|
var _analytics2 = require("../pm-plugins/utils/analytics");
|
|
16
|
+
var _collapsedHeading = require("../pm-plugins/utils/collapsed-heading");
|
|
15
17
|
var _getSelection = require("../pm-plugins/utils/getSelection");
|
|
16
18
|
var _dragPreview = require("./drag-preview");
|
|
17
19
|
var _blockControlsSurfaceDragHandleUtils = require("./block-controls-surface-drag-handle-utils");
|
|
@@ -50,6 +52,15 @@ var useBlockControlsSurfaceDragSource = exports.useBlockControlsSurfaceDragSourc
|
|
|
50
52
|
if (typeof handlePos !== 'number') {
|
|
51
53
|
return tr;
|
|
52
54
|
}
|
|
55
|
+
if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_collapsible_headings') && (0, _collapsedHeading.isCollapsedHeading)(api, handlePos)) {
|
|
56
|
+
(0, _collapsedHeading.prepareCollapsedHeadingSelection)({
|
|
57
|
+
api: api,
|
|
58
|
+
expand: false,
|
|
59
|
+
headingPos: handlePos,
|
|
60
|
+
tr: tr
|
|
61
|
+
});
|
|
62
|
+
return tr;
|
|
63
|
+
}
|
|
53
64
|
if (!tr.selection.empty && (0, _getSelection.isHandleCorrelatedToSelection)(view.state, tr.selection, handlePos)) {
|
|
54
65
|
var _api$blockControls;
|
|
55
66
|
api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.setMultiSelectPositions()({
|
|
@@ -17,6 +17,7 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
|
17
17
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
18
18
|
import { key } from '../pm-plugins/main';
|
|
19
19
|
import { attachMoveNodeAnalytics, getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics';
|
|
20
|
+
import { isCollapsedHeading, updateCollapsedHeadingAfterMove } from '../pm-plugins/utils/collapsed-heading';
|
|
20
21
|
import { getNestedNodePosition } from '../pm-plugins/utils/getNestedNodePosition';
|
|
21
22
|
import { setCursorPositionAtMovedNode } from '../pm-plugins/utils/getSelection';
|
|
22
23
|
import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
|
|
@@ -369,6 +370,7 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
|
|
|
369
370
|
if (!handleNode) {
|
|
370
371
|
return tr;
|
|
371
372
|
}
|
|
373
|
+
const wasCollapsedHeading = isExperimentEnabled('platform_editor_collapsible_headings') && isCollapsedHeading(api, start);
|
|
372
374
|
let sliceFrom = start;
|
|
373
375
|
let sliceTo;
|
|
374
376
|
let sourceNodeTypes, hasSelectedMultipleNodes;
|
|
@@ -487,6 +489,15 @@ export const moveNode = api => (start, to, inputMethod = INPUT_METHOD.DRAG_AND_D
|
|
|
487
489
|
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
488
490
|
}
|
|
489
491
|
const $mappedTo = tr.doc.resolve(mappedTo);
|
|
492
|
+
if (isExperimentEnabled('platform_editor_collapsible_headings')) {
|
|
493
|
+
updateCollapsedHeadingAfterMove({
|
|
494
|
+
api,
|
|
495
|
+
destinationPos: mappedTo,
|
|
496
|
+
isNested: $mappedTo.parent.type.name !== 'doc',
|
|
497
|
+
tr,
|
|
498
|
+
wasCollapsed: wasCollapsedHeading
|
|
499
|
+
});
|
|
500
|
+
}
|
|
490
501
|
const expandAncestor = findParentNodeOfTypeClosestToPos($to, [expand, nestedExpand]);
|
|
491
502
|
if (expandAncestor) {
|
|
492
503
|
const wasExpandExpanded = expandedState.get(expandAncestor.node);
|
|
@@ -2,10 +2,12 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
3
3
|
import { Fragment, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
5
6
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
6
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
8
|
import { attachMoveNodeAnalytics, fireInsertLayoutAnalytics, getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics';
|
|
8
9
|
import { containsNodeOfType, isFragmentOfType } from '../pm-plugins/utils/check-fragment';
|
|
10
|
+
import { isCollapsedHeading } from '../pm-plugins/utils/collapsed-heading';
|
|
9
11
|
import { maxLayoutColumnSupported } from '../pm-plugins/utils/consts';
|
|
10
12
|
import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
|
|
11
13
|
import { getMultiSelectionIfPosInside } from '../pm-plugins/utils/selection';
|
|
@@ -231,6 +233,12 @@ export const moveToLayout = api => (from, to, options) => ({
|
|
|
231
233
|
if (!canMove) {
|
|
232
234
|
return tr;
|
|
233
235
|
}
|
|
236
|
+
if (isExperimentEnabled('platform_editor_collapsible_headings') && isCollapsedHeading(api, from)) {
|
|
237
|
+
var _api$blockCollapse;
|
|
238
|
+
(_api$blockCollapse = api.blockCollapse) === null || _api$blockCollapse === void 0 ? void 0 : _api$blockCollapse.commands.expandHeading(from)({
|
|
239
|
+
tr
|
|
240
|
+
});
|
|
241
|
+
}
|
|
234
242
|
const {
|
|
235
243
|
toNode,
|
|
236
244
|
$to,
|