@atlaskit/editor-plugin-block-controls 2.23.0 → 2.24.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.
@@ -247,39 +247,27 @@ export var DragHandle = function DragHandle(_ref) {
247
247
  return;
248
248
  }
249
249
  api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.execute(function (_ref6) {
250
- var _api$blockControls, _api$analytics3;
250
+ var _api$blockControls2, _api$analytics3;
251
251
  var tr = _ref6.tr;
252
252
  var isMultiSelect = editorExperiment('platform_editor_element_drag_and_drop_multiselect', true, {
253
253
  exposure: true
254
254
  });
255
- var selectionStart = start;
256
255
  if (isMultiSelect) {
257
- var selection = tr.selection;
258
- var selectionFrom = selection.$from.pos;
259
- var selectionTo = selection.$to.pos;
260
- var $selectionFrom = tr.doc.resolve(selectionFrom);
261
- var $selectionTo = tr.doc.resolve(selectionTo);
262
- selectionStart = $selectionFrom.start();
263
- var selectionEnd = $selectionTo.end();
264
256
  var handlePos = getPos();
265
257
  if (typeof handlePos !== 'number') {
266
258
  return tr;
267
259
  }
268
- var posBeforeNode = $selectionFrom.pos ? $selectionFrom.start() - 1 : $selectionFrom.pos;
269
- var shouldExpandSelection = handlePos >= posBeforeNode && handlePos <= selectionEnd;
270
- if (shouldExpandSelection) {
271
- //TODO: What happens if not a text selection?
272
- var newSelection = TextSelection.create(tr.doc, selectionStart, selectionEnd);
273
- tr.setSelection(newSelection);
274
- } else {
275
- var _$selectionFrom = tr.doc.resolve(handlePos + 1);
276
- selectNode(tr, handlePos, _$selectionFrom.node().type.name);
260
+ if (!tr.selection.empty && handlePos >= tr.selection.$from.start() - 1 && handlePos <= tr.selection.to) {
261
+ var _api$blockControls;
262
+ api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.setMultiSelectPositions()({
263
+ tr: tr
264
+ });
277
265
  }
278
266
  }
279
- api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 || _api$blockControls.commands.setNodeDragged(getPos, anchorName, nodeType)({
267
+ api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || _api$blockControls2.commands.setNodeDragged(getPos, anchorName, nodeType)({
280
268
  tr: tr
281
269
  });
282
- var resolvedMovingNode = tr.doc.resolve(selectionStart);
270
+ var resolvedMovingNode = tr.doc.resolve(start);
283
271
  var maybeNode = resolvedMovingNode.nodeAfter;
284
272
  tr.setMeta('scrollIntoView', false);
285
273
  api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.attachAnalyticsEvent({
@@ -427,6 +415,9 @@ export var DragHandle = function DragHandle(_ref) {
427
415
  var message = helpDescriptors.map(function (descriptor) {
428
416
  return descriptor.keymap ? [descriptor.description, getAriaKeyshortcuts(descriptor.keymap)] : [descriptor.description];
429
417
  }).join('. ');
418
+ var handleOnDrop = function handleOnDrop(event) {
419
+ editorExperiment('platform_editor_element_drag_and_drop_multiselect', true) && event.stopPropagation();
420
+ };
430
421
  var renderButton = function renderButton() {
431
422
  return (
432
423
  // eslint-disable-next-line @atlaskit/design-system/no-html-button
@@ -442,7 +433,10 @@ export var DragHandle = function DragHandle(_ref) {
442
433
  style: positionStyles,
443
434
  onClick: handleOnClick,
444
435
  onMouseDown: handleMouseDown,
445
- onKeyDown: handleKeyDown,
436
+ onKeyDown: handleKeyDown
437
+ // eslint-disable-next-line @atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop
438
+ ,
439
+ onDrop: handleOnDrop,
446
440
  "data-testid": "block-ctrl-drag-handle"
447
441
  }, jsx(Box, {
448
442
  as: "span",
@@ -6,6 +6,7 @@ import { type AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
6
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
7
7
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
8
8
  import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
9
+ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
9
10
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
10
11
  import { type DecorationSet } from '@atlaskit/editor-prosemirror/view';
11
12
  export type ActiveNode = {
@@ -14,6 +15,14 @@ export type ActiveNode = {
14
15
  nodeType: string;
15
16
  handleOptions?: HandleOptions;
16
17
  };
18
+ export type MultiSelectDnD = {
19
+ anchor: number;
20
+ head: number;
21
+ textAnchor: number;
22
+ textHead: number;
23
+ userAnchor: number;
24
+ userHead: number;
25
+ };
17
26
  export interface PluginState {
18
27
  decorations: DecorationSet;
19
28
  isDragging: boolean;
@@ -32,6 +41,7 @@ export interface PluginState {
32
41
  * is dragging the node without using drag handle, i,e, native prosemirror DnD
33
42
  */
34
43
  isPMDragging: boolean;
44
+ multiSelectDnD?: MultiSelectDnD;
35
45
  }
36
46
  export type ReleaseHiddenDecoration = () => boolean | undefined;
37
47
  export type BlockControlsSharedState = {
@@ -39,6 +49,7 @@ export type BlockControlsSharedState = {
39
49
  activeNode?: ActiveNode;
40
50
  isDragging: boolean;
41
51
  isPMDragging: boolean;
52
+ multiSelectDnD?: MultiSelectDnD;
42
53
  } | undefined;
43
54
  export type HandleOptions = {
44
55
  isFocused: boolean;
@@ -54,7 +65,8 @@ export type BlockControlsPluginDependencies = [
54
65
  * For Typeahead - Empty line prompt experiment
55
66
  * Clean up ticket ED-24824
56
67
  */
57
- OptionalPlugin<QuickInsertPlugin>
68
+ OptionalPlugin<QuickInsertPlugin>,
69
+ OptionalPlugin<SelectionPlugin>
58
70
  ];
59
71
  export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
60
72
  dependencies: BlockControlsPluginDependencies;
@@ -74,6 +86,7 @@ export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
74
86
  moveNode: MoveNode;
75
87
  showDragHandleAt: (pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => EditorCommand;
76
88
  setNodeDragged: (getPos: () => number | undefined, anchorName: string, nodeType: string) => EditorCommand;
89
+ setMultiSelectPositions: () => EditorCommand;
77
90
  };
78
91
  }>;
79
92
  export type BlockControlsMeta = {
@@ -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
  isNestedEnabled: boolean;
13
+ isMultiSelectEnabled: boolean;
13
14
  }
14
15
  export declare const newApply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, anchorRectCache?: AnchorRectCache) => {
15
16
  decorations: DecorationSet;
@@ -22,6 +23,7 @@ export declare const newApply: (api: ExtractInjectionAPI<BlockControlsPlugin> |
22
23
  isResizerResizing: boolean;
23
24
  isDocSizeLimitEnabled: boolean | null;
24
25
  isPMDragging: any;
26
+ multiSelectDnD: any;
25
27
  };
26
28
  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) => {
27
29
  decorations: DecorationSet;
@@ -0,0 +1,6 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { BlockControlsPlugin } from '../../blockControlsPluginType';
3
+ export declare const getMultiSelectionIfPosInside: (api: ExtractInjectionAPI<BlockControlsPlugin>, pos: number) => {
4
+ anchor?: number;
5
+ head?: number;
6
+ };
@@ -6,6 +6,7 @@ import { type AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
6
6
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
7
7
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
8
8
  import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
9
+ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
9
10
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
10
11
  import { type DecorationSet } from '@atlaskit/editor-prosemirror/view';
11
12
  export type ActiveNode = {
@@ -14,6 +15,14 @@ export type ActiveNode = {
14
15
  nodeType: string;
15
16
  handleOptions?: HandleOptions;
16
17
  };
18
+ export type MultiSelectDnD = {
19
+ anchor: number;
20
+ head: number;
21
+ textAnchor: number;
22
+ textHead: number;
23
+ userAnchor: number;
24
+ userHead: number;
25
+ };
17
26
  export interface PluginState {
18
27
  decorations: DecorationSet;
19
28
  isDragging: boolean;
@@ -32,6 +41,7 @@ export interface PluginState {
32
41
  * is dragging the node without using drag handle, i,e, native prosemirror DnD
33
42
  */
34
43
  isPMDragging: boolean;
44
+ multiSelectDnD?: MultiSelectDnD;
35
45
  }
36
46
  export type ReleaseHiddenDecoration = () => boolean | undefined;
37
47
  export type BlockControlsSharedState = {
@@ -39,6 +49,7 @@ export type BlockControlsSharedState = {
39
49
  activeNode?: ActiveNode;
40
50
  isDragging: boolean;
41
51
  isPMDragging: boolean;
52
+ multiSelectDnD?: MultiSelectDnD;
42
53
  } | undefined;
43
54
  export type HandleOptions = {
44
55
  isFocused: boolean;
@@ -54,7 +65,8 @@ export type BlockControlsPluginDependencies = [
54
65
  * For Typeahead - Empty line prompt experiment
55
66
  * Clean up ticket ED-24824
56
67
  */
57
- OptionalPlugin<QuickInsertPlugin>
68
+ OptionalPlugin<QuickInsertPlugin>,
69
+ OptionalPlugin<SelectionPlugin>
58
70
  ];
59
71
  export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
60
72
  dependencies: BlockControlsPluginDependencies;
@@ -74,6 +86,7 @@ export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
74
86
  moveNode: MoveNode;
75
87
  showDragHandleAt: (pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => EditorCommand;
76
88
  setNodeDragged: (getPos: () => number | undefined, anchorName: string, nodeType: string) => EditorCommand;
89
+ setMultiSelectPositions: () => EditorCommand;
77
90
  };
78
91
  }>;
79
92
  export type BlockControlsMeta = {
@@ -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
  isNestedEnabled: boolean;
13
+ isMultiSelectEnabled: boolean;
13
14
  }
14
15
  export declare const newApply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, anchorRectCache?: AnchorRectCache) => {
15
16
  decorations: DecorationSet;
@@ -22,6 +23,7 @@ export declare const newApply: (api: ExtractInjectionAPI<BlockControlsPlugin> |
22
23
  isResizerResizing: boolean;
23
24
  isDocSizeLimitEnabled: boolean | null;
24
25
  isPMDragging: any;
26
+ multiSelectDnD: any;
25
27
  };
26
28
  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) => {
27
29
  decorations: DecorationSet;
@@ -0,0 +1,6 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { BlockControlsPlugin } from '../../blockControlsPluginType';
3
+ export declare const getMultiSelectionIfPosInside: (api: ExtractInjectionAPI<BlockControlsPlugin>, pos: number) => {
4
+ anchor?: number;
5
+ head?: number;
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "2.23.0",
3
+ "version": "2.24.0",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,12 +31,13 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@atlaskit/adf-schema": "^46.1.0",
34
- "@atlaskit/editor-common": "^99.10.0",
34
+ "@atlaskit/editor-common": "^99.11.0",
35
35
  "@atlaskit/editor-plugin-accessibility-utils": "^1.4.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.12.0",
37
37
  "@atlaskit/editor-plugin-editor-disabled": "^1.5.0",
38
38
  "@atlaskit/editor-plugin-feature-flags": "^1.3.0",
39
39
  "@atlaskit/editor-plugin-quick-insert": "^1.10.0",
40
+ "@atlaskit/editor-plugin-selection": "^1.8.0",
40
41
  "@atlaskit/editor-plugin-width": "^2.1.0",
41
42
  "@atlaskit/editor-prosemirror": "7.0.0",
42
43
  "@atlaskit/editor-shared-styles": "^3.2.0",
@@ -48,7 +49,7 @@
48
49
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.2.0",
49
50
  "@atlaskit/primitives": "^13.5.0",
50
51
  "@atlaskit/theme": "^15.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^2.43.0",
52
+ "@atlaskit/tmp-editor-statsig": "^2.44.0",
52
53
  "@atlaskit/tokens": "^3.3.0",
53
54
  "@atlaskit/tooltip": "^19.1.0",
54
55
  "@babel/runtime": "^7.0.0",