@atlaskit/editor-plugin-selection 3.1.1 → 3.2.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/editor-plugin-selection
2
2
 
3
+ ## 3.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`265c1bf0cefa4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/265c1bf0cefa4) -
8
+ Sorted type and interface props to improve Atlaskit docs
9
+ - Updated dependencies
10
+
11
+ ## 3.2.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`22c631389088c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/22c631389088c) -
16
+ Add option to provide custom selection to get\* selection actions
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 3.1.1
4
23
 
5
24
  ### Patch Changes
@@ -6,12 +6,12 @@ export declare enum SelectionActionTypes {
6
6
  SET_RELATIVE_SELECTION = "SET_RELATIVE_SELECTION"
7
7
  }
8
8
  export interface SetDecorations {
9
- type: SelectionActionTypes.SET_DECORATIONS;
10
9
  decorationSet: DecorationSet;
11
10
  selection: Selection;
11
+ type: SelectionActionTypes.SET_DECORATIONS;
12
12
  }
13
13
  export interface SetRelativeSelection {
14
- type: SelectionActionTypes.SET_RELATIVE_SELECTION;
15
14
  selectionRelativeToNode?: RelativeSelectionPos;
15
+ type: SelectionActionTypes.SET_RELATIVE_SELECTION;
16
16
  }
17
17
  export type SelectionAction = SetDecorations | SetRelativeSelection;
@@ -10,14 +10,14 @@ export declare const setSelectionTopLevelBlocks: (tr: Transaction, event: React.
10
10
  left: number;
11
11
  top: number;
12
12
  }) => {
13
- pos: number;
14
13
  inside: number;
14
+ pos: number;
15
15
  } | null | void, editorFocused: boolean) => void;
16
16
  export declare const setCursorForTopLevelBlocks: (event: React.MouseEvent<any>, editorRef: HTMLElement, posAtCoords: (coords: {
17
17
  left: number;
18
18
  top: number;
19
19
  }) => {
20
- pos: number;
21
20
  inside: number;
21
+ pos: number;
22
22
  } | null | void, editorFocused: boolean) => Command;
23
23
  export declare const hasGapCursorPlugin: (state: EditorState) => boolean;
@@ -20,8 +20,8 @@ export declare const getNodesToDecorateFromSelection: (selection: Selection, doc
20
20
  pos: number;
21
21
  }[];
22
22
  export declare function shouldRecalcDecorations({ oldEditorState, newEditorState, }: {
23
- oldEditorState: EditorState;
24
23
  newEditorState: EditorState;
24
+ oldEditorState: EditorState;
25
25
  }): boolean;
26
26
  export declare const isSelectableContainerNode: (node?: PmNode | null) => boolean;
27
27
  export declare const isSelectableChildNode: (node?: PmNode | null) => boolean;
@@ -3,13 +3,13 @@ import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/
3
3
  import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
4
4
  import type { EditorSelectionAPI, SelectionPluginOptions } from './types';
5
5
  export type SelectionPlugin = NextEditorPlugin<'selection', {
6
- pluginConfiguration: SelectionPluginOptions | undefined;
7
6
  actions: EditorSelectionAPI;
8
- dependencies: [OptionalPlugin<InteractionPlugin>];
9
7
  commands: {
10
- displayGapCursor: (toggle: boolean) => EditorCommand;
11
8
  clearManualSelection: () => EditorCommand;
9
+ displayGapCursor: (toggle: boolean) => EditorCommand;
12
10
  setManualSelection: (anchor: number, head: number) => EditorCommand;
13
11
  };
12
+ dependencies: [OptionalPlugin<InteractionPlugin>];
13
+ pluginConfiguration: SelectionPluginOptions | undefined;
14
14
  sharedState: SelectionSharedState;
15
15
  }>;
@@ -11,21 +11,31 @@ export declare enum SelectionDirection {
11
11
  After = 1
12
12
  }
13
13
  export type SetSelectionRelativeToNode = (props: {
14
- selectionRelativeToNode?: RelativeSelectionPos;
15
14
  selection?: Selection | null;
15
+ selectionRelativeToNode?: RelativeSelectionPos;
16
16
  }) => (state: EditorState) => Transaction;
17
+ type SelectionUtilityOptions = {
18
+ /**
19
+ * Use a specific selection rather than the current which is the default
20
+ */
21
+ selection?: Selection;
22
+ };
17
23
  export type EditorSelectionAPI = {
18
- selectNearNode: SetSelectionRelativeToNode;
19
24
  /**
20
25
  * Gets the current selection fragment.
26
+ * @param props Options to customise the selection fragment
27
+ * @param props.selection Use a specific selection rather than the current
21
28
  * @returns The current selection fragment as an array of JSON nodes.
22
29
  */
23
- getSelectionFragment: () => JSONNode[] | null;
30
+ getSelectionFragment: (props?: SelectionUtilityOptions) => JSONNode[] | null;
24
31
  /**
25
32
  * Gets the current selection local IDs. This includes all local IDs
33
+ * @param props Options to customise the selection fragment
34
+ * @param props.selection Use a specific selection rather than the current
26
35
  * @returns The current selection local IDs as an array of strings.
27
36
  */
28
- getSelectionLocalIds: () => string[] | null;
37
+ getSelectionLocalIds: (props?: SelectionUtilityOptions) => string[] | null;
38
+ selectNearNode: SetSelectionRelativeToNode;
29
39
  };
