@atlaskit/editor-plugin-block-controls 3.8.3 → 3.8.5

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 (57) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/editor-commands/move-node.js +50 -62
  3. package/dist/cjs/editor-commands/show-drag-handle.js +5 -73
  4. package/dist/cjs/pm-plugins/decorations-anchor.js +9 -10
  5. package/dist/cjs/pm-plugins/decorations-common.js +2 -5
  6. package/dist/cjs/pm-plugins/decorations-drag-handle.js +44 -34
  7. package/dist/cjs/pm-plugins/decorations-drop-target.js +46 -48
  8. package/dist/cjs/pm-plugins/decorations-quick-insert-button.js +32 -13
  9. package/dist/cjs/pm-plugins/handle-mouse-over.js +5 -10
  10. package/dist/cjs/pm-plugins/keymap.js +10 -13
  11. package/dist/cjs/pm-plugins/main.js +4 -177
  12. package/dist/cjs/ui/drag-handle.js +28 -10
  13. package/dist/cjs/ui/drop-target.js +1 -1
  14. package/dist/cjs/ui/global-styles.js +1 -28
  15. package/dist/cjs/ui/quick-insert-button.js +37 -5
  16. package/dist/cjs/ui/visibility-container.js +30 -0
  17. package/dist/es2019/editor-commands/move-node.js +50 -62
  18. package/dist/es2019/editor-commands/show-drag-handle.js +4 -69
  19. package/dist/es2019/pm-plugins/decorations-anchor.js +10 -11
  20. package/dist/es2019/pm-plugins/decorations-common.js +1 -2
  21. package/dist/es2019/pm-plugins/decorations-drag-handle.js +45 -37
  22. package/dist/es2019/pm-plugins/decorations-drop-target.js +47 -49
  23. package/dist/es2019/pm-plugins/decorations-quick-insert-button.js +29 -12
  24. package/dist/es2019/pm-plugins/handle-mouse-over.js +5 -10
  25. package/dist/es2019/pm-plugins/keymap.js +10 -13
  26. package/dist/es2019/pm-plugins/main.js +3 -158
  27. package/dist/es2019/ui/drag-handle.js +28 -9
  28. package/dist/es2019/ui/drop-target.js +1 -1
  29. package/dist/es2019/ui/global-styles.js +1 -42
  30. package/dist/es2019/ui/quick-insert-button.js +37 -4
  31. package/dist/es2019/ui/visibility-container.js +24 -0
  32. package/dist/esm/editor-commands/move-node.js +50 -62
  33. package/dist/esm/editor-commands/show-drag-handle.js +5 -73
  34. package/dist/esm/pm-plugins/decorations-anchor.js +10 -11
  35. package/dist/esm/pm-plugins/decorations-common.js +1 -4
  36. package/dist/esm/pm-plugins/decorations-drag-handle.js +45 -35
  37. package/dist/esm/pm-plugins/decorations-drop-target.js +47 -49
  38. package/dist/esm/pm-plugins/decorations-quick-insert-button.js +33 -14
  39. package/dist/esm/pm-plugins/handle-mouse-over.js +5 -10
  40. package/dist/esm/pm-plugins/keymap.js +10 -13
  41. package/dist/esm/pm-plugins/main.js +5 -177
  42. package/dist/esm/ui/drag-handle.js +27 -9
  43. package/dist/esm/ui/drop-target.js +1 -1
  44. package/dist/esm/ui/global-styles.js +1 -28
  45. package/dist/esm/ui/quick-insert-button.js +36 -4
  46. package/dist/esm/ui/visibility-container.js +23 -0
  47. package/dist/types/pm-plugins/decorations-common.d.ts +1 -1
  48. package/dist/types/pm-plugins/main.d.ts +1 -15
  49. package/dist/types/ui/drag-handle.d.ts +7 -4
  50. package/dist/types/ui/quick-insert-button.d.ts +1 -0
  51. package/dist/types/ui/visibility-container.d.ts +9 -0
  52. package/dist/types-ts4.5/pm-plugins/decorations-common.d.ts +1 -1
  53. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -15
  54. package/dist/types-ts4.5/ui/drag-handle.d.ts +7 -4
  55. package/dist/types-ts4.5/ui/quick-insert-button.d.ts +1 -0
  56. package/dist/types-ts4.5/ui/visibility-container.d.ts +9 -0
  57. package/package.json +5 -2
