@atlaskit/editor-plugin-selection-extension 3.0.1 → 3.1.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 +20 -0
- package/dist/cjs/pm-plugins/actions.js +93 -0
- package/dist/cjs/pm-plugins/main.js +21 -0
- package/dist/cjs/pm-plugins/utils/getOffsetByPath.js +83 -0
- package/dist/cjs/pm-plugins/utils/index.js +23 -6
- package/dist/cjs/selectionExtensionPlugin.js +29 -2
- package/dist/cjs/types/index.js +2 -0
- package/dist/cjs/ui/extension/SelectionExtensionComponentWrapper.js +12 -6
- package/dist/es2019/pm-plugins/actions.js +93 -0
- package/dist/es2019/pm-plugins/main.js +22 -0
- package/dist/es2019/pm-plugins/utils/getOffsetByPath.js +76 -0
- package/dist/es2019/pm-plugins/utils/index.js +22 -5
- package/dist/es2019/selectionExtensionPlugin.js +31 -2
- package/dist/es2019/types/index.js +2 -0
- package/dist/es2019/ui/extension/SelectionExtensionComponentWrapper.js +11 -4
- package/dist/esm/pm-plugins/actions.js +87 -0
- package/dist/esm/pm-plugins/main.js +21 -0
- package/dist/esm/pm-plugins/utils/getOffsetByPath.js +78 -0
- package/dist/esm/pm-plugins/utils/index.js +21 -5
- package/dist/esm/selectionExtensionPlugin.js +29 -2
- package/dist/esm/types/index.js +2 -0
- package/dist/esm/ui/extension/SelectionExtensionComponentWrapper.js +13 -7
- package/dist/types/pm-plugins/actions.d.ts +8 -0
- package/dist/types/pm-plugins/main.d.ts +24 -0
- package/dist/types/pm-plugins/utils/getOffsetByPath.d.ts +14 -0
- package/dist/types/pm-plugins/utils/index.d.ts +12 -2
- package/dist/types/selectionExtensionPluginType.d.ts +8 -1
- package/dist/types/types/index.d.ts +17 -1
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +8 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +24 -0
- package/dist/types-ts4.5/pm-plugins/utils/getOffsetByPath.d.ts +14 -0
- package/dist/types-ts4.5/pm-plugins/utils/index.d.ts +12 -2
- package/dist/types-ts4.5/selectionExtensionPluginType.d.ts +8 -1
- package/dist/types-ts4.5/types/index.d.ts +17 -1
- package/package.json +3 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ADFEntity } from '@atlaskit/adf-utils/types';
|
|
2
|
+
import type { CommandDispatch } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { type LinkInsertionOption } from '../types';
|
|
5
|
+
export declare const insertSmartLinks: (linkInsertionOption: LinkInsertionOption | LinkInsertionOption[], selectedNodeAdf: ADFEntity) => (state: EditorState, dispatch: CommandDispatch) => {
|
|
6
|
+
status: 'success' | 'error';
|
|
7
|
+
message?: string;
|
|
8
|
+
};
|
|
@@ -4,4 +4,28 @@ import { type SelectionExtensionPluginState } from '../types';
|
|
|
4
4
|
export declare const selectionExtensionPluginKey: PluginKey<SelectionExtensionPluginState>;
|
|
5
5
|
export declare const createPlugin: () => SafePlugin<SelectionExtensionPluginState | {
|
|
6
6
|
activeExtension: any;
|
|
7
|
+
selectedNode?: import("prosemirror-model").Node | undefined;
|
|
8
|
+
nodePos?: number | undefined;
|
|
9
|
+
startTrackChanges?: boolean | undefined;
|
|
10
|
+
docChangedAfterClick?: boolean | undefined;
|
|
11
|
+
} | {
|
|
12
|
+
selectedNode: any;
|
|
13
|
+
nodePos: any;
|
|
14
|
+
startTrackChanges: boolean;
|
|
15
|
+
docChangedAfterClick: boolean;
|
|
16
|
+
activeExtension?: {
|
|
17
|
+
extension: import("../types").SelectionExtension;
|
|
18
|
+
selection: import("../types").SelectionExtensionSelectionInfo;
|
|
19
|
+
coords: import("../types").SelectionExtensionCoords;
|
|
20
|
+
} | undefined;
|
|
21
|
+
} | {
|
|
22
|
+
startTrackChanges: any;
|
|
23
|
+
activeExtension?: {
|
|
24
|
+
extension: import("../types").SelectionExtension;
|
|
25
|
+
selection: import("../types").SelectionExtensionSelectionInfo;
|
|
26
|
+
coords: import("../types").SelectionExtensionCoords;
|
|
27
|
+
} | undefined;
|
|
28
|
+
selectedNode?: import("prosemirror-model").Node | undefined;
|
|
29
|
+
nodePos?: number | undefined;
|
|
30
|
+
docChangedAfterClick?: boolean | undefined;
|
|
7
31
|
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
export interface NodeOffset {
|
|
3
|
+
type: 'node';
|
|
4
|
+
from: number;
|
|
5
|
+
to: number;
|
|
6
|
+
matches: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface AttrsOffset {
|
|
9
|
+
type: 'attrs';
|
|
10
|
+
from: number;
|
|
11
|
+
path: string[];
|
|
12
|
+
}
|
|
13
|
+
export type Offset = NodeOffset | AttrsOffset;
|
|
14
|
+
export declare function getOffsetByPath(root: PMNode, pos: number, pointer: string, from?: number, to?: number): Offset;
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import { type ADFEntity } from '@atlaskit/adf-utils/types';
|
|
2
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
1
3
|
import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { type
|
|
3
|
-
|
|
4
|
+
import { type SelectionRange } from '../../types';
|
|
5
|
+
type SelectionInfo = {
|
|
6
|
+
selectedNodeAdf: ADFEntity;
|
|
7
|
+
selectionRanges: SelectionRange[];
|
|
8
|
+
selectedNode: PMNode;
|
|
9
|
+
nodePos: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const getSelectionInfo: (state: EditorState) => SelectionInfo;
|
|
12
|
+
export declare const validateSelectedNode: (selectedNodeAdf: ADFEntity, selectedNode: PMNode) => boolean;
|
|
13
|
+
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { type ADFEntity } from '@atlaskit/adf-utils/types';
|
|
1
2
|
import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
4
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
4
5
|
import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
|
|
5
|
-
import type { SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
|
|
6
|
+
import type { LinkInsertionOption, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
|
|
6
7
|
export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
7
8
|
pluginConfiguration: SelectionExtensionPluginOptions | undefined;
|
|
8
9
|
dependencies: [
|
|
@@ -18,4 +19,10 @@ export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
|
18
19
|
}) => EditorCommand;
|
|
19
20
|
clearActiveExtension: () => EditorCommand;
|
|
20
21
|
};
|
|
22
|
+
actions: {
|
|
23
|
+
insertSmartLinks: (linkInsertionOption: LinkInsertionOption | LinkInsertionOption[], selectedNodeAdf: ADFEntity) => {
|
|
24
|
+
status: 'success' | 'error';
|
|
25
|
+
message?: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
21
28
|
}>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { ADFEntity } from '@atlaskit/adf-utils/types';
|
|
3
3
|
import { type MenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
4
4
|
import type { ViewMode } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
5
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
6
|
export type MenuItemsType = Array<{
|
|
6
7
|
items: MenuItem[];
|
|
7
8
|
}>;
|
|
@@ -70,10 +71,21 @@ export type SelectionExtensionCoords = {
|
|
|
70
71
|
top: number;
|
|
71
72
|
bottom: number;
|
|
72
73
|
};
|
|
74
|
+
export type InsertPosition = {
|
|
75
|
+
pointer: string;
|
|
76
|
+
from?: number;
|
|
77
|
+
to?: number;
|
|
78
|
+
};
|
|
79
|
+
export type LinkInsertionOption = {
|
|
80
|
+
link: string;
|
|
81
|
+
insertPosition: InsertPosition;
|
|
82
|
+
};
|
|
73
83
|
export declare enum SelectionExtensionActionTypes {
|
|
74
84
|
SET_ACTIVE_EXTENSION = "set-active-extension",
|
|
75
85
|
UPDATE_ACTIVE_EXTENSION_COORDS = "update-active-extension-coords",
|
|
76
|
-
CLEAR_ACTIVE_EXTENSION = "clear-active-extension"
|
|
86
|
+
CLEAR_ACTIVE_EXTENSION = "clear-active-extension",
|
|
87
|
+
SET_SELECTED_NODE = "set-selected-node",
|
|
88
|
+
START_TRACK_CHANGES = "start-track-changes"
|
|
77
89
|
}
|
|
78
90
|
export type UpdateActiveExtensionAction = {
|
|
79
91
|
type: SelectionExtensionActionTypes.SET_ACTIVE_EXTENSION;
|
|
@@ -90,5 +102,9 @@ export type SelectionExtensionPluginState = {
|
|
|
90
102
|
selection: SelectionExtensionSelectionInfo;
|
|
91
103
|
coords: SelectionExtensionCoords;
|
|
92
104
|
};
|
|
105
|
+
selectedNode?: PMNode;
|
|
106
|
+
nodePos?: number;
|
|
107
|
+
startTrackChanges?: boolean;
|
|
108
|
+
docChangedAfterClick?: boolean;
|
|
93
109
|
};
|
|
94
110
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection-extension",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "editor-plugin-selection-extension plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -45,8 +45,9 @@
|
|
|
45
45
|
"@atlaskit/icon": "^27.3.0",
|
|
46
46
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
47
47
|
"@atlaskit/primitives": "^14.10.0",
|
|
48
|
-
"@atlaskit/tmp-editor-statsig": "^9.
|
|
48
|
+
"@atlaskit/tmp-editor-statsig": "^9.1.0",
|
|
49
49
|
"@babel/runtime": "^7.0.0",
|
|
50
|
+
"lodash": "^4.17.21",
|
|
50
51
|
"react-intl-next": "npm:react-intl@^5.18.1",
|
|
51
52
|
"uuid": "^3.1.0"
|
|
52
53
|
},
|