30
40
  export interface SelectionPluginOptions extends LongPressSelectionPluginOptions {
31
41
  /**
@@ -6,12 +6,12 @@ export declare enum SelectionActionTypes {
6
6
  SET_RELATIVE_SELECTION = "SET_RELATIVE_SELECTION"
7
7
  }
8
8
  export interface SetDecorations {
9
- type: SelectionActionTypes.SET_DECORATIONS;
10
9
  decorationSet: DecorationSet;
11
10
  selection: Selection;
11
+ type: SelectionActionTypes.SET_DECORATIONS;
12
12
  }
13
13
  export interface SetRelativeSelection {
14
- type: SelectionActionTypes.SET_RELATIVE_SELECTION;
15
14
  selectionRelativeToNode?: RelativeSelectionPos;
15
+ type: SelectionActionTypes.SET_RELATIVE_SELECTION;
16
16
  }
17
17
  export type SelectionAction = SetDecorations | SetRelativeSelection;
@@ -10,14 +10,14 @@ export declare const setSelectionTopLevelBlocks: (tr: Transaction, event: React.
10
10
  left: number;
11
11
  top: number;
12
12
  }) => {
13
- pos: number;
14
13
  inside: number;
14
+ pos: number;
15
15
  } | null | void, editorFocused: boolean) => void;
16
16
  export declare const setCursorForTopLevelBlocks: (event: React.MouseEvent<any>, editorRef: HTMLElement, posAtCoords: (coords: {
17
17
  left: number;
18
18
  top: number;
19
19
  }) => {
20
- pos: number;
21
20
  inside: number;
21
+ pos: number;
22
22
  } | null | void, editorFocused: boolean) => Command;
23
23
  export declare const hasGapCursorPlugin: (state: EditorState) => boolean;
@@ -20,8 +20,8 @@ export declare const getNodesToDecorateFromSelection: (selection: Selection, doc
20
20
  pos: number;
21
21
  }[];
22
22
  export declare function shouldRecalcDecorations({ oldEditorState, newEditorState, }: {
23
- oldEditorState: EditorState;
24
23
  newEditorState: EditorState;
24
+ oldEditorState: EditorState;
25
25
  }): boolean;
26
26
  export declare const isSelectableContainerNode: (node?: PmNode | null) => boolean;
27
27
  export declare const isSelectableChildNode: (node?: PmNode | null) => boolean;
@@ -3,15 +3,15 @@ import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/
3
3
  import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
4
4
  import type { EditorSelectionAPI, SelectionPluginOptions } from './types';
5
5
  export type SelectionPlugin = NextEditorPlugin<'selection', {
6
- pluginConfiguration: SelectionPluginOptions | undefined;
7
6
  actions: EditorSelectionAPI;
8
- dependencies: [
9
- OptionalPlugin<InteractionPlugin>
10
- ];
11
7
  commands: {
12
- displayGapCursor: (toggle: boolean) => EditorCommand;
13
8
  clearManualSelection: () => EditorCommand;
9
+ displayGapCursor: (toggle: boolean) => EditorCommand;
14
10
  setManualSelection: (anchor: number, head: number) => EditorCommand;
15
11
  };
12
+ dependencies: [
13
+ OptionalPlugin<InteractionPlugin>
14
+ ];
15
+ pluginConfiguration: SelectionPluginOptions | undefined;
16
16
  sharedState: SelectionSharedState;
17
17
  }>;
@@ -11,21 +11,31 @@ export declare enum SelectionDirection {
11
11
  After = 1
12
12
  }
13
13
  export type SetSelectionRelativeToNode = (props: {
14
- selectionRelativeToNode?: RelativeSelectionPos;
15
14
  selection?: Selection | null;
15
+ selectionRelativeToNode?: RelativeSelectionPos;
16
16
  }) => (state: EditorState) => Transaction;
17
+ type SelectionUtilityOptions = {
18
+ /**
19
+ * Use a specific selection rather than the current which is the default
20
+ */
21
+ selection?: Selection;
22
+ };
17
23
  export type EditorSelectionAPI = {
18
- selectNearNode: SetSelectionRelativeToNode;
19
24
  /**
20
25
  * Gets the current selection fragment.
26
+ * @param props Options to customise the selection fragment
27
+ * @param props.selection Use a specific selection rather than the current
21
28
  * @returns The current selection fragment as an array of JSON nodes.
22
29
  */
23
- getSelectionFragment: () => JSONNode[] | null;
30
+ getSelectionFragment: (props?: SelectionUtilityOptions) => JSONNode[] | null;
24
31
  /**
25
32
  * Gets the current selection local IDs. This includes all local IDs
33
+ * @param props Options to customise the selection fragment
34
+ * @param props.selection Use a specific selection rather than the current
26
35
  * @returns The current selection local IDs as an array of strings.
27
36
  */
28
- getSelectionLocalIds: () => string[] | null;
37
+ getSelectionLocalIds: (props?: SelectionUtilityOptions) => string[] | null;
38
+ selectNearNode: SetSelectionRelativeToNode;
29
39
  };
30
40
  export interface SelectionPluginOptions extends LongPressSelectionPluginOptions {
31
41
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection",
3
- "version": "3.1.1",
3
+ "version": "3.2.1",
4
4
  "description": "Selection plugin for @atlaskit/editor-core",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -25,12 +25,12 @@
25
25
  "@atlaskit/editor-shared-styles": "^3.6.0",
26
26
  "@atlaskit/editor-tables": "^2.9.0",
27
27
  "@atlaskit/platform-feature-flags": "^1.1.0",
28
- "@atlaskit/tmp-editor-statsig": "^11.3.0",
28
+ "@atlaskit/tmp-editor-statsig": "^11.5.0",
29
29
  "@atlaskit/tokens": "^6.0.0",
30
30
  "@babel/runtime": "^7.0.0"
31
31
  },
32
32
  "peerDependencies": {
33
- "@atlaskit/editor-common": "^107.27.0",
33
+ "@atlaskit/editor-common": "^107.28.0",
34
34
  "react": "^18.2.0"
35
35
  },
36
36
  "techstack": {