@@ -29,7 +29,7 @@ export const handleMouseOver = (view, event, api) => {
29
29
  if (rootElement) {
30
30
  var _rootElement$parentEl;
31
31
  // We want to exlude handles from showing for empty paragraph and heading nodes
32
- if (editorExperiment('nested-dnd', true) && isEmptyNestedParagraphOrHeading(rootElement)) {
32
+ if (isEmptyNestedParagraphOrHeading(rootElement)) {
33
33
  return false;
34
34
  }
35
35
  if (rootElement.getAttribute('data-drag-handler-node-type') === 'media' && editorExperiment('advanced_layouts', true)) {
@@ -42,12 +42,12 @@ export const handleMouseOver = (view, event, api) => {
42
42
  const parentElementType = parentElement === null || parentElement === void 0 ? void 0 : parentElement.getAttribute('data-drag-handler-node-type');
43
43
  if (editorExperiment('advanced_layouts', true)) {
44
44
  // We want to exclude handles from showing for direct descendant of table nodes (i.e. nodes in cells)
45
- if (parentElement && (parentElementType === 'table' || parentElementType === 'tableRow') && editorExperiment('nested-dnd', true)) {
45
+ if (parentElement && (parentElementType === 'table' || parentElementType === 'tableRow')) {
46
46
  rootElement = parentElement;
47
47
  }
48
48
  } else {
49
49
  // We want to exclude handles from showing for direct descendant of table nodes (i.e. nodes in cells)
50
- if (parentElement && parentElementType === 'table' && editorExperiment('nested-dnd', true)) {
50
+ if (parentElement && parentElementType === 'table') {
51
51
  rootElement = parentElement;
52
52
  }
53
53
  }
@@ -68,7 +68,7 @@ export const handleMouseOver = (view, event, api) => {
68
68
  }
69
69
  const parentRootElement = rootElement.parentElement;
70
70
  let pos;
71
- if (parentRootElement && editorExperiment('nested-dnd', true)) {
71
+ if (parentRootElement) {
72
72
  var _parentRootElement$ch;
73
73
  const childNodes = Array.from(parentRootElement.childNodes);
74
74
  const index = childNodes.indexOf(rootElement);
@@ -86,12 +86,7 @@ export const handleMouseOver = (view, event, api) => {
86
86
  // Don't show drag handle for layout column in a single column layout
87
87
  return false;
88
88
  }
89
- let targetPos;
90
- if (editorExperiment('nested-dnd', true)) {
91
- targetPos = view.state.doc.resolve(pos).pos;
92
- } else {
93
- targetPos = view.state.doc.resolve(pos).start(1) - 1;
94
- }
89
+ const targetPos = view.state.doc.resolve(pos).pos;
95
90
  let rootAnchorName;
96
91
  let rootNodeType;
97
92
  let rootPos;
@@ -1,7 +1,6 @@
1
1
  import { bindKeymapWithCommand, dragToMoveDown, dragToMoveLeft, dragToMoveRight, dragToMoveUp, showElementDragHandle } from '@atlaskit/editor-common/keymaps';
2
2
  import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
4
  import { moveNodeViaShortcut } from '../editor-commands/move-node';
6
5
  import { showDragHandleAtSelection } from '../editor-commands/show-drag-handle';
7
6
  import { DIRECTION } from './utils/consts';
@@ -11,8 +10,8 @@ function keymapList(api, formatMessage) {
11
10
  bindKeymapWithCommand(
12
11
  // Ignored via go/ees005
13
12
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
14
- showElementDragHandle.common, (state, dispatch, view) => {
15
- showDragHandleAtSelection(api)(state, dispatch, view);
13
+ showElementDragHandle.common, state => {
14
+ showDragHandleAtSelection(api)(state);
16
15
  //we always want to handle this shortcut to prevent default browser special char insert when option + alphabetical key is used
17
16
  return true;
18
17
  }, keymapList);
@@ -24,16 +23,14 @@ function keymapList(api, formatMessage) {
24
23
  // Ignored via go/ees005
25
24
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
26
25
  dragToMoveDown.common, moveNodeViaShortcut(api, DIRECTION.DOWN, formatMessage), keymapList);
27
- if (editorExperiment('nested-dnd', true)) {
28
- bindKeymapWithCommand(
29
- // Ignored via go/ees005
30
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
31
- dragToMoveLeft.common, moveNodeViaShortcut(api, DIRECTION.LEFT, formatMessage), keymapList);
32
- bindKeymapWithCommand(
33
- // Ignored via go/ees005
34
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
35
- dragToMoveRight.common, moveNodeViaShortcut(api, DIRECTION.RIGHT, formatMessage), keymapList);
36
- }
26
+ bindKeymapWithCommand(
27
+ // Ignored via go/ees005
28
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
29
+ dragToMoveLeft.common, moveNodeViaShortcut(api, DIRECTION.LEFT, formatMessage), keymapList);
30
+ bindKeymapWithCommand(
31
+ // Ignored via go/ees005
32
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
33
+ dragToMoveRight.common, moveNodeViaShortcut(api, DIRECTION.RIGHT, formatMessage), keymapList);
37
34
  }
38
35
  return keymapList;
39
36
  }
@@ -1,10 +1,9 @@
1
1
  import rafSchedule from 'raf-schd';
2
- import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
3
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
4
3
  import { browser } from '@atlaskit/editor-common/browser';
5
4
  import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
6
5
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
- import { isEmptyDocument, isTextInput } from '@atlaskit/editor-common/utils';
6
+ import { isEmptyDocument } from '@atlaskit/editor-common/utils';
8
7
  import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
9
8
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
10
9
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -181,7 +180,7 @@ const getDecorationAtPos = (decorations, pos, to) => {
181
180
  const nodeDecAtActivePos = nodeDecsAtActivePos.pop();
182
181
  return nodeDecAtActivePos;
183
182
  };
184
- export const newApply = (api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) => {
183
+ export const apply = (api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) => {
185
184
  var _meta$multiSelectDnD, _activeNode, _activeNode2, _meta$activeNode$hand, _activeNode3, _activeNode4, _meta$isDragging, _meta$isDragging2, _meta$toggleMenu, _meta$editorHeight, _meta$editorWidthLeft, _meta$editorWidthRigh, _meta$isPMDragging, _meta$isShiftDown, _meta$lastDragCancell;
186
185
  let {
187
186
  activeNode,
@@ -425,158 +424,10 @@ export const newApply = (api, formatMessage, tr, currentState, newState, flags,
425
424
  lastDragCancelled: (_meta$lastDragCancell = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell !== void 0 ? _meta$lastDragCancell : lastDragCancelled
426
425
  };
427
426
  };
428
- export const oldApply = (api, formatMessage, tr, currentState, oldState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) => {
429
- var _meta$activeNode2, _meta$activeNode$hand2, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2, _meta$lastDragCancell2;
430
- const {
431
- isNestedEnabled
432
- } = flags;
433
- const {
434
- activeNode,
435
- isMenuOpen,
436
- editorHeight,
437
- editorWidthLeft,
438
- editorWidthRight,
439
- isDragging,
440
- isPMDragging,
441
- lastDragCancelled
442
- } = currentState;
443
- let {
444
- decorations,
445
- isResizerResizing
446
- } = currentState;
447
-
448
- // Remap existing decorations when steps exist
449
- if (tr.docChanged) {
450
- decorations = decorations.map(tr.mapping, tr.doc);
451
- }
452
- const meta = tr.getMeta(key);
453
-
454
- // If tables or media are being resized, we want to hide the drag handle
455
- const resizerMeta = tr.getMeta('is-resizer-resizing');
456
- isResizerResizing = resizerMeta !== null && resizerMeta !== void 0 ? resizerMeta : isResizerResizing;
457
- const canIgnoreTr = () => !tr.steps.every(e => e instanceof AnalyticsStep);
458
- const maybeNodeCountChanged = isNestedEnabled ? !isTextInput(tr) && tr.docChanged && canIgnoreTr() : oldState.doc.childCount !== newState.doc.childCount;
459
- const shouldRemoveHandle = !tr.getMeta('isRemote');
460
-
461
- // During resize, remove the drag handle widget so its dom positioning doesn't need to be maintained
462
- // Also remove the handle when the node is moved or the node count changes. This helps prevent incorrect positioning
463
- // Don't remove the handle if remote changes are changing the node count, its prosemirror position can be mapped instead
464
- if (isResizerResizing || maybeNodeCountChanged && shouldRemoveHandle || meta !== null && meta !== void 0 && meta.nodeMoved) {
465
- const oldHandle = decorations.find(undefined, undefined, spec => spec.type === 'drag-handle');
466
- decorations = decorations.remove(oldHandle);
467
- }
468
- const decsLength = isNestedEnabled ? decorations.find(undefined, undefined, spec => spec.type === 'node-decoration').length : decorations.find().filter(({
469
- spec
470
- }) => spec.type !== 'drag-handle').length;
471
- let isDecsMissing = false;
472
- let isDropTargetsMissing = false;
473
- if (isNestedEnabled) {
474
- var _meta$isDragging3;
475
- isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && maybeNodeCountChanged;
476
- isDropTargetsMissing = ((_meta$isDragging3 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging3 !== void 0 ? _meta$isDragging3 : isDragging) && maybeNodeCountChanged && !(meta !== null && meta !== void 0 && meta.nodeMoved);
477
- } else {
478
- isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && decsLength !== newState.doc.childCount;
479
- const dropTargetLen = decorations.find(undefined, undefined, spec => spec.type === 'drop-target-decoration').length;
480
- isDropTargetsMissing = isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && dropTargetLen !== newState.doc.childCount + 1;
481
- }
482
-
483
- // This is not targeted enough - it's trying to catch events like expand being set to breakout
484
- const maybeWidthUpdated = tr.docChanged && oldState.doc.nodeSize === newState.doc.nodeSize && !maybeNodeCountChanged;
485
-
486
- // This addresses scenarios such as undoing table resizing,
487
- // where a keyboard shortcut triggers a width change, and
488
- // the node's actual width is then updated in a separate renderering cycle.
489
- // The tr.meta.activeNode is triggered by the showDragHandleAt function during the mouse entry event
490
- // (when the table node rerenders)
491
- // The activeNode is from the previous rendering cycle, and verify if they share the same anchor.
492
- const maybeTableWidthUpdated = (meta === null || meta === void 0 ? void 0 : meta.activeNode) && (meta === null || meta === void 0 ? void 0 : (_meta$activeNode2 = meta.activeNode) === null || _meta$activeNode2 === void 0 ? void 0 : _meta$activeNode2.nodeType) === 'table' && meta.activeNode.anchorName === (activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName);
493
- const redrawDecorations = decorations === DecorationSet.empty || (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== editorHeight || (meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== editorWidthLeft || (meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== undefined && (meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== editorWidthRight || maybeWidthUpdated || maybeNodeCountChanged || maybeTableWidthUpdated || resizerMeta === false || isDecsMissing || !!(meta !== null && meta !== void 0 && meta.nodeMoved) && tr.docChanged;
494
-
495
- // Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
496
- if (redrawDecorations && !isResizerResizing && api) {
497
- const oldNodeDecs = decorations.find(undefined, undefined, spec => spec.type !== 'drop-target-decoration');
498
- decorations = decorations.remove(oldNodeDecs);
499
- const newNodeDecs = nodeDecorations(newState);
500
- decorations = decorations.add(newState.doc, [...newNodeDecs]);
501
- if (activeNode && !(meta !== null && meta !== void 0 && meta.nodeMoved) && !isDecsMissing) {
502
- var _meta$activeNode$pos, _meta$activeNode3, _ref, _meta$activeNode$anch, _meta$activeNode4, _decAtPos$spec, _ref2, _meta$activeNode$node, _meta$activeNode5, _decAtPos$spec2, _meta$activeNode6;
503
- let mappedPosisiton = tr.mapping.map(activeNode.pos);
504
- const prevMappedPos = oldState.tr.mapping.map(activeNode.pos);
505
-
506
- // When a node type changed to be nested inside another node, the position of the active node is off by 1
507
- // This is a workaround to fix the position of the active node when it is nested
508
- if (tr.docChanged && !maybeNodeCountChanged && mappedPosisiton === prevMappedPos + 1) {
509
- mappedPosisiton = prevMappedPos;
510
- }
511
- const newActiveNode = tr.doc.nodeAt(mappedPosisiton);
512
- if (newActiveNode && (newActiveNode === null || newActiveNode === void 0 ? void 0 : newActiveNode.type.name) !== activeNode.nodeType) {
513
- const oldHandle = decorations.find(undefined, undefined, spec => spec.type === 'drag-handle');
514
- decorations = decorations.remove(oldHandle);
515
- }
516
- const decAtPos = newNodeDecs.find(dec => dec.from === mappedPosisiton);
517
- const draghandleDec = dragHandleDecoration(api, formatMessage, (_meta$activeNode$pos = meta === null || meta === void 0 ? void 0 : (_meta$activeNode3 = meta.activeNode) === null || _meta$activeNode3 === void 0 ? void 0 : _meta$activeNode3.pos) !== null && _meta$activeNode$pos !== void 0 ? _meta$activeNode$pos : mappedPosisiton, (_ref = (_meta$activeNode$anch = meta === null || meta === void 0 ? void 0 : (_meta$activeNode4 = meta.activeNode) === null || _meta$activeNode4 === void 0 ? void 0 : _meta$activeNode4.anchorName) !== null && _meta$activeNode$anch !== void 0 ? _meta$activeNode$anch : decAtPos === null || decAtPos === void 0 ? void 0 : (_decAtPos$spec = decAtPos.spec) === null || _decAtPos$spec === void 0 ? void 0 : _decAtPos$spec.anchorName) !== null && _ref !== void 0 ? _ref : activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName, (_ref2 = (_meta$activeNode$node = meta === null || meta === void 0 ? void 0 : (_meta$activeNode5 = meta.activeNode) === null || _meta$activeNode5 === void 0 ? void 0 : _meta$activeNode5.nodeType) !== null && _meta$activeNode$node !== void 0 ? _meta$activeNode$node : decAtPos === null || decAtPos === void 0 ? void 0 : (_decAtPos$spec2 = decAtPos.spec) === null || _decAtPos$spec2 === void 0 ? void 0 : _decAtPos$spec2.nodeType) !== null && _ref2 !== void 0 ? _ref2 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType, nodeViewPortalProviderAPI, meta === null || meta === void 0 ? void 0 : (_meta$activeNode6 = meta.activeNode) === null || _meta$activeNode6 === void 0 ? void 0 : _meta$activeNode6.handleOptions);
518
- decorations = decorations.add(newState.doc, [draghandleDec]);
519
- }
520
- }
521
-
522
- // Remove previous drag handle widget and draw new drag handle widget when activeNode changes
523
- if (api && meta !== null && meta !== void 0 && meta.activeNode && ((meta === null || meta === void 0 ? void 0 : meta.activeNode.pos) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.pos) && (meta === null || meta === void 0 ? void 0 : meta.activeNode.anchorName) !== (activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName) || meta !== null && meta !== void 0 && (_meta$activeNode$hand2 = meta.activeNode.handleOptions) !== null && _meta$activeNode$hand2 !== void 0 && _meta$activeNode$hand2.isFocused)) {
524
- const oldHandle = decorations.find(undefined, undefined, spec => spec.type === 'drag-handle');
525
- decorations = decorations.remove(oldHandle);
526
- const decs = dragHandleDecoration(api, formatMessage, meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, nodeViewPortalProviderAPI, meta.activeNode.handleOptions);
527
- decorations = decorations.add(newState.doc, [decs]);
528
- }
529
- if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
530
- // Remove drop target decoration when dragging stops
531
- const dropTargetDecs = decorations.find(undefined, undefined, spec => spec.type === 'drop-target-decoration');
532
- decorations = decorations.remove(dropTargetDecs);
533
- }
534
-
535
- // Map active node position when the document changes
536
- const mappedActiveNodePos = tr.docChanged && activeNode ? {
537
- pos: tr.mapping.map(activeNode.pos),
538
- anchorName: activeNode.anchorName,
539
- nodeType: activeNode.nodeType
540
- } : activeNode;
541
- const shouldCreateDropTargets = (meta === null || meta === void 0 ? void 0 : meta.isDragging) || isDropTargetsMissing;
542
- if (api) {
543
- // Add drop targets when node is being dragged
544
- // if the transaction is only for analytics and user is dragging, continue to draw drop targets
545
- if (shouldCreateDropTargets) {
546
- var _meta$activeNode7;
547
- const decs = dropTargetDecorations(newState, api, formatMessage, nodeViewPortalProviderAPI, isNestedEnabled ? (_meta$activeNode7 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode7 !== void 0 ? _meta$activeNode7 : mappedActiveNodePos : meta === null || meta === void 0 ? void 0 : meta.activeNode, anchorRectCache);
548
- decorations = decorations.add(newState.doc, decs);
549
- }
550
- }
551
- const isEmptyDoc = isNestedEnabled ? newState.doc.childCount === 1 && newState.doc.nodeSize <= 4 && (newState.doc.firstChild === null || newState.doc.firstChild.nodeSize <= 2) : newState.doc.childCount === 1 && newState.doc.nodeSize <= 4;
552
- if (isEmptyDoc) {
553
- const hasNodeDecoration = !!decorations.find(undefined, undefined, spec => spec.type === 'node-decoration').length;
554
- if (!hasNodeDecoration) {
555
- decorations = decorations.add(newState.doc, [emptyParagraphNodeDecorations()]);
556
- }
557
- }
558
- const newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && decorations.find(undefined, undefined, spec => spec.type === 'drag-handle').length === 0 ? null : (_meta$activeNode8 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode8 !== void 0 ? _meta$activeNode8 : mappedActiveNodePos;
559
- return {
560
- decorations,
561
- activeNode: newActiveNode,
562
- isDragging: (_meta$isDragging4 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging4 !== void 0 ? _meta$isDragging4 : isDragging,
563
- isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
564
- editorHeight: (_meta$editorHeight2 = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight2 !== void 0 ? _meta$editorHeight2 : currentState.editorHeight,
565
- editorWidthLeft: (_meta$editorWidthLeft2 = meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== null && _meta$editorWidthLeft2 !== void 0 ? _meta$editorWidthLeft2 : currentState.editorWidthLeft,
566
- editorWidthRight: (_meta$editorWidthRigh2 = meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== null && _meta$editorWidthRigh2 !== void 0 ? _meta$editorWidthRigh2 : currentState.editorWidthRight,
567
- isResizerResizing: isResizerResizing,
568
- isDocSizeLimitEnabled: initialState.isDocSizeLimitEnabled,
569
- isPMDragging: (_meta$isPMDragging2 = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging2 !== void 0 ? _meta$isPMDragging2 : isPMDragging,
570
- lastDragCancelled: (_meta$lastDragCancell2 = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell2 !== void 0 ? _meta$lastDragCancell2 : lastDragCancelled
571
- };
572
- };
573
427
  export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
574
428
  const {
575
429
  formatMessage
576
430
  } = getIntl();
577
- const isNestedEnabled = editorExperiment('nested-dnd', true, {
578
- exposure: true
579
- });
580
431
  const isAdvancedLayoutEnabled = editorExperiment('advanced_layouts', true, {
581
432
  exposure: true
582
433
  });
@@ -584,7 +435,6 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
584
435
  exposure: true
585
436
  });
586
437
  const flags = {
587
- isNestedEnabled,
588
438
  isMultiSelectEnabled
589
439
  };
590
440
  let anchorRectCache;
@@ -597,12 +447,7 @@ export const createPlugin = (api, getIntl, nodeViewPortalProviderAPI) => {
597
447
  init() {
598
448
  return initialState;
599
449
  },
600
- apply(tr, currentState, oldState, newState) {
601
- if (isNestedEnabled) {
602
- return newApply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
603
- }
604
- return oldApply(api, formatMessage, tr, currentState, oldState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
605
- }
450
+ apply: (tr, currentState, _, newState) => apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache)
606
451
  },
607
452
  props: {
608
453
  decorations: state => {
@@ -32,6 +32,7 @@ import { alignAnchorHeadInDirectionOfPos, expandSelectionHeadToNodeAtPos } from
32
32
  import { BLOCK_MENU_ENABLED, DRAG_HANDLE_BORDER_RADIUS, DRAG_HANDLE_HEIGHT, DRAG_HANDLE_MAX_SHIFT_CLICK_DEPTH, DRAG_HANDLE_WIDTH, DRAG_HANDLE_ZINDEX, dragHandleGap, nodeMargins, spacingBetweenNodesForPreview, topPositionAdjustment } from './consts';
33
33
  import { dragPreview } from './drag-preview';
34
34
  import { refreshAnchorName } from './utils/anchor-name';
35
+ import { VisibilityContainer } from './visibility-container';
35
36
  const iconWrapperStyles = xcss({
36
37
  display: 'flex',
37
38
  justifyContent: 'center',
@@ -500,14 +501,11 @@ export const DragHandle = ({
500
501
  }, [anchorName, api, getPos, isMultiSelect, nodeType, start, view]);
501
502
  const macroInteractionUpdates = featureFlagsState === null || featureFlagsState === void 0 ? void 0 : featureFlagsState.macroInteractionUpdates;
502
503
  const calculatePosition = useCallback(() => {
503
- let parentNodeType;
504
- if (editorExperiment('nested-dnd', true)) {
505
- const pos = getPos();
506
- const $pos = pos && view.state.doc.resolve(pos);
507
- const parentPos = $pos && $pos.depth ? $pos.before() : undefined;
508
- const node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
509
- parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
510
- }
504
+ const pos = getPos();
505
+ const $pos = pos && view.state.doc.resolve(pos);
506
+ const parentPos = $pos && $pos.depth ? $pos.before() : undefined;
507
+ const node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
508
+ const parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
511
509
  const supportsAnchor = CSS.supports('top', `anchor(${anchorName} start)`) && CSS.supports('left', `anchor(${anchorName} start)`);
512
510
  const safeAnchorName = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_2') ? refreshAnchorName({
513
511
  getPos,
@@ -631,7 +629,7 @@ export const DragHandle = ({
631
629
  keymap: dragToMoveDown
632
630
  }];
633
631
  let isParentNodeOfTypeLayout;
634
- if (!isTopLevelNode && editorExperiment('nested-dnd', true)) {
632
+ if (!isTopLevelNode) {
635
633
  const pos = getPos();
636
634
  if (typeof pos === 'number') {
637
635
  var _$pos$parent;
@@ -761,4 +759,25 @@ export const DragHandle = ({
761
759
  const stickyRender = isTooltip ? stickyWithTooltip() : stickyWithoutTooltip();
762
760
  const render = isTooltip ? buttonWithTooltip() : renderButton();
763
761
  return fg('platform_editor_controls_sticky_controls') ? stickyRender : render;
762
+ };
763
+ export const DragHandleWithVisibility = ({
764
+ view,
765
+ api,
766
+ formatMessage,
767
+ getPos,
768
+ anchorName,
769
+ nodeType,
770
+ anchorRectCache
771
+ }) => {
772
+ return jsx(VisibilityContainer, {
773
+ api: api
774
+ }, jsx(DragHandle, {
775
+ view: view,
776
+ api: api,
777
+ formatMessage: formatMessage,
778
+ getPos: getPos,
779
+ anchorName: anchorName,
780
+ nodeType: nodeType,
781
+ anchorRectCache: anchorRectCache
782
+ }));
764
783
  };
@@ -205,7 +205,7 @@ export const DropTarget = props => {
205
205
  width: isNestedDropTarget ? 'unset' : '100%',
206
206
  [EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH]: isNestedDropTarget ? '100%' : `${(widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH}px`,
207
207
  [EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN]: isNestedDropTarget ? getNestedNodeLeftPaddingMargin(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0',
208
- [EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX]: editorExperiment('nested-dnd', true) ? layers.navigation() : layers.card()
208
+ [EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX]: layers.navigation()
209
209
  };
210
210
  return jsx(Fragment, null, jsx(HoverZone, {
211
211
  onDragEnter: () => setIsDraggedOver(true),
@@ -14,38 +14,6 @@ import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, DRAG_HANDLE_WIDTH } from './consts';
14
14
  */
15
15
  const dragHandlerAnchorSelector = '[data-drag-handler-anchor-name]:not([data-drag-handler-node-type="tableRow"], [data-drag-handler-node-type="media"])';
16
16
  const extendedHoverZone = () => css({
17
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
18
- [`.block-ctrl-drag-preview ${dragHandlerAnchorSelector}::after`]: {
19
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
20
- display: 'none !important'
21
- },
22
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
23
- '.ProseMirror': {
24
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
25
- [`&& ${dragHandlerAnchorSelector}::after`]: {
26
- content: '""',
27
- position: 'absolute',
28
- top: 0,
29
- left: '-100%',
30
- width: '100%',
31
- height: '100%',
32
- background: 'transparent',
33
- cursor: 'default',
34
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
35
- zIndex: -1
36
- }
37
- },
38
- // TODO: ED-23995 - this style override needs to be moved to the Rule styles after FF cleanup - packages/editor/editor-common/src/styles/shared/rule.ts
39
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
40
- 'hr[data-drag-handler-anchor-name]': {
41
- overflow: 'visible'
42
- },
43
- //eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
44
- '[data-blocks-drag-handle-container="true"] + *::after': {
45
- display: 'none'
46
- }
47
- });
48
- const extendedHoverZoneNested = () => css({
49
17
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
50
18
  [`.block-ctrl-drag-preview ${dragHandlerAnchorSelector}::after`]: {
51
19
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
@@ -225,15 +193,6 @@ const withRelativePosStyle = css({
225
193
  }
226
194
  });
227
195
  const withAnchorNameZindexStyle = css({
228
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
229
- '.ProseMirror': {
230
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors, @atlaskit/ui-styling-standard/no-unsafe-values
231
- [`&& ${dragHandlerAnchorSelector}`]: {
232
- zIndex: 1
233
- }
234
- }
235
- });
236
- const withAnchorNameZindexNestedStyle = css({
237
196
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
238
197
  '.ProseMirror': {
239
198
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
@@ -259,6 +218,6 @@ const blockCardWithoutLayout = css({
259
218
  });
260
219
  export const GlobalStylesWrapper = () => {
261
220
  return jsx(Global, {
262
- styles: [globalStyles(), globalDnDStyle, editorExperiment('nested-dnd', true) ? extendedHoverZoneNested() : extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, editorExperiment('nested-dnd', true) ? withAnchorNameZindexNestedStyle : withAnchorNameZindexStyle,,]
221
+ styles: [globalStyles(), globalDnDStyle, extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, withAnchorNameZindexStyle,,]
263
222
  });
264
223
  };
@@ -15,6 +15,7 @@ import { rootElementGap, topPositionAdjustment, QUICK_INSERT_DIMENSIONS, QUICK_I
15
15
  import { refreshAnchorName } from './utils/anchor-name';
16
16
  import { isInTextSelection, isNestedNodeSelected, isNonEditableBlock, isSelectionInNode } from './utils/document-checks';
17
17
  import { createNewLine } from './utils/editor-commands';
18
+ import { VisibilityContainer } from './visibility-container';
18
19
  const TEXT_PARENT_TYPES = ['paragraph', 'heading', 'blockquote', 'taskItem', 'decisionItem'];
19
20
  const buttonStyles = xcss({
20
21
  boxSizing: 'border-box',
@@ -101,6 +102,7 @@ export const TypeAheadControl = ({
101
102
  anchorRectCache
102
103
  }) => {
103
104
  const macroInteractionUpdates = useSharedPluginStateSelector(api, 'featureFlags.macroInteractionUpdates');
105
+ // remove when platform_editor_controls_patch_1 is removed
104
106
  const isTypeAheadOpen = useSharedPluginStateSelector(api, 'typeAhead.isOpen');
105
107
  const [positionStyles, setPositionStyles] = useState({
106
108
  display: 'none'
@@ -252,20 +254,51 @@ export const TypeAheadControl = ({
252
254
  testId: "editor-quick-insert-button",
253
255
  type: "button",
254
256
  "aria-label": formatMessage(messages.insert),
255
- xcss: [fg('platform_editor_controls_sticky_controls') ? buttonStyles : stickyButtonStyles, isTypeAheadOpen && fg('platform_editor_controls_patch_1') && disabledStyles],
257
+ xcss: [fg('platform_editor_controls_sticky_controls') ? buttonStyles : stickyButtonStyles,
258
+ // remove disabledStyles and platform_editor_controls_widget_visibility check when platform_editor_controls_patch_1 is removed
259
+ isTypeAheadOpen && !fg('platform_editor_controls_widget_visibility') && fg('platform_editor_controls_patch_1') ? disabledStyles : undefined],
256
260
  onClick: handleQuickInsert,
257
261
  onMouseDown: fg('platform_editor_controls_patch_1') ? undefined : handleMouseDown,
258
- isDisabled: fg('platform_editor_controls_patch_1') ? isTypeAheadOpen : undefined
262
+ isDisabled: !fg('platform_editor_controls_widget_visibility') && fg('platform_editor_controls_patch_1') && isTypeAheadOpen
259
263
  }, /*#__PURE__*/React.createElement(AddIcon, {
260
264
  label: "add",
261
- color: isTypeAheadOpen ? "var(--ds-icon-disabled, #091E424F)" : "var(--ds-icon-subtle, #626F86)"
265
+ color:
266
+ // remove color.icon.disabled when platform_editor_controls_patch_1 is removed
267
+ isTypeAheadOpen && !fg('platform_editor_controls_widget_visibility') ? "var(--ds-icon-disabled, #091E424F)" : "var(--ds-icon-subtle, #626F86)"
262
268
  })));
263
269
  return /*#__PURE__*/React.createElement(Box
264
270
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
265
271
  , {
266
272
  style: positionStyles,
267
- xcss: [containerStaticStyles, isTypeAheadOpen && fg('platform_editor_controls_patch_1') && disabledContainerStyles]
273
+ xcss: [containerStaticStyles,
274
+ // remove disabledContainerStyles and platform_editor_controls_widget_visibility check when platform_editor_controls_patch_1 is removed
275
+ isTypeAheadOpen && !fg('platform_editor_controls_widget_visibility') && fg('platform_editor_controls_patch_1') && disabledContainerStyles]
268
276
  }, fg('platform_editor_controls_sticky_controls') ? /*#__PURE__*/React.createElement(Box, {
269
277
  xcss: [tooltipContainerStyles]
270
278
  }, tooltipPressable()) : tooltipPressable());
279
+ };
280
+ export const QuickInsertWithVisibility = ({
281
+ view,
282
+ api,
283
+ formatMessage,
284
+ getPos,
285
+ nodeType,
286
+ anchorName,
287
+ rootAnchorName,
288
+ rootNodeType,
289
+ anchorRectCache
290
+ }) => {
291
+ return /*#__PURE__*/React.createElement(VisibilityContainer, {
292
+ api: api
293
+ }, /*#__PURE__*/React.createElement(TypeAheadControl, {
294
+ view: view,
295
+ api: api,
296
+ formatMessage: formatMessage,
297
+ getPos: getPos,
298
+ nodeType: nodeType,
299
+ anchorName: anchorName,
300
+ rootAnchorName: rootAnchorName,
301
+ rootNodeType: rootNodeType,
302
+ anchorRectCache: anchorRectCache
303
+ }));
271
304
  };
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
3
+ import { Box, xcss } from '@atlaskit/primitives';
4
+ const baseStyles = xcss({
5
+ transition: 'opacity 0.1s ease-in-out, visibility 0.1s ease-in-out'
6
+ });
7
+ const visibleStyles = xcss({
8
+ opacity: 1,
9
+ visibility: 'visible'
10
+ });
11
+ const hiddenStyles = xcss({
12
+ opacity: 0,
13
+ // CONFIRM this change doesnt cause this issue to regress https://product-fabric.atlassian.net/browse/ED-24136
14
+ visibility: 'hidden'
15
+ });
16
+ export const VisibilityContainer = ({
17
+ api,
18
+ children
19
+ }) => {
20
+ const isOpen = useSharedPluginStateSelector(api, 'typeAhead.isOpen');
21
+ return /*#__PURE__*/React.createElement(Box, {
22
+ xcss: [baseStyles, isOpen ? hiddenStyles : visibleStyles]
23
+ }, children);
24
+ };