@atlaskit/editor-plugin-selection-extension 3.4.0 → 3.4.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.
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { ADFEntity } from '@atlaskit/adf-utils/types';
3
- import { type MenuItem } from '@atlaskit/editor-common/ui-menu';
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
@@ -117,4 +118,39 @@ export type ReplaceWithAdfResult = {
117
118
  export type InsertAdfAtEndOfDocResult = {
118
119
  status: 'success' | 'failed';
119
120
  };
121
+ export type ExtensionSource = 'first-party' | 'external';
122
+ export type ExtensionConfiguration = {
123
+ key: string;
124
+ source: ExtensionSource;
125
+ inlineToolbar?: ToolbarExtensionConfiguration;
126
+ primaryToolbar?: ToolbarExtensionConfiguration;
127
+ blockMenu?: BlockMenuExtensionConfiguration;
128
+ };
129
+ export type GetToolbarItemFn = () => ExtensionToolbarItemConfiguration;
130
+ export type GetMenuItemsFn = () => ExtensionMenuItemConfiguration[];
131
+ export type ToolbarExtensionConfiguration = {
132
+ getToolbarItem?: GetToolbarItemFn;
133
+ getMenuItems?: GetMenuItemsFn;
134
+ };
135
+ export type BlockMenuExtensionConfiguration = {
136
+ getMenuItems?: GetMenuItemsFn;
137
+ };
138
+ export type ExtensionToolbarItemConfiguration = {
139
+ icon: React.ComponentType<React.PropsWithChildren<{
140
+ label: string;
141
+ }>>;
142
+ tooltip: string;
143
+ isDisabled?: boolean;
144
+ onClick?: () => void;
145
+ label?: string;
146
+ };
147
+ export type ExtensionMenuItemConfiguration = {
148
+ label: string;
149
+ icon: React.ComponentType<React.PropsWithChildren<{
150
+ label: string;
151
+ }>>;
152
+ onClick?: () => void;
153
+ isDisabled?: boolean;
154
+ contentComponent?: React.ComponentType<SelectionExtensionComponentProps>;
155
+ };
120
156
  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,18 +1,8 @@
1
- import { type Command, type FloatingToolbarOverflowDropdownOptions } from '@atlaskit/editor-common/types';
2
- export declare const selectionToolbar: (options: FloatingToolbarOverflowDropdownOptions<Command>) => {
3
- isToolbarAbove: boolean;
4
- items: ({
5
- type: "separator";
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 { SelectionExtensionComponentProps, SelectionExtensionPluginOptions, SelectionExtension, LinkInsertionOption, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, DynamicSelectionExtension, ReplaceWithAdfResult, InsertAdfAtEndOfDocResult, } from './types';
3
+ export type { BlockMenuExtensionConfiguration, DynamicSelectionExtension, ExtensionConfiguration, ExtensionMenuItemConfiguration, ExtensionToolbarItemConfiguration, InsertAdfAtEndOfDocResult, LinkInsertionOption, ReplaceWithAdfResult, SelectionExtension, SelectionExtensionComponentProps, SelectionExtensionConfig, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, ToolbarExtensionConfiguration, } from './types';
@@ -2,6 +2,7 @@ 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';
6
7
  import type { DynamicSelectionExtension, InsertAdfAtEndOfDocResult, LinkInsertionOption, ReplaceWithAdfResult, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
7
8
  export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
@@ -9,6 +10,7 @@ export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
9
10
  dependencies: [
10
11
  OptionalPlugin<AnalyticsPlugin>,
11
12
  OptionalPlugin<EditorViewModePlugin>,
13
+ OptionalPlugin<PrimaryToolbarPlugin>,
12
14
  SelectionToolbarPlugin
13
15
  ];
14
16
  sharedState: SelectionExtensionPluginState | null;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { ADFEntity } from '@atlaskit/adf-utils/types';
3
- import { type MenuItem } from '@atlaskit/editor-common/ui-menu';
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
@@ -117,4 +118,39 @@ export type ReplaceWithAdfResult = {
117
118
  export type InsertAdfAtEndOfDocResult = {
118
119
  status: 'success' | 'failed';
119
120
  };
121
+ export type ExtensionSource = 'first-party' | 'external';
122
+ export type ExtensionConfiguration = {
123
+ key: string;
124
+ source: ExtensionSource;
125
+ inlineToolbar?: ToolbarExtensionConfiguration;
126
+ primaryToolbar?: ToolbarExtensionConfiguration;
127
+ blockMenu?: BlockMenuExtensionConfiguration;
128
+ };
129
+ export type GetToolbarItemFn = () => ExtensionToolbarItemConfiguration;
130
+ export type GetMenuItemsFn = () => ExtensionMenuItemConfiguration[];
131
+ export type ToolbarExtensionConfiguration = {
132
+ getToolbarItem?: GetToolbarItemFn;
133
+ getMenuItems?: GetMenuItemsFn;
134
+ };
135
+ export type BlockMenuExtensionConfiguration = {
136
+ getMenuItems?: GetMenuItemsFn;
137
+ };
138
+ export type ExtensionToolbarItemConfiguration = {
139
+ icon: React.ComponentType<React.PropsWithChildren<{
140
+ label: string;
141
+ }>>;
142
+ tooltip: string;
143
+ isDisabled?: boolean;
144
+ onClick?: () => void;
145
+ label?: string;
146
+ };
147
+ export type ExtensionMenuItemConfiguration = {
148
+ label: string;
149
+ icon: React.ComponentType<React.PropsWithChildren<{
150
+ label: string;
151
+ }>>;
152
+ onClick?: () => void;
153
+ isDisabled?: boolean;
154
+ contentComponent?: React.ComponentType<SelectionExtensionComponentProps>;
155
+ };
120
156
  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,18 +1,8 @@
1
- import { type Command, type FloatingToolbarOverflowDropdownOptions } from '@atlaskit/editor-common/types';
2
- export declare const selectionToolbar: (options: FloatingToolbarOverflowDropdownOptions<Command>) => {
3
- isToolbarAbove: boolean;
4
- items: ({
5
- type: "separator";
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.0",
3
+ "version": "3.4.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",
@@ -36,9 +36,10 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@atlaskit/adf-utils": "^19.20.0",
39
- "@atlaskit/editor-json-transformer": "^8.24.0",
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",
43
44
  "@atlaskit/editor-prosemirror": "7.0.0",
44
45
  "@atlaskit/editor-tables": "^2.9.0",
@@ -52,7 +53,7 @@
52
53
  "uuid": "^3.1.0"
53
54
  },
54
55
  "peerDependencies": {
55
- "@atlaskit/editor-common": "^107.12.0",
56
+ "@atlaskit/editor-common": "^107.13.0",
56
57
  "react": "^18.2.0"
57
58
  },
58
59
  "devDependencies": {