@atlaskit/editor-plugin-paste-options-toolbar 8.2.4 → 8.4.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.
- package/CHANGELOG.md +24 -0
- package/dist/cjs/editor-commands/commands.js +5 -1
- package/dist/cjs/pasteOptionsToolbarPlugin.js +44 -35
- package/dist/cjs/pm-plugins/main.js +16 -9
- package/dist/cjs/pm-plugins/reducer.js +2 -0
- package/dist/cjs/ui/on-paste-actions-menu/PasteActionsMenu.js +81 -60
- package/dist/cjs/ui/on-paste-actions-menu/PasteActionsMenuContent.compiled.css +2 -8
- package/dist/cjs/ui/on-paste-actions-menu/PasteActionsMenuContent.js +10 -13
- package/dist/cjs/ui/on-paste-actions-menu/PasteMenuComponents.compiled.css +1 -0
- package/dist/cjs/ui/on-paste-actions-menu/PasteMenuComponents.js +205 -0
- package/dist/es2019/editor-commands/commands.js +4 -2
- package/dist/es2019/pasteOptionsToolbarPlugin.js +41 -28
- package/dist/es2019/pm-plugins/main.js +12 -5
- package/dist/es2019/pm-plugins/reducer.js +2 -0
- package/dist/es2019/ui/on-paste-actions-menu/PasteActionsMenu.js +82 -62
- package/dist/es2019/ui/on-paste-actions-menu/PasteActionsMenuContent.compiled.css +2 -8
- package/dist/es2019/ui/on-paste-actions-menu/PasteActionsMenuContent.js +11 -12
- package/dist/es2019/ui/on-paste-actions-menu/PasteMenuComponents.compiled.css +1 -0
- package/dist/es2019/ui/on-paste-actions-menu/PasteMenuComponents.js +187 -0
- package/dist/esm/editor-commands/commands.js +5 -1
- package/dist/esm/pasteOptionsToolbarPlugin.js +44 -34
- package/dist/esm/pm-plugins/main.js +12 -5
- package/dist/esm/pm-plugins/reducer.js +2 -0
- package/dist/esm/ui/on-paste-actions-menu/PasteActionsMenu.js +84 -63
- package/dist/esm/ui/on-paste-actions-menu/PasteActionsMenuContent.compiled.css +2 -8
- package/dist/esm/ui/on-paste-actions-menu/PasteActionsMenuContent.js +11 -14
- package/dist/esm/ui/on-paste-actions-menu/PasteMenuComponents.compiled.css +1 -0
- package/dist/esm/ui/on-paste-actions-menu/PasteMenuComponents.js +196 -0
- package/dist/types/editor-actions/actions.d.ts +2 -0
- package/dist/types/editor-commands/commands.d.ts +1 -1
- package/dist/types/pasteOptionsToolbarPluginType.d.ts +3 -0
- package/dist/types/pm-plugins/main.d.ts +3 -1
- package/dist/types/types/types.d.ts +3 -0
- package/dist/types/ui/on-paste-actions-menu/PasteActionsMenu.d.ts +1 -3
- package/dist/types/ui/on-paste-actions-menu/PasteActionsMenuContent.d.ts +2 -8
- package/dist/types/ui/on-paste-actions-menu/PasteMenuComponents.d.ts +12 -0
- package/dist/types-ts4.5/editor-actions/actions.d.ts +2 -0
- package/dist/types-ts4.5/editor-commands/commands.d.ts +1 -1
- package/dist/types-ts4.5/pasteOptionsToolbarPluginType.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +3 -1
- package/dist/types-ts4.5/types/types.d.ts +3 -0
- package/dist/types-ts4.5/ui/on-paste-actions-menu/PasteActionsMenu.d.ts +1 -3
- package/dist/types-ts4.5/ui/on-paste-actions-menu/PasteActionsMenuContent.d.ts +2 -8
- package/dist/types-ts4.5/ui/on-paste-actions-menu/PasteMenuComponents.d.ts +12 -0
- package/package.json +6 -4
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/* PasteMenuComponents.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
|
+
import "./PasteMenuComponents.compiled.css";
|
|
3
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
+
import React, { useCallback } from 'react';
|
|
5
|
+
import { cx } from '@compiled/react';
|
|
6
|
+
import { useIntl } from 'react-intl-next';
|
|
7
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
8
|
+
import { pasteOptionsToolbarMessages as messages } from '@atlaskit/editor-common/messages';
|
|
9
|
+
import { useEditorToolbar, PASTE_MENU, PASTE_MENU_SECTION, PASTE_NESTED_MENU, PASTE_MENU_NESTED_SECTION, PASTE_RICH_TEXT_MENU_ITEM, PASTE_MARKDOWN_MENU_ITEM, PASTE_PLAIN_TEXT_MENU_ITEM, PASTE_MENU_RANK, PASTE_MENU_SECTION_RANK, PASTE_NESTED_MENU_RANK, PASTE_MENU_NESTED_SECTION_RANK } from '@atlaskit/editor-common/toolbar';
|
|
10
|
+
import { ToolbarDropdownItem, ToolbarDropdownItemSection, ToolbarNestedDropdownMenu } from '@atlaskit/editor-toolbar';
|
|
11
|
+
import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
|
|
12
|
+
import ClipboardIcon from '@atlaskit/icon/core/clipboard';
|
|
13
|
+
import { Box } from '@atlaskit/primitives/compiled';
|
|
14
|
+
import { changeToMarkdownWithAnalytics, changeToPlainTextWithAnalytics, changeToRichTextWithAnalytics } from '../../editor-commands/commands';
|
|
15
|
+
import { ToolbarDropdownOption } from '../../types/types';
|
|
16
|
+
var nestedMenuStyles = {
|
|
17
|
+
narrowSection: "_10gv1lit"
|
|
18
|
+
};
|
|
19
|
+
export var isPasteOptionSelected = function isPasteOptionSelected(pasteType, selectedOption) {
|
|
20
|
+
switch (pasteType) {
|
|
21
|
+
case 'rich-text':
|
|
22
|
+
return selectedOption === ToolbarDropdownOption.RichText;
|
|
23
|
+
case 'markdown':
|
|
24
|
+
return selectedOption === ToolbarDropdownOption.Markdown;
|
|
25
|
+
case 'plain-text':
|
|
26
|
+
return selectedOption === ToolbarDropdownOption.PlainText;
|
|
27
|
+
default:
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var PasteMenuItem = function PasteMenuItem(_ref) {
|
|
32
|
+
var api = _ref.api,
|
|
33
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
34
|
+
pasteType = _ref.pasteType;
|
|
35
|
+
var intl = useIntl();
|
|
36
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
37
|
+
editorView = _useEditorToolbar.editorView;
|
|
38
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['pasteOptionsToolbarPlugin'], function (states) {
|
|
39
|
+
var _pluginState$selected, _pluginState$plaintex, _pluginState$isPlainT;
|
|
40
|
+
var pluginState = states.pasteOptionsToolbarPluginState;
|
|
41
|
+
return {
|
|
42
|
+
selectedOption: (_pluginState$selected = pluginState === null || pluginState === void 0 ? void 0 : pluginState.selectedOption) !== null && _pluginState$selected !== void 0 ? _pluginState$selected : ToolbarDropdownOption.None,
|
|
43
|
+
plaintextLength: (_pluginState$plaintex = pluginState === null || pluginState === void 0 ? void 0 : pluginState.plaintextLength) !== null && _pluginState$plaintex !== void 0 ? _pluginState$plaintex : 0,
|
|
44
|
+
isPlainText: (_pluginState$isPlainT = pluginState === null || pluginState === void 0 ? void 0 : pluginState.isPlainText) !== null && _pluginState$isPlainT !== void 0 ? _pluginState$isPlainT : false
|
|
45
|
+
};
|
|
46
|
+
}),
|
|
47
|
+
selectedOption = _useSharedPluginState.selectedOption,
|
|
48
|
+
plaintextLength = _useSharedPluginState.plaintextLength,
|
|
49
|
+
isPlainText = _useSharedPluginState.isPlainText;
|
|
50
|
+
var getDefaultLabel = useCallback(function (type) {
|
|
51
|
+
switch (type) {
|
|
52
|
+
case 'rich-text':
|
|
53
|
+
return intl.formatMessage(messages.richTextAction);
|
|
54
|
+
case 'markdown':
|
|
55
|
+
return intl.formatMessage(messages.markdownAction);
|
|
56
|
+
case 'plain-text':
|
|
57
|
+
return intl.formatMessage(messages.plainTextAction);
|
|
58
|
+
default:
|
|
59
|
+
return type;
|
|
60
|
+
}
|
|
61
|
+
}, [intl]);
|
|
62
|
+
var handleClick = useCallback(function (e) {
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
if (!editorView) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
switch (pasteType) {
|
|
68
|
+
case 'rich-text':
|
|
69
|
+
changeToRichTextWithAnalytics(editorAnalyticsAPI)()(editorView.state, editorView.dispatch);
|
|
70
|
+
break;
|
|
71
|
+
case 'markdown':
|
|
72
|
+
changeToMarkdownWithAnalytics(editorAnalyticsAPI, plaintextLength)()(editorView.state, editorView.dispatch);
|
|
73
|
+
break;
|
|
74
|
+
case 'plain-text':
|
|
75
|
+
changeToPlainTextWithAnalytics(editorAnalyticsAPI, plaintextLength)()(editorView.state, editorView.dispatch);
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}, [editorView, editorAnalyticsAPI, plaintextLength, pasteType]);
|
|
79
|
+
if (pasteType === 'rich-text' && isPlainText) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
var displayLabel = getDefaultLabel(pasteType);
|
|
83
|
+
var isSelected = isPasteOptionSelected(pasteType, selectedOption);
|
|
84
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
85
|
+
onClick: handleClick,
|
|
86
|
+
isSelected: isSelected,
|
|
87
|
+
testId: "paste-".concat(pasteType, "-menu-item"),
|
|
88
|
+
hasNestedDropdownMenu: true
|
|
89
|
+
}, displayLabel);
|
|
90
|
+
};
|
|
91
|
+
var PasteOptionsNestedMenu = function PasteOptionsNestedMenu(_ref2) {
|
|
92
|
+
var children = _ref2.children;
|
|
93
|
+
var intl = useIntl();
|
|
94
|
+
return /*#__PURE__*/React.createElement(ToolbarNestedDropdownMenu, {
|
|
95
|
+
elemBefore: /*#__PURE__*/React.createElement(ClipboardIcon, {
|
|
96
|
+
size: "small",
|
|
97
|
+
label: intl.formatMessage(messages.pasteOptions)
|
|
98
|
+
}),
|
|
99
|
+
elemAfter: /*#__PURE__*/React.createElement(ChevronRightIcon, {
|
|
100
|
+
size: "small",
|
|
101
|
+
label: intl.formatMessage(messages.pasteOptions)
|
|
102
|
+
}),
|
|
103
|
+
testId: "paste-options-nested-menu",
|
|
104
|
+
text: intl.formatMessage(messages.pasteOptions)
|
|
105
|
+
}, children);
|
|
106
|
+
};
|
|
107
|
+
export var getPasteMenuComponents = function getPasteMenuComponents(_ref3) {
|
|
108
|
+
var api = _ref3.api,
|
|
109
|
+
editorAnalyticsAPI = _ref3.editorAnalyticsAPI;
|
|
110
|
+
return [{
|
|
111
|
+
type: PASTE_MENU.type,
|
|
112
|
+
key: PASTE_MENU.key
|
|
113
|
+
}, {
|
|
114
|
+
type: PASTE_MENU_SECTION.type,
|
|
115
|
+
key: PASTE_MENU_SECTION.key,
|
|
116
|
+
parents: [{
|
|
117
|
+
type: PASTE_MENU.type,
|
|
118
|
+
key: PASTE_MENU.key,
|
|
119
|
+
rank: PASTE_MENU_RANK[PASTE_MENU_SECTION.key]
|
|
120
|
+
}],
|
|
121
|
+
component: function component(props) {
|
|
122
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
123
|
+
hasSeparator: true
|
|
124
|
+
}, props.children);
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
type: PASTE_NESTED_MENU.type,
|
|
128
|
+
key: PASTE_NESTED_MENU.key,
|
|
129
|
+
parents: [{
|
|
130
|
+
type: PASTE_MENU_SECTION.type,
|
|
131
|
+
key: PASTE_MENU_SECTION.key,
|
|
132
|
+
rank: PASTE_MENU_SECTION_RANK[PASTE_NESTED_MENU.key]
|
|
133
|
+
}],
|
|
134
|
+
component: function component(props) {
|
|
135
|
+
return /*#__PURE__*/React.createElement(PasteOptionsNestedMenu, null, props.children);
|
|
136
|
+
}
|
|
137
|
+
}, {
|
|
138
|
+
type: PASTE_MENU_NESTED_SECTION.type,
|
|
139
|
+
key: PASTE_MENU_NESTED_SECTION.key,
|
|
140
|
+
parents: [{
|
|
141
|
+
type: PASTE_NESTED_MENU.type,
|
|
142
|
+
key: PASTE_NESTED_MENU.key,
|
|
143
|
+
rank: PASTE_NESTED_MENU_RANK[PASTE_MENU_NESTED_SECTION.key]
|
|
144
|
+
}],
|
|
145
|
+
component: function component(props) {
|
|
146
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
147
|
+
xcss: cx(nestedMenuStyles.narrowSection)
|
|
148
|
+
}, /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, props.children));
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: PASTE_RICH_TEXT_MENU_ITEM.key,
|
|
152
|
+
type: PASTE_RICH_TEXT_MENU_ITEM.type,
|
|
153
|
+
component: function component() {
|
|
154
|
+
return /*#__PURE__*/React.createElement(PasteMenuItem, {
|
|
155
|
+
api: api,
|
|
156
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
157
|
+
pasteType: "rich-text"
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
parents: [{
|
|
161
|
+
key: PASTE_MENU_NESTED_SECTION.key,
|
|
162
|
+
type: PASTE_MENU_NESTED_SECTION.type,
|
|
163
|
+
rank: PASTE_MENU_NESTED_SECTION_RANK[PASTE_RICH_TEXT_MENU_ITEM.key]
|
|
164
|
+
}]
|
|
165
|
+
}, {
|
|
166
|
+
key: PASTE_MARKDOWN_MENU_ITEM.key,
|
|
167
|
+
type: PASTE_MARKDOWN_MENU_ITEM.type,
|
|
168
|
+
component: function component() {
|
|
169
|
+
return /*#__PURE__*/React.createElement(PasteMenuItem, {
|
|
170
|
+
api: api,
|
|
171
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
172
|
+
pasteType: "markdown"
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
parents: [{
|
|
176
|
+
key: PASTE_MENU_NESTED_SECTION.key,
|
|
177
|
+
type: PASTE_MENU_NESTED_SECTION.type,
|
|
178
|
+
rank: PASTE_MENU_NESTED_SECTION_RANK[PASTE_MARKDOWN_MENU_ITEM.key]
|
|
179
|
+
}]
|
|
180
|
+
}, {
|
|
181
|
+
key: PASTE_PLAIN_TEXT_MENU_ITEM.key,
|
|
182
|
+
type: PASTE_PLAIN_TEXT_MENU_ITEM.type,
|
|
183
|
+
component: function component() {
|
|
184
|
+
return /*#__PURE__*/React.createElement(PasteMenuItem, {
|
|
185
|
+
api: api,
|
|
186
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
187
|
+
pasteType: "plain-text"
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
parents: [{
|
|
191
|
+
key: PASTE_MENU_NESTED_SECTION.key,
|
|
192
|
+
type: PASTE_MENU_NESTED_SECTION.type,
|
|
193
|
+
rank: PASTE_MENU_NESTED_SECTION_RANK[PASTE_PLAIN_TEXT_MENU_ITEM.key]
|
|
194
|
+
}]
|
|
195
|
+
}];
|
|
196
|
+
};
|
|
@@ -11,11 +11,13 @@ export declare enum PastePluginActionTypes {
|
|
|
11
11
|
export interface ShowPasteOptions {
|
|
12
12
|
data: {
|
|
13
13
|
isPlainText: boolean;
|
|
14
|
+
pasteAncestorNodeNames: string[];
|
|
14
15
|
pasteEndPos: number;
|
|
15
16
|
pasteStartPos: number;
|
|
16
17
|
plaintext: string;
|
|
17
18
|
richTextSlice: Slice;
|
|
18
19
|
selectedOption: ToolbarDropdownOption;
|
|
20
|
+
showLegacyOptions: boolean;
|
|
19
21
|
};
|
|
20
22
|
type: PastePluginActionTypes.SHOW_PASTE_OPTIONS;
|
|
21
23
|
}
|
|
@@ -3,7 +3,7 @@ import type { Command } from '@atlaskit/editor-common/types';
|
|
|
3
3
|
import type { LastContentPasted } from '@atlaskit/editor-plugin-paste';
|
|
4
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import { ToolbarDropdownOption } from '../types/types';
|
|
6
|
-
export declare const showToolbar: (lastContentPasted: LastContentPasted, selectedOption: ToolbarDropdownOption) => Command;
|
|
6
|
+
export declare const showToolbar: (lastContentPasted: LastContentPasted, selectedOption: ToolbarDropdownOption, showLegacyOptions?: boolean, pasteAncestorNodeNames?: string[]) => Command;
|
|
7
7
|
export declare const changeToPlainText: () => Command;
|
|
8
8
|
export declare const changeToPlainTextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, sliceSize: number) => () => Command;
|
|
9
9
|
export declare const dropdownClickHandler: () => Command;
|
|
@@ -10,12 +10,15 @@ export type PasteOptionsToolbarPluginDependencies = [
|
|
|
10
10
|
];
|
|
11
11
|
export interface PasteOptionsToolbarSharedState {
|
|
12
12
|
isPlainText: boolean;
|
|
13
|
+
pasteAncestorNodeNames: string[];
|
|
13
14
|
pasteEndPos: number;
|
|
14
15
|
pasteStartPos: number;
|
|
15
16
|
plaintextLength: number;
|
|
16
17
|
selectedOption: ToolbarDropdownOption;
|
|
18
|
+
showLegacyOptions: boolean;
|
|
17
19
|
showToolbar: boolean;
|
|
18
20
|
}
|
|
19
21
|
export type PasteOptionsToolbarPlugin = NextEditorPlugin<'pasteOptionsToolbarPlugin', {
|
|
20
22
|
dependencies: PasteOptionsToolbarPluginDependencies;
|
|
23
|
+
sharedState: PasteOptionsToolbarSharedState;
|
|
21
24
|
}>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
export declare function createPlugin(dispatch: Dispatch
|
|
3
|
+
export declare function createPlugin(dispatch: Dispatch, options?: {
|
|
4
|
+
useNewPasteMenu?: boolean;
|
|
5
|
+
}): SafePlugin<import("../types/types").PasteOptionsPluginState>;
|
|
@@ -12,14 +12,17 @@ export interface PasteOptionsPluginState {
|
|
|
12
12
|
highlightContent: boolean;
|
|
13
13
|
highlightDecorationSet: DecorationSet;
|
|
14
14
|
isPlainText: boolean;
|
|
15
|
+
pasteAncestorNodeNames: string[];
|
|
15
16
|
pasteEndPos: number;
|
|
16
17
|
pasteStartPos: number;
|
|
17
18
|
plaintext: string;
|
|
18
19
|
richTextSlice: Slice;
|
|
19
20
|
selectedOption: ToolbarDropdownOption;
|
|
21
|
+
showLegacyOptions: boolean;
|
|
20
22
|
showToolbar: boolean;
|
|
21
23
|
}
|
|
22
24
|
export interface Position {
|
|
23
25
|
left?: number;
|
|
24
26
|
top?: number;
|
|
25
27
|
}
|
|
28
|
+
export type PasteType = 'rich-text' | 'markdown' | 'plain-text';
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
4
|
import type { PasteOptionsToolbarPlugin } from '../../pasteOptionsToolbarPluginType';
|
|
6
5
|
interface PasteActionsMenuProps {
|
|
7
6
|
api: ExtractInjectionAPI<PasteOptionsToolbarPlugin> | undefined;
|
|
8
7
|
boundariesElement?: HTMLElement;
|
|
9
|
-
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
10
8
|
editorView: EditorView;
|
|
11
9
|
mountTo?: HTMLElement;
|
|
12
10
|
scrollableElement?: HTMLElement;
|
|
13
11
|
}
|
|
14
|
-
export declare const PasteActionsMenu: ({ api, editorView, mountTo, boundariesElement, scrollableElement,
|
|
12
|
+
export declare const PasteActionsMenu: ({ api, editorView, mountTo, boundariesElement, scrollableElement, }: PasteActionsMenuProps) => React.JSX.Element | null;
|
|
15
13
|
export {};
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { RegisterComponent, SurfaceIdentifier } from '@atlaskit/editor-ui-control-model';
|
|
3
|
-
export interface MenuOption {
|
|
4
|
-
id: string;
|
|
5
|
-
label: string;
|
|
6
|
-
onClick: (e: React.MouseEvent) => void;
|
|
7
|
-
selected: boolean;
|
|
8
|
-
}
|
|
9
3
|
interface PasteActionsMenuContentProps {
|
|
10
4
|
aiSurface?: SurfaceIdentifier;
|
|
11
5
|
aiSurfaceComponents?: RegisterComponent[];
|
|
12
6
|
onMouseDown: (e: React.MouseEvent) => void;
|
|
13
7
|
onMouseEnter: () => void;
|
|
14
|
-
|
|
8
|
+
pasteSurfaceComponents?: RegisterComponent[];
|
|
15
9
|
}
|
|
16
|
-
export declare const PasteActionsMenuContent: ({
|
|
10
|
+
export declare const PasteActionsMenuContent: ({ onMouseDown, onMouseEnter, aiSurface, aiSurfaceComponents, pasteSurfaceComponents, }: PasteActionsMenuContentProps) => React.JSX.Element;
|
|
17
11
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { RegisterComponent } from '@atlaskit/editor-ui-control-model';
|
|
4
|
+
import type { PasteOptionsToolbarPlugin } from '../../pasteOptionsToolbarPluginType';
|
|
5
|
+
import { ToolbarDropdownOption, type PasteType } from '../../types/types';
|
|
6
|
+
export declare const isPasteOptionSelected: (pasteType: PasteType, selectedOption: ToolbarDropdownOption) => boolean;
|
|
7
|
+
interface PasteMenuComponentsConfig {
|
|
8
|
+
api: ExtractInjectionAPI<PasteOptionsToolbarPlugin> | undefined;
|
|
9
|
+
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare const getPasteMenuComponents: ({ api, editorAnalyticsAPI, }: PasteMenuComponentsConfig) => RegisterComponent[];
|
|
12
|
+
export {};
|
|
@@ -11,11 +11,13 @@ export declare enum PastePluginActionTypes {
|
|
|
11
11
|
export interface ShowPasteOptions {
|
|
12
12
|
data: {
|
|
13
13
|
isPlainText: boolean;
|
|
14
|
+
pasteAncestorNodeNames: string[];
|
|
14
15
|
pasteEndPos: number;
|
|
15
16
|
pasteStartPos: number;
|
|
16
17
|
plaintext: string;
|
|
17
18
|
richTextSlice: Slice;
|
|
18
19
|
selectedOption: ToolbarDropdownOption;
|
|
20
|
+
showLegacyOptions: boolean;
|
|
19
21
|
};
|
|
20
22
|
type: PastePluginActionTypes.SHOW_PASTE_OPTIONS;
|
|
21
23
|
}
|
|
@@ -3,7 +3,7 @@ import type { Command } from '@atlaskit/editor-common/types';
|
|
|
3
3
|
import type { LastContentPasted } from '@atlaskit/editor-plugin-paste';
|
|
4
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import { ToolbarDropdownOption } from '../types/types';
|
|
6
|
-
export declare const showToolbar: (lastContentPasted: LastContentPasted, selectedOption: ToolbarDropdownOption) => Command;
|
|
6
|
+
export declare const showToolbar: (lastContentPasted: LastContentPasted, selectedOption: ToolbarDropdownOption, showLegacyOptions?: boolean, pasteAncestorNodeNames?: string[]) => Command;
|
|
7
7
|
export declare const changeToPlainText: () => Command;
|
|
8
8
|
export declare const changeToPlainTextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, sliceSize: number) => () => Command;
|
|
9
9
|
export declare const dropdownClickHandler: () => Command;
|
|
@@ -10,12 +10,15 @@ export type PasteOptionsToolbarPluginDependencies = [
|
|
|
10
10
|
];
|
|
11
11
|
export interface PasteOptionsToolbarSharedState {
|
|
12
12
|
isPlainText: boolean;
|
|
13
|
+
pasteAncestorNodeNames: string[];
|
|
13
14
|
pasteEndPos: number;
|
|
14
15
|
pasteStartPos: number;
|
|
15
16
|
plaintextLength: number;
|
|
16
17
|
selectedOption: ToolbarDropdownOption;
|
|
18
|
+
showLegacyOptions: boolean;
|
|
17
19
|
showToolbar: boolean;
|
|
18
20
|
}
|
|
19
21
|
export type PasteOptionsToolbarPlugin = NextEditorPlugin<'pasteOptionsToolbarPlugin', {
|
|
20
22
|
dependencies: PasteOptionsToolbarPluginDependencies;
|
|
23
|
+
sharedState: PasteOptionsToolbarSharedState;
|
|
21
24
|
}>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
export declare function createPlugin(dispatch: Dispatch
|
|
3
|
+
export declare function createPlugin(dispatch: Dispatch, options?: {
|
|
4
|
+
useNewPasteMenu?: boolean;
|
|
5
|
+
}): SafePlugin<import("../types/types").PasteOptionsPluginState>;
|
|
@@ -12,14 +12,17 @@ export interface PasteOptionsPluginState {
|
|
|
12
12
|
highlightContent: boolean;
|
|
13
13
|
highlightDecorationSet: DecorationSet;
|
|
14
14
|
isPlainText: boolean;
|
|
15
|
+
pasteAncestorNodeNames: string[];
|
|
15
16
|
pasteEndPos: number;
|
|
16
17
|
pasteStartPos: number;
|
|
17
18
|
plaintext: string;
|
|
18
19
|
richTextSlice: Slice;
|
|
19
20
|
selectedOption: ToolbarDropdownOption;
|
|
21
|
+
showLegacyOptions: boolean;
|
|
20
22
|
showToolbar: boolean;
|
|
21
23
|
}
|
|
22
24
|
export interface Position {
|
|
23
25
|
left?: number;
|
|
24
26
|
top?: number;
|
|
25
27
|
}
|
|
28
|
+
export type PasteType = 'rich-text' | 'markdown' | 'plain-text';
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
4
|
import type { PasteOptionsToolbarPlugin } from '../../pasteOptionsToolbarPluginType';
|
|
6
5
|
interface PasteActionsMenuProps {
|
|
7
6
|
api: ExtractInjectionAPI<PasteOptionsToolbarPlugin> | undefined;
|
|
8
7
|
boundariesElement?: HTMLElement;
|
|
9
|
-
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
10
8
|
editorView: EditorView;
|
|
11
9
|
mountTo?: HTMLElement;
|
|
12
10
|
scrollableElement?: HTMLElement;
|
|
13
11
|
}
|
|
14
|
-
export declare const PasteActionsMenu: ({ api, editorView, mountTo, boundariesElement, scrollableElement,
|
|
12
|
+
export declare const PasteActionsMenu: ({ api, editorView, mountTo, boundariesElement, scrollableElement, }: PasteActionsMenuProps) => React.JSX.Element | null;
|
|
15
13
|
export {};
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { RegisterComponent, SurfaceIdentifier } from '@atlaskit/editor-ui-control-model';
|
|
3
|
-
export interface MenuOption {
|
|
4
|
-
id: string;
|
|
5
|
-
label: string;
|
|
6
|
-
onClick: (e: React.MouseEvent) => void;
|
|
7
|
-
selected: boolean;
|
|
8
|
-
}
|
|
9
3
|
interface PasteActionsMenuContentProps {
|
|
10
4
|
aiSurface?: SurfaceIdentifier;
|
|
11
5
|
aiSurfaceComponents?: RegisterComponent[];
|
|
12
6
|
onMouseDown: (e: React.MouseEvent) => void;
|
|
13
7
|
onMouseEnter: () => void;
|
|
14
|
-
|
|
8
|
+
pasteSurfaceComponents?: RegisterComponent[];
|
|
15
9
|
}
|
|
16
|
-
export declare const PasteActionsMenuContent: ({
|
|
10
|
+
export declare const PasteActionsMenuContent: ({ onMouseDown, onMouseEnter, aiSurface, aiSurfaceComponents, pasteSurfaceComponents, }: PasteActionsMenuContentProps) => React.JSX.Element;
|
|
17
11
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { RegisterComponent } from '@atlaskit/editor-ui-control-model';
|
|
4
|
+
import type { PasteOptionsToolbarPlugin } from '../../pasteOptionsToolbarPluginType';
|
|
5
|
+
import { ToolbarDropdownOption, type PasteType } from '../../types/types';
|
|
6
|
+
export declare const isPasteOptionSelected: (pasteType: PasteType, selectedOption: ToolbarDropdownOption) => boolean;
|
|
7
|
+
interface PasteMenuComponentsConfig {
|
|
8
|
+
api: ExtractInjectionAPI<PasteOptionsToolbarPlugin> | undefined;
|
|
9
|
+
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare const getPasteMenuComponents: ({ api, editorAnalyticsAPI, }: PasteMenuComponentsConfig) => RegisterComponent[];
|
|
12
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste-options-toolbar",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0",
|
|
4
4
|
"description": "Paste options toolbar for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,22 +32,24 @@
|
|
|
32
32
|
"@atlaskit/css": "^0.19.0",
|
|
33
33
|
"@atlaskit/editor-markdown-transformer": "^5.20.0",
|
|
34
34
|
"@atlaskit/editor-plugin-analytics": "^7.0.0",
|
|
35
|
-
"@atlaskit/editor-plugin-paste": "^8.
|
|
35
|
+
"@atlaskit/editor-plugin-paste": "^8.6.0",
|
|
36
36
|
"@atlaskit/editor-plugin-ui-control-registry": "^1.1.0",
|
|
37
37
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
38
38
|
"@atlaskit/editor-shared-styles": "^3.10.0",
|
|
39
|
+
"@atlaskit/editor-toolbar": "^0.19.0",
|
|
39
40
|
"@atlaskit/editor-ui-control-model": "^1.1.0",
|
|
40
41
|
"@atlaskit/icon": "^32.0.0",
|
|
41
42
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
42
43
|
"@atlaskit/primitives": "^18.0.0",
|
|
43
|
-
"@atlaskit/tmp-editor-statsig": "^35.
|
|
44
|
+
"@atlaskit/tmp-editor-statsig": "^35.4.0",
|
|
44
45
|
"@atlaskit/tokens": "^11.0.0",
|
|
45
46
|
"@babel/runtime": "^7.0.0",
|
|
47
|
+
"@compiled/react": "^0.20.0",
|
|
46
48
|
"@emotion/react": "^11.7.1",
|
|
47
49
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
48
50
|
},
|
|
49
51
|
"peerDependencies": {
|
|
50
|
-
"@atlaskit/editor-common": "^111.
|
|
52
|
+
"@atlaskit/editor-common": "^111.31.0",
|
|
51
53
|
"react": "^18.2.0",
|
|
52
54
|
"react-dom": "^18.2.0"
|
|
53
55
|
},
|