@atlaskit/editor-plugin-block-controls 3.8.4 → 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 (42) hide show
  1. package/CHANGELOG.md +9 -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 +18 -22
  7. package/dist/cjs/pm-plugins/decorations-drop-target.js +46 -48
  8. package/dist/cjs/pm-plugins/handle-mouse-over.js +5 -10
  9. package/dist/cjs/pm-plugins/keymap.js +10 -13
  10. package/dist/cjs/pm-plugins/main.js +4 -177
  11. package/dist/cjs/ui/drag-handle.js +6 -9
  12. package/dist/cjs/ui/drop-target.js +1 -1
  13. package/dist/cjs/ui/global-styles.js +1 -28
  14. package/dist/es2019/editor-commands/move-node.js +50 -62
  15. package/dist/es2019/editor-commands/show-drag-handle.js +4 -69
  16. package/dist/es2019/pm-plugins/decorations-anchor.js +10 -11
  17. package/dist/es2019/pm-plugins/decorations-common.js +1 -2
  18. package/dist/es2019/pm-plugins/decorations-drag-handle.js +18 -24
  19. package/dist/es2019/pm-plugins/decorations-drop-target.js +47 -49
  20. package/dist/es2019/pm-plugins/handle-mouse-over.js +5 -10
  21. package/dist/es2019/pm-plugins/keymap.js +10 -13
  22. package/dist/es2019/pm-plugins/main.js +3 -158
  23. package/dist/es2019/ui/drag-handle.js +6 -9
  24. package/dist/es2019/ui/drop-target.js +1 -1
  25. package/dist/es2019/ui/global-styles.js +1 -42
  26. package/dist/esm/editor-commands/move-node.js +50 -62
  27. package/dist/esm/editor-commands/show-drag-handle.js +5 -73
  28. package/dist/esm/pm-plugins/decorations-anchor.js +10 -11
  29. package/dist/esm/pm-plugins/decorations-common.js +1 -4
  30. package/dist/esm/pm-plugins/decorations-drag-handle.js +18 -22
  31. package/dist/esm/pm-plugins/decorations-drop-target.js +47 -49
  32. package/dist/esm/pm-plugins/handle-mouse-over.js +5 -10
  33. package/dist/esm/pm-plugins/keymap.js +10 -13
  34. package/dist/esm/pm-plugins/main.js +5 -177
  35. package/dist/esm/ui/drag-handle.js +6 -9
  36. package/dist/esm/ui/drop-target.js +1 -1
  37. package/dist/esm/ui/global-styles.js +1 -28
  38. package/dist/types/pm-plugins/decorations-common.d.ts +1 -1
  39. package/dist/types/pm-plugins/main.d.ts +1 -15
  40. package/dist/types-ts4.5/pm-plugins/decorations-common.d.ts +1 -1
  41. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -15
  42. package/package.json +2 -2
