@atlaskit/editor-plugin-paste-options-toolbar 8.4.1 → 9.0.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 +8 -0
- package/dist/cjs/editor-commands/commands.js +9 -6
- package/dist/cjs/pasteOptionsToolbarPlugin.js +1 -2
- package/dist/cjs/ui/on-paste-actions-menu/PasteActionsMenu.js +21 -2
- package/dist/cjs/ui/on-paste-actions-menu/PasteMenuComponents.js +3 -6
- package/dist/cjs/ui/on-paste-actions-menu/hasVisibleButton.js +17 -6
- package/dist/es2019/editor-commands/commands.js +9 -6
- package/dist/es2019/pasteOptionsToolbarPlugin.js +1 -2
- package/dist/es2019/ui/on-paste-actions-menu/PasteActionsMenu.js +23 -4
- package/dist/es2019/ui/on-paste-actions-menu/PasteMenuComponents.js +3 -6
- package/dist/es2019/ui/on-paste-actions-menu/hasVisibleButton.js +10 -2
- package/dist/esm/editor-commands/commands.js +9 -6
- package/dist/esm/pasteOptionsToolbarPlugin.js +1 -2
- package/dist/esm/ui/on-paste-actions-menu/PasteActionsMenu.js +23 -4
- package/dist/esm/ui/on-paste-actions-menu/PasteMenuComponents.js +3 -6
- package/dist/esm/ui/on-paste-actions-menu/hasVisibleButton.js +16 -5
- package/dist/types/editor-commands/commands.d.ts +3 -3
- package/dist/types/ui/on-paste-actions-menu/PasteMenuComponents.d.ts +1 -3
- package/dist/types/ui/on-paste-actions-menu/hasVisibleButton.d.ts +5 -0
- package/dist/types-ts4.5/editor-commands/commands.d.ts +3 -3
- package/dist/types-ts4.5/ui/on-paste-actions-menu/PasteMenuComponents.d.ts +1 -3
- package/dist/types-ts4.5/ui/on-paste-actions-menu/hasVisibleButton.d.ts +5 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste-options-toolbar
|
|
2
2
|
|
|
3
|
+
## 9.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7091cae4a7f26`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7091cae4a7f26) -
|
|
8
|
+
EDITOR-5607 Add analytics for new editor paste menu
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 8.4.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -49,7 +49,7 @@ var changeToPlainText = exports.changeToPlainText = function changeToPlainText()
|
|
|
49
49
|
};
|
|
50
50
|
return (0, _pluginFactory.createCommand)(commandAction, plaintextTransformer);
|
|
51
51
|
};
|
|
52
|
-
var changeToPlainTextWithAnalytics = exports.changeToPlainTextWithAnalytics = function changeToPlainTextWithAnalytics(editorAnalyticsAPI, sliceSize) {
|
|
52
|
+
var changeToPlainTextWithAnalytics = exports.changeToPlainTextWithAnalytics = function changeToPlainTextWithAnalytics(editorAnalyticsAPI, sliceSize, invokedFrom) {
|
|
53
53
|
return function () {
|
|
54
54
|
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
|
|
55
55
|
action: _analytics.ACTION.PASTED,
|
|
@@ -59,7 +59,8 @@ var changeToPlainTextWithAnalytics = exports.changeToPlainTextWithAnalytics = fu
|
|
|
59
59
|
inputMethod: _analytics.INPUT_METHOD.TOOLBAR,
|
|
60
60
|
type: _analytics.PasteTypes.plain,
|
|
61
61
|
content: _analytics.PasteContents.text,
|
|
62
|
-
pasteSize: sliceSize
|
|
62
|
+
pasteSize: sliceSize,
|
|
63
|
+
invokedFrom: invokedFrom
|
|
63
64
|
}
|
|
64
65
|
})(changeToPlainText());
|
|
65
66
|
};
|
|
@@ -85,7 +86,7 @@ var changeToRichText = exports.changeToRichText = function changeToRichText() {
|
|
|
85
86
|
};
|
|
86
87
|
return (0, _pluginFactory.createCommand)(commandAction, transformer);
|
|
87
88
|
};
|
|
88
|
-
var changeToRichTextWithAnalytics = exports.changeToRichTextWithAnalytics = function changeToRichTextWithAnalytics(editorAnalyticsAPI) {
|
|
89
|
+
var changeToRichTextWithAnalytics = exports.changeToRichTextWithAnalytics = function changeToRichTextWithAnalytics(editorAnalyticsAPI, invokedFrom) {
|
|
89
90
|
return function () {
|
|
90
91
|
var payloadCallback = function payloadCallback(state) {
|
|
91
92
|
var _pastePluginState$ric;
|
|
@@ -98,7 +99,8 @@ var changeToRichTextWithAnalytics = exports.changeToRichTextWithAnalytics = func
|
|
|
98
99
|
inputMethod: _analytics.INPUT_METHOD.TOOLBAR,
|
|
99
100
|
type: _analytics.PasteTypes.richText,
|
|
100
101
|
content: _analytics.PasteContents.text,
|
|
101
|
-
pasteSize: ((_pastePluginState$ric = pastePluginState.richTextSlice) === null || _pastePluginState$ric === void 0 ? void 0 : _pastePluginState$ric.size) || 0
|
|
102
|
+
pasteSize: ((_pastePluginState$ric = pastePluginState.richTextSlice) === null || _pastePluginState$ric === void 0 ? void 0 : _pastePluginState$ric.size) || 0,
|
|
103
|
+
invokedFrom: invokedFrom
|
|
102
104
|
}
|
|
103
105
|
};
|
|
104
106
|
};
|
|
@@ -123,7 +125,7 @@ var changeToMarkDown = exports.changeToMarkDown = function changeToMarkDown() {
|
|
|
123
125
|
};
|
|
124
126
|
return (0, _pluginFactory.createCommand)(commandAction, markdownTransformer);
|
|
125
127
|
};
|
|
126
|
-
var changeToMarkdownWithAnalytics = exports.changeToMarkdownWithAnalytics = function changeToMarkdownWithAnalytics(editorAnalyticsAPI, sliceSize) {
|
|
128
|
+
var changeToMarkdownWithAnalytics = exports.changeToMarkdownWithAnalytics = function changeToMarkdownWithAnalytics(editorAnalyticsAPI, sliceSize, invokedFrom) {
|
|
127
129
|
return function () {
|
|
128
130
|
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
|
|
129
131
|
action: _analytics.ACTION.PASTED,
|
|
@@ -133,7 +135,8 @@ var changeToMarkdownWithAnalytics = exports.changeToMarkdownWithAnalytics = func
|
|
|
133
135
|
inputMethod: _analytics.INPUT_METHOD.TOOLBAR,
|
|
134
136
|
type: _analytics.PasteTypes.markdown,
|
|
135
137
|
content: _analytics.PasteContents.text,
|
|
136
|
-
pasteSize: sliceSize
|
|
138
|
+
pasteSize: sliceSize,
|
|
139
|
+
invokedFrom: invokedFrom
|
|
137
140
|
}
|
|
138
141
|
})(changeToMarkDown());
|
|
139
142
|
};
|
|
@@ -22,8 +22,7 @@ var pasteOptionsToolbarPlugin = exports.pasteOptionsToolbarPlugin = function pas
|
|
|
22
22
|
if ((0, _expValEquals.expValEquals)('platform_editor_paste_actions_menu', 'isEnabled', true)) {
|
|
23
23
|
var _api$uiControlRegistr;
|
|
24
24
|
api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register((0, _PasteMenuComponents.getPasteMenuComponents)({
|
|
25
|
-
api: api
|
|
26
|
-
editorAnalyticsAPI: editorAnalyticsAPI
|
|
25
|
+
api: api
|
|
27
26
|
}));
|
|
28
27
|
}
|
|
29
28
|
return {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.PasteActionsMenu = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
9
10
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
11
|
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
11
12
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
@@ -40,12 +41,13 @@ function getPopupOffset(dom) {
|
|
|
40
41
|
return [-(window.innerWidth - rightEdge - 50), 20];
|
|
41
42
|
}
|
|
42
43
|
var PasteActionsMenu = exports.PasteActionsMenu = function PasteActionsMenu(_ref) {
|
|
43
|
-
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
44
|
+
var _api$analytics, _api$uiControlRegistr, _api$uiControlRegistr2, _api$uiControlRegistr3, _api$uiControlRegistr4;
|
|
44
45
|
var api = _ref.api,
|
|
45
46
|
editorView = _ref.editorView,
|
|
46
47
|
mountTo = _ref.mountTo,
|
|
47
48
|
boundariesElement = _ref.boundariesElement,
|
|
48
49
|
scrollableElement = _ref.scrollableElement;
|
|
50
|
+
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
49
51
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['paste'], function (states) {
|
|
50
52
|
var _states$pasteState;
|
|
51
53
|
return {
|
|
@@ -53,6 +55,7 @@ var PasteActionsMenu = exports.PasteActionsMenu = function PasteActionsMenu(_ref
|
|
|
53
55
|
};
|
|
54
56
|
}),
|
|
55
57
|
lastContentPasted = _useSharedPluginState.lastContentPasted;
|
|
58
|
+
var prevShowToolbarRef = (0, _react.useRef)(false);
|
|
56
59
|
(0, _react.useEffect)(function () {
|
|
57
60
|
if (!lastContentPasted) {
|
|
58
61
|
(0, _commands.hideToolbar)()(editorView.state, editorView.dispatch);
|
|
@@ -82,6 +85,22 @@ var PasteActionsMenu = exports.PasteActionsMenu = function PasteActionsMenu(_ref
|
|
|
82
85
|
};
|
|
83
86
|
}),
|
|
84
87
|
isToolbarShown = _useSharedPluginState2.showToolbar;
|
|
88
|
+
var aiSurfaceComponents = (_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents('ai-paste-menu')) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
|
|
89
|
+
var visibleAiActionKeys = (0, _hasVisibleButton.getVisibleKeys)(aiSurfaceComponents, ['button', 'menu-item']);
|
|
90
|
+
(0, _react.useEffect)(function () {
|
|
91
|
+
if (!prevShowToolbarRef.current && isToolbarShown) {
|
|
92
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent({
|
|
93
|
+
action: _analytics.ACTION.OPENED,
|
|
94
|
+
actionSubject: _analytics.ACTION_SUBJECT.PASTE_ACTIONS_MENU,
|
|
95
|
+
eventType: _analytics.EVENT_TYPE.UI,
|
|
96
|
+
attributes: {
|
|
97
|
+
visibleAiActions: visibleAiActionKeys
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
prevShowToolbarRef.current = isToolbarShown;
|
|
102
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
103
|
+
}, [isToolbarShown, editorAnalyticsAPI]);
|
|
85
104
|
var preventEditorFocusLoss = (0, _react.useCallback)(function (e) {
|
|
86
105
|
e.preventDefault();
|
|
87
106
|
}, []);
|
|
@@ -105,7 +124,7 @@ var PasteActionsMenu = exports.PasteActionsMenu = function PasteActionsMenu(_ref
|
|
|
105
124
|
handleDismiss();
|
|
106
125
|
}
|
|
107
126
|
}, [handleDismiss]);
|
|
108
|
-
var pasteMenuComponents = (_api$
|
|
127
|
+
var pasteMenuComponents = (_api$uiControlRegistr3 = api === null || api === void 0 || (_api$uiControlRegistr4 = api.uiControlRegistry) === null || _api$uiControlRegistr4 === void 0 ? void 0 : _api$uiControlRegistr4.actions.getComponents(_toolbar.PASTE_MENU.key)) !== null && _api$uiControlRegistr3 !== void 0 ? _api$uiControlRegistr3 : [];
|
|
109
128
|
var anyComponentVisible = (0, _hasVisibleButton.hasVisibleButton)(pasteMenuComponents);
|
|
110
129
|
if (!isToolbarShown) {
|
|
111
130
|
return null;
|
|
@@ -38,12 +38,13 @@ var isPasteOptionSelected = exports.isPasteOptionSelected = function isPasteOpti
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
var PasteMenuItem = function PasteMenuItem(_ref) {
|
|
41
|
+
var _api$analytics;
|
|
41
42
|
var api = _ref.api,
|
|
42
|
-
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
43
43
|
pasteType = _ref.pasteType;
|
|
44
44
|
var intl = (0, _reactIntlNext.useIntl)();
|
|
45
45
|
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
|
|
46
46
|
editorView = _useEditorToolbar.editorView;
|
|
47
|
+
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
47
48
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['pasteOptionsToolbarPlugin'], function (states) {
|
|
48
49
|
var _pluginState$selected, _pluginState$plaintex, _pluginState$isPlainT;
|
|
49
50
|
var pluginState = states.pasteOptionsToolbarPluginState;
|
|
@@ -114,8 +115,7 @@ var PasteOptionsNestedMenu = function PasteOptionsNestedMenu(_ref2) {
|
|
|
114
115
|
}, children);
|
|
115
116
|
};
|
|
116
117
|
var getPasteMenuComponents = exports.getPasteMenuComponents = function getPasteMenuComponents(_ref3) {
|
|
117
|
-
var api = _ref3.api
|
|
118
|
-
editorAnalyticsAPI = _ref3.editorAnalyticsAPI;
|
|
118
|
+
var api = _ref3.api;
|
|
119
119
|
return [{
|
|
120
120
|
type: _toolbar.PASTE_MENU.type,
|
|
121
121
|
key: _toolbar.PASTE_MENU.key
|
|
@@ -167,7 +167,6 @@ var getPasteMenuComponents = exports.getPasteMenuComponents = function getPasteM
|
|
|
167
167
|
component: function component() {
|
|
168
168
|
return /*#__PURE__*/_react.default.createElement(PasteMenuItem, {
|
|
169
169
|
api: api,
|
|
170
|
-
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
171
170
|
pasteType: "rich-text"
|
|
172
171
|
});
|
|
173
172
|
},
|
|
@@ -182,7 +181,6 @@ var getPasteMenuComponents = exports.getPasteMenuComponents = function getPasteM
|
|
|
182
181
|
component: function component() {
|
|
183
182
|
return /*#__PURE__*/_react.default.createElement(PasteMenuItem, {
|
|
184
183
|
api: api,
|
|
185
|
-
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
186
184
|
pasteType: "markdown"
|
|
187
185
|
});
|
|
188
186
|
},
|
|
@@ -197,7 +195,6 @@ var getPasteMenuComponents = exports.getPasteMenuComponents = function getPasteM
|
|
|
197
195
|
component: function component() {
|
|
198
196
|
return /*#__PURE__*/_react.default.createElement(PasteMenuItem, {
|
|
199
197
|
api: api,
|
|
200
|
-
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
201
198
|
pasteType: "plain-text"
|
|
202
199
|
});
|
|
203
200
|
},
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.hasVisibleButton = void 0;
|
|
6
|
+
exports.hasVisibleButton = exports.getVisibleKeys = void 0;
|
|
7
7
|
var _isComponentOrAncestorHidden = function isComponentOrAncestorHidden(component, componentsByKey) {
|
|
8
8
|
var _component$isHidden, _component$parents;
|
|
9
9
|
if ((_component$isHidden = component.isHidden) !== null && _component$isHidden !== void 0 && _component$isHidden.call(component)) {
|
|
@@ -16,16 +16,27 @@ var _isComponentOrAncestorHidden = function isComponentOrAncestorHidden(componen
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* Returns
|
|
20
|
-
* A
|
|
19
|
+
* Returns the keys of visible button/menu-item components in the list.
|
|
20
|
+
* A component is visible when neither it nor any of its ancestors are hidden.
|
|
21
21
|
*/
|
|
22
|
-
var
|
|
22
|
+
var getVisibleKeys = exports.getVisibleKeys = function getVisibleKeys(components) {
|
|
23
|
+
var types = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['menu-item'];
|
|
23
24
|
var componentsByKey = new Map(components.map(function (c) {
|
|
24
25
|
return [c.key, c];
|
|
25
26
|
}));
|
|
26
27
|
return components.filter(function (c) {
|
|
27
|
-
return c.type
|
|
28
|
-
}).
|
|
28
|
+
return types.includes(c.type);
|
|
29
|
+
}).filter(function (c) {
|
|
29
30
|
return !_isComponentOrAncestorHidden(c, componentsByKey);
|
|
31
|
+
}).map(function (c) {
|
|
32
|
+
return c.key;
|
|
30
33
|
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Returns true when at least one menu-item button in the list is visible.
|
|
38
|
+
* A button is visible when neither it nor any of its ancestors are hidden.
|
|
39
|
+
*/
|
|
40
|
+
var hasVisibleButton = exports.hasVisibleButton = function hasVisibleButton(components) {
|
|
41
|
+
return getVisibleKeys(components).length > 0;
|
|
31
42
|
};
|
|
@@ -41,7 +41,7 @@ export const changeToPlainText = () => {
|
|
|
41
41
|
};
|
|
42
42
|
return createCommand(commandAction, plaintextTransformer);
|
|
43
43
|
};
|
|
44
|
-
export const changeToPlainTextWithAnalytics = (editorAnalyticsAPI, sliceSize) => () => {
|
|
44
|
+
export const changeToPlainTextWithAnalytics = (editorAnalyticsAPI, sliceSize, invokedFrom) => () => {
|
|
45
45
|
return withAnalytics(editorAnalyticsAPI, {
|
|
46
46
|
action: ACTION.PASTED,
|
|
47
47
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
@@ -50,7 +50,8 @@ export const changeToPlainTextWithAnalytics = (editorAnalyticsAPI, sliceSize) =>
|
|
|
50
50
|
inputMethod: INPUT_METHOD.TOOLBAR,
|
|
51
51
|
type: PasteTypes.plain,
|
|
52
52
|
content: PasteContents.text,
|
|
53
|
-
pasteSize: sliceSize
|
|
53
|
+
pasteSize: sliceSize,
|
|
54
|
+
invokedFrom
|
|
54
55
|
}
|
|
55
56
|
})(changeToPlainText());
|
|
56
57
|
};
|
|
@@ -75,7 +76,7 @@ export const changeToRichText = () => {
|
|
|
75
76
|
};
|
|
76
77
|
return createCommand(commandAction, transformer);
|
|
77
78
|
};
|
|
78
|
-
export const changeToRichTextWithAnalytics = editorAnalyticsAPI => () => {
|
|
79
|
+
export const changeToRichTextWithAnalytics = (editorAnalyticsAPI, invokedFrom) => () => {
|
|
79
80
|
const payloadCallback = state => {
|
|
80
81
|
var _pastePluginState$ric;
|
|
81
82
|
const pastePluginState = pasteOptionsPluginKey.getState(state);
|
|
@@ -87,7 +88,8 @@ export const changeToRichTextWithAnalytics = editorAnalyticsAPI => () => {
|
|
|
87
88
|
inputMethod: INPUT_METHOD.TOOLBAR,
|
|
88
89
|
type: PasteTypes.richText,
|
|
89
90
|
content: PasteContents.text,
|
|
90
|
-
pasteSize: ((_pastePluginState$ric = pastePluginState.richTextSlice) === null || _pastePluginState$ric === void 0 ? void 0 : _pastePluginState$ric.size) || 0
|
|
91
|
+
pasteSize: ((_pastePluginState$ric = pastePluginState.richTextSlice) === null || _pastePluginState$ric === void 0 ? void 0 : _pastePluginState$ric.size) || 0,
|
|
92
|
+
invokedFrom
|
|
91
93
|
}
|
|
92
94
|
};
|
|
93
95
|
};
|
|
@@ -111,7 +113,7 @@ export const changeToMarkDown = () => {
|
|
|
111
113
|
};
|
|
112
114
|
return createCommand(commandAction, markdownTransformer);
|
|
113
115
|
};
|
|
114
|
-
export const changeToMarkdownWithAnalytics = (editorAnalyticsAPI, sliceSize) => () => {
|
|
116
|
+
export const changeToMarkdownWithAnalytics = (editorAnalyticsAPI, sliceSize, invokedFrom) => () => {
|
|
115
117
|
return withAnalytics(editorAnalyticsAPI, {
|
|
116
118
|
action: ACTION.PASTED,
|
|
117
119
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
@@ -120,7 +122,8 @@ export const changeToMarkdownWithAnalytics = (editorAnalyticsAPI, sliceSize) =>
|
|
|
120
122
|
inputMethod: INPUT_METHOD.TOOLBAR,
|
|
121
123
|
type: PasteTypes.markdown,
|
|
122
124
|
content: PasteContents.text,
|
|
123
|
-
pasteSize: sliceSize
|
|
125
|
+
pasteSize: sliceSize,
|
|
126
|
+
invokedFrom
|
|
124
127
|
}
|
|
125
128
|
})(changeToMarkDown());
|
|
126
129
|
};
|
|
@@ -15,8 +15,7 @@ export const pasteOptionsToolbarPlugin = ({
|
|
|
15
15
|
if (expValEquals('platform_editor_paste_actions_menu', 'isEnabled', true)) {
|
|
16
16
|
var _api$uiControlRegistr;
|
|
17
17
|
api === null || api === void 0 ? void 0 : (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 ? void 0 : _api$uiControlRegistr.actions.register(getPasteMenuComponents({
|
|
18
|
-
api
|
|
19
|
-
editorAnalyticsAPI
|
|
18
|
+
api
|
|
20
19
|
}));
|
|
21
20
|
}
|
|
22
21
|
return {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React, { useCallback, useEffect } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
4
|
import { EditorToolbarProvider, PASTE_MENU } from '@atlaskit/editor-common/toolbar';
|
|
4
5
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
@@ -9,7 +10,7 @@ import { ToolbarDropdownMenuProvider } from '@atlaskit/editor-toolbar';
|
|
|
9
10
|
import { hideToolbar, highlightContent, showToolbar } from '../../editor-commands/commands';
|
|
10
11
|
import { ToolbarDropdownOption } from '../../types/types';
|
|
11
12
|
import { isToolbarVisible } from '../toolbar';
|
|
12
|
-
import { hasVisibleButton } from './hasVisibleButton';
|
|
13
|
+
import { getVisibleKeys, hasVisibleButton } from './hasVisibleButton';
|
|
13
14
|
import { PasteActionsMenuContent } from './PasteActionsMenuContent';
|
|
14
15
|
const PopupWithListeners = withReactEditorViewOuterListeners(Popup);
|
|
15
16
|
function getTargetElement(editorView) {
|
|
@@ -40,7 +41,8 @@ export const PasteActionsMenu = ({
|
|
|
40
41
|
boundariesElement,
|
|
41
42
|
scrollableElement
|
|
42
43
|
}) => {
|
|
43
|
-
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
44
|
+
var _api$analytics, _api$uiControlRegistr, _api$uiControlRegistr2, _api$uiControlRegistr3, _api$uiControlRegistr4;
|
|
45
|
+
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
44
46
|
const {
|
|
45
47
|
lastContentPasted
|
|
46
48
|
} = useSharedPluginStateWithSelector(api, ['paste'], states => {
|
|
@@ -49,6 +51,7 @@ export const PasteActionsMenu = ({
|
|
|
49
51
|
lastContentPasted: (_states$pasteState = states.pasteState) === null || _states$pasteState === void 0 ? void 0 : _states$pasteState.lastContentPasted
|
|
50
52
|
};
|
|
51
53
|
});
|
|
54
|
+
const prevShowToolbarRef = useRef(false);
|
|
52
55
|
useEffect(() => {
|
|
53
56
|
if (!lastContentPasted) {
|
|
54
57
|
hideToolbar()(editorView.state, editorView.dispatch);
|
|
@@ -79,6 +82,22 @@ export const PasteActionsMenu = ({
|
|
|
79
82
|
showToolbar: (_pluginState$showTool = pluginState === null || pluginState === void 0 ? void 0 : pluginState.showToolbar) !== null && _pluginState$showTool !== void 0 ? _pluginState$showTool : false
|
|
80
83
|
};
|
|
81
84
|
});
|
|
85
|
+
const aiSurfaceComponents = (_api$uiControlRegistr = api === null || api === void 0 ? void 0 : (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents('ai-paste-menu')) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
|
|
86
|
+
const visibleAiActionKeys = getVisibleKeys(aiSurfaceComponents, ['button', 'menu-item']);
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (!prevShowToolbarRef.current && isToolbarShown) {
|
|
89
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.fireAnalyticsEvent({
|
|
90
|
+
action: ACTION.OPENED,
|
|
91
|
+
actionSubject: ACTION_SUBJECT.PASTE_ACTIONS_MENU,
|
|
92
|
+
eventType: EVENT_TYPE.UI,
|
|
93
|
+
attributes: {
|
|
94
|
+
visibleAiActions: visibleAiActionKeys
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
prevShowToolbarRef.current = isToolbarShown;
|
|
99
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
100
|
+
}, [isToolbarShown, editorAnalyticsAPI]);
|
|
82
101
|
const preventEditorFocusLoss = useCallback(e => {
|
|
83
102
|
e.preventDefault();
|
|
84
103
|
}, []);
|
|
@@ -102,7 +121,7 @@ export const PasteActionsMenu = ({
|
|
|
102
121
|
handleDismiss();
|
|
103
122
|
}
|
|
104
123
|
}, [handleDismiss]);
|
|
105
|
-
const pasteMenuComponents = (_api$
|
|
124
|
+
const pasteMenuComponents = (_api$uiControlRegistr3 = api === null || api === void 0 ? void 0 : (_api$uiControlRegistr4 = api.uiControlRegistry) === null || _api$uiControlRegistr4 === void 0 ? void 0 : _api$uiControlRegistr4.actions.getComponents(PASTE_MENU.key)) !== null && _api$uiControlRegistr3 !== void 0 ? _api$uiControlRegistr3 : [];
|
|
106
125
|
const anyComponentVisible = hasVisibleButton(pasteMenuComponents);
|
|
107
126
|
if (!isToolbarShown) {
|
|
108
127
|
return null;
|
|
@@ -30,13 +30,14 @@ export const isPasteOptionSelected = (pasteType, selectedOption) => {
|
|
|
30
30
|
};
|
|
31
31
|
const PasteMenuItem = ({
|
|
32
32
|
api,
|
|
33
|
-
editorAnalyticsAPI,
|
|
34
33
|
pasteType
|
|
35
34
|
}) => {
|
|
35
|
+
var _api$analytics;
|
|
36
36
|
const intl = useIntl();
|
|
37
37
|
const {
|
|
38
38
|
editorView
|
|
39
39
|
} = useEditorToolbar();
|
|
40
|
+
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
40
41
|
const {
|
|
41
42
|
selectedOption,
|
|
42
43
|
plaintextLength,
|
|
@@ -109,8 +110,7 @@ const PasteOptionsNestedMenu = ({
|
|
|
109
110
|
}, children);
|
|
110
111
|
};
|
|
111
112
|
export const getPasteMenuComponents = ({
|
|
112
|
-
api
|
|
113
|
-
editorAnalyticsAPI
|
|
113
|
+
api
|
|
114
114
|
}) => [{
|
|
115
115
|
type: PASTE_MENU.type,
|
|
116
116
|
key: PASTE_MENU.key
|
|
@@ -155,7 +155,6 @@ export const getPasteMenuComponents = ({
|
|
|
155
155
|
type: PASTE_RICH_TEXT_MENU_ITEM.type,
|
|
156
156
|
component: () => /*#__PURE__*/React.createElement(PasteMenuItem, {
|
|
157
157
|
api: api,
|
|
158
|
-
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
159
158
|
pasteType: "rich-text"
|
|
160
159
|
}),
|
|
161
160
|
parents: [{
|
|
@@ -168,7 +167,6 @@ export const getPasteMenuComponents = ({
|
|
|
168
167
|
type: PASTE_MARKDOWN_MENU_ITEM.type,
|
|
169
168
|
component: () => /*#__PURE__*/React.createElement(PasteMenuItem, {
|
|
170
169
|
api: api,
|
|
171
|
-
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
172
170
|
pasteType: "markdown"
|
|
173
171
|
}),
|
|
174
172
|
parents: [{
|
|
@@ -181,7 +179,6 @@ export const getPasteMenuComponents = ({
|
|
|
181
179
|
type: PASTE_PLAIN_TEXT_MENU_ITEM.type,
|
|
182
180
|
component: () => /*#__PURE__*/React.createElement(PasteMenuItem, {
|
|
183
181
|
api: api,
|
|
184
|
-
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
185
182
|
pasteType: "plain-text"
|
|
186
183
|
}),
|
|
187
184
|
parents: [{
|
|
@@ -9,11 +9,19 @@ const isComponentOrAncestorHidden = (component, componentsByKey) => {
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Returns the keys of visible button/menu-item components in the list.
|
|
14
|
+
* A component is visible when neither it nor any of its ancestors are hidden.
|
|
15
|
+
*/
|
|
16
|
+
export const getVisibleKeys = (components, types = ['menu-item']) => {
|
|
17
|
+
const componentsByKey = new Map(components.map(c => [c.key, c]));
|
|
18
|
+
return components.filter(c => types.includes(c.type)).filter(c => !isComponentOrAncestorHidden(c, componentsByKey)).map(c => c.key);
|
|
19
|
+
};
|
|
20
|
+
|
|
12
21
|
/**
|
|
13
22
|
* Returns true when at least one menu-item button in the list is visible.
|
|
14
23
|
* A button is visible when neither it nor any of its ancestors are hidden.
|
|
15
24
|
*/
|
|
16
25
|
export const hasVisibleButton = components => {
|
|
17
|
-
|
|
18
|
-
return components.filter(c => c.type === 'menu-item').some(c => !isComponentOrAncestorHidden(c, componentsByKey));
|
|
26
|
+
return getVisibleKeys(components).length > 0;
|
|
19
27
|
};
|
|
@@ -43,7 +43,7 @@ export var changeToPlainText = function changeToPlainText() {
|
|
|
43
43
|
};
|
|
44
44
|
return createCommand(commandAction, plaintextTransformer);
|
|
45
45
|
};
|
|
46
|
-
export var changeToPlainTextWithAnalytics = function changeToPlainTextWithAnalytics(editorAnalyticsAPI, sliceSize) {
|
|
46
|
+
export var changeToPlainTextWithAnalytics = function changeToPlainTextWithAnalytics(editorAnalyticsAPI, sliceSize, invokedFrom) {
|
|
47
47
|
return function () {
|
|
48
48
|
return withAnalytics(editorAnalyticsAPI, {
|
|
49
49
|
action: ACTION.PASTED,
|
|
@@ -53,7 +53,8 @@ export var changeToPlainTextWithAnalytics = function changeToPlainTextWithAnalyt
|
|
|
53
53
|
inputMethod: INPUT_METHOD.TOOLBAR,
|
|
54
54
|
type: PasteTypes.plain,
|
|
55
55
|
content: PasteContents.text,
|
|
56
|
-
pasteSize: sliceSize
|
|
56
|
+
pasteSize: sliceSize,
|
|
57
|
+
invokedFrom: invokedFrom
|
|
57
58
|
}
|
|
58
59
|
})(changeToPlainText());
|
|
59
60
|
};
|
|
@@ -79,7 +80,7 @@ export var changeToRichText = function changeToRichText() {
|
|
|
79
80
|
};
|
|
80
81
|
return createCommand(commandAction, transformer);
|
|
81
82
|
};
|
|
82
|
-
export var changeToRichTextWithAnalytics = function changeToRichTextWithAnalytics(editorAnalyticsAPI) {
|
|
83
|
+
export var changeToRichTextWithAnalytics = function changeToRichTextWithAnalytics(editorAnalyticsAPI, invokedFrom) {
|
|
83
84
|
return function () {
|
|
84
85
|
var payloadCallback = function payloadCallback(state) {
|
|
85
86
|
var _pastePluginState$ric;
|
|
@@ -92,7 +93,8 @@ export var changeToRichTextWithAnalytics = function changeToRichTextWithAnalytic
|
|
|
92
93
|
inputMethod: INPUT_METHOD.TOOLBAR,
|
|
93
94
|
type: PasteTypes.richText,
|
|
94
95
|
content: PasteContents.text,
|
|
95
|
-
pasteSize: ((_pastePluginState$ric = pastePluginState.richTextSlice) === null || _pastePluginState$ric === void 0 ? void 0 : _pastePluginState$ric.size) || 0
|
|
96
|
+
pasteSize: ((_pastePluginState$ric = pastePluginState.richTextSlice) === null || _pastePluginState$ric === void 0 ? void 0 : _pastePluginState$ric.size) || 0,
|
|
97
|
+
invokedFrom: invokedFrom
|
|
96
98
|
}
|
|
97
99
|
};
|
|
98
100
|
};
|
|
@@ -117,7 +119,7 @@ export var changeToMarkDown = function changeToMarkDown() {
|
|
|
117
119
|
};
|
|
118
120
|
return createCommand(commandAction, markdownTransformer);
|
|
119
121
|
};
|
|
120
|
-
export var changeToMarkdownWithAnalytics = function changeToMarkdownWithAnalytics(editorAnalyticsAPI, sliceSize) {
|
|
122
|
+
export var changeToMarkdownWithAnalytics = function changeToMarkdownWithAnalytics(editorAnalyticsAPI, sliceSize, invokedFrom) {
|
|
121
123
|
return function () {
|
|
122
124
|
return withAnalytics(editorAnalyticsAPI, {
|
|
123
125
|
action: ACTION.PASTED,
|
|
@@ -127,7 +129,8 @@ export var changeToMarkdownWithAnalytics = function changeToMarkdownWithAnalytic
|
|
|
127
129
|
inputMethod: INPUT_METHOD.TOOLBAR,
|
|
128
130
|
type: PasteTypes.markdown,
|
|
129
131
|
content: PasteContents.text,
|
|
130
|
-
pasteSize: sliceSize
|
|
132
|
+
pasteSize: sliceSize,
|
|
133
|
+
invokedFrom: invokedFrom
|
|
131
134
|
}
|
|
132
135
|
})(changeToMarkDown());
|
|
133
136
|
};
|
|
@@ -14,8 +14,7 @@ export var pasteOptionsToolbarPlugin = function pasteOptionsToolbarPlugin(_ref)
|
|
|
14
14
|
if (expValEquals('platform_editor_paste_actions_menu', 'isEnabled', true)) {
|
|
15
15
|
var _api$uiControlRegistr;
|
|
16
16
|
api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register(getPasteMenuComponents({
|
|
17
|
-
api: api
|
|
18
|
-
editorAnalyticsAPI: editorAnalyticsAPI
|
|
17
|
+
api: api
|
|
19
18
|
}));
|
|
20
19
|
}
|
|
21
20
|
return {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React, { useCallback, useEffect } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
4
|
import { EditorToolbarProvider, PASTE_MENU } from '@atlaskit/editor-common/toolbar';
|
|
4
5
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
@@ -9,7 +10,7 @@ import { ToolbarDropdownMenuProvider } from '@atlaskit/editor-toolbar';
|
|
|
9
10
|
import { hideToolbar, highlightContent, showToolbar } from '../../editor-commands/commands';
|
|
10
11
|
import { ToolbarDropdownOption } from '../../types/types';
|
|
11
12
|
import { isToolbarVisible } from '../toolbar';
|
|
12
|
-
import { hasVisibleButton } from './hasVisibleButton';
|
|
13
|
+
import { getVisibleKeys, hasVisibleButton } from './hasVisibleButton';
|
|
13
14
|
import { PasteActionsMenuContent } from './PasteActionsMenuContent';
|
|
14
15
|
var PopupWithListeners = withReactEditorViewOuterListeners(Popup);
|
|
15
16
|
function getTargetElement(editorView) {
|
|
@@ -32,12 +33,13 @@ function getPopupOffset(dom) {
|
|
|
32
33
|
return [-(window.innerWidth - rightEdge - 50), 20];
|
|
33
34
|
}
|
|
34
35
|
export var PasteActionsMenu = function PasteActionsMenu(_ref) {
|
|
35
|
-
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
36
|
+
var _api$analytics, _api$uiControlRegistr, _api$uiControlRegistr2, _api$uiControlRegistr3, _api$uiControlRegistr4;
|
|
36
37
|
var api = _ref.api,
|
|
37
38
|
editorView = _ref.editorView,
|
|
38
39
|
mountTo = _ref.mountTo,
|
|
39
40
|
boundariesElement = _ref.boundariesElement,
|
|
40
41
|
scrollableElement = _ref.scrollableElement;
|
|
42
|
+
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
41
43
|
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['paste'], function (states) {
|
|
42
44
|
var _states$pasteState;
|
|
43
45
|
return {
|
|
@@ -45,6 +47,7 @@ export var PasteActionsMenu = function PasteActionsMenu(_ref) {
|
|
|
45
47
|
};
|
|
46
48
|
}),
|
|
47
49
|
lastContentPasted = _useSharedPluginState.lastContentPasted;
|
|
50
|
+
var prevShowToolbarRef = useRef(false);
|
|
48
51
|
useEffect(function () {
|
|
49
52
|
if (!lastContentPasted) {
|
|
50
53
|
hideToolbar()(editorView.state, editorView.dispatch);
|
|
@@ -74,6 +77,22 @@ export var PasteActionsMenu = function PasteActionsMenu(_ref) {
|
|
|
74
77
|
};
|
|
75
78
|
}),
|
|
76
79
|
isToolbarShown = _useSharedPluginState2.showToolbar;
|
|
80
|
+
var aiSurfaceComponents = (_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents('ai-paste-menu')) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
|
|
81
|
+
var visibleAiActionKeys = getVisibleKeys(aiSurfaceComponents, ['button', 'menu-item']);
|
|
82
|
+
useEffect(function () {
|
|
83
|
+
if (!prevShowToolbarRef.current && isToolbarShown) {
|
|
84
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent({
|
|
85
|
+
action: ACTION.OPENED,
|
|
86
|
+
actionSubject: ACTION_SUBJECT.PASTE_ACTIONS_MENU,
|
|
87
|
+
eventType: EVENT_TYPE.UI,
|
|
88
|
+
attributes: {
|
|
89
|
+
visibleAiActions: visibleAiActionKeys
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
prevShowToolbarRef.current = isToolbarShown;
|
|
94
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
95
|
+
}, [isToolbarShown, editorAnalyticsAPI]);
|
|
77
96
|
var preventEditorFocusLoss = useCallback(function (e) {
|
|
78
97
|
e.preventDefault();
|
|
79
98
|
}, []);
|
|
@@ -97,7 +116,7 @@ export var PasteActionsMenu = function PasteActionsMenu(_ref) {
|
|
|
97
116
|
handleDismiss();
|
|
98
117
|
}
|
|
99
118
|
}, [handleDismiss]);
|
|
100
|
-
var pasteMenuComponents = (_api$
|
|
119
|
+
var pasteMenuComponents = (_api$uiControlRegistr3 = api === null || api === void 0 || (_api$uiControlRegistr4 = api.uiControlRegistry) === null || _api$uiControlRegistr4 === void 0 ? void 0 : _api$uiControlRegistr4.actions.getComponents(PASTE_MENU.key)) !== null && _api$uiControlRegistr3 !== void 0 ? _api$uiControlRegistr3 : [];
|
|
101
120
|
var anyComponentVisible = hasVisibleButton(pasteMenuComponents);
|
|
102
121
|
if (!isToolbarShown) {
|
|
103
122
|
return null;
|
|
@@ -29,12 +29,13 @@ export var isPasteOptionSelected = function isPasteOptionSelected(pasteType, sel
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
var PasteMenuItem = function PasteMenuItem(_ref) {
|
|
32
|
+
var _api$analytics;
|
|
32
33
|
var api = _ref.api,
|
|
33
|
-
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
34
34
|
pasteType = _ref.pasteType;
|
|
35
35
|
var intl = useIntl();
|
|
36
36
|
var _useEditorToolbar = useEditorToolbar(),
|
|
37
37
|
editorView = _useEditorToolbar.editorView;
|
|
38
|
+
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
38
39
|
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['pasteOptionsToolbarPlugin'], function (states) {
|
|
39
40
|
var _pluginState$selected, _pluginState$plaintex, _pluginState$isPlainT;
|
|
40
41
|
var pluginState = states.pasteOptionsToolbarPluginState;
|
|
@@ -105,8 +106,7 @@ var PasteOptionsNestedMenu = function PasteOptionsNestedMenu(_ref2) {
|
|
|
105
106
|
}, children);
|
|
106
107
|
};
|
|
107
108
|
export var getPasteMenuComponents = function getPasteMenuComponents(_ref3) {
|
|
108
|
-
var api = _ref3.api
|
|
109
|
-
editorAnalyticsAPI = _ref3.editorAnalyticsAPI;
|
|
109
|
+
var api = _ref3.api;
|
|
110
110
|
return [{
|
|
111
111
|
type: PASTE_MENU.type,
|
|
112
112
|
key: PASTE_MENU.key
|
|
@@ -158,7 +158,6 @@ export var getPasteMenuComponents = function getPasteMenuComponents(_ref3) {
|
|
|
158
158
|
component: function component() {
|
|
159
159
|
return /*#__PURE__*/React.createElement(PasteMenuItem, {
|
|
160
160
|
api: api,
|
|
161
|
-
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
162
161
|
pasteType: "rich-text"
|
|
163
162
|
});
|
|
164
163
|
},
|
|
@@ -173,7 +172,6 @@ export var getPasteMenuComponents = function getPasteMenuComponents(_ref3) {
|
|
|
173
172
|
component: function component() {
|
|
174
173
|
return /*#__PURE__*/React.createElement(PasteMenuItem, {
|
|
175
174
|
api: api,
|
|
176
|
-
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
177
175
|
pasteType: "markdown"
|
|
178
176
|
});
|
|
179
177
|
},
|
|
@@ -188,7 +186,6 @@ export var getPasteMenuComponents = function getPasteMenuComponents(_ref3) {
|
|
|
188
186
|
component: function component() {
|
|
189
187
|
return /*#__PURE__*/React.createElement(PasteMenuItem, {
|
|
190
188
|
api: api,
|
|
191
|
-
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
192
189
|
pasteType: "plain-text"
|
|
193
190
|
});
|
|
194
191
|
},
|
|
@@ -10,16 +10,27 @@ var _isComponentOrAncestorHidden = function isComponentOrAncestorHidden(componen
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Returns
|
|
14
|
-
* A
|
|
13
|
+
* Returns the keys of visible button/menu-item components in the list.
|
|
14
|
+
* A component is visible when neither it nor any of its ancestors are hidden.
|
|
15
15
|
*/
|
|
16
|
-
export var
|
|
16
|
+
export var getVisibleKeys = function getVisibleKeys(components) {
|
|
17
|
+
var types = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['menu-item'];
|
|
17
18
|
var componentsByKey = new Map(components.map(function (c) {
|
|
18
19
|
return [c.key, c];
|
|
19
20
|
}));
|
|
20
21
|
return components.filter(function (c) {
|
|
21
|
-
return c.type
|
|
22
|
-
}).
|
|
22
|
+
return types.includes(c.type);
|
|
23
|
+
}).filter(function (c) {
|
|
23
24
|
return !_isComponentOrAncestorHidden(c, componentsByKey);
|
|
25
|
+
}).map(function (c) {
|
|
26
|
+
return c.key;
|
|
24
27
|
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Returns true when at least one menu-item button in the list is visible.
|
|
32
|
+
* A button is visible when neither it nor any of its ancestors are hidden.
|
|
33
|
+
*/
|
|
34
|
+
export var hasVisibleButton = function hasVisibleButton(components) {
|
|
35
|
+
return getVisibleKeys(components).length > 0;
|
|
25
36
|
};
|
|
@@ -5,12 +5,12 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
|
5
5
|
import { ToolbarDropdownOption } from '../types/types';
|
|
6
6
|
export declare const showToolbar: (lastContentPasted: LastContentPasted, selectedOption: ToolbarDropdownOption, showLegacyOptions?: boolean, pasteAncestorNodeNames?: string[]) => Command;
|
|
7
7
|
export declare const changeToPlainText: () => Command;
|
|
8
|
-
export declare const changeToPlainTextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, sliceSize: number) => () => Command;
|
|
8
|
+
export declare const changeToPlainTextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, sliceSize: number, invokedFrom?: string) => () => Command;
|
|
9
9
|
export declare const dropdownClickHandler: () => Command;
|
|
10
10
|
export declare const changeToRichText: () => Command;
|
|
11
|
-
export declare const changeToRichTextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => () => Command;
|
|
11
|
+
export declare const changeToRichTextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, invokedFrom?: string) => () => Command;
|
|
12
12
|
export declare const changeToMarkDown: () => Command;
|
|
13
|
-
export declare const changeToMarkdownWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, sliceSize: number) => () => Command;
|
|
13
|
+
export declare const changeToMarkdownWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, sliceSize: number, invokedFrom?: string) => () => Command;
|
|
14
14
|
export declare const highlightContent: () => Command;
|
|
15
15
|
export declare const hideToolbar: () => Command;
|
|
16
16
|
export declare const checkAndHideToolbar: (view: EditorView) => void;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
1
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
2
|
import type { RegisterComponent } from '@atlaskit/editor-ui-control-model';
|
|
4
3
|
import type { PasteOptionsToolbarPlugin } from '../../pasteOptionsToolbarPluginType';
|
|
@@ -6,7 +5,6 @@ import { ToolbarDropdownOption, type PasteType } from '../../types/types';
|
|
|
6
5
|
export declare const isPasteOptionSelected: (pasteType: PasteType, selectedOption: ToolbarDropdownOption) => boolean;
|
|
7
6
|
interface PasteMenuComponentsConfig {
|
|
8
7
|
api: ExtractInjectionAPI<PasteOptionsToolbarPlugin> | undefined;
|
|
9
|
-
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
10
8
|
}
|
|
11
|
-
export declare const getPasteMenuComponents: ({ api,
|
|
9
|
+
export declare const getPasteMenuComponents: ({ api, }: PasteMenuComponentsConfig) => RegisterComponent[];
|
|
12
10
|
export {};
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { RegisterComponent } from '@atlaskit/editor-ui-control-model';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the keys of visible button/menu-item components in the list.
|
|
4
|
+
* A component is visible when neither it nor any of its ancestors are hidden.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getVisibleKeys: (components: RegisterComponent[], types?: RegisterComponent["type"][]) => string[];
|
|
2
7
|
/**
|
|
3
8
|
* Returns true when at least one menu-item button in the list is visible.
|
|
4
9
|
* A button is visible when neither it nor any of its ancestors are hidden.
|
|
@@ -5,12 +5,12 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
|
5
5
|
import { ToolbarDropdownOption } from '../types/types';
|
|
6
6
|
export declare const showToolbar: (lastContentPasted: LastContentPasted, selectedOption: ToolbarDropdownOption, showLegacyOptions?: boolean, pasteAncestorNodeNames?: string[]) => Command;
|
|
7
7
|
export declare const changeToPlainText: () => Command;
|
|
8
|
-
export declare const changeToPlainTextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, sliceSize: number) => () => Command;
|
|
8
|
+
export declare const changeToPlainTextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, sliceSize: number, invokedFrom?: string) => () => Command;
|
|
9
9
|
export declare const dropdownClickHandler: () => Command;
|
|
10
10
|
export declare const changeToRichText: () => Command;
|
|
11
|
-
export declare const changeToRichTextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => () => Command;
|
|
11
|
+
export declare const changeToRichTextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, invokedFrom?: string) => () => Command;
|
|
12
12
|
export declare const changeToMarkDown: () => Command;
|
|
13
|
-
export declare const changeToMarkdownWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, sliceSize: number) => () => Command;
|
|
13
|
+
export declare const changeToMarkdownWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, sliceSize: number, invokedFrom?: string) => () => Command;
|
|
14
14
|
export declare const highlightContent: () => Command;
|
|
15
15
|
export declare const hideToolbar: () => Command;
|
|
16
16
|
export declare const checkAndHideToolbar: (view: EditorView) => void;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
1
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
2
|
import type { RegisterComponent } from '@atlaskit/editor-ui-control-model';
|
|
4
3
|
import type { PasteOptionsToolbarPlugin } from '../../pasteOptionsToolbarPluginType';
|
|
@@ -6,7 +5,6 @@ import { ToolbarDropdownOption, type PasteType } from '../../types/types';
|
|
|
6
5
|
export declare const isPasteOptionSelected: (pasteType: PasteType, selectedOption: ToolbarDropdownOption) => boolean;
|
|
7
6
|
interface PasteMenuComponentsConfig {
|
|
8
7
|
api: ExtractInjectionAPI<PasteOptionsToolbarPlugin> | undefined;
|
|
9
|
-
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
10
8
|
}
|
|
11
|
-
export declare const getPasteMenuComponents: ({ api,
|
|
9
|
+
export declare const getPasteMenuComponents: ({ api, }: PasteMenuComponentsConfig) => RegisterComponent[];
|
|
12
10
|
export {};
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { RegisterComponent } from '@atlaskit/editor-ui-control-model';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the keys of visible button/menu-item components in the list.
|
|
4
|
+
* A component is visible when neither it nor any of its ancestors are hidden.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getVisibleKeys: (components: RegisterComponent[], types?: RegisterComponent["type"][]) => string[];
|
|
2
7
|
/**
|
|
3
8
|
* Returns true when at least one menu-item button in the list is visible.
|
|
4
9
|
* A button is visible when neither it nor any of its ancestors are hidden.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste-options-toolbar",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Paste options toolbar for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@atlaskit/css": "^0.19.0",
|
|
33
33
|
"@atlaskit/editor-markdown-transformer": "^5.20.0",
|
|
34
|
-
"@atlaskit/editor-plugin-analytics": "^
|
|
35
|
-
"@atlaskit/editor-plugin-paste": "^
|
|
36
|
-
"@atlaskit/editor-plugin-ui-control-registry": "^
|
|
34
|
+
"@atlaskit/editor-plugin-analytics": "^8.0.0",
|
|
35
|
+
"@atlaskit/editor-plugin-paste": "^9.0.0",
|
|
36
|
+
"@atlaskit/editor-plugin-ui-control-registry": "^2.0.0",
|
|
37
37
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
38
38
|
"@atlaskit/editor-shared-styles": "^3.10.0",
|
|
39
39
|
"@atlaskit/editor-toolbar": "^0.19.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@atlaskit/icon": "^32.0.0",
|
|
42
42
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
43
43
|
"@atlaskit/primitives": "^18.0.0",
|
|
44
|
-
"@atlaskit/tmp-editor-statsig": "^35.
|
|
44
|
+
"@atlaskit/tmp-editor-statsig": "^35.10.0",
|
|
45
45
|
"@atlaskit/tokens": "^11.1.0",
|
|
46
46
|
"@babel/runtime": "^7.0.0",
|
|
47
47
|
"@compiled/react": "^0.20.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@atlaskit/editor-common": "^
|
|
52
|
+
"@atlaskit/editor-common": "^112.0.0",
|
|
53
53
|
"react": "^18.2.0",
|
|
54
54
|
"react-dom": "^18.2.0"
|
|
55
55
|
},
|