@atlaskit/editor-plugin-block-controls 3.16.2 → 3.17.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.
@@ -22,6 +22,10 @@ export type ActiveNode = {
22
22
  rootAnchorName?: string;
23
23
  rootNodeType?: string;
24
24
  };
25
+ export type ActiveDropTargetNode = {
26
+ pos: number;
27
+ nodeTypeName: string | null;
28
+ };
25
29
  export type MultiSelectDnD = {
26
30
  anchor: number;
27
31
  head: number;
@@ -39,6 +43,7 @@ export interface PluginState {
39
43
  editorWidthLeft: number;
40
44
  editorWidthRight: number;
41
45
  activeNode?: ActiveNode;
46
+ activeDropTargetNode?: ActiveDropTargetNode;
42
47
  isResizerResizing: boolean;
43
48
  /**
44
49
  * @private
@@ -59,6 +64,7 @@ export type BlockControlsSharedState = {
59
64
  isMenuOpen: boolean;
60
65
  menuTriggerBy?: string;
61
66
  activeNode?: ActiveNode;
67
+ activeDropTargetNode?: ActiveDropTargetNode;
62
68
  isDragging: boolean;
63
69
  isPMDragging: boolean;
64
70
  multiSelectDnD?: MultiSelectDnD;
@@ -0,0 +1,9 @@
1
+ import { type IntlShape } from 'react-intl-next';
2
+ import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
3
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
+ import type { Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
5
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
6
+ import { Decoration } from '@atlaskit/editor-prosemirror/view';
7
+ import type { ActiveDropTargetNode, ActiveNode, BlockControlsPlugin } from '../blockControlsPluginType';
8
+ export declare const canMoveNodeOrSliceToPos: (state: EditorState, node: PMNode, parent: PMNode, index: number, $toPos: ResolvedPos, activeNode?: ActiveNode) => boolean | null;
9
+ export declare const getActiveDropTargetDecorations: (activeDropTargetNode: ActiveDropTargetNode, state: EditorState, api: ExtractInjectionAPI<BlockControlsPlugin>, formatMessage: IntlShape['formatMessage'], nodeViewPortalProviderAPI: PortalProviderAPI, activeNode?: ActiveNode) => Decoration[];
@@ -0,0 +1,22 @@
1
+ import type { Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
3
+ type SurroundingNodes = {
4
+ pos: number;
5
+ node: PMNode;
6
+ depth: number;
7
+ index: number;
8
+ parent: PMNode;
9
+ before: PMNode | null;
10
+ after: PMNode | null;
11
+ };
12
+ /**
13
+ * This function returns the surrounding nodes of a given resolved position in the editor.
14
+ * It provides the position, node, parent, before and after nodes, index, and depth.
15
+ * @param state current editor state
16
+ * @param $pos a resolved position in the editor state.
17
+ * @returns {SurroundingNodes} An object containing the surrounding nodes information.
18
+ * @example
19
+ * const surroundingNodes = findSurroundingNodes(state, $pos);
20
+ */
21
+ export declare const findSurroundingNodes: (state: EditorState, $pos: ResolvedPos, nodeType?: string | null) => SurroundingNodes;
22
+ export {};
@@ -5,7 +5,7 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
5
  import type { EditorState, ReadonlyTransaction } from '@atlaskit/editor-prosemirror/state';
6
6
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
7
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
8
- import type { BlockControlsPlugin, PluginState } from '../blockControlsPluginType';
8
+ import type { ActiveDropTargetNode, BlockControlsPlugin, PluginState } from '../blockControlsPluginType';
9
9
  import { AnchorRectCache } from './utils/anchor-utils';
10
10
  export declare const key: PluginKey<PluginState>;
11
11
  export interface FlagType {
@@ -15,6 +15,7 @@ export declare const getDecorations: (state: EditorState) => DecorationSet | und
15
15
  export declare const apply: (api: ExtractInjectionAPI<BlockControlsPlugin> | undefined, formatMessage: IntlShape['formatMessage'], tr: ReadonlyTransaction, currentState: PluginState, newState: EditorState, flags: FlagType, nodeViewPortalProviderAPI: PortalProviderAPI, anchorRectCache?: AnchorRectCache) => {
16
16
  decorations: DecorationSet;
17
17
  activeNode: any;
18
+ activeDropTargetNode: ActiveDropTargetNode | undefined;
18
19
  isDragging: any;
19
20
  isMenuOpen: boolean | undefined;
20
21
  menuTriggerBy: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "3.16.2",
3
+ "version": "3.17.0",
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": "^106.5.0",
36
+ "@atlaskit/editor-common": "^106.6.0",
37
37
  "@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^2.3.0",
39
39
  "@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
@@ -56,7 +56,7 @@
56
56
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^3.2.0",
57
57
  "@atlaskit/primitives": "^14.8.0",
58
58
  "@atlaskit/theme": "^18.0.0",
59
- "@atlaskit/tmp-editor-statsig": "^6.1.0",
59
+ "@atlaskit/tmp-editor-statsig": "^6.2.0",
60
60
  "@atlaskit/tokens": "^5.1.0",
61
61
  "@atlaskit/tooltip": "^20.3.0",
62
62
  "@babel/runtime": "^7.0.0",