@@ -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, function (state, dispatch, view) {
15
- showDragHandleAtSelection(api)(state, dispatch, view);
13
+ showElementDragHandle.common, function (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,14 +1,12 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
4
  import rafSchedule from 'raf-schd';
6
- import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
7
5
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
8
6
  import { browser } from '@atlaskit/editor-common/browser';
9
7
  import { isMeasuring, startMeasure, stopMeasure } from '@atlaskit/editor-common/performance-measures';
10
8
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
11
- import { isEmptyDocument, isTextInput } from '@atlaskit/editor-common/utils';
9
+ import { isEmptyDocument } from '@atlaskit/editor-common/utils';
12
10
  import { NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
13
11
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
14
12
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -180,7 +178,7 @@ var getDecorationAtPos = function getDecorationAtPos(decorations, pos, to) {
180
178
  var nodeDecAtActivePos = nodeDecsAtActivePos.pop();
181
179
  return nodeDecAtActivePos;
182
180
  };
183
- export var newApply = function newApply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) {
181
+ var _apply = function apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) {
184
182
  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;
185
183
  var activeNode = currentState.activeNode,
186
184
  decorations = currentState.decorations,
@@ -421,176 +419,10 @@ export var newApply = function newApply(api, formatMessage, tr, currentState, ne
421
419
  lastDragCancelled: (_meta$lastDragCancell = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell !== void 0 ? _meta$lastDragCancell : lastDragCancelled
422
420
  };
423
421
  };
424
- export var oldApply = function oldApply(api, formatMessage, tr, currentState, oldState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache) {
425
- var _meta$activeNode2, _meta$activeNode$hand2, _meta$activeNode8, _meta$isDragging4, _meta$editorHeight2, _meta$editorWidthLeft2, _meta$editorWidthRigh2, _meta$isPMDragging2, _meta$lastDragCancell2;
426
- var isNestedEnabled = flags.isNestedEnabled;
427
- var activeNode = currentState.activeNode,
428
- isMenuOpen = currentState.isMenuOpen,
429
- editorHeight = currentState.editorHeight,
430
- editorWidthLeft = currentState.editorWidthLeft,
431
- editorWidthRight = currentState.editorWidthRight,
432
- isDragging = currentState.isDragging,
433
- isPMDragging = currentState.isPMDragging,
434
- lastDragCancelled = currentState.lastDragCancelled;
435
- var decorations = currentState.decorations,
436
- isResizerResizing = currentState.isResizerResizing;
437
-
438
- // Remap existing decorations when steps exist
439
- if (tr.docChanged) {
440
- decorations = decorations.map(tr.mapping, tr.doc);
441
- }
442
- var meta = tr.getMeta(key);
443
-
444
- // If tables or media are being resized, we want to hide the drag handle
445
- var resizerMeta = tr.getMeta('is-resizer-resizing');
446
- isResizerResizing = resizerMeta !== null && resizerMeta !== void 0 ? resizerMeta : isResizerResizing;
447
- var canIgnoreTr = function canIgnoreTr() {
448
- return !tr.steps.every(function (e) {
449
- return e instanceof AnalyticsStep;
450
- });
451
- };
452
- var maybeNodeCountChanged = isNestedEnabled ? !isTextInput(tr) && tr.docChanged && canIgnoreTr() : oldState.doc.childCount !== newState.doc.childCount;
453
- var shouldRemoveHandle = !tr.getMeta('isRemote');
454
-
455
- // During resize, remove the drag handle widget so its dom positioning doesn't need to be maintained
456
- // Also remove the handle when the node is moved or the node count changes. This helps prevent incorrect positioning
457
- // Don't remove the handle if remote changes are changing the node count, its prosemirror position can be mapped instead
458
- if (isResizerResizing || maybeNodeCountChanged && shouldRemoveHandle || meta !== null && meta !== void 0 && meta.nodeMoved) {
459
- var oldHandle = decorations.find(undefined, undefined, function (spec) {
460
- return spec.type === 'drag-handle';
461
- });
462
- decorations = decorations.remove(oldHandle);
463
- }
464
- var decsLength = isNestedEnabled ? decorations.find(undefined, undefined, function (spec) {
465
- return spec.type === 'node-decoration';
466
- }).length : decorations.find().filter(function (_ref6) {
467
- var spec = _ref6.spec;
468
- return spec.type !== 'drag-handle';
469
- }).length;
470
- var isDecsMissing = false;
471
- var isDropTargetsMissing = false;
472
- if (isNestedEnabled) {
473
- var _meta$isDragging3;
474
- isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && maybeNodeCountChanged;
475
- 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);
476
- } else {
477
- isDecsMissing = !(isDragging || meta !== null && meta !== void 0 && meta.isDragging) && decsLength !== newState.doc.childCount;
478
- var dropTargetLen = decorations.find(undefined, undefined, function (spec) {
479
- return spec.type === 'drop-target-decoration';
480
- }).length;
481
- isDropTargetsMissing = isDragging && (meta === null || meta === void 0 ? void 0 : meta.isDragging) !== false && dropTargetLen !== newState.doc.childCount + 1;
482
- }
483
-
484
- // This is not targeted enough - it's trying to catch events like expand being set to breakout
485
- var maybeWidthUpdated = tr.docChanged && oldState.doc.nodeSize === newState.doc.nodeSize && !maybeNodeCountChanged;
486
-
487
- // This addresses scenarios such as undoing table resizing,
488
- // where a keyboard shortcut triggers a width change, and
489
- // the node's actual width is then updated in a separate renderering cycle.
490
- // The tr.meta.activeNode is triggered by the showDragHandleAt function during the mouse entry event
491
- // (when the table node rerenders)
492
- // The activeNode is from the previous rendering cycle, and verify if they share the same anchor.
493
- var maybeTableWidthUpdated = (meta === null || meta === void 0 ? void 0 : meta.activeNode) && (meta === null || meta === 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);
494
- var 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;
495
-
496
- // Draw node and mouseWrapper decorations at top level node if decorations is empty, editor height changes or node is moved
497
- if (redrawDecorations && !isResizerResizing && api) {
498
- var oldNodeDecs = decorations.find(undefined, undefined, function (spec) {
499
- return spec.type !== 'drop-target-decoration';
500
- });
501
- decorations = decorations.remove(oldNodeDecs);
502
- var newNodeDecs = nodeDecorations(newState);
503
- decorations = decorations.add(newState.doc, _toConsumableArray(newNodeDecs));
504
- if (activeNode && !(meta !== null && meta !== void 0 && meta.nodeMoved) && !isDecsMissing) {
505
- var _meta$activeNode$pos, _meta$activeNode3, _ref7, _meta$activeNode$anch, _meta$activeNode4, _decAtPos$spec, _ref8, _meta$activeNode$node, _meta$activeNode5, _decAtPos$spec2, _meta$activeNode6;
506
- var mappedPosisiton = tr.mapping.map(activeNode.pos);
507
- var prevMappedPos = oldState.tr.mapping.map(activeNode.pos);
508
-
509
- // When a node type changed to be nested inside another node, the position of the active node is off by 1
510
- // This is a workaround to fix the position of the active node when it is nested
511
- if (tr.docChanged && !maybeNodeCountChanged && mappedPosisiton === prevMappedPos + 1) {
512
- mappedPosisiton = prevMappedPos;
513
- }
514
- var _newActiveNode = tr.doc.nodeAt(mappedPosisiton);
515
- if (_newActiveNode && (_newActiveNode === null || _newActiveNode === void 0 ? void 0 : _newActiveNode.type.name) !== activeNode.nodeType) {
516
- var _oldHandle2 = decorations.find(undefined, undefined, function (spec) {
517
- return spec.type === 'drag-handle';
518
- });
519
- decorations = decorations.remove(_oldHandle2);
520
- }
521
- var decAtPos = newNodeDecs.find(function (dec) {
522
- return dec.from === mappedPosisiton;
523
- });
524
- var draghandleDec = dragHandleDecoration(api, formatMessage, (_meta$activeNode$pos = meta === null || meta === 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, (_ref7 = (_meta$activeNode$anch = meta === null || meta === 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 || (_decAtPos$spec = decAtPos.spec) === null || _decAtPos$spec === void 0 ? void 0 : _decAtPos$spec.anchorName) !== null && _ref7 !== void 0 ? _ref7 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.anchorName, (_ref8 = (_meta$activeNode$node = meta === null || meta === 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 || (_decAtPos$spec2 = decAtPos.spec) === null || _decAtPos$spec2 === void 0 ? void 0 : _decAtPos$spec2.nodeType) !== null && _ref8 !== void 0 ? _ref8 : activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType, nodeViewPortalProviderAPI, meta === null || meta === void 0 || (_meta$activeNode6 = meta.activeNode) === null || _meta$activeNode6 === void 0 ? void 0 : _meta$activeNode6.handleOptions);
525
- decorations = decorations.add(newState.doc, [draghandleDec]);
526
- }
527
- }
528
-
529
- // Remove previous drag handle widget and draw new drag handle widget when activeNode changes
530
- 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)) {
531
- var _oldHandle3 = decorations.find(undefined, undefined, function (spec) {
532
- return spec.type === 'drag-handle';
533
- });
534
- decorations = decorations.remove(_oldHandle3);
535
- var decs = dragHandleDecoration(api, formatMessage, meta.activeNode.pos, meta.activeNode.anchorName, meta.activeNode.nodeType, nodeViewPortalProviderAPI, meta.activeNode.handleOptions);
536
- decorations = decorations.add(newState.doc, [decs]);
537
- }
538
- if ((meta === null || meta === void 0 ? void 0 : meta.isDragging) === false || isDropTargetsMissing) {
539
- // Remove drop target decoration when dragging stops
540
- var dropTargetDecs = decorations.find(undefined, undefined, function (spec) {
541
- return spec.type === 'drop-target-decoration';
542
- });
543
- decorations = decorations.remove(dropTargetDecs);
544
- }
545
-
546
- // Map active node position when the document changes
547
- var mappedActiveNodePos = tr.docChanged && activeNode ? {
548
- pos: tr.mapping.map(activeNode.pos),
549
- anchorName: activeNode.anchorName,
550
- nodeType: activeNode.nodeType
551
- } : activeNode;
552
- var shouldCreateDropTargets = (meta === null || meta === void 0 ? void 0 : meta.isDragging) || isDropTargetsMissing;
553
- if (api) {
554
- // Add drop targets when node is being dragged
555
- // if the transaction is only for analytics and user is dragging, continue to draw drop targets
556
- if (shouldCreateDropTargets) {
557
- var _meta$activeNode7;
558
- var _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);
559
- decorations = decorations.add(newState.doc, _decs);
560
- }
561
- }
562
- var 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;
563
- if (isEmptyDoc) {
564
- var hasNodeDecoration = !!decorations.find(undefined, undefined, function (spec) {
565
- return spec.type === 'node-decoration';
566
- }).length;
567
- if (!hasNodeDecoration) {
568
- decorations = decorations.add(newState.doc, [emptyParagraphNodeDecorations()]);
569
- }
570
- }
571
- var newActiveNode = isEmptyDoc || !(meta !== null && meta !== void 0 && meta.activeNode) && decorations.find(undefined, undefined, function (spec) {
572
- return spec.type === 'drag-handle';
573
- }).length === 0 ? null : (_meta$activeNode8 = meta === null || meta === void 0 ? void 0 : meta.activeNode) !== null && _meta$activeNode8 !== void 0 ? _meta$activeNode8 : mappedActiveNodePos;
574
- return {
575
- decorations: decorations,
576
- activeNode: newActiveNode,
577
- isDragging: (_meta$isDragging4 = meta === null || meta === void 0 ? void 0 : meta.isDragging) !== null && _meta$isDragging4 !== void 0 ? _meta$isDragging4 : isDragging,
578
- isMenuOpen: meta !== null && meta !== void 0 && meta.toggleMenu ? !isMenuOpen : isMenuOpen,
579
- editorHeight: (_meta$editorHeight2 = meta === null || meta === void 0 ? void 0 : meta.editorHeight) !== null && _meta$editorHeight2 !== void 0 ? _meta$editorHeight2 : currentState.editorHeight,
580
- editorWidthLeft: (_meta$editorWidthLeft2 = meta === null || meta === void 0 ? void 0 : meta.editorWidthLeft) !== null && _meta$editorWidthLeft2 !== void 0 ? _meta$editorWidthLeft2 : currentState.editorWidthLeft,
581
- editorWidthRight: (_meta$editorWidthRigh2 = meta === null || meta === void 0 ? void 0 : meta.editorWidthRight) !== null && _meta$editorWidthRigh2 !== void 0 ? _meta$editorWidthRigh2 : currentState.editorWidthRight,
582
- isResizerResizing: isResizerResizing,
583
- isDocSizeLimitEnabled: initialState.isDocSizeLimitEnabled,
584
- isPMDragging: (_meta$isPMDragging2 = meta === null || meta === void 0 ? void 0 : meta.isPMDragging) !== null && _meta$isPMDragging2 !== void 0 ? _meta$isPMDragging2 : isPMDragging,
585
- lastDragCancelled: (_meta$lastDragCancell2 = meta === null || meta === void 0 ? void 0 : meta.lastDragCancelled) !== null && _meta$lastDragCancell2 !== void 0 ? _meta$lastDragCancell2 : lastDragCancelled
586
- };
587
- };
422
+ export { _apply as apply };
588
423
  export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProviderAPI) {
589
424
  var _getIntl = getIntl(),
590
425
  formatMessage = _getIntl.formatMessage;
591
- var isNestedEnabled = editorExperiment('nested-dnd', true, {
592
- exposure: true
593
- });
594
426
  var isAdvancedLayoutEnabled = editorExperiment('advanced_layouts', true, {
595
427
  exposure: true
596
428
  });
@@ -598,7 +430,6 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
598
430
  exposure: true
599
431
  });
