@atlaskit/editor-plugin-selection-extension 3.4.0 → 3.4.2
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 +17 -0
- package/dist/cjs/selectionExtensionPlugin.js +75 -35
- package/dist/cjs/ui/LegacyToolbarComponent.js +120 -0
- package/dist/cjs/ui/extensions.js +60 -0
- package/dist/cjs/ui/getBoundingBoxFromSelection.js +7 -0
- package/dist/cjs/ui/selectionToolbar.js +32 -5
- package/dist/es2019/selectionExtensionPlugin.js +63 -27
- package/dist/es2019/ui/LegacyToolbarComponent.js +109 -0
- package/dist/es2019/ui/extensions.js +54 -0
- package/dist/es2019/ui/getBoundingBoxFromSelection.js +7 -1
- package/dist/es2019/ui/selectionToolbar.js +38 -14
- package/dist/esm/selectionExtensionPlugin.js +75 -35
- package/dist/esm/ui/LegacyToolbarComponent.js +111 -0
- package/dist/esm/ui/extensions.js +54 -0
- package/dist/esm/ui/getBoundingBoxFromSelection.js +7 -0
- package/dist/esm/ui/selectionToolbar.js +31 -5
- package/dist/types/index.d.ts +1 -1
- package/dist/types/selectionExtensionPluginType.d.ts +4 -0
- package/dist/types/types/index.d.ts +41 -1
- package/dist/types/ui/LegacyToolbarComponent.d.ts +16 -0
- package/dist/types/ui/extensions.d.ts +27 -0
- package/dist/types/ui/getBoundingBoxFromSelection.d.ts +3 -2
- package/dist/types/ui/selectionToolbar.d.ts +7 -17
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/selectionExtensionPluginType.d.ts +4 -0
- package/dist/types-ts4.5/types/index.d.ts +41 -1
- package/dist/types-ts4.5/ui/LegacyToolbarComponent.d.ts +16 -0
- package/dist/types-ts4.5/ui/extensions.d.ts +27 -0
- package/dist/types-ts4.5/ui/getBoundingBoxFromSelection.d.ts +3 -2
- package/dist/types-ts4.5/ui/selectionToolbar.d.ts +7 -17
- package/package.json +10 -4
|
@@ -1,7 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { getToolbarItemExtensions } from './extensions';
|
|
5
|
+
import { LegacyExtensionToolbarItem } from './LegacyToolbarComponent';
|
|
6
|
+
export var selectionToolbar = function selectionToolbar(_ref) {
|
|
7
|
+
var overflowOptions = _ref.overflowOptions,
|
|
8
|
+
_ref$extensionList = _ref.extensionList,
|
|
9
|
+
extensionList = _ref$extensionList === void 0 ? [] : _ref$extensionList;
|
|
10
|
+
var inlineToolbarItemExtensions = fg('platform_editor_selection_extension_api_v2') ? getToolbarItemExtensions(extensionList, 'inlineToolbar') : [];
|
|
2
11
|
return {
|
|
3
|
-
|
|
4
|
-
|
|
12
|
+
items: [].concat(_toConsumableArray(inlineToolbarItemExtensions.length ? [{
|
|
13
|
+
type: 'separator',
|
|
14
|
+
fullHeight: true,
|
|
15
|
+
supportsViewMode: true
|
|
16
|
+
}].concat(_toConsumableArray(inlineToolbarItemExtensions.map(function (_ref2) {
|
|
17
|
+
var getToolbarItem = _ref2.getToolbarItem,
|
|
18
|
+
getMenuItems = _ref2.getMenuItems;
|
|
19
|
+
return {
|
|
20
|
+
type: 'custom',
|
|
21
|
+
render: function render() {
|
|
22
|
+
return /*#__PURE__*/React.createElement(LegacyExtensionToolbarItem, {
|
|
23
|
+
toolbarItem: getToolbarItem(),
|
|
24
|
+
getMenuItems: getMenuItems
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
fallback: [],
|
|
28
|
+
supportsViewMode: true
|
|
29
|
+
};
|
|
30
|
+
}))) : []), [{
|
|
5
31
|
type: 'separator',
|
|
6
32
|
fullHeight: true,
|
|
7
33
|
supportsViewMode: true
|
|
@@ -9,8 +35,8 @@ export var selectionToolbar = function selectionToolbar(options) {
|
|
|
9
35
|
type: 'overflow-dropdown',
|
|
10
36
|
dropdownWidth: 240,
|
|
11
37
|
supportsViewMode: true,
|
|
12
|
-
options:
|
|
13
|
-
}],
|
|
38
|
+
options: overflowOptions
|
|
39
|
+
}]),
|
|
14
40
|
rank: -6
|
|
15
41
|
};
|
|
16
42
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { selectionExtensionPlugin } from './selectionExtensionPlugin';
|
|
2
2
|
export type { SelectionExtensionPlugin } from './selectionExtensionPluginType';
|
|
3
|
-
export type {
|
|
3
|
+
export type { BlockMenuExtensionConfiguration, DynamicSelectionExtension, ExtensionConfiguration, ExtensionMenuItemConfiguration, ExtensionToolbarItemConfiguration, InsertAdfAtEndOfDocResult, LinkInsertionOption, ReplaceWithAdfResult, SelectionExtension, SelectionExtensionComponentProps, SelectionExtensionConfig, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, ToolbarExtensionConfiguration, } from './types';
|
|
@@ -2,13 +2,17 @@ import { type ADFEntity } from '@atlaskit/adf-utils/types';
|
|
|
2
2
|
import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
4
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
5
|
+
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
5
6
|
import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
|
|
7
|
+
import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
|
|
6
8
|
import type { DynamicSelectionExtension, InsertAdfAtEndOfDocResult, LinkInsertionOption, ReplaceWithAdfResult, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
|
|
7
9
|
export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
8
10
|
pluginConfiguration: SelectionExtensionPluginOptions | undefined;
|
|
9
11
|
dependencies: [
|
|
10
12
|
OptionalPlugin<AnalyticsPlugin>,
|
|
11
13
|
OptionalPlugin<EditorViewModePlugin>,
|
|
14
|
+
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
15
|
+
OptionalPlugin<UserPreferencesPlugin>,
|
|
12
16
|
SelectionToolbarPlugin
|
|
13
17
|
];
|
|
14
18
|
sharedState: SelectionExtensionPluginState | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ADFEntity } from '@atlaskit/adf-utils/types';
|
|
3
|
-
import {
|
|
3
|
+
import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
4
4
|
import type { ViewMode } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
5
5
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
export type MenuItemsType = Array<{
|
|
@@ -61,6 +61,7 @@ type SelectionExtensionModes = ViewMode;
|
|
|
61
61
|
export type SelectionExtensionPluginOptions = {
|
|
62
62
|
pageModes?: SelectionExtensionModes | SelectionExtensionModes[];
|
|
63
63
|
extensions?: SelectionExtensions;
|
|
64
|
+
extensionList?: ExtensionConfiguration[];
|
|
64
65
|
};
|
|
65
66
|
/**
|
|
66
67
|
* @private
|
|
@@ -74,6 +75,10 @@ export type SelectionExtensionCoords = {
|
|
|
74
75
|
top: number;
|
|
75
76
|
bottom: number;
|
|
76
77
|
};
|
|
78
|
+
export type BoundingBoxOffset = {
|
|
79
|
+
top: number;
|
|
80
|
+
bottom: number;
|
|
81
|
+
};
|
|
77
82
|
export type InsertPosition = {
|
|
78
83
|
pointer: string;
|
|
79
84
|
from?: number;
|
|
@@ -117,4 +122,39 @@ export type ReplaceWithAdfResult = {
|
|
|
117
122
|
export type InsertAdfAtEndOfDocResult = {
|
|
118
123
|
status: 'success' | 'failed';
|
|
119
124
|
};
|
|
125
|
+
export type ExtensionSource = 'first-party' | 'external';
|
|
126
|
+
export type ExtensionConfiguration = {
|
|
127
|
+
key: string;
|
|
128
|
+
source: ExtensionSource;
|
|
129
|
+
inlineToolbar?: ToolbarExtensionConfiguration;
|
|
130
|
+
primaryToolbar?: ToolbarExtensionConfiguration;
|
|
131
|
+
blockMenu?: BlockMenuExtensionConfiguration;
|
|
132
|
+
};
|
|
133
|
+
export type GetToolbarItemFn = () => ExtensionToolbarItemConfiguration;
|
|
134
|
+
export type GetMenuItemsFn = () => ExtensionMenuItemConfiguration[];
|
|
135
|
+
export type ToolbarExtensionConfiguration = {
|
|
136
|
+
getToolbarItem?: GetToolbarItemFn;
|
|
137
|
+
getMenuItems?: GetMenuItemsFn;
|
|
138
|
+
};
|
|
139
|
+
export type BlockMenuExtensionConfiguration = {
|
|
140
|
+
getMenuItems?: GetMenuItemsFn;
|
|
141
|
+
};
|
|
142
|
+
export type ExtensionToolbarItemConfiguration = {
|
|
143
|
+
icon: React.ComponentType<React.PropsWithChildren<{
|
|
144
|
+
label: string;
|
|
145
|
+
}>>;
|
|
146
|
+
tooltip: string;
|
|
147
|
+
isDisabled?: boolean;
|
|
148
|
+
onClick?: () => void;
|
|
149
|
+
label?: string;
|
|
150
|
+
};
|
|
151
|
+
export type ExtensionMenuItemConfiguration = {
|
|
152
|
+
label: string;
|
|
153
|
+
icon: React.ComponentType<React.PropsWithChildren<{
|
|
154
|
+
label: string;
|
|
155
|
+
}>>;
|
|
156
|
+
onClick?: () => void;
|
|
157
|
+
isDisabled?: boolean;
|
|
158
|
+
contentComponent?: React.ComponentType<SelectionExtensionComponentProps>;
|
|
159
|
+
};
|
|
120
160
|
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ExtensionToolbarItemConfiguration, GetMenuItemsFn, GetToolbarItemFn } from '../types';
|
|
3
|
+
export type ToolbarItemExtension = {
|
|
4
|
+
getToolbarItem: GetToolbarItemFn;
|
|
5
|
+
getMenuItems?: GetMenuItemsFn;
|
|
6
|
+
};
|
|
7
|
+
type LegacyPrimaryToolbarComponentProps = {
|
|
8
|
+
primaryToolbarItemExtensions: ToolbarItemExtension[];
|
|
9
|
+
};
|
|
10
|
+
export declare const LegacyPrimaryToolbarComponent: ({ primaryToolbarItemExtensions, }: LegacyPrimaryToolbarComponentProps) => React.JSX.Element;
|
|
11
|
+
type LegacyExtensionToolbarItemProps = {
|
|
12
|
+
toolbarItem: ExtensionToolbarItemConfiguration;
|
|
13
|
+
getMenuItems?: GetMenuItemsFn;
|
|
14
|
+
};
|
|
15
|
+
export declare const LegacyExtensionToolbarItem: ({ toolbarItem, getMenuItems, }: LegacyExtensionToolbarItemProps) => React.JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ExtensionConfiguration, ExtensionSource, GetMenuItemsFn, GetToolbarItemFn, SelectionExtensionConfig } from '../types';
|
|
2
|
+
export type ToolbarItemExtension = {
|
|
3
|
+
getToolbarItem: GetToolbarItemFn;
|
|
4
|
+
getMenuItems?: GetMenuItemsFn;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* From the full list of extensions, extract only those that have a toolbar item configuration
|
|
8
|
+
* for the specified type (either 'primaryToolbar' or 'inlineToolbar').
|
|
9
|
+
*
|
|
10
|
+
* @param extensionList - List of all extensions
|
|
11
|
+
* @param toolbarType - Type of toolbar ('primaryToolbar' or 'inlineToolbar')
|
|
12
|
+
* @returns Array of ToolbarItemExtension objects
|
|
13
|
+
* @example
|
|
14
|
+
*/
|
|
15
|
+
export declare const getToolbarItemExtensions: (extensionList: ExtensionConfiguration[], toolbarType: 'primaryToolbar' | 'inlineToolbar') => ToolbarItemExtension[];
|
|
16
|
+
/**
|
|
17
|
+
* From the full list of extensions, extract only those that have a menu item configuration
|
|
18
|
+
* for the specified source (either 'first-party' or 'external').
|
|
19
|
+
*
|
|
20
|
+
* Map each to the legacy format for SelectionExtensionConfig.
|
|
21
|
+
*
|
|
22
|
+
* @param extensionList - List of all extensions
|
|
23
|
+
* @param targetSource - Source of the extensions ('first-party' or 'external')
|
|
24
|
+
* @returns Array of SelectionExtensionConfig objects
|
|
25
|
+
* @example
|
|
26
|
+
*/
|
|
27
|
+
export declare const getMenuItemExtensions: (extensionList: ExtensionConfiguration[], targetSource: ExtensionSource) => SelectionExtensionConfig[];
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
import type { SelectionExtensionCoords } from '../types';
|
|
2
|
+
import type { SelectionExtensionCoords, BoundingBoxOffset } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Calculates the bounding box coordinates of a text selection within an editor view.
|
|
5
5
|
*
|
|
6
6
|
* @param view - The editor view instance.
|
|
7
7
|
* @param from - The starting position of the selection.
|
|
8
8
|
* @param to - The ending position of the selection.
|
|
9
|
+
* @param offset - Optional offset to adjust the top and bottom coordinates of the bounding box.`
|
|
9
10
|
* @returns An object containing the top, left, bottom, and right coordinates of the bounding box.
|
|
10
11
|
*/
|
|
11
|
-
export declare const getBoundingBoxFromSelection: (view: EditorView, from: number, to: number) => SelectionExtensionCoords;
|
|
12
|
+
export declare const getBoundingBoxFromSelection: (view: EditorView, from: number, to: number, offset?: BoundingBoxOffset) => SelectionExtensionCoords;
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
fullHeight: boolean;
|
|
7
|
-
supportsViewMode: boolean;
|
|
8
|
-
dropdownWidth?: undefined;
|
|
9
|
-
options?: undefined;
|
|
10
|
-
} | {
|
|
11
|
-
type: "overflow-dropdown";
|
|
12
|
-
dropdownWidth: number;
|
|
13
|
-
supportsViewMode: boolean;
|
|
14
|
-
options: FloatingToolbarOverflowDropdownOptions<Command>;
|
|
15
|
-
fullHeight?: undefined;
|
|
16
|
-
})[];
|
|
17
|
-
rank: number;
|
|
1
|
+
import type { Command, FloatingToolbarOverflowDropdownOptions, SelectionToolbarGroup } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { ExtensionConfiguration } from '../types';
|
|
3
|
+
type SelectionToolbarOptions = {
|
|
4
|
+
overflowOptions: FloatingToolbarOverflowDropdownOptions<Command>;
|
|
5
|
+
extensionList?: ExtensionConfiguration[];
|
|
18
6
|
};
|
|
7
|
+
export declare const selectionToolbar: ({ overflowOptions, extensionList, }: SelectionToolbarOptions) => SelectionToolbarGroup;
|
|
8
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { selectionExtensionPlugin } from './selectionExtensionPlugin';
|
|
2
2
|
export type { SelectionExtensionPlugin } from './selectionExtensionPluginType';
|
|
3
|
-
export type {
|
|
3
|
+
export type { BlockMenuExtensionConfiguration, DynamicSelectionExtension, ExtensionConfiguration, ExtensionMenuItemConfiguration, ExtensionToolbarItemConfiguration, InsertAdfAtEndOfDocResult, LinkInsertionOption, ReplaceWithAdfResult, SelectionExtension, SelectionExtensionComponentProps, SelectionExtensionConfig, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, ToolbarExtensionConfiguration, } from './types';
|
|
@@ -2,13 +2,17 @@ import { type ADFEntity } from '@atlaskit/adf-utils/types';
|
|
|
2
2
|
import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
4
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
5
|
+
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
5
6
|
import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
|
|
7
|
+
import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
|
|
6
8
|
import type { DynamicSelectionExtension, InsertAdfAtEndOfDocResult, LinkInsertionOption, ReplaceWithAdfResult, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
|
|
7
9
|
export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
8
10
|
pluginConfiguration: SelectionExtensionPluginOptions | undefined;
|
|
9
11
|
dependencies: [
|
|
10
12
|
OptionalPlugin<AnalyticsPlugin>,
|
|
11
13
|
OptionalPlugin<EditorViewModePlugin>,
|
|
14
|
+
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
15
|
+
OptionalPlugin<UserPreferencesPlugin>,
|
|
12
16
|
SelectionToolbarPlugin
|
|
13
17
|
];
|
|
14
18
|
sharedState: SelectionExtensionPluginState | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ADFEntity } from '@atlaskit/adf-utils/types';
|
|
3
|
-
import {
|
|
3
|
+
import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
4
4
|
import type { ViewMode } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
5
5
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
export type MenuItemsType = Array<{
|
|
@@ -61,6 +61,7 @@ type SelectionExtensionModes = ViewMode;
|
|
|
61
61
|
export type SelectionExtensionPluginOptions = {
|
|
62
62
|
pageModes?: SelectionExtensionModes | SelectionExtensionModes[];
|
|
63
63
|
extensions?: SelectionExtensions;
|
|
64
|
+
extensionList?: ExtensionConfiguration[];
|
|
64
65
|
};
|
|
65
66
|
/**
|
|
66
67
|
* @private
|
|
@@ -74,6 +75,10 @@ export type SelectionExtensionCoords = {
|
|
|
74
75
|
top: number;
|
|
75
76
|
bottom: number;
|
|
76
77
|
};
|
|
78
|
+
export type BoundingBoxOffset = {
|
|
79
|
+
top: number;
|
|
80
|
+
bottom: number;
|
|
81
|
+
};
|
|
77
82
|
export type InsertPosition = {
|
|
78
83
|
pointer: string;
|
|
79
84
|
from?: number;
|
|
@@ -117,4 +122,39 @@ export type ReplaceWithAdfResult = {
|
|
|
117
122
|
export type InsertAdfAtEndOfDocResult = {
|
|
118
123
|
status: 'success' | 'failed';
|
|
119
124
|
};
|
|
125
|
+
export type ExtensionSource = 'first-party' | 'external';
|
|
126
|
+
export type ExtensionConfiguration = {
|
|
127
|
+
key: string;
|
|
128
|
+
source: ExtensionSource;
|
|
129
|
+
inlineToolbar?: ToolbarExtensionConfiguration;
|
|
130
|
+
primaryToolbar?: ToolbarExtensionConfiguration;
|
|
131
|
+
blockMenu?: BlockMenuExtensionConfiguration;
|
|
132
|
+
};
|
|
133
|
+
export type GetToolbarItemFn = () => ExtensionToolbarItemConfiguration;
|
|
134
|
+
export type GetMenuItemsFn = () => ExtensionMenuItemConfiguration[];
|
|
135
|
+
export type ToolbarExtensionConfiguration = {
|
|
136
|
+
getToolbarItem?: GetToolbarItemFn;
|
|
137
|
+
getMenuItems?: GetMenuItemsFn;
|
|
138
|
+
};
|
|
139
|
+
export type BlockMenuExtensionConfiguration = {
|
|
140
|
+
getMenuItems?: GetMenuItemsFn;
|
|
141
|
+
};
|
|
142
|
+
export type ExtensionToolbarItemConfiguration = {
|
|
143
|
+
icon: React.ComponentType<React.PropsWithChildren<{
|
|
144
|
+
label: string;
|
|
145
|
+
}>>;
|
|
146
|
+
tooltip: string;
|
|
147
|
+
isDisabled?: boolean;
|
|
148
|
+
onClick?: () => void;
|
|
149
|
+
label?: string;
|
|
150
|
+
};
|
|
151
|
+
export type ExtensionMenuItemConfiguration = {
|
|
152
|
+
label: string;
|
|
153
|
+
icon: React.ComponentType<React.PropsWithChildren<{
|
|
154
|
+
label: string;
|
|
155
|
+
}>>;
|
|
156
|
+
onClick?: () => void;
|
|
157
|
+
isDisabled?: boolean;
|
|
158
|
+
contentComponent?: React.ComponentType<SelectionExtensionComponentProps>;
|
|
159
|
+
};
|
|
120
160
|
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ExtensionToolbarItemConfiguration, GetMenuItemsFn, GetToolbarItemFn } from '../types';
|
|
3
|
+
export type ToolbarItemExtension = {
|
|
4
|
+
getToolbarItem: GetToolbarItemFn;
|
|
5
|
+
getMenuItems?: GetMenuItemsFn;
|
|
6
|
+
};
|
|
7
|
+
type LegacyPrimaryToolbarComponentProps = {
|
|
8
|
+
primaryToolbarItemExtensions: ToolbarItemExtension[];
|
|
9
|
+
};
|
|
10
|
+
export declare const LegacyPrimaryToolbarComponent: ({ primaryToolbarItemExtensions, }: LegacyPrimaryToolbarComponentProps) => React.JSX.Element;
|
|
11
|
+
type LegacyExtensionToolbarItemProps = {
|
|
12
|
+
toolbarItem: ExtensionToolbarItemConfiguration;
|
|
13
|
+
getMenuItems?: GetMenuItemsFn;
|
|
14
|
+
};
|
|
15
|
+
export declare const LegacyExtensionToolbarItem: ({ toolbarItem, getMenuItems, }: LegacyExtensionToolbarItemProps) => React.JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ExtensionConfiguration, ExtensionSource, GetMenuItemsFn, GetToolbarItemFn, SelectionExtensionConfig } from '../types';
|
|
2
|
+
export type ToolbarItemExtension = {
|
|
3
|
+
getToolbarItem: GetToolbarItemFn;
|
|
4
|
+
getMenuItems?: GetMenuItemsFn;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* From the full list of extensions, extract only those that have a toolbar item configuration
|
|
8
|
+
* for the specified type (either 'primaryToolbar' or 'inlineToolbar').
|
|
9
|
+
*
|
|
10
|
+
* @param extensionList - List of all extensions
|
|
11
|
+
* @param toolbarType - Type of toolbar ('primaryToolbar' or 'inlineToolbar')
|
|
12
|
+
* @returns Array of ToolbarItemExtension objects
|
|
13
|
+
* @example
|
|
14
|
+
*/
|
|
15
|
+
export declare const getToolbarItemExtensions: (extensionList: ExtensionConfiguration[], toolbarType: 'primaryToolbar' | 'inlineToolbar') => ToolbarItemExtension[];
|
|
16
|
+
/**
|
|
17
|
+
* From the full list of extensions, extract only those that have a menu item configuration
|
|
18
|
+
* for the specified source (either 'first-party' or 'external').
|
|
19
|
+
*
|
|
20
|
+
* Map each to the legacy format for SelectionExtensionConfig.
|
|
21
|
+
*
|
|
22
|
+
* @param extensionList - List of all extensions
|
|
23
|
+
* @param targetSource - Source of the extensions ('first-party' or 'external')
|
|
24
|
+
* @returns Array of SelectionExtensionConfig objects
|
|
25
|
+
* @example
|
|
26
|
+
*/
|
|
27
|
+
export declare const getMenuItemExtensions: (extensionList: ExtensionConfiguration[], targetSource: ExtensionSource) => SelectionExtensionConfig[];
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
import type { SelectionExtensionCoords } from '../types';
|
|
2
|
+
import type { SelectionExtensionCoords, BoundingBoxOffset } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Calculates the bounding box coordinates of a text selection within an editor view.
|
|
5
5
|
*
|
|
6
6
|
* @param view - The editor view instance.
|
|
7
7
|
* @param from - The starting position of the selection.
|
|
8
8
|
* @param to - The ending position of the selection.
|
|
9
|
+
* @param offset - Optional offset to adjust the top and bottom coordinates of the bounding box.`
|
|
9
10
|
* @returns An object containing the top, left, bottom, and right coordinates of the bounding box.
|
|
10
11
|
*/
|
|
11
|
-
export declare const getBoundingBoxFromSelection: (view: EditorView, from: number, to: number) => SelectionExtensionCoords;
|
|
12
|
+
export declare const getBoundingBoxFromSelection: (view: EditorView, from: number, to: number, offset?: BoundingBoxOffset) => SelectionExtensionCoords;
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
fullHeight: boolean;
|
|
7
|
-
supportsViewMode: boolean;
|
|
8
|
-
dropdownWidth?: undefined;
|
|
9
|
-
options?: undefined;
|
|
10
|
-
} | {
|
|
11
|
-
type: "overflow-dropdown";
|
|
12
|
-
dropdownWidth: number;
|
|
13
|
-
supportsViewMode: boolean;
|
|
14
|
-
options: FloatingToolbarOverflowDropdownOptions<Command>;
|
|
15
|
-
fullHeight?: undefined;
|
|
16
|
-
})[];
|
|
17
|
-
rank: number;
|
|
1
|
+
import type { Command, FloatingToolbarOverflowDropdownOptions, SelectionToolbarGroup } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { ExtensionConfiguration } from '../types';
|
|
3
|
+
type SelectionToolbarOptions = {
|
|
4
|
+
overflowOptions: FloatingToolbarOverflowDropdownOptions<Command>;
|
|
5
|
+
extensionList?: ExtensionConfiguration[];
|
|
18
6
|
};
|
|
7
|
+
export declare const selectionToolbar: ({ overflowOptions, extensionList, }: SelectionToolbarOptions) => SelectionToolbarGroup;
|
|
8
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection-extension",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.2",
|
|
4
4
|
"description": "editor-plugin-selection-extension plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,23 +36,26 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@atlaskit/adf-utils": "^19.20.0",
|
|
39
|
-
"@atlaskit/editor-json-transformer": "^8.
|
|
39
|
+
"@atlaskit/editor-json-transformer": "^8.25.0",
|
|
40
40
|
"@atlaskit/editor-plugin-analytics": "^3.0.0",
|
|
41
41
|
"@atlaskit/editor-plugin-editor-viewmode": "^5.0.0",
|
|
42
|
+
"@atlaskit/editor-plugin-primary-toolbar": "^4.1.0",
|
|
42
43
|
"@atlaskit/editor-plugin-selection-toolbar": "^4.2.0",
|
|
44
|
+
"@atlaskit/editor-plugin-user-preferences": "^1.2.0",
|
|
43
45
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
46
|
+
"@atlaskit/editor-shared-styles": "^3.5.0",
|
|
44
47
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
45
48
|
"@atlaskit/icon": "^27.8.0",
|
|
46
49
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
47
50
|
"@atlaskit/primitives": "^14.11.0",
|
|
48
|
-
"@atlaskit/tmp-editor-statsig": "^9.
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^9.20.0",
|
|
49
52
|
"@babel/runtime": "^7.0.0",
|
|
50
53
|
"lodash": "^4.17.21",
|
|
51
54
|
"react-intl-next": "npm:react-intl@^5.18.1",
|
|
52
55
|
"uuid": "^3.1.0"
|
|
53
56
|
},
|
|
54
57
|
"peerDependencies": {
|
|
55
|
-
"@atlaskit/editor-common": "^107.
|
|
58
|
+
"@atlaskit/editor-common": "^107.16.0",
|
|
56
59
|
"react": "^18.2.0"
|
|
57
60
|
},
|
|
58
61
|
"devDependencies": {
|
|
@@ -109,6 +112,9 @@
|
|
|
109
112
|
},
|
|
110
113
|
"platform_editor_selection_extension_api_v2": {
|
|
111
114
|
"type": "boolean"
|
|
115
|
+
},
|
|
116
|
+
"platform_editor_use_preferences_plugin": {
|
|
117
|
+
"type": "boolean"
|
|
112
118
|
}
|
|
113
119
|
}
|
|
114
120
|
}
|