@atlaskit/editor-plugin-block-controls 7.4.2 → 7.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/blockControlsPlugin.js +6 -1
  3. package/dist/cjs/editor-commands/move-node.js +3 -3
  4. package/dist/cjs/pm-plugins/handle-mouse-over.js +7 -2
  5. package/dist/cjs/pm-plugins/main.js +25 -13
  6. package/dist/cjs/pm-plugins/utils/getSelection.js +7 -7
  7. package/dist/cjs/pm-plugins/utils/transactions.js +4 -3
  8. package/dist/cjs/ui/drag-handle.js +23 -23
  9. package/dist/cjs/ui/global-styles.js +5 -1
  10. package/dist/es2019/blockControlsPlugin.js +6 -1
  11. package/dist/es2019/editor-commands/move-node.js +3 -3
  12. package/dist/es2019/pm-plugins/handle-mouse-over.js +7 -2
  13. package/dist/es2019/pm-plugins/main.js +25 -13
  14. package/dist/es2019/pm-plugins/utils/getSelection.js +7 -7
  15. package/dist/es2019/pm-plugins/utils/transactions.js +4 -3
  16. package/dist/es2019/ui/drag-handle.js +23 -23
  17. package/dist/es2019/ui/global-styles.js +5 -1
  18. package/dist/esm/blockControlsPlugin.js +6 -1
  19. package/dist/esm/editor-commands/move-node.js +3 -3
  20. package/dist/esm/pm-plugins/handle-mouse-over.js +7 -2
  21. package/dist/esm/pm-plugins/main.js +25 -13
  22. package/dist/esm/pm-plugins/utils/getSelection.js +7 -7
  23. package/dist/esm/pm-plugins/utils/transactions.js +4 -3
  24. package/dist/esm/ui/drag-handle.js +23 -23
  25. package/dist/esm/ui/global-styles.js +5 -1
  26. package/dist/types/blockControlsPluginType.d.ts +3 -1
  27. package/dist/types/pm-plugins/main.d.ts +1 -0
  28. package/dist/types/pm-plugins/utils/getSelection.d.ts +5 -3
  29. package/dist/types/pm-plugins/utils/transactions.d.ts +2 -1
  30. package/dist/types-ts4.5/blockControlsPluginType.d.ts +3 -1
  31. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -0
  32. package/dist/types-ts4.5/pm-plugins/utils/getSelection.d.ts +5 -3
  33. package/dist/types-ts4.5/pm-plugins/utils/transactions.d.ts +2 -1
  34. package/package.json +4 -3
@@ -1,9 +1,9 @@
1
1
  import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
2
+ import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
2
3
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
3
4
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
4
5
  import { selectTableClosestToPos } from '@atlaskit/editor-tables/utils';
