@atlaskit/editor-plugin-block-controls 1.13.11 → 2.0.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.
@@ -74,7 +74,7 @@ var getDropTargetOffsetStyle = function getDropTargetOffsetStyle(prevNode, nextN
74
74
  export var DropTarget = function DropTarget(_ref3) {
75
75
  var _dynamicStyle;
76
76
  var api = _ref3.api,
77
- id = _ref3.id,
77
+ getPos = _ref3.getPos,
78
78
  prevNode = _ref3.prevNode,
79
79
  nextNode = _ref3.nextNode,
80
80
  parentNode = _ref3.parentNode,
@@ -106,15 +106,11 @@ export var DropTarget = function DropTarget(_ref3) {
106
106
  onDrop: function onDrop() {
107
107
  var _api$blockControls;
108
108
  var _ref4 = (api === null || api === void 0 || (_api$blockControls = api.blockControls) === null || _api$blockControls === void 0 ? void 0 : _api$blockControls.sharedState.currentState()) || {},
109
- activeNode = _ref4.activeNode,
110
- decorationState = _ref4.decorationState;
111
- if (!activeNode || !decorationState) {
109
+ activeNode = _ref4.activeNode;
110
+ if (!activeNode) {
112
111
  return;
113
112
  }
114
- var _ref5 = decorationState.find(function (dec) {
115
- return dec.id === id;
116
- }) || {},
117
- pos = _ref5.pos;
113
+ var pos = getPos();
118
114
  if (activeNode && pos !== undefined) {
119
115
  var _api$core, _api$blockControls2;
120
116
  var start = activeNode.pos;
@@ -122,7 +118,7 @@ export var DropTarget = function DropTarget(_ref3) {
122
118
  }
123
119
  }
124
120
  });
125
- }, [id, api, formatMessage]);
121
+ }, [api, formatMessage, getPos]);
126
122
  var dropTargetOffsetStyle = useMemo(function () {
127
123
  /**
128
124
  * First child of a nested node.
@@ -5,17 +5,18 @@ export var getSelection = function getSelection(tr, start) {
5
5
  var isNodeSelection = node && NodeSelection.isSelectable(node);
6
6
  var nodeSize = node ? node.nodeSize : 1;
7
7
  var $startPos = tr.doc.resolve(start);
8
+ var nodeName = node === null || node === void 0 ? void 0 : node.type.name;
8
9
 
9
10
  // decisionList node is not selectable, but we want to select the whole node not just text
10
- if (isNodeSelection || (node === null || node === void 0 ? void 0 : node.type.name) === 'decisionList') {
11
+ if (isNodeSelection || nodeName === 'decisionList') {
11
12
  return new NodeSelection($startPos);
12
- } else if ((node === null || node === void 0 ? void 0 : node.type.name) === 'mediaGroup' && node.childCount === 1) {
13
+ } else if (nodeName === 'mediaGroup' && (node === null || node === void 0 ? void 0 : node.childCount) === 1) {
13
14
  var $mediaStartPos = tr.doc.resolve(start + 1);
14
15
  return new NodeSelection($mediaStartPos);
15
16
  } else if (
16
17
  // Even though mediaGroup is not selectable,
17
18
  // we need a quick way to make all child media nodes appear as selected without the need for a custom selection
18
- (node === null || node === void 0 ? void 0 : node.type.name) === 'mediaGroup') {
19
+ nodeName === 'mediaGroup') {
19
20
  return new NodeSelection($startPos);
20
21
  } else {
21
22
  // To trigger the annotation floating toolbar for non-selectable node, we need to select inline nodes
@@ -1,2 +1,2 @@
1
1
  export { blockControlsPlugin } from './plugin';
2
- export type { BlockControlsPlugin, DecorationState, BlockControlsSharedState, HandleOptions, MoveNodeMethod, } from './types';
2
+ export type { BlockControlsPlugin, BlockControlsSharedState, HandleOptions, MoveNodeMethod, } from './types';
@@ -3,13 +3,7 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
4
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { ActiveNode, BlockControlsPlugin, HandleOptions } from '../types';
6
- export declare const dropTargetDecorations: (newState: EditorState, api: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage: IntlShape['formatMessage'], activeNode?: ActiveNode) => {
7
- decs: Decoration[];
8
- decorationState: {
9
- id: number;
10
- pos: number;
11
- }[];
12
- };
6
+ export declare const dropTargetDecorations: (newState: EditorState, api: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage: IntlShape['formatMessage'], activeNode?: ActiveNode) => Decoration[];
13
7
  export declare const emptyParagraphNodeDecorations: () => Decoration;
14
8
  export declare const nodeDecorations: (newState: EditorState) => Decoration[];
15
9
  export declare const dragHandleDecoration: (api: ExtractInjectionAPI<BlockControlsPlugin>, getIntl: () => IntlShape, pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => Decoration;
@@ -16,13 +16,12 @@ export type ActiveNode = {
16
16
  };
17
17
  export interface PluginState {
18
18
  decorations: DecorationSet;
19
- decorationState: DecorationState;
20
19
  isDragging: boolean;
21
20
  isMenuOpen?: boolean;
22
21
  editorHeight: number;
23
22
  editorWidthLeft: number;
24
23
  editorWidthRight: number;
25
- activeNode: ActiveNode | null;
24
+ activeNode?: ActiveNode;
26
25
  isResizerResizing: boolean;
27
26
  /**
28
27
  * @private
@@ -38,8 +37,7 @@ export interface PluginState {
38
37
  export type ReleaseHiddenDecoration = () => boolean | undefined;
39
38
  export type BlockControlsSharedState = {
40
39
  isMenuOpen: boolean;
41
- activeNode: ActiveNode | null;
42
- decorationState: DecorationState;
40
+ activeNode?: ActiveNode;
43
41
  isDragging: boolean;
44
42
  isPMDragging: boolean;
45
43
  } | undefined;
@@ -63,13 +61,9 @@ export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
63
61
  commands: {
64
62
  moveNode: (start: number, to: number, inputMethod?: MoveNodeMethod, formatMessage?: IntlShape['formatMessage']) => EditorCommand;
65
63
  showDragHandleAt: (pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => EditorCommand;
66
- setNodeDragged: (posNumber: number, anchorName: string, nodeType: string) => EditorCommand;
64
+ setNodeDragged: (getPos: () => number | undefined, anchorName: string, nodeType: string) => EditorCommand;
67
65
  };
68
66
  }>;
69
- export type DecorationState = {
70
- id: number;
71
- pos: number;
72
- }[];
73
67
  export type BlockControlsMeta = {
74
68
  activeNode: ActiveNode;
75
69
  type: string;
@@ -5,10 +5,10 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { BlockControlsPlugin } from '../types';
6
6
  export type DropTargetProps = {
7
7
  api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
8
- id: number;
8
+ getPos: () => number | undefined;
9
9
  prevNode?: PMNode;
10
10
  nextNode?: PMNode;
11
11
  parentNode?: PMNode;
12
12
  formatMessage?: IntlShape['formatMessage'];
13
13
  };
14
- export declare const DropTarget: ({ api, id, prevNode, nextNode, parentNode, formatMessage, }: DropTargetProps) => jsx.JSX.Element;
14
+ export declare const DropTarget: ({ api, getPos, prevNode, nextNode, parentNode, formatMessage, }: DropTargetProps) => jsx.JSX.Element;
@@ -1,2 +1,2 @@
1
1
  export { blockControlsPlugin } from './plugin';
2
- export type { BlockControlsPlugin, DecorationState, BlockControlsSharedState, HandleOptions, MoveNodeMethod, } from './types';
2
+ export type { BlockControlsPlugin, BlockControlsSharedState, HandleOptions, MoveNodeMethod, } from './types';
@@ -3,13 +3,7 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
4
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { ActiveNode, BlockControlsPlugin, HandleOptions } from '../types';
6
- export declare const dropTargetDecorations: (newState: EditorState, api: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage: IntlShape['formatMessage'], activeNode?: ActiveNode) => {
7
- decs: Decoration[];
8
- decorationState: {
9
- id: number;
10
- pos: number;
11
- }[];
12
- };
6
+ export declare const dropTargetDecorations: (newState: EditorState, api: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage: IntlShape['formatMessage'], activeNode?: ActiveNode) => Decoration[];
13
7
  export declare const emptyParagraphNodeDecorations: () => Decoration;
14
8
  export declare const nodeDecorations: (newState: EditorState) => Decoration[];
15
9
  export declare const dragHandleDecoration: (api: ExtractInjectionAPI<BlockControlsPlugin>, getIntl: () => IntlShape, pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => Decoration;
@@ -16,13 +16,12 @@ export type ActiveNode = {
16
16
  };
17
17
  export interface PluginState {
18
18
  decorations: DecorationSet;
19
- decorationState: DecorationState;
20
19
  isDragging: boolean;
21
20
  isMenuOpen?: boolean;
22
21
  editorHeight: number;
23
22
  editorWidthLeft: number;
24
23
  editorWidthRight: number;
25
- activeNode: ActiveNode | null;
24
+ activeNode?: ActiveNode;
26
25
  isResizerResizing: boolean;
27
26
  /**
28
27
  * @private
@@ -38,8 +37,7 @@ export interface PluginState {
38
37
  export type ReleaseHiddenDecoration = () => boolean | undefined;
39
38
  export type BlockControlsSharedState = {
40
39
  isMenuOpen: boolean;
41
- activeNode: ActiveNode | null;
42
- decorationState: DecorationState;
40
+ activeNode?: ActiveNode;
43
41
  isDragging: boolean;
44
42
  isPMDragging: boolean;
45
43
  } | undefined;
@@ -63,13 +61,9 @@ export type BlockControlsPlugin = NextEditorPlugin<'blockControls', {
63
61
  commands: {
64
62
  moveNode: (start: number, to: number, inputMethod?: MoveNodeMethod, formatMessage?: IntlShape['formatMessage']) => EditorCommand;
65
63
  showDragHandleAt: (pos: number, anchorName: string, nodeType: string, handleOptions?: HandleOptions) => EditorCommand;
66
- setNodeDragged: (posNumber: number, anchorName: string, nodeType: string) => EditorCommand;
64
+ setNodeDragged: (getPos: () => number | undefined, anchorName: string, nodeType: string) => EditorCommand;
67
65
  };
68
66
  }>;
69
- export type DecorationState = {
70
- id: number;
71
- pos: number;
72
- }[];
73
67
  export type BlockControlsMeta = {
74
68
  activeNode: ActiveNode;
75
69
  type: string;
@@ -5,10 +5,10 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
5
  import type { BlockControlsPlugin } from '../types';
6
6
  export type DropTargetProps = {
7
7
  api: ExtractInjectionAPI<BlockControlsPlugin> | undefined;
8
- id: number;
8
+ getPos: () => number | undefined;
9
9
  prevNode?: PMNode;
10
10
  nextNode?: PMNode;
11
11
  parentNode?: PMNode;
12
12
  formatMessage?: IntlShape['formatMessage'];
13
13
  };
14
- export declare const DropTarget: ({ api, id, prevNode, nextNode, parentNode, formatMessage, }: DropTargetProps) => jsx.JSX.Element;
14
+ export declare const DropTarget: ({ api, getPos, prevNode, nextNode, parentNode, formatMessage, }: DropTargetProps) => jsx.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "1.13.11",
3
+ "version": "2.0.0",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -48,7 +48,7 @@
48
48
  "@atlaskit/primitives": "^12.1.0",
49
49
  "@atlaskit/theme": "^13.0.0",
50
50
  "@atlaskit/tmp-editor-statsig": "^2.1.0",
51
- "@atlaskit/tokens": "^1.59.0",
51
+ "@atlaskit/tokens": "^1.60.0",
52
52
  "@atlaskit/tooltip": "^18.7.0",
53
53
  "@babel/runtime": "^7.0.0",
54
54
  "@emotion/react": "^11.7.1",
@@ -128,6 +128,9 @@
128
128
  },
129
129
  "platform_editor_element_drag_and_drop_debug": {
130
130
  "type": "boolean"
131
+ },
132
+ "platform_editor_element_drag_and_drop_ed_24885": {
133
+ "type": "boolean"
131
134
  }
132
135
  }
133
136
  }