@atlaskit/editor-plugin-block-controls 18.1.0 → 18.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/editor-commands/move-node.js +11 -0
  3. package/dist/cjs/editor-commands/move-to-layout.js +8 -0
  4. package/dist/cjs/pm-plugins/utils/collapsed-heading.js +69 -0
  5. package/dist/cjs/ui/block-controls-left-surface.js +5 -4
  6. package/dist/cjs/ui/block-controls-surface-drag-handle.js +10 -0
  7. package/dist/cjs/ui/drag-handle.js +3 -14
  8. package/dist/cjs/ui/should-use-nested-drag-handle-icon.js +1 -5
  9. package/dist/cjs/ui/use-block-controls-surface-drag-source.js +11 -0
  10. package/dist/es2019/editor-commands/move-node.js +11 -0
  11. package/dist/es2019/editor-commands/move-to-layout.js +8 -0
  12. package/dist/es2019/pm-plugins/utils/collapsed-heading.js +65 -0
  13. package/dist/es2019/ui/block-controls-left-surface.js +5 -4
  14. package/dist/es2019/ui/block-controls-surface-drag-handle.js +10 -0
  15. package/dist/es2019/ui/drag-handle.js +3 -13
  16. package/dist/es2019/ui/should-use-nested-drag-handle-icon.js +1 -5
  17. package/dist/es2019/ui/use-block-controls-surface-drag-source.js +11 -0
  18. package/dist/esm/editor-commands/move-node.js +11 -0
  19. package/dist/esm/editor-commands/move-to-layout.js +8 -0
  20. package/dist/esm/pm-plugins/utils/collapsed-heading.js +63 -0
  21. package/dist/esm/ui/block-controls-left-surface.js +5 -4
  22. package/dist/esm/ui/block-controls-surface-drag-handle.js +10 -0
  23. package/dist/esm/ui/drag-handle.js +3 -14
  24. package/dist/esm/ui/should-use-nested-drag-handle-icon.js +1 -5
  25. package/dist/esm/ui/use-block-controls-surface-drag-source.js +11 -0
  26. package/dist/types/blockControlsPluginType.d.ts +2 -0
  27. package/dist/types/pm-plugins/utils/collapsed-heading.d.ts +27 -0
  28. package/dist/types/ui/drag-handle.d.ts +1 -1
  29. package/package.json +4 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/editor-plugin-block-controls
2
2
 