5
6
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
6
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
7
  export var getInlineNodePos = function getInlineNodePos(tr, start, nodeSize) {
8
8
  var $startPos = tr.doc.resolve(start);
9
9
  // To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
@@ -115,25 +115,25 @@ var newGetSelection = function newGetSelection(tr, start) {
115
115
  inlineNodeEndPos = _getInlineNodePos2.inlineNodeEndPos;
116
116
  return new TextSelection(tr.doc.resolve(inlineNodePos), tr.doc.resolve(inlineNodeEndPos));
117
117
  };
118
- export var getSelection = function getSelection(tr, start) {
119
- if (editorExperiment('platform_editor_controls', 'variant1')) {
118
+ export var getSelection = function getSelection(tr, start, api) {
119
+ if (areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar))) {
120
120
  return newGetSelection(tr, start);
121
121
  }
122
122
  return oldGetSelection(tr, start);
123
123
  };
124
- export var selectNode = function selectNode(tr, start, nodeType) {
124
+ export var selectNode = function selectNode(tr, start, nodeType, api) {
125
125
  // For table, we need to do cell selection instead of node selection
126
126
  if (nodeType === 'table') {
127
127
  tr = selectTableClosestToPos(tr, tr.doc.resolve(start + 1));
128
128
  return tr;
129
129
  }
130
- var selection = getSelection(tr, start);
130
+ var selection = getSelection(tr, start, api);
131
131
  if (selection) {
132
132
  tr.setSelection(selection);
133
133
  }
134
134
  return tr;
135
135
  };
136
- export var setCursorPositionAtMovedNode = function setCursorPositionAtMovedNode(tr, start) {
136
+ export var setCursorPositionAtMovedNode = function setCursorPositionAtMovedNode(tr, start, api) {
137
137
  var node = tr.doc.nodeAt(start);
138
138
  var isNodeSelection = node && NodeSelection.isSelectable(node);
139
139
  var nodeSize = node ? node.nodeSize : 1;
@@ -147,7 +147,7 @@ export var setCursorPositionAtMovedNode = function setCursorPositionAtMovedNode(
147
147
  }
148
148
 
149
149
  // this is a fix for empty paragraph selection - can safely use start position as the paragraph is empty
150
- if ((node === null || node === void 0 ? void 0 : node.type.name) === 'paragraph' && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && editorExperiment('platform_editor_controls', 'variant1')) {
150
+ if ((node === null || node === void 0 ? void 0 : node.type.name) === 'paragraph' && (node === null || node === void 0 ? void 0 : node.childCount) === 0 && areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar))) {
151
151
  var _selection = new TextSelection(tr.doc.resolve(start));
152
152
  tr.setSelection(_selection);
153
153
  return tr;
@@ -1,5 +1,4 @@
1
1
  import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
2
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
2
  /**
4
3
  * Checks if step adds inline char
5
4
  * @param s
@@ -41,7 +40,7 @@ var isStepContentReplacedWithAnotherOfSameSize = function isStepContentReplacedW
41
40
  * Number of ReplaceStep and ReplaceAroundStep steps 'numReplaceSteps'.
42
41
  * 'isAllText' if all steps are represent adding inline text or a backspace/delete or no-op
43
42
  */
44
- export var getTrMetadata = function getTrMetadata(tr) {
43
+ export var getTrMetadata = function getTrMetadata(tr, flags) {
45
44
  var from;
46
45
  var to;
47
46
  var numReplaceSteps = 0;
@@ -52,7 +51,9 @@ export var getTrMetadata = function getTrMetadata(tr) {
52
51
  if (s instanceof ReplaceAroundStep || s instanceof ReplaceStep && !isStepText(s) && !isStepDelete(s)) {
53
52
  isAllText = false;
54
53
  }
55
- if (editorExperiment('platform_editor_controls', 'variant1')) {
54
+ // Fixes drag handle and quick insert button overlap issues
55
+ if (flags.toolbarFlagsEnabled) {
56
+ // platform_editor_controls note: fixes drag handle and quick insert button overlap issues
56
57
  isReplacedWithSameSize = isStepContentReplacedWithAnotherOfSameSize(s);
57
58
  }
58
59
  var mappedTo = tr.mapping.map(s.to);
@@ -293,7 +293,7 @@ var getNodeMargins = function getNodeMargins(node) {
293
293
  return nodeMargins[nodeTypeName] || nodeMargins['default'];
294
294
  };
295
295
  export var DragHandle = function DragHandle(_ref) {
296
- var _api$core2, _api$blockControls4, _api$analytics2, _api$core4, _api$core6, _api$blockControls6, _api$userIntent2;
296
+ var _api$core3;
297
297
  var view = _ref.view,
298
298
  api = _ref.api,
299
299
  formatMessage = _ref.formatMessage,
@@ -388,10 +388,10 @@ export var DragHandle = function DragHandle(_ref) {
388
388
  var _selection = new NodeSelection(tr.doc.resolve(startPos));
389
389
  tr.setSelection(_selection);
390
390
  } else {
391
- tr = selectNode(tr, startPos, nodeType);
391
+ tr = selectNode(tr, startPos, nodeType, api);
392
392
  }
393
393
  } else {
394
- tr = selectNode(tr, startPos, nodeType);
394
+ tr = selectNode(tr, startPos, nodeType, api);
395
395
  }
396
396
  if (BLOCK_MENU_ENABLED && editorExperiment('platform_editor_controls', 'variant1')) {
397
397
  var _api$blockControls;
@@ -437,7 +437,7 @@ export var DragHandle = function DragHandle(_ref) {
437
437
  return tr;
438
438
  });
439
439
  view.focus();
440
- }, [isMultiSelect, api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions, api === null || api === void 0 ? void 0 : api.blockControls.sharedState, api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 ? void 0 : _api$blockControls4.commands, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, view, dragHandleSelected, getPos, isTopLevelNode, nodeType, anchorName]);
440
+ }, [isMultiSelect, api, view, dragHandleSelected, getPos, isTopLevelNode, nodeType, anchorName]);
441
441
 
442
442
  // TODO: ED-26959 - This needs to be investigated further. Drag preview generation is not always working
443
443
  // as expected with a node selection. This workaround sets the selection to the node on mouseDown,
@@ -455,9 +455,9 @@ export var DragHandle = function DragHandle(_ref) {
455
455
  var handleKeyDown = useCallback(function (e) {
456
456
  // allow user to use spacebar to select the node
457
457
  if (!e.repeat && e.key === ' ') {
458
- var _api$core3;
458
+ var _api$core2;
459
459
  var startPos = getPos();
460
- api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref3) {
460
+ api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref3) {
461
461
  var tr = _ref3.tr;
462
462
  if (startPos === undefined) {
463
463
  return tr;
@@ -481,28 +481,28 @@ export var DragHandle = function DragHandle(_ref) {
481
481
  // return focus to editor to resume editing from caret position
482
482
  view.focus();
483
483
  }
484
- }, [getPos, api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions, isMultiSelect, view]);
484
+ }, [getPos, api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions, isMultiSelect, view]);
485
485
  var handleKeyDownNew = useCallback(function (e) {
486
486
  // allow user to use spacebar to select the node
487
487
  if (e.key === 'Enter' || !e.repeat && e.key === ' ') {
488
- var _api$core5;
488
+ var _api$core4;
489
489
  if (document.activeElement !== buttonRef.current) {
490
490
  return;
491
491
  }
492
492
  e.preventDefault();
493
493
  e.stopPropagation();
494
494
  var startPos = getPos();
495
- api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref4) {
496
- var _api$blockControls5, _api$userIntent;
495
+ api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref4) {
496
+ var _api$blockControls4, _api$userIntent;
497
497
  var tr = _ref4.tr;
498
498
  if (startPos === undefined) {
499
499
  return tr;
500
500
  }
501
- tr = selectNode(tr, startPos, nodeType);
501
+ tr = selectNode(tr, startPos, nodeType, api);
502
502
  !isMultiSelect && tr.setMeta(key, {
503
503
  pos: startPos
504
504
  });
505
- api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.toggleBlockMenu({
505
+ api === null || api === void 0 || (_api$blockControls4 = api.blockControls) === null || _api$blockControls4 === void 0 || _api$blockControls4.commands.toggleBlockMenu({
506
506
  anchorName: anchorName,
507
507
  openedViaKeyboard: true
508
508
  })({
@@ -520,7 +520,7 @@ export var DragHandle = function DragHandle(_ref) {
520
520
  // return focus to editor to resume editing from caret position
521
521
  view.focus();
522
522
  }
523
- }, [getPos, api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 ? void 0 : _api$core6.actions, api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 ? void 0 : _api$blockControls6.commands, api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.commands, nodeType, isMultiSelect, anchorName, view]);
523
+ }, [getPos, api, nodeType, isMultiSelect, anchorName, view]);
524
524
  useEffect(function () {
525
525
  var element = buttonRef.current;
526
526
  if (!element) {
@@ -538,8 +538,8 @@ export var DragHandle = function DragHandle(_ref) {
538
538
  var _api$blockControls$sh2;
539
539
  var nativeSetDragImage = _ref5.nativeSetDragImage;
540
540
  if (isMultiSelect) {
541
- var _api$core7;
542
- api === null || api === void 0 || (_api$core7 = api.core) === null || _api$core7 === void 0 || _api$core7.actions.execute(function (_ref6) {
541
+ var _api$core5;
542
+ api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref6) {
543
543
  var tr = _ref6.tr;
544
544
  var handlePos = getPos();
545
545
  if (typeof handlePos !== 'number') {
@@ -547,12 +547,12 @@ export var DragHandle = function DragHandle(_ref) {
547
547
  }
548
548
  var newHandlePosCheck = isHandleCorrelatedToSelection(view.state, tr.selection, handlePos);
549
549
  if (!tr.selection.empty && newHandlePosCheck) {
550
- var _api$blockControls7;
551
- api === null || api === void 0 || (_api$blockControls7 = api.blockControls) === null || _api$blockControls7 === void 0 || _api$blockControls7.commands.setMultiSelectPositions()({
550
+ var _api$blockControls5;
551
+ api === null || api === void 0 || (_api$blockControls5 = api.blockControls) === null || _api$blockControls5 === void 0 || _api$blockControls5.commands.setMultiSelectPositions()({
552
552
  tr: tr
553
553
  });
554
554
  } else if (fg('platform_editor_elements_dnd_select_node_on_drag')) {
555
- tr = selectNode(tr, handlePos, nodeType);
555
+ tr = selectNode(tr, handlePos, nodeType, api);
556
556
  }
557
557
  return tr;
558
558
  });
@@ -651,12 +651,12 @@ export var DragHandle = function DragHandle(_ref) {
651
651
  });
652
652
  },
653
653
  onDragStart: function onDragStart() {
654
- var _api$core8;
654
+ var _api$core6;
655
655
  if (start === undefined) {
656
656
  return;
657
657
  }
658
- api === null || api === void 0 || (_api$core8 = api.core) === null || _api$core8 === void 0 || _api$core8.actions.execute(function (_ref8) {
659
- var _api$blockControls$sh3, _api$blockControls8, _api$analytics3;
658
+ api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref8) {
659
+ var _api$blockControls$sh3, _api$blockControls6, _api$analytics2;
660
660
  var tr = _ref8.tr;
661
661
  var nodeTypes, hasSelectedMultipleNodes;
662
662
  var resolvedMovingNode = tr.doc.resolve(start);
@@ -670,11 +670,11 @@ export var DragHandle = function DragHandle(_ref) {
670
670
  nodeTypes = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.type.name;
671
671
  hasSelectedMultipleNodes = false;
672
672
  }
673
- api === null || api === void 0 || (_api$blockControls8 = api.blockControls) === null || _api$blockControls8 === void 0 || _api$blockControls8.commands.setNodeDragged(getPos, anchorName, nodeType)({
673
+ api === null || api === void 0 || (_api$blockControls6 = api.blockControls) === null || _api$blockControls6 === void 0 || _api$blockControls6.commands.setNodeDragged(getPos, anchorName, nodeType)({
674
674
  tr: tr
675
675
  });
676
676
  tr.setMeta('scrollIntoView', false);
677
- api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.attachAnalyticsEvent({
677
+ api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
678
678
  eventType: EVENT_TYPE.UI,
679
679
  action: ACTION.DRAGGED,
680
680
  actionSubject: ACTION_SUBJECT.ELEMENT,
@@ -6,6 +6,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
6
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
7
  import { css, Global, jsx } from '@emotion/react';
8
8
  import { tableControlsSpacing, DRAG_HANDLE_WIDTH } from '@atlaskit/editor-common/styles';
9
+ import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
9
10
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
10
11
  import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
11
12
  import { akEditorBreakoutPadding, akEditorCalculatedWideLayoutWidth, akEditorCalculatedWideLayoutWidthSmallViewport, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout } from '@atlaskit/editor-shared-styles';
@@ -402,9 +403,12 @@ export var GlobalStylesWrapper = function GlobalStylesWrapper(_ref) {
402
403
  var isDragging = useSharedPluginStateSelector(api, 'blockControls.isDragging', {
403
404
  disabled: !expValEquals('platform_editor_block_controls_perf_optimization', 'isEnabled', true)
404
405
  });
406
+ var toolbarFlagsEnabled = areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
405
407
  return jsx(Global, {
406
408
  styles: [globalStyles(), globalDnDStyle, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? extendedHoverZoneNext() : extendedHoverZone(), isDragging && (expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? extendedDragZoneNext : extendedDragZone), editorExperiment('platform_editor_preview_panel_responsiveness', true, {
407
409
  exposure: true
408
- }) ? expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined, editorExperiment('platform_editor_controls', 'variant1') ? undefined : withInlineNodeStyle, editorExperiment('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) && expValEquals('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone]
410
+ }) ? expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? extendHoverZoneReducedNext : extendHoverZoneReduced : undefined,
411
+ // platform_editor_controls note: this allows drag handles to render on empty lines
412
+ toolbarFlagsEnabled ? undefined : withInlineNodeStyle, editorExperiment('platform_editor_block_control_optimise_render', true) ? quickInsertStyles : undefined, withDeleteLinesStyleFix, withMediaSingleStyleFix, legacyBreakoutWideLayoutStyle, headingWithIndentationInLayoutStyleFix, editorExperiment('advanced_layouts', true) ? blockCardWithoutLayout : undefined, withDividerInPanelStyleFix, withFormatInLayoutStyleFix, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? withRelativePosStyleNext : withRelativePosStyle, topLevelNodeMarginStyles, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) ? withAnchorNameZindexStyleNext : withAnchorNameZindexStyle, expValEquals('platform_editor_native_anchor_support', 'isEnabled', true) && expValEquals('advanced_layouts', 'isEnabled', true) ? layoutColumnExtendedHoverZone : layoutColumnWithoutHoverZone]
409
413
  });
410
414
  };
@@ -10,6 +10,7 @@ import type { LimitedModePlugin } from '@atlaskit/editor-plugin-limited-mode';
10
10
  import type { MetricsPlugin } from '@atlaskit/editor-plugin-metrics';
11
11
  import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
12
12
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
13
+ import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
13
14
  import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
14
15
  import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
15
16
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
@@ -101,7 +102,8 @@ export type BlockControlsPluginDependencies = [
101
102
  OptionalPlugin<SelectionPlugin>,
102
103
  OptionalPlugin<MetricsPlugin>,
103
104
  OptionalPlugin<InteractionPlugin>,
104
- OptionalPlugin<UserIntentPlugin>
105
+ OptionalPlugin<UserIntentPlugin>,
106
+ OptionalPlugin<ToolbarPlugin>
105
107
  ];
106
108
  export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
107
109
  commands: {
@@ -10,6 +10,7 @@ import { AnchorRectCache } from './utils/anchor-utils';
10
10
  export declare const key: PluginKey<PluginState>;
11
11
  export interface FlagType {
12
12
  isMultiSelectEnabled: boolean;
13
+ toolbarFlagsEnabled: boolean;
13
14
  }
14
15
  export declare const getDecorations: (state: EditorState) => DecorationSet | undefined;
15
16
  export declare const apply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape["formatMessage"], tr: ReadonlyTransaction, currentState: PluginState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, anchorRectCache?: AnchorRectCache, resizeObserverWidth?: ResizeObserver, pragmaticCleanup?: (() => void) | null) => PluginState | {
@@ -1,13 +1,15 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
1
2
  import { type ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
3
  import { type EditorState, NodeSelection, TextSelection, type Transaction, type Selection } from '@atlaskit/editor-prosemirror/state';
4
+ import type { BlockControlsPlugin } from '../../blockControlsPluginType';
3
5
  export declare const getInlineNodePos: (tr: Transaction, start: number, nodeSize: number) => {
4
6
  inlineNodeEndPos: number;
5
7
  inlineNodePos: number;
6
8
  };
7
9
  export declare const isNodeWithCodeBlock: (tr: Transaction, start: number, nodeSize: number) => boolean;
8
- export declare const getSelection: (tr: Transaction, start: number) => false | NodeSelection | TextSelection;
9
- export declare const selectNode: (tr: Transaction, start: number, nodeType: string) => Transaction;
10
- export declare const setCursorPositionAtMovedNode: (tr: Transaction, start: number) => Transaction;
10
+ export declare const getSelection: (tr: Transaction, start: number, api?: ExtractInjectionAPI<BlockControlsPlugin>) => false | NodeSelection | TextSelection;
11
+ export declare const selectNode: (tr: Transaction, start: number, nodeType: string, api?: ExtractInjectionAPI<BlockControlsPlugin>) => Transaction;
12
+ export declare const setCursorPositionAtMovedNode: (tr: Transaction, start: number, api?: ExtractInjectionAPI<BlockControlsPlugin>) => Transaction;
11
13
  /**
12
14
  * Checks if handle position is with the selection or corresponds to a (partially) selected node
13
15
  * @param state
@@ -1,5 +1,6 @@
1
1
  import type { ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
2
2
  import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
3
+ import type { FlagType } from '../main';
3
4
  interface TransactionMetadata {
4
5
  from: number;
5
6
  isAllText: boolean;
@@ -26,5 +27,5 @@ export declare const isStepDelete: (s: ReplaceStep) => boolean;
26
27
  * Number of ReplaceStep and ReplaceAroundStep steps 'numReplaceSteps'.
27
28
  * 'isAllText' if all steps are represent adding inline text or a backspace/delete or no-op
28
29
  */
29
- export declare const getTrMetadata: (tr: Transaction | ReadonlyTransaction) => TransactionMetadata;
30
+ export declare const getTrMetadata: (tr: Transaction | ReadonlyTransaction, flags: FlagType) => TransactionMetadata;
30
31
  export {};
@@ -10,6 +10,7 @@ import type { LimitedModePlugin } from '@atlaskit/editor-plugin-limited-mode';
10
10
  import type { MetricsPlugin } from '@atlaskit/editor-plugin-metrics';
11
11
  import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
12
12
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
13
+ import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
13
14
  import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
14
15
  import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
15
16
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
@@ -101,7 +102,8 @@ export type BlockControlsPluginDependencies = [
101
102
  OptionalPlugin<SelectionPlugin>,
102
103
  OptionalPlugin<MetricsPlugin>,
103
104
  OptionalPlugin<InteractionPlugin>,
104
- OptionalPlugin<UserIntentPlugin>
105
+ OptionalPlugin<UserIntentPlugin>,
106
+ OptionalPlugin<ToolbarPlugin>
105
107
  ];
106
108
  export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
107
109
  commands: {
@@ -10,6 +10,7 @@ import { AnchorRectCache } from './utils/anchor-utils';
10
10
  export declare const key: PluginKey<PluginState>;
11
11
  export interface FlagType {
12
12
  isMultiSelectEnabled: boolean;
13
+ toolbarFlagsEnabled: boolean;
13
14
  }
14
15
  export declare const getDecorations: (state: EditorState) => DecorationSet | undefined;
15
16
  export declare const apply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape["formatMessage"], tr: ReadonlyTransaction, currentState: PluginState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, anchorRectCache?: AnchorRectCache, resizeObserverWidth?: ResizeObserver, pragmaticCleanup?: (() => void) | null) => PluginState | {
@@ -1,13 +1,15 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
1
2
  import { type ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
3
  import { type EditorState, NodeSelection, TextSelection, type Transaction, type Selection } from '@atlaskit/editor-prosemirror/state';
4
+ import type { BlockControlsPlugin } from '../../blockControlsPluginType';
3
5
  export declare const getInlineNodePos: (tr: Transaction, start: number, nodeSize: number) => {
4
6
  inlineNodeEndPos: number;
5
7
  inlineNodePos: number;
6
8
  };
7
9
  export declare const isNodeWithCodeBlock: (tr: Transaction, start: number, nodeSize: number) => boolean;
8
- export declare const getSelection: (tr: Transaction, start: number) => false | NodeSelection | TextSelection;
9
- export declare const selectNode: (tr: Transaction, start: number, nodeType: string) => Transaction;
10
- export declare const setCursorPositionAtMovedNode: (tr: Transaction, start: number) => Transaction;
10
+ export declare const getSelection: (tr: Transaction, start: number, api?: ExtractInjectionAPI<BlockControlsPlugin>) => false | NodeSelection | TextSelection;
11
+ export declare const selectNode: (tr: Transaction, start: number, nodeType: string, api?: ExtractInjectionAPI<BlockControlsPlugin>) => Transaction;
12
+ export declare const setCursorPositionAtMovedNode: (tr: Transaction, start: number, api?: ExtractInjectionAPI<BlockControlsPlugin>) => Transaction;
11
13
  /**
12
14
  * Checks if handle position is with the selection or corresponds to a (partially) selected node
13
15
  * @param state
@@ -1,5 +1,6 @@
1
1
  import type { ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
2
2
  import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
3
+ import type { FlagType } from '../main';
3
4
  interface TransactionMetadata {
4
5
  from: number;
5
6
  isAllText: boolean;
@@ -26,5 +27,5 @@ export declare const isStepDelete: (s: ReplaceStep) => boolean;
26
27
  * Number of ReplaceStep and ReplaceAroundStep steps 'numReplaceSteps'.
27
28
  * 'isAllText' if all steps are represent adding inline text or a backspace/delete or no-op
28
29
  */
29
- export declare const getTrMetadata: (tr: Transaction | ReadonlyTransaction) => TransactionMetadata;
30
+ export declare const getTrMetadata: (tr: Transaction | ReadonlyTransaction, flags: FlagType) => TransactionMetadata;
30
31
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "7.4.2",
3
+ "version": "7.5.0",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
- "@atlaskit/adf-schema": "^51.3.0",
31
+ "@atlaskit/adf-schema": "^51.3.1",
32
32
  "@atlaskit/editor-plugin-accessibility-utils": "^6.0.0",
33
33
  "@atlaskit/editor-plugin-analytics": "^6.2.0",
34
34
  "@atlaskit/editor-plugin-editor-disabled": "^6.1.0",
@@ -38,6 +38,7 @@
38
38
  "@atlaskit/editor-plugin-metrics": "^7.1.0",
39
39
  "@atlaskit/editor-plugin-quick-insert": "^6.0.0",
40
40
  "@atlaskit/editor-plugin-selection": "^6.1.0",
41
+ "@atlaskit/editor-plugin-toolbar": "^3.4.0",
41
42
  "@atlaskit/editor-plugin-type-ahead": "^6.5.0",
42
43
  "@atlaskit/editor-plugin-user-intent": "^4.0.0",
43
44
  "@atlaskit/editor-plugin-width": "^7.0.0",
@@ -64,7 +65,7 @@
64
65
  "uuid": "^3.1.0"
65
66
  },
66
67
  "peerDependencies": {
67
- "@atlaskit/editor-common": "^110.16.0",
68
+ "@atlaskit/editor-common": "^110.18.0",
68
69
  "react": "^18.2.0",
69
70
  "react-dom": "^18.2.0",
70
71
  "react-intl-next": "npm:react-intl@^5.18.1"