600
432
  var flags = {
601
- isNestedEnabled: isNestedEnabled,
602
433
  isMultiSelectEnabled: isMultiSelectEnabled
603
434
  };
604
435
  var anchorRectCache;
@@ -611,11 +442,8 @@ export var createPlugin = function createPlugin(api, getIntl, nodeViewPortalProv
611
442
  init: function init() {
612
443
  return initialState;
613
444
  },
614
- apply: function apply(tr, currentState, oldState, newState) {
615
- if (isNestedEnabled) {
616
- return newApply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
617
- }
618
- return oldApply(api, formatMessage, tr, currentState, oldState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
445
+ apply: function apply(tr, currentState, _, newState) {
446
+ return _apply(api, formatMessage, tr, currentState, newState, flags, nodeViewPortalProviderAPI, anchorRectCache);
619
447
  }
620
448
  },
621
449
  props: {
@@ -509,14 +509,11 @@ export var DragHandle = function DragHandle(_ref) {
509
509
  }, [anchorName, api, getPos, isMultiSelect, nodeType, start, view]);
510
510
  var macroInteractionUpdates = featureFlagsState === null || featureFlagsState === void 0 ? void 0 : featureFlagsState.macroInteractionUpdates;
511
511
  var calculatePosition = useCallback(function () {
512
- var parentNodeType;
513
- if (editorExperiment('nested-dnd', true)) {
514
- var pos = getPos();
515
- var $pos = pos && view.state.doc.resolve(pos);
516
- var parentPos = $pos && $pos.depth ? $pos.before() : undefined;
517
- var node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
518
- parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
519
- }
512
+ var pos = getPos();
513
+ var $pos = pos && view.state.doc.resolve(pos);
514
+ var parentPos = $pos && $pos.depth ? $pos.before() : undefined;
515
+ var node = parentPos !== undefined ? view.state.doc.nodeAt(parentPos) : undefined;
516
+ var parentNodeType = node === null || node === void 0 ? void 0 : node.type.name;
520
517
  var supportsAnchor = CSS.supports('top', "anchor(".concat(anchorName, " start)")) && CSS.supports('left', "anchor(".concat(anchorName, " start)"));
521
518
  var safeAnchorName = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_2') ? refreshAnchorName({
522
519
  getPos: getPos,
@@ -641,7 +638,7 @@ export var DragHandle = function DragHandle(_ref) {
641
638
  keymap: dragToMoveDown
642
639
  }];
643
640
  var isParentNodeOfTypeLayout;
644
- if (!isTopLevelNode && editorExperiment('nested-dnd', true)) {
641
+ if (!isTopLevelNode) {
645
642
  var pos = getPos();
646
643
  if (typeof pos === 'number') {
647
644
  var _$pos$parent;
@@ -205,7 +205,7 @@ export var DropTarget = function DropTarget(props) {
205
205
  };
206
206
  var dynamicStyle = _defineProperty(_defineProperty(_defineProperty({
207
207
  width: isNestedDropTarget ? 'unset' : '100%'
208
- }, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat((widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH, "px")), EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, isNestedDropTarget ? getNestedNodeLeftPaddingMargin(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, editorExperiment('nested-dnd', true) ? layers.navigation() : layers.card());
208
+ }, EDITOR_BLOCK_CONTROLS_DROP_INDICATOR_WIDTH, isNestedDropTarget ? '100%' : "".concat((widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || DEFAULT_DROP_INDICATOR_WIDTH, "px")), EDITOR_BLOCK_CONTROLS_DROP_TARGET_LEFT_MARGIN, isNestedDropTarget ? getNestedNodeLeftPaddingMargin(parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) : '0'), EDITOR_BLOCK_CONTROLS_DROP_TARGET_ZINDEX, layers.navigation());
209
209
  return jsx(Fragment, null, jsx(HoverZone, {
210
210
  onDragEnter: function onDragEnter() {
211
211
  return setIsDraggedOver(true);
@@ -15,27 +15,6 @@ import { DRAG_HANDLE_MAX_WIDTH_PLUS_GAP, DRAG_HANDLE_WIDTH } from './consts';
15
15
  */
16
16
  var dragHandlerAnchorSelector = '[data-drag-handler-anchor-name]:not([data-drag-handler-node-type="tableRow"], [data-drag-handler-node-type="media"])';
17
17
  var extendedHoverZone = function extendedHoverZone() {
18
- return css(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ".block-ctrl-drag-preview ".concat(dragHandlerAnchorSelector, "::after"), {
19
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
20
- display: 'none !important'
21
- }), '.ProseMirror', _defineProperty({}, "&& ".concat(dragHandlerAnchorSelector, "::after"), {
22
- content: '""',
23
- position: 'absolute',
24
- top: 0,
25
- left: '-100%',
26
- width: '100%',
27
- height: '100%',
28
- background: 'transparent',
29
- cursor: 'default',
30
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
31
- zIndex: -1
32
- })), 'hr[data-drag-handler-anchor-name]', {
33
- overflow: 'visible'
34
- }), '[data-blocks-drag-handle-container="true"] + *::after', {
35
- display: 'none'
36
- }));
37
- };
38
- var extendedHoverZoneNested = function extendedHoverZoneNested() {
39
18
  return css(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ".block-ctrl-drag-preview ".concat(dragHandlerAnchorSelector, "::after"), {
40
19
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
41
20
  display: 'none !important'
@@ -177,12 +156,6 @@ var withRelativePosStyle = css({
177
156
  })
178
157
  });
179
158
  var withAnchorNameZindexStyle = css({
180
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
181
- '.ProseMirror': _defineProperty({}, "&& ".concat(dragHandlerAnchorSelector), {
182
- zIndex: 1
183
- })
184
- });
185
- var withAnchorNameZindexNestedStyle = css({
186
159
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
187
160
  '.ProseMirror': {
188
161
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
@@ -208,6 +181,6 @@ var blockCardWithoutLayout = css({
208
181
  });
209
182
  export var GlobalStylesWrapper = function GlobalStylesWrapper() {
210
183
  return jsx(Global, {
211
- 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,,]
184
+ styles: [globalStyles(), globalDnDStyle, extendedHoverZone(), withInlineNodeStyle, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, withRelativePosStyle, topLevelNodeMarginStyles, withAnchorNameZindexStyle,,]
212
185
  });
213
186
  };
@@ -3,7 +3,7 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
3
  export declare const TYPE_DROP_TARGET_DEC = "drop-target-decoration";
4
4
  export declare const TYPE_HANDLE_DEC = "drag-handle";
5
5
  export declare const TYPE_NODE_DEC = "node-decoration";
6
- export declare const getNestedDepth: () => 0 | 100;
6
+ export declare const NESTED_DEPTH = 100;
7
7
  export declare const getNodeAnchor: (node: PMNode) => string;
8
8
  export declare const getNodeTypeWithLevel: (node: PMNode) => string;
9
9
  export declare const unmountDecorations: (nodeViewPortalProviderAPI: PortalProviderAPI, selector: string, key: string) => void;
@@ -9,11 +9,10 @@ import type { BlockControlsPlugin, PluginState } from '../blockControlsPluginTyp
9
9
  import { AnchorRectCache } from './utils/anchor-utils';
10
10
  export declare const key: PluginKey<PluginState>;
11
11
  export interface FlagType {
12
- isNestedEnabled: boolean;
13
12
  isMultiSelectEnabled: boolean;
14
13
  }
15
14
  export declare const getDecorations: (state: EditorState) => DecorationSet | undefined;
16
- export declare const newApply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, anchorRectCache?: AnchorRectCache) => {
15
+ export declare const apply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, anchorRectCache?: AnchorRectCache) => {
17
16
  decorations: DecorationSet;
18
17
  activeNode: any;
19
18
  isDragging: any;
@@ -29,17 +28,4 @@ export declare const newApply: (api: ExtractInjectionAPI<BlockControlsPlugin> |
29
28
  isShiftDown: any;
30
29
  lastDragCancelled: any;
31
30
  };
32
- export declare const oldApply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, oldState: EditorState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, anchorRectCache?: AnchorRectCache) => {
33
- decorations: DecorationSet;
34
- activeNode: any;
35
- isDragging: any;
36
- isMenuOpen: boolean | undefined;
37
- editorHeight: any;
38
- editorWidthLeft: any;
39
- editorWidthRight: any;
40
- isResizerResizing: boolean;
41
- isDocSizeLimitEnabled: boolean | null;
42
- isPMDragging: any;
43
- lastDragCancelled: any;
44
- };
45
31
  export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI) => SafePlugin<PluginState>;
@@ -3,7 +3,7 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
3
  export declare const TYPE_DROP_TARGET_DEC = "drop-target-decoration";
4
4
  export declare const TYPE_HANDLE_DEC = "drag-handle";
5
5
  export declare const TYPE_NODE_DEC = "node-decoration";
6
- export declare const getNestedDepth: () => 0 | 100;
6
+ export declare const NESTED_DEPTH = 100;
7
7
  export declare const getNodeAnchor: (node: PMNode) => string;
8
8
  export declare const getNodeTypeWithLevel: (node: PMNode) => string;
9
9
  export declare const unmountDecorations: (nodeViewPortalProviderAPI: PortalProviderAPI, selector: string, key: string) => void;
@@ -9,11 +9,10 @@ import type { BlockControlsPlugin, PluginState } from '../blockControlsPluginTyp
9
9
  import { AnchorRectCache } from './utils/anchor-utils';
10
10
  export declare const key: PluginKey<PluginState>;
11
11
  export interface FlagType {
12
- isNestedEnabled: boolean;
13
12
  isMultiSelectEnabled: boolean;
14
13
  }
15
14
  export declare const getDecorations: (state: EditorState) => DecorationSet | undefined;
16
- export declare const newApply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, anchorRectCache?: AnchorRectCache) => {
15
+ export declare const apply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, anchorRectCache?: AnchorRectCache) => {
17
16
  decorations: DecorationSet;
18
17
  activeNode: any;
19
18
  isDragging: any;
@@ -29,17 +28,4 @@ export declare const newApply: (api: ExtractInjectionAPI<BlockControlsPlugin> |
29
28
  isShiftDown: any;
30
29
  lastDragCancelled: any;
31
30
  };
32
- export declare const oldApply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, oldState: EditorState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, anchorRectCache?: AnchorRectCache) => {
33
- decorations: DecorationSet;
34
- activeNode: any;
35
- isDragging: any;
36
- isMenuOpen: boolean | undefined;
37
- editorHeight: any;
38
- editorWidthLeft: any;
39
- editorWidthRight: any;
40
- isResizerResizing: boolean;
41
- isDocSizeLimitEnabled: boolean | null;
42
- isPMDragging: any;
43
- lastDragCancelled: any;
44
- };
45
31
  export declare const createPlugin: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, getIntl: () => IntlShape, nodeViewPortalProviderAPI: PortalProviderAPI) => SafePlugin<PluginState>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "3.8.4",
3
+ "version": "3.8.5",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@atlaskit/adf-schema": "^47.6.0",
36
- "@atlaskit/editor-common": "^103.0.0",
36
+ "@atlaskit/editor-common": "^103.1.0",
37
37
  "@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
39
39
  "@atlaskit/editor-plugin-editor-disabled": "^2.0.0",