3
+ ## 18.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`0cec43eb08826`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0cec43eb08826) -
8
+ Clean up experiment platform_editor_nested_drag_handle_icon
9
+ - Updated dependencies
10
+
11
+ ## 18.2.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`00fc2f11bb42e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/00fc2f11bb42e) -
16
+ [ux] Support dragging and changing the format of complete collapsed heading sections under
17
+ `platform_editor_collapsible_headings`.
18
+
19
+ ### Patch Changes
20
+
21
+ - [`834dc6bee730b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/834dc6bee730b) -
22
+ [ux] Keep collapsed heading controls visible under `platform_editor_collapsible_headings` when
23
+ another editor node is active.
24
+ - Updated dependencies
25
+
3
26
  ## 18.1.0
4
27
 
5
28
  ### Minor 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,
@@ -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
- }, willRenderPersistent && /*#__PURE__*/_react.default.createElement(_visibilityContainer.VisibilityContainer, {
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: persistentComponents,
60
+ components: hoverOnlyComponents,
61
61
  surface: _surfaceKeys.BLOCK_CONTROLS_LEFT_SURFACE,
62
62
  surfaceContext: surfaceContext
63
- })), willRenderHoverOnly && /*#__PURE__*/_react.default.createElement(_visibilityContainer.VisibilityContainer, {
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: hoverOnlyComponents,
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
  });
@@ -368,8 +368,6 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
368
368
  anchorName = _ref2.anchorName,
369
369
  nodeType = _ref2.nodeType,
370
370
  handleOptions = _ref2.handleOptions,
371
- _ref2$isTopLevelNode = _ref2.isTopLevelNode,
372
- isTopLevelNode = _ref2$isTopLevelNode === void 0 ? true : _ref2$isTopLevelNode,
373
371
  anchorRectCache = _ref2.anchorRectCache;
374
372
  var buttonRef = (0, _react.useRef)(null);
375
373
  var mouseDownRef = (0, _react.useRef)(false);
@@ -417,23 +415,15 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref2) {
417
415
  var start = getPos();
418
416
  var isLayoutColumn = nodeType === 'layoutColumn';
419
417
 
420
- // Dynamically calculate if node is top-level based on current position (gated by experiment)
421
- var isTopLevelNodeDynamic = (0, _react.useMemo)(function () {
422
- if (!(0, _expValEquals.expValEquals)('platform_editor_nested_drag_handle_icon', 'isEnabled', true)) {
423
- return isTopLevelNode;
424
- }
418
+ // Dynamically calculate if node is top-level based on current position
419
+ var isTopLevelNodeValue = (0, _react.useMemo)(function () {
425
420
  var pos = getPos();
426
421
  if (typeof pos === 'number') {
427
422
  var $pos = view.state.doc.resolve(pos);
428
423
  return ($pos === null || $pos === void 0 ? void 0 : $pos.parent.type.name) === 'doc';
429
424
  }
430
425
  return true;
431
- }, [getPos, view.state.doc, isTopLevelNode]);
432
-
433
- // Use the dynamic value when experiment is on, otherwise use the prop
434
- // When cleaning up the experiment, you can safely remove the isTopLevelNode as an prop and
435
- // just rely on the dynamic value (rename it to isTopLevelNode for simplicitiy)
436
- var isTopLevelNodeValue = (0, _expValEquals.expValEquals)('platform_editor_nested_drag_handle_icon', 'isEnabled', true) ? isTopLevelNodeDynamic : isTopLevelNode;
426
+ }, [getPos, view.state.doc]);
437
427
  (0, _react.useEffect)(function () {
438
428
  // blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
439
429
  if (nodeType === 'blockCard') {
@@ -1299,7 +1289,6 @@ var DragHandleWithVisibility = exports.DragHandleWithVisibility = function DragH
1299
1289
  anchorName: anchorName,
1300
1290
  nodeType: nodeType,
1301
1291
  handleOptions: handleOptions,
1302
- isTopLevelNode: isTopLevelNode,
1303
1292
  anchorRectCache: anchorRectCache
1304
1293
  }));
1305
1294
  };
@@ -5,15 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.shouldUseNestedDragHandleIcon = void 0;
7
7
  var _fg = require("@atlaskit/platform-feature-flags/fg");
8
- var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
9
- // Nested icon for non-top-level nodes when the experiment is on. Exception: with the
8
+ // Nested icon for non-top-level nodes. Exception: with the
10
9
  // kill switch OFF, layout columns use the full block handle instead.
11
10
  // TODO: EDITOR-7732 - remove this whole function when
12
11
  // `platform_editor_layout_column_menu_kill_switch_1` is cleaned up
13
12
  var shouldUseNestedDragHandleIcon = exports.shouldUseNestedDragHandleIcon = function shouldUseNestedDragHandleIcon(isTopLevelNode, isLayoutColumn) {
14
- if (!(0, _expValEquals.expValEquals)('platform_editor_nested_drag_handle_icon', 'isEnabled', true)) {
15
- return false;
16
- }
17
13
  if (isTopLevelNode) {
18
14
  return false;
19
15
  }
@@ -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,
@@ -0,0 +1,65 @@
1
+ /** Document range containing a heading and all content in its section. */
2
+
3
+ /** Returns the full section range when the heading at this position is collapsed. */
4
+ export const getCollapsedHeadingRange = (api, headingPos) => {
5
+ var _api$blockCollapse, _api$blockCollapse$sh;
6
+ const sectionEnd = api === null || api === void 0 ? void 0 : (_api$blockCollapse = api.blockCollapse) === null || _api$blockCollapse === void 0 ? void 0 : (_api$blockCollapse$sh = _api$blockCollapse.sharedState.currentState()) === null || _api$blockCollapse$sh === void 0 ? void 0 : _api$blockCollapse$sh.collapsedSectionEnds.get(headingPos);
7
+ return sectionEnd === undefined ? undefined : {
8
+ from: headingPos,
9
+ to: sectionEnd
10
+ };
11
+ };
12
+
13
+ /** Returns whether the heading at this position has a collapsed section. */
14
+ export const isCollapsedHeading = (api, headingPos) => {
15
+ var _api$blockCollapse$sh2, _api$blockCollapse2, _api$blockCollapse2$s;
16
+ return (_api$blockCollapse$sh2 = api === null || api === void 0 ? void 0 : (_api$blockCollapse2 = api.blockCollapse) === null || _api$blockCollapse2 === void 0 ? void 0 : (_api$blockCollapse2$s = _api$blockCollapse2.sharedState.currentState()) === null || _api$blockCollapse2$s === void 0 ? void 0 : _api$blockCollapse2$s.collapsedSectionEnds.has(headingPos)) !== null && _api$blockCollapse$sh2 !== void 0 ? _api$blockCollapse$sh2 : false;
17
+ };
18
+
19
+ /** Selects a collapsed section for drag or block-menu operations, optionally expanding it. */
20
+ export const prepareCollapsedHeadingSelection = ({
21
+ api,
22
+ expand,
23
+ headingPos,
24
+ tr
25
+ }) => {
26
+ var _api$blockControls;
27
+ const range = getCollapsedHeadingRange(api, headingPos);
28
+ if (!range) {
29
+ return false;
30
+ }
31
+ if (expand) {
32
+ var _api$blockCollapse3;
33
+ api === null || api === void 0 ? void 0 : (_api$blockCollapse3 = api.blockCollapse) === null || _api$blockCollapse3 === void 0 ? void 0 : _api$blockCollapse3.commands.expandHeading(headingPos)({
34
+ tr
35
+ });
36
+ }
37
+ api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.commands.setMultiSelectPositions(range.from, range.to)({
38
+ tr
39
+ });
40
+ return true;
41
+ };
42
+
43
+ /** Preserves collapse for root moves and expands headings moved into nested containers. */
44
+ export const updateCollapsedHeadingAfterMove = ({
45
+ api,
46
+ destinationPos,
47
+ isNested,
48
+ tr,
49
+ wasCollapsed
50
+ }) => {
51
+ var _api$blockCollapse5;
52
+ if (!wasCollapsed) {
53
+ return;
54
+ }
55
+ if (isNested) {
56
+ var _api$blockCollapse4;
57
+ api === null || api === void 0 ? void 0 : (_api$blockCollapse4 = api.blockCollapse) === null || _api$blockCollapse4 === void 0 ? void 0 : _api$blockCollapse4.commands.expandHeading(destinationPos)({
58
+ tr
59
+ });
60
+ return;
61
+ }
62
+ api === null || api === void 0 ? void 0 : (_api$blockCollapse5 = api.blockCollapse) === null || _api$blockCollapse5 === void 0 ? void 0 : _api$blockCollapse5.commands.collapseHeadingsAtPositions([destinationPos])({
63
+ tr
64
+ });
65
+ };
@@ -46,22 +46,23 @@ export const BlockControlsLeftSurface = ({
46
46
  className: ax(["_kqswstnw _1pbyb4wl"])
47
47
  }, /*#__PURE__*/React.createElement("div", {
48
48
  className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc"])
49
- }, willRenderPersistent && /*#__PURE__*/React.createElement(VisibilityContainer, {
49
+ }, willRenderHoverOnly && /*#__PURE__*/React.createElement(VisibilityContainer, {
50
50
  api: api,
51
51
  controlSide: getBlockControlsSurfaceControlSide(surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT), isExperimentEnabled('platform_editor_controls_reliable_anchor')),
52
52
  forceVisibleOnMouseOut: forceVisibleOnMouseOut,
53
53
  shouldUseDisplayContents: true
54
54
  }, /*#__PURE__*/React.createElement(SurfaceRenderer, {
55
- components: persistentComponents,
55
+ components: hoverOnlyComponents,
56
56
  surface: BLOCK_CONTROLS_LEFT_SURFACE,
57
57
  surfaceContext: surfaceContext
58
- })), willRenderHoverOnly && /*#__PURE__*/React.createElement(VisibilityContainer, {
58
+ })), willRenderPersistent && /*#__PURE__*/React.createElement(VisibilityContainer, {
59
59
  api: api,
60
60
  controlSide: getBlockControlsSurfaceControlSide(surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT), isExperimentEnabled('platform_editor_controls_reliable_anchor')),
61
61
  forceVisibleOnMouseOut: forceVisibleOnMouseOut,
62
+ isPersistent: true,
62
63
  shouldUseDisplayContents: true
63
64
  }, /*#__PURE__*/React.createElement(SurfaceRenderer, {
64
- components: hoverOnlyComponents,
65
+ components: persistentComponents,
65
66
  surface: BLOCK_CONTROLS_LEFT_SURFACE,
66
67
  surfaceContext: surfaceContext
67
68
  }))));
@@ -15,10 +15,12 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
15
15
  import { TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
16
16
  import { blockControlsMessages } from '@atlaskit/editor-common/messages';
17
17
  import DragHandleVerticalIcon from '@atlaskit/icon/core/drag-handle-vertical';
18
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
18
19
  import { fg } from '@atlaskit/platform-feature-flags/fg';
19
20
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
20
21
  import Tooltip from '@atlaskit/tooltip/Tooltip';
21
22
  import { selectionPreservationPluginKey } from '../pm-plugins/selection-preservation/plugin-key';
23
+ import { prepareCollapsedHeadingSelection } from '../pm-plugins/utils/collapsed-heading';
22
24
  import { expandAndUpdateSelection } from '../pm-plugins/utils/expand-and-update-selection';
23
25
  import { isHandleCorrelatedToSelection } from '../pm-plugins/utils/getSelection';
24
26
  import { buildLayoutColumnMenuMeta } from './block-controls-surface-drag-handle-utils';
@@ -211,6 +213,14 @@ export const BlockControlsSurfaceDragHandle = ({
211
213
  startPos,
212
214
  tr
213
215
  });
216
+ if (isExperimentEnabled('platform_editor_collapsible_headings')) {
217
+ prepareCollapsedHeadingSelection({
218
+ api,
219
+ expand: true,
220
+ headingPos: startPos,
221
+ tr
222
+ });
223
+ }
214
224
  api === null || api === void 0 ? void 0 : (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.commands.startPreservingSelection()({
215
225
  tr
216
226
  });
@@ -360,7 +360,6 @@ export const DragHandle = ({
360
360
  anchorName,
361
361
  nodeType,
362
362
  handleOptions,
363
- isTopLevelNode = true,
364
363
  anchorRectCache
365
364
  }) => {
366
365
  var _api$core4, _api$blockControls8;
@@ -396,23 +395,15 @@ export const DragHandle = ({
396
395
  const start = getPos();
397
396
  const isLayoutColumn = nodeType === 'layoutColumn';
398
397
 
399
- // Dynamically calculate if node is top-level based on current position (gated by experiment)
400
- const isTopLevelNodeDynamic = useMemo(() => {
401
- if (!expValEquals('platform_editor_nested_drag_handle_icon', 'isEnabled', true)) {
402
- return isTopLevelNode;
403
- }
398
+ // Dynamically calculate if node is top-level based on current position
399
+ const isTopLevelNodeValue = useMemo(() => {
404
400
  const pos = getPos();
405
401
  if (typeof pos === 'number') {
406
402
  const $pos = view.state.doc.resolve(pos);
407
403
  return ($pos === null || $pos === void 0 ? void 0 : $pos.parent.type.name) === 'doc';
408
404
  }
409
405
  return true;
410
- }, [getPos, view.state.doc, isTopLevelNode]);
411
-
412
- // Use the dynamic value when experiment is on, otherwise use the prop
413
- // When cleaning up the experiment, you can safely remove the isTopLevelNode as an prop and
414
- // just rely on the dynamic value (rename it to isTopLevelNode for simplicitiy)
415
- const isTopLevelNodeValue = expValEquals('platform_editor_nested_drag_handle_icon', 'isEnabled', true) ? isTopLevelNodeDynamic : isTopLevelNode;
406
+ }, [getPos, view.state.doc]);
416
407
  useEffect(() => {
417
408
  // blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
418
409
  if (nodeType === 'blockCard') {
@@ -1273,7 +1264,6 @@ export const DragHandleWithVisibility = ({
1273
1264
  anchorName: anchorName,
1274
1265
  nodeType: nodeType,
1275
1266
  handleOptions: handleOptions,
1276
- isTopLevelNode: isTopLevelNode,
1277
1267
  anchorRectCache: anchorRectCache
1278
1268
  }));
1279
1269
  };
@@ -1,14 +1,10 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags/fg';
2
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
2
 
4
- // Nested icon for non-top-level nodes when the experiment is on. Exception: with the
3
+ // Nested icon for non-top-level nodes. Exception: with the
5
4
  // kill switch OFF, layout columns use the full block handle instead.
6
5
  // TODO: EDITOR-7732 - remove this whole function when
7
6
  // `platform_editor_layout_column_menu_kill_switch_1` is cleaned up
8
7
  export const shouldUseNestedDragHandleIcon = (isTopLevelNode, isLayoutColumn) => {
9
- if (!expValEquals('platform_editor_nested_drag_handle_icon', 'isEnabled', true)) {
10
- return false;
11
- }
12
8
  if (isTopLevelNode) {
13
9
  return false;
14
10
  }
@@ -2,10 +2,12 @@ import { useEffect } from 'react';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
3
3
  import { startMeasure } from '@atlaskit/editor-common/performance-measures';
4
4
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
5
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
5
6
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter';
6
7
  import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/utils/set-custom-native-drag-preview';
7
8
  import { defaultActiveAnchorTracker } from '../pm-plugins/utils/active-anchor-tracker';
8
9
  import { getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics';
10
+ import { isCollapsedHeading, prepareCollapsedHeadingSelection } from '../pm-plugins/utils/collapsed-heading';
9
11
  import { isHandleCorrelatedToSelection, selectNode } from '../pm-plugins/utils/getSelection';
10
12
  import { dragPreview } from './drag-preview';
11
13
  import { getNodeMarginsForDragPreview, getNodeSpacingForDragPreview } from './block-controls-surface-drag-handle-utils';
@@ -45,6 +47,15 @@ export const useBlockControlsSurfaceDragSource = ({
45
47
  if (typeof handlePos !== 'number') {
46
48
  return tr;
47
49
  }
50
+ if (isExperimentEnabled('platform_editor_collapsible_headings') && isCollapsedHeading(api, handlePos)) {
51
+ prepareCollapsedHeadingSelection({
52
+ api,
53
+ expand: false,
54
+ headingPos: handlePos,
55
+ tr
56
+ });
57
+ return tr;
58
+ }
48
59
  if (!tr.selection.empty && isHandleCorrelatedToSelection(view.state, tr.selection, handlePos)) {
49
60
  var _api$blockControls;
50
61
  api === null || api === void 0 ? void 0 : (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.commands.setMultiSelectPositions()({
@@ -20,6 +20,7 @@ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
20
20
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
21
21
  import { key } from '../pm-plugins/main';
22
22
  import { attachMoveNodeAnalytics, getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics';
23
+ import { isCollapsedHeading, updateCollapsedHeadingAfterMove } from '../pm-plugins/utils/collapsed-heading';
23
24
  import { getNestedNodePosition } from '../pm-plugins/utils/getNestedNodePosition';
24
25
  import { setCursorPositionAtMovedNode } from '../pm-plugins/utils/getSelection';
25
26
  import { removeFromSource } from '../pm-plugins/utils/remove-from-source';
@@ -363,6 +364,7 @@ export var moveNode = function moveNode(api) {
363
364
  if (!handleNode) {
364
365
  return tr;
365
366
  }
367
+ var wasCollapsedHeading = isExperimentEnabled('platform_editor_collapsible_headings') && isCollapsedHeading(api, start);
366
368
  var sliceFrom = start;
367
369
  var sliceTo;
368
370
  var sourceNodeTypes, hasSelectedMultipleNodes;
@@ -480,6 +482,15 @@ export var moveNode = function moveNode(api) {
480
482
  api === null || api === void 0 || api.core.actions.focus();
481
483
  }
482
484
  var $mappedTo = tr.doc.resolve(mappedTo);
485
+ if (isExperimentEnabled('platform_editor_collapsible_headings')) {
486
+ updateCollapsedHeadingAfterMove({
487
+ api: api,
488
+ destinationPos: mappedTo,
489
+ isNested: $mappedTo.parent.type.name !== 'doc',
490
+ tr: tr,
491
+ wasCollapsed: wasCollapsedHeading
492
+ });
493
+ }
483
494
  var expandAncestor = findParentNodeOfTypeClosestToPos($to, [expand, nestedExpand]);
484
495
  if (expandAncestor) {
485
496
  var 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';
@@ -237,6 +239,12 @@ export var moveToLayout = function moveToLayout(api) {
237
239
  if (!canMove) {
238
240
  return tr;
239
241
  }
242
+ if (isExperimentEnabled('platform_editor_collapsible_headings') && isCollapsedHeading(api, from)) {
243
+ var _api$blockCollapse;
244
+ (_api$blockCollapse = api.blockCollapse) === null || _api$blockCollapse === void 0 || _api$blockCollapse.commands.expandHeading(from)({
245
+ tr: tr
246
+ });
247
+ }
240
248
  var toNode = canMove.toNode,
241
249
  $to = canMove.$to,
242
250
  sourceContent = canMove.sourceContent,
@@ -0,0 +1,63 @@
1
+ /** Document range containing a heading and all content in its section. */
2
+
3
+ /** Returns the full section range when the heading at this position is collapsed. */
4
+ export var getCollapsedHeadingRange = function getCollapsedHeadingRange(api, headingPos) {
5
+ var _api$blockCollapse;
6
+ 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);
7
+ return sectionEnd === undefined ? undefined : {
8
+ from: headingPos,
9
+ to: sectionEnd
10
+ };
11
+ };
12
+
13
+ /** Returns whether the heading at this position has a collapsed section. */
14
+ export var isCollapsedHeading = function isCollapsedHeading(api, headingPos) {
15
+ var _api$blockCollapse$sh, _api$blockCollapse2;
16
+ 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;
17
+ };
18
+
19
+ /** Selects a collapsed section for drag or block-menu operations, optionally expanding it. */
20
+ export var prepareCollapsedHeadingSelection = function prepareCollapsedHeadingSelection(_ref) {
21
+ var _api$blockControls;
22
+ var api = _ref.api,
23
+ expand = _ref.expand,
24
+ headingPos = _ref.headingPos,
25
+ tr = _ref.tr;
26
+ var range = getCollapsedHeadingRange(api, headingPos);
27
+ if (!range) {
28
+ return false;
29
+ }
30
+ if (expand) {
31
+ var _api$blockCollapse3;
32
+ api === null || api === void 0 || (_api$blockCollapse3 = api.blockCollapse) === null || _api$blockCollapse3 === void 0 || _api$blockCollapse3.commands.expandHeading(headingPos)({
33
+ tr: tr
34
+ });
35
+ }
36
+ api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.setMultiSelectPositions(range.from, range.to)({
37
+ tr: tr
38
+ });
39
+ return true;
40
+ };
41
+
42
+ /** Preserves collapse for root moves and expands headings moved into nested containers. */
43
+ export var updateCollapsedHeadingAfterMove = function updateCollapsedHeadingAfterMove(_ref2) {
44
+ var _api$blockCollapse5;
45
+ var api = _ref2.api,
46
+ destinationPos = _ref2.destinationPos,
47
+ isNested = _ref2.isNested,
48
+ tr = _ref2.tr,
49
+ wasCollapsed = _ref2.wasCollapsed;
50
+ if (!wasCollapsed) {
51
+ return;
52
+ }
53
+ if (isNested) {
54
+ var _api$blockCollapse4;
55
+ api === null || api === void 0 || (_api$blockCollapse4 = api.blockCollapse) === null || _api$blockCollapse4 === void 0 || _api$blockCollapse4.commands.expandHeading(destinationPos)({
56
+ tr: tr
57
+ });
58
+ return;
59
+ }
60
+ api === null || api === void 0 || (_api$blockCollapse5 = api.blockCollapse) === null || _api$blockCollapse5 === void 0 || _api$blockCollapse5.commands.collapseHeadingsAtPositions([destinationPos])({
61
+ tr: tr
62
+ });
63
+ };
@@ -44,22 +44,23 @@ export var BlockControlsLeftSurface = function BlockControlsLeftSurface(_ref) {
44
44
  className: ax(["_kqswstnw _1pbyb4wl"])
45
45
  }, /*#__PURE__*/React.createElement("div", {
46
46
  className: ax(["_zulpv77o _4cvr1h6o _1e0c1txw", isSticky && "_kqsw1if8 _154iu2gc"])
47
- }, willRenderPersistent && /*#__PURE__*/React.createElement(VisibilityContainer, {
47
+ }, willRenderHoverOnly && /*#__PURE__*/React.createElement(VisibilityContainer, {
48
48
  api: api,
49
49
  controlSide: getBlockControlsSurfaceControlSide(surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT), isExperimentEnabled('platform_editor_controls_reliable_anchor')),
50
50
  forceVisibleOnMouseOut: forceVisibleOnMouseOut,
51
51
  shouldUseDisplayContents: true
52
52
  }, /*#__PURE__*/React.createElement(SurfaceRenderer, {
53
- components: persistentComponents,
53
+ components: hoverOnlyComponents,
54
54
  surface: BLOCK_CONTROLS_LEFT_SURFACE,
55
55
  surfaceContext: surfaceContext
56
- })), willRenderHoverOnly && /*#__PURE__*/React.createElement(VisibilityContainer, {
56
+ })), willRenderPersistent && /*#__PURE__*/React.createElement(VisibilityContainer, {
57
57
  api: api,
58
58
  controlSide: getBlockControlsSurfaceControlSide(surfaceContext.get(BLOCK_CONTROL_UI_CONTEXT), isExperimentEnabled('platform_editor_controls_reliable_anchor')),
59
59
  forceVisibleOnMouseOut: forceVisibleOnMouseOut,
60
+ isPersistent: true,
60
61
  shouldUseDisplayContents: true
61
62
  }, /*#__PURE__*/React.createElement(SurfaceRenderer, {
62
- components: hoverOnlyComponents,
63
+ components: persistentComponents,
63
64
  surface: BLOCK_CONTROLS_LEFT_SURFACE,
64
65
  surfaceContext: surfaceContext
65
66
  }))));
@@ -16,10 +16,12 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
16
16
  import { TooltipContentWithMultipleShortcuts } from '@atlaskit/editor-common/keymaps';
17
17
  import { blockControlsMessages } from '@atlaskit/editor-common/messages';
18
18
  import DragHandleVerticalIcon from '@atlaskit/icon/core/drag-handle-vertical';
19
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
19
20
  import { fg } from '@atlaskit/platform-feature-flags/fg';
20
21
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
21
22
  import Tooltip from '@atlaskit/tooltip/Tooltip';
22
23
  import { selectionPreservationPluginKey } from '../pm-plugins/selection-preservation/plugin-key';
24
+ import { prepareCollapsedHeadingSelection } from '../pm-plugins/utils/collapsed-heading';
23
25
  import { expandAndUpdateSelection } from '../pm-plugins/utils/expand-and-update-selection';
24
26
  import { isHandleCorrelatedToSelection } from '../pm-plugins/utils/getSelection';
25
27
  import { buildLayoutColumnMenuMeta } from './block-controls-surface-drag-handle-utils';
@@ -215,6 +217,14 @@ export var BlockControlsSurfaceDragHandle = function BlockControlsSurfaceDragHan
215
217
  startPos: startPos,
216
218
  tr: tr
217
219
  });
220
+ if (isExperimentEnabled('platform_editor_collapsible_headings')) {
221
+ prepareCollapsedHeadingSelection({
222
+ api: api,
223
+ expand: true,
224
+ headingPos: startPos,
225
+ tr: tr
226
+ });
227
+ }
218
228
  api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.startPreservingSelection()({
219
229
  tr: tr
220
230
  });
@@ -364,8 +364,6 @@ export var DragHandle = function DragHandle(_ref2) {
364
364
  anchorName = _ref2.anchorName,
365
365
  nodeType = _ref2.nodeType,
366
366
  handleOptions = _ref2.handleOptions,
367
- _ref2$isTopLevelNode = _ref2.isTopLevelNode,
368
- isTopLevelNode = _ref2$isTopLevelNode === void 0 ? true : _ref2$isTopLevelNode,
369
367
  anchorRectCache = _ref2.anchorRectCache;
370
368
  var buttonRef = useRef(null);
371
369
  var mouseDownRef = useRef(false);
@@ -413,23 +411,15 @@ export var DragHandle = function DragHandle(_ref2) {
413
411
  var start = getPos();
414
412
  var isLayoutColumn = nodeType === 'layoutColumn';
415
413
 
416
- // Dynamically calculate if node is top-level based on current position (gated by experiment)
417
- var isTopLevelNodeDynamic = useMemo(function () {
418
- if (!expValEquals('platform_editor_nested_drag_handle_icon', 'isEnabled', true)) {
419
- return isTopLevelNode;
420
- }
414
+ // Dynamically calculate if node is top-level based on current position
415
+ var isTopLevelNodeValue = useMemo(function () {
421
416
  var pos = getPos();
422
417
  if (typeof pos === 'number') {
423
418
  var $pos = view.state.doc.resolve(pos);
424
419
  return ($pos === null || $pos === void 0 ? void 0 : $pos.parent.type.name) === 'doc';
425
420
  }
426
421
  return true;
427
- }, [getPos, view.state.doc, isTopLevelNode]);
428
-
429
- // Use the dynamic value when experiment is on, otherwise use the prop
430
- // When cleaning up the experiment, you can safely remove the isTopLevelNode as an prop and
431
- // just rely on the dynamic value (rename it to isTopLevelNode for simplicitiy)
432
- var isTopLevelNodeValue = expValEquals('platform_editor_nested_drag_handle_icon', 'isEnabled', true) ? isTopLevelNodeDynamic : isTopLevelNode;
422
+ }, [getPos, view.state.doc]);
433
423
  useEffect(function () {
434
424
  // blockCard/datasource width is rendered correctly after this decoraton does. We need to observe for changes.
435
425
  if (nodeType === 'blockCard') {
@@ -1295,7 +1285,6 @@ export var DragHandleWithVisibility = function DragHandleWithVisibility(_ref10)
1295
1285
  anchorName: anchorName,
1296
1286
  nodeType: nodeType,
1297
1287
  handleOptions: handleOptions,
1298
- isTopLevelNode: isTopLevelNode,
1299
1288
  anchorRectCache: anchorRectCache
1300
1289
  }));
1301
1290
  };
@@ -1,14 +1,10 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags/fg';
2
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
2
 
4
- // Nested icon for non-top-level nodes when the experiment is on. Exception: with the
3
+ // Nested icon for non-top-level nodes. Exception: with the
5
4
  // kill switch OFF, layout columns use the full block handle instead.
6
5
  // TODO: EDITOR-7732 - remove this whole function when
7
6
  // `platform_editor_layout_column_menu_kill_switch_1` is cleaned up
8
7
  export var shouldUseNestedDragHandleIcon = function shouldUseNestedDragHandleIcon(isTopLevelNode, isLayoutColumn) {
9
- if (!expValEquals('platform_editor_nested_drag_handle_icon', 'isEnabled', true)) {
10
- return false;
11
- }
12
8
  if (isTopLevelNode) {
13
9
  return false;
14
10
  }
@@ -2,10 +2,12 @@ import { useEffect } from 'react';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
3
3
  import { startMeasure } from '@atlaskit/editor-common/performance-measures';
4
4
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
5
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
5
6
  import { draggable } from '@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter';
6
7
  import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/utils/set-custom-native-drag-preview';
7
8
  import { defaultActiveAnchorTracker } from '../pm-plugins/utils/active-anchor-tracker';
8
9
  import { getMultiSelectAnalyticsAttributes } from '../pm-plugins/utils/analytics';
10
+ import { isCollapsedHeading, prepareCollapsedHeadingSelection } from '../pm-plugins/utils/collapsed-heading';
9
11
  import { isHandleCorrelatedToSelection, selectNode } from '../pm-plugins/utils/getSelection';
10
12
  import { dragPreview } from './drag-preview';
11
13
  import { getNodeMarginsForDragPreview, getNodeSpacingForDragPreview } from './block-controls-surface-drag-handle-utils';
@@ -44,6 +46,15 @@ export var useBlockControlsSurfaceDragSource = function useBlockControlsSurfaceD
44
46
  if (typeof handlePos !== 'number') {
45
47
  return tr;
46
48
  }
49
+ if (isExperimentEnabled('platform_editor_collapsible_headings') && isCollapsedHeading(api, handlePos)) {
50
+ prepareCollapsedHeadingSelection({
51
+ api: api,
52
+ expand: false,
53
+ headingPos: handlePos,
54
+ tr: tr
55
+ });
56
+ return tr;
57
+ }
47
58
  if (!tr.selection.empty && isHandleCorrelatedToSelection(view.state, tr.selection, handlePos)) {
48
59
  var _api$blockControls;
49
60
  api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.setMultiSelectPositions()({
@@ -4,6 +4,7 @@ import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
4
4
  import type { DIRECTION, EditorCommand, NextEditorPlugin, OptionalPlugin, PublicPluginAPI } from '@atlaskit/editor-common/types';
5
5
  import type { AccessibilityUtilsPlugin } from '@atlaskit/editor-plugin-accessibility-utils';
6
6
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
7
+ import type { BlockCollapsePlugin } from '@atlaskit/editor-plugin-block-collapse/blockCollapsePluginType';
7
8
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
8
9
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
9
10
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
@@ -152,6 +153,7 @@ export type NodeDecorationFactory = {
152
153
  };
153
154
  export type MoveNode = (start: number, to: number, inputMethod?: MoveNodeMethod, formatMessage?: IntlShape['formatMessage']) => EditorCommand;
154
155
  export type BlockControlsPluginDependencies = [
156
+ OptionalPlugin<BlockCollapsePlugin>,
155
157
  OptionalPlugin<LimitedModePlugin>,
156
158
  OptionalPlugin<EditorDisabledPlugin>,
157
159
  OptionalPlugin<EditorViewModePlugin>,
@@ -0,0 +1,27 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ import type { BlockControlsPlugin } from '../../blockControlsPluginType';
4
+ /** Document range containing a heading and all content in its section. */
5
+ export type CollapsedHeadingRange = {
6
+ from: number;
7
+ to: number;
8
+ };
9
+ /** Returns the full section range when the heading at this position is collapsed. */
10
+ export declare const getCollapsedHeadingRange: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, headingPos: number) => CollapsedHeadingRange | undefined;
11
+ /** Returns whether the heading at this position has a collapsed section. */
12
+ export declare const isCollapsedHeading: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, headingPos: number) => boolean;
13
+ /** Selects a collapsed section for drag or block-menu operations, optionally expanding it. */
14
+ export declare const prepareCollapsedHeadingSelection: ({ api, expand, headingPos, tr, }: {
15
+ api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
16
+ expand: boolean;
17
+ headingPos: number;
18
+ tr: Transaction;
19
+ }) => boolean;
20
+ /** Preserves collapse for root moves and expands headings moved into nested containers. */
21
+ export declare const updateCollapsedHeadingAfterMove: ({ api, destinationPos, isNested, tr, wasCollapsed, }: {
22
+ api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
23
+ destinationPos: number;
24
+ isNested: boolean;
25
+ tr: Transaction;
26
+ wasCollapsed: boolean;
27
+ }) => void;
@@ -15,6 +15,6 @@ type DragHandleProps = {
15
15
  nodeType: string;
16
16
  view: EditorView;
17
17
  };
18
- export declare const DragHandle: ({ view, api, formatMessage, getPos, anchorName, nodeType, handleOptions, isTopLevelNode, anchorRectCache, }: DragHandleProps) => jsx.JSX.Element;
18
+ export declare const DragHandle: ({ view, api, formatMessage, getPos, anchorName, nodeType, handleOptions, anchorRectCache, }: DragHandleProps) => jsx.JSX.Element;
19
19
  export declare const DragHandleWithVisibility: ({ view, api, formatMessage, getPos, anchorName, nodeType, handleOptions, isTopLevelNode, anchorRectCache, }: DragHandleProps) => jsx.JSX.Element;
20
20
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "18.1.0",
3
+ "version": "18.2.1",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -26,13 +26,14 @@
26
26
  "@atlaskit/docs": "^12.2.0",
27
27
  "@atlaskit/editor-plugin-accessibility-utils": "^17.0.0",
28
28
  "@atlaskit/editor-plugin-analytics": "^17.0.0",
29
+ "@atlaskit/editor-plugin-block-collapse": "^3.1.0",
29
30
  "@atlaskit/editor-plugin-editor-disabled": "^17.0.0",
30
31
  "@atlaskit/editor-plugin-editor-viewmode": "^19.0.0",
31
32
  "@atlaskit/editor-plugin-feature-flags": "^16.0.0",
32
33
  "@atlaskit/editor-plugin-interaction": "^28.0.0",
33
34
  "@atlaskit/editor-plugin-limited-mode": "^14.1.0",
34
35
  "@atlaskit/editor-plugin-metrics": "^18.0.0",
35
- "@atlaskit/editor-plugin-quick-insert": "^17.0.0",
36
+ "@atlaskit/editor-plugin-quick-insert": "^17.1.0",
36
37
  "@atlaskit/editor-plugin-selection": "^17.0.0",
37
38
  "@atlaskit/editor-plugin-show-diff": "^15.0.0",
38
39
  "@atlaskit/editor-plugin-toolbar": "^14.0.0",
@@ -55,7 +56,7 @@
55
56
  "@atlaskit/primitives": "^22.5.0",
56
57
  "@atlaskit/section-message": "^10.2.0",
57
58
  "@atlaskit/theme": "^28.2.0",
58
- "@atlaskit/tmp-editor-statsig": "^179.0.0",
59
+ "@atlaskit/tmp-editor-statsig": "^180.0.0",
59
60
  "@atlaskit/tokens": "^16.11.0",
60
61
  "@atlaskit/tooltip": "^24.3.0",
61
62
  "@babel/runtime": "^7.0.0",