@atlaskit/editor-plugin-paste-options-toolbar 11.2.3 → 11.3.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/pasteOptionsToolbarPlugin.js +51 -13
- package/dist/cjs/ui/utils/paste-menu-rules/hasMixedNodes.js +76 -0
- package/dist/cjs/ui/utils/paste-menu-rules/isNotSingleLink.js +117 -0
- package/dist/cjs/ui/utils/paste-menu-rules/rules.js +82 -1
- package/dist/es2019/pasteOptionsToolbarPlugin.js +49 -13
- package/dist/es2019/ui/utils/paste-menu-rules/hasMixedNodes.js +70 -0
- package/dist/es2019/ui/utils/paste-menu-rules/isNotSingleLink.js +111 -0
- package/dist/es2019/ui/utils/paste-menu-rules/rules.js +72 -1
- package/dist/esm/pasteOptionsToolbarPlugin.js +51 -13
- package/dist/esm/ui/utils/paste-menu-rules/hasMixedNodes.js +70 -0
- package/dist/esm/ui/utils/paste-menu-rules/isNotSingleLink.js +111 -0
- package/dist/esm/ui/utils/paste-menu-rules/rules.js +82 -1
- package/dist/types/pasteOptionsToolbarPluginType.d.ts +17 -0
- package/dist/types/ui/utils/paste-menu-rules/hasMixedNodes.d.ts +10 -0
- package/dist/types/ui/utils/paste-menu-rules/isNotSingleLink.d.ts +17 -0
- package/dist/types/ui/utils/paste-menu-rules/types.d.ts +39 -0
- package/dist/types-ts4.5/pasteOptionsToolbarPluginType.d.ts +17 -0
- package/dist/types-ts4.5/ui/utils/paste-menu-rules/hasMixedNodes.d.ts +10 -0
- package/dist/types-ts4.5/ui/utils/paste-menu-rules/isNotSingleLink.d.ts +17 -0
- package/dist/types-ts4.5/ui/utils/paste-menu-rules/types.d.ts +39 -0
- package/package.json +7 -5
|
@@ -60,14 +60,53 @@ export interface PasteMenuRuleFactories {
|
|
|
60
60
|
* names appear in the ancestor list at the insertion point.
|
|
61
61
|
*/
|
|
62
62
|
excludedAncestorRule: (excludedNames: string[]) => PasteMenuRule;
|
|
63
|
+
/**
|
|
64
|
+
* A rule that hides the button when the pasted content contains more than
|
|
65
|
+
* one node type.
|
|
66
|
+
*/
|
|
67
|
+
hideIfMixedNodesRule: PasteMenuRule;
|
|
68
|
+
/**
|
|
69
|
+
* A rule that hides the button when the pasted content contains only a
|
|
70
|
+
* single node type.
|
|
71
|
+
*/
|
|
72
|
+
hideIfSingleNodeRule: PasteMenuRule;
|
|
73
|
+
/**
|
|
74
|
+
* A rule that hides the button when the pasted content IS a single
|
|
75
|
+
* standalone link (the inverse of `notSingleLinkRule`).
|
|
76
|
+
*
|
|
77
|
+
* Use this to hide buttons that should NOT appear for single-link pastes,
|
|
78
|
+
* e.g. Improve Writing, Fix Spelling — leaving only Ask Rovo visible.
|
|
79
|
+
*/
|
|
80
|
+
isSingleLinkRule: PasteMenuRule;
|
|
81
|
+
/**
|
|
82
|
+
* Returns a rule that hides the button when the pasted plain-text is
|
|
83
|
+
* longer than `maxChars` characters.
|
|
84
|
+
*/
|
|
85
|
+
maxCharsRule: (maxChars: number) => PasteMenuRule;
|
|
63
86
|
/**
|
|
64
87
|
* Returns a rule that hides the button when the pasted plain-text is
|
|
65
88
|
* shorter than `minChars` characters.
|
|
66
89
|
*/
|
|
67
90
|
minCharsRule: (minChars: number) => PasteMenuRule;
|
|
91
|
+
/**
|
|
92
|
+
* A rule that hides the button when the paste source is NOT an external
|
|
93
|
+
* application (i.e. the content was pasted from within the Fabric editor
|
|
94
|
+
* or renderer rather than from a third-party source).
|
|
95
|
+
*/
|
|
96
|
+
notExternalPasteRule: PasteMenuRule;
|
|
68
97
|
/**
|
|
69
98
|
* A rule that hides the button when the pasted content is plain text
|
|
70
99
|
* (i.e. not rich-text / prose).
|
|
71
100
|
*/
|
|
72
101
|
notProseRule: PasteMenuRule;
|
|
102
|
+
/**
|
|
103
|
+
* A rule that hides the button when the pasted content is a single
|
|
104
|
+
* standalone link — i.e. a bare URL link (text equals href) alone in a
|
|
105
|
+
* paragraph, or a single inline card (smartlink) alone in a paragraph.
|
|
106
|
+
*
|
|
107
|
+
* Returns `true` (hidden) when the paste is NOT a single link — e.g. a
|
|
108
|
+
* link with a custom label, a link with sibling text or nodes, or
|
|
109
|
+
* multiple paragraphs.
|
|
110
|
+
*/
|
|
111
|
+
notSingleLinkRule: PasteMenuRule;
|
|
73
112
|
}
|
|
@@ -2,6 +2,7 @@ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/t
|
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
3
|
import type { PastePlugin } from '@atlaskit/editor-plugin-paste';
|
|
4
4
|
import type { UiControlRegistryPlugin } from '@atlaskit/editor-plugin-ui-control-registry';
|
|
5
|
+
import type { RegisterComponent } from '@atlaskit/editor-ui-control-model';
|
|
5
6
|
import type { ToolbarDropdownOption } from './types/types';
|
|
6
7
|
import type { PasteMenuRuleFactories } from './ui/utils/paste-menu-rules/types';
|
|
7
8
|
export type PasteOptionsToolbarPluginDependencies = [
|
|
@@ -35,6 +36,22 @@ export type PasteOptionsToolbarPlugin = NextEditorPlugin<'pasteOptionsToolbarPlu
|
|
|
35
36
|
};
|
|
36
37
|
dependencies: PasteOptionsToolbarPluginDependencies;
|
|
37
38
|
pluginConfiguration?: {
|
|
39
|
+
/**
|
|
40
|
+
* Optional factory for composing product-specific paste menu buttons.
|
|
41
|
+
* Called with the pre-bound rule factories so products can compose
|
|
42
|
+
* `isHidden` callbacks before plugin setup.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* pasteMenuButtonsFactory: (rules) => [
|
|
46
|
+
* {
|
|
47
|
+
* type: 'menu-item',
|
|
48
|
+
* key: 'my-product-button',
|
|
49
|
+
* isHidden: rules.allRules(rules.notProseRule, rules.minCharsRule(100)),
|
|
50
|
+
* component: () => <MyProductButton />,
|
|
51
|
+
* },
|
|
52
|
+
* ]
|
|
53
|
+
*/
|
|
54
|
+
pasteMenuButtonsFactory?: (rules: PasteMenuRuleFactories) => RegisterComponent[];
|
|
38
55
|
usePopupBasedPasteActionsMenu?: boolean;
|
|
39
56
|
};
|
|
40
57
|
sharedState: PasteOptionsToolbarSharedState;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if the slice contains sibling block nodes of different types
|
|
4
|
+
* at the same level anywhere in the document tree.
|
|
5
|
+
*
|
|
6
|
+
* Structural container nodes (bulletList, orderedList, taskList, decisionList,
|
|
7
|
+
* table, tableRow) are excluded from the sibling check because their children
|
|
8
|
+
* are typed by structure, not content. All other container nodes are checked.
|
|
9
|
+
*/
|
|
10
|
+
export declare const hasMixedNodes: (slice: Slice | undefined) => boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
/**
|
|
3
|
+
* Returns `true` when the pasted content is NOT a single standalone link.
|
|
4
|
+
*
|
|
5
|
+
* A paste is considered a "single link" (returns `false`) when:
|
|
6
|
+
* - The slice contains exactly one paragraph with one text node whose text
|
|
7
|
+
* equals its `link` mark href (bare URL link, no custom label), OR
|
|
8
|
+
* - The slice contains exactly one paragraph with a single `inlineCard` node
|
|
9
|
+
* (smartlink from the renderer or editor).
|
|
10
|
+
*
|
|
11
|
+
* Returns `true` (not a single link) when:
|
|
12
|
+
* - The pasted link has a custom label (text ≠ href)
|
|
13
|
+
* - There are multiple paragraphs or sibling nodes
|
|
14
|
+
* - There is additional text alongside the link in the same paragraph
|
|
15
|
+
* - The slice is absent (plain-text paste)
|
|
16
|
+
*/
|
|
17
|
+
export declare const isNotSingleLink: (slice: Slice | undefined) => boolean;
|
|
@@ -60,14 +60,53 @@ export interface PasteMenuRuleFactories {
|
|
|
60
60
|
* names appear in the ancestor list at the insertion point.
|
|
61
61
|
*/
|
|
62
62
|
excludedAncestorRule: (excludedNames: string[]) => PasteMenuRule;
|
|
63
|
+
/**
|
|
64
|
+
* A rule that hides the button when the pasted content contains more than
|
|
65
|
+
* one node type.
|
|
66
|
+
*/
|
|
67
|
+
hideIfMixedNodesRule: PasteMenuRule;
|
|
68
|
+
/**
|
|
69
|
+
* A rule that hides the button when the pasted content contains only a
|
|
70
|
+
* single node type.
|
|
71
|
+
*/
|
|
72
|
+
hideIfSingleNodeRule: PasteMenuRule;
|
|
73
|
+
/**
|
|
74
|
+
* A rule that hides the button when the pasted content IS a single
|
|
75
|
+
* standalone link (the inverse of `notSingleLinkRule`).
|
|
76
|
+
*
|
|
77
|
+
* Use this to hide buttons that should NOT appear for single-link pastes,
|
|
78
|
+
* e.g. Improve Writing, Fix Spelling — leaving only Ask Rovo visible.
|
|
79
|
+
*/
|
|
80
|
+
isSingleLinkRule: PasteMenuRule;
|
|
81
|
+
/**
|
|
82
|
+
* Returns a rule that hides the button when the pasted plain-text is
|
|
83
|
+
* longer than `maxChars` characters.
|
|
84
|
+
*/
|
|
85
|
+
maxCharsRule: (maxChars: number) => PasteMenuRule;
|
|
63
86
|
/**
|
|
64
87
|
* Returns a rule that hides the button when the pasted plain-text is
|
|
65
88
|
* shorter than `minChars` characters.
|
|
66
89
|
*/
|
|
67
90
|
minCharsRule: (minChars: number) => PasteMenuRule;
|
|
91
|
+
/**
|
|
92
|
+
* A rule that hides the button when the paste source is NOT an external
|
|
93
|
+
* application (i.e. the content was pasted from within the Fabric editor
|
|
94
|
+
* or renderer rather than from a third-party source).
|
|
95
|
+
*/
|
|
96
|
+
notExternalPasteRule: PasteMenuRule;
|
|
68
97
|
/**
|
|
69
98
|
* A rule that hides the button when the pasted content is plain text
|
|
70
99
|
* (i.e. not rich-text / prose).
|
|
71
100
|
*/
|
|
72
101
|
notProseRule: PasteMenuRule;
|
|
102
|
+
/**
|
|
103
|
+
* A rule that hides the button when the pasted content is a single
|
|
104
|
+
* standalone link — i.e. a bare URL link (text equals href) alone in a
|
|
105
|
+
* paragraph, or a single inline card (smartlink) alone in a paragraph.
|
|
106
|
+
*
|
|
107
|
+
* Returns `true` (hidden) when the paste is NOT a single link — e.g. a
|
|
108
|
+
* link with a custom label, a link with sibling text or nodes, or
|
|
109
|
+
* multiple paragraphs.
|
|
110
|
+
*/
|
|
111
|
+
notSingleLinkRule: PasteMenuRule;
|
|
73
112
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste-options-toolbar",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.1",
|
|
4
4
|
"description": "Paste options toolbar for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,25 +37,27 @@
|
|
|
37
37
|
"@atlaskit/editor-plugin-ui-control-registry": "^4.1.0",
|
|
38
38
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
39
39
|
"@atlaskit/editor-shared-styles": "^3.11.0",
|
|
40
|
-
"@atlaskit/editor-toolbar": "^1.
|
|
40
|
+
"@atlaskit/editor-toolbar": "^1.7.0",
|
|
41
41
|
"@atlaskit/editor-ui-control-model": "^1.2.0",
|
|
42
|
-
"@atlaskit/icon": "^35.
|
|
42
|
+
"@atlaskit/icon": "^35.1.0",
|
|
43
43
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
44
44
|
"@atlaskit/primitives": "^19.0.0",
|
|
45
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
45
|
+
"@atlaskit/tmp-editor-statsig": "^83.0.0",
|
|
46
46
|
"@atlaskit/tokens": "^13.0.0",
|
|
47
47
|
"@babel/runtime": "^7.0.0",
|
|
48
48
|
"@compiled/react": "^0.20.0",
|
|
49
49
|
"@emotion/react": "^11.7.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@atlaskit/editor-common": "^114.
|
|
52
|
+
"@atlaskit/editor-common": "^114.47.0",
|
|
53
53
|
"react": "^18.2.0",
|
|
54
54
|
"react-dom": "^18.2.0",
|
|
55
55
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@testing-library/react": "^16.3.0",
|
|
59
|
+
"react": "^18.2.0",
|
|
60
|
+
"react-dom": "^18.2.0",
|
|
59
61
|
"react-intl": "^6.6.2",
|
|
60
62
|
"wait-for-expect": "^1.2.0"
|
|
61
63
|
},
|