@atlaskit/editor-plugin-paste-options-toolbar 9.1.7 → 9.1.8
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
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste-options-toolbar
|
|
2
2
|
|
|
3
|
+
## 9.1.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`fb9bbd5719238`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fb9bbd5719238) -
|
|
8
|
+
EDITOR-6193 Correcting `visibleAiActions` attribute of paste actions menu which was not being
|
|
9
|
+
populated.
|
|
10
|
+
|
|
3
11
|
## 9.1.7
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -225,7 +225,7 @@ function onPositionCalculated(editorView, pasteStartPos, pasteEndPos, targetElem
|
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
227
|
var PasteActionsMenu = exports.PasteActionsMenu = function PasteActionsMenu(_ref) {
|
|
228
|
-
var _api$analytics, _api$uiControlRegistr, _api$uiControlRegistr2
|
|
228
|
+
var _api$analytics, _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
229
229
|
var api = _ref.api,
|
|
230
230
|
editorView = _ref.editorView,
|
|
231
231
|
mountTo = _ref.mountTo,
|
|
@@ -279,22 +279,6 @@ var PasteActionsMenu = exports.PasteActionsMenu = function PasteActionsMenu(_ref
|
|
|
279
279
|
isToolbarShown = _useSharedPluginState2.showToolbar,
|
|
280
280
|
pasteStartPos = _useSharedPluginState2.pasteStartPos,
|
|
281
281
|
pasteEndPos = _useSharedPluginState2.pasteEndPos;
|
|
282
|
-
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 : [];
|
|
283
|
-
var visibleAiActionKeys = (0, _hasVisibleButton.getVisibleKeys)(aiSurfaceComponents, ['button', 'menu-item']);
|
|
284
|
-
(0, _react.useEffect)(function () {
|
|
285
|
-
if (!prevShowToolbarRef.current && isToolbarShown) {
|
|
286
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent({
|
|
287
|
-
action: _analytics.ACTION.OPENED,
|
|
288
|
-
actionSubject: _analytics.ACTION_SUBJECT.PASTE_ACTIONS_MENU,
|
|
289
|
-
eventType: _analytics.EVENT_TYPE.UI,
|
|
290
|
-
attributes: {
|
|
291
|
-
visibleAiActions: visibleAiActionKeys
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
prevShowToolbarRef.current = isToolbarShown;
|
|
296
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
297
|
-
}, [isToolbarShown, editorAnalyticsAPI]);
|
|
298
282
|
var preventEditorFocusLoss = (0, _react.useCallback)(function (e) {
|
|
299
283
|
e.preventDefault();
|
|
300
284
|
}, []);
|
|
@@ -326,22 +310,38 @@ var PasteActionsMenu = exports.PasteActionsMenu = function PasteActionsMenu(_ref
|
|
|
326
310
|
// onPositionCalculated with fresh viewport coordinates.
|
|
327
311
|
var overflowScrollParent = isToolbarShown ? (0, _ui.findOverflowScrollParent)(editorView.dom) : false;
|
|
328
312
|
var effectiveScrollableElement = overflowScrollParent || scrollableElement;
|
|
329
|
-
var pasteMenuComponents = (_api$
|
|
313
|
+
var pasteMenuComponents = (_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(_toolbar.PASTE_MENU.key)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
|
|
330
314
|
var anyComponentVisible = (0, _hasVisibleButton.hasVisibleButton)(pasteMenuComponents);
|
|
331
315
|
|
|
332
|
-
// Two positioning modes:
|
|
333
|
-
// 1. Inline: no AI actions visible — menu appears to the right of the cursor,
|
|
334
|
-
// vertically centered with the text line.
|
|
335
|
-
// 2. Block-anchored: AI actions are visible — menu appears at the right edge
|
|
336
|
-
// of the content block, aligned with paste start.
|
|
337
|
-
var hasVisibleAiActions = (0, _hasVisibleButton.getVisibleKeys)(
|
|
338
316
|
// eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- pasteMenuComponents changes by reference each render; filter is small (< 10 items)
|
|
339
|
-
pasteMenuComponents.filter(function (c) {
|
|
317
|
+
var aiMenuItems = pasteMenuComponents.filter(function (c) {
|
|
340
318
|
var _c$parents;
|
|
341
319
|
return c.type === 'menu-item' && ((_c$parents = c.parents) === null || _c$parents === void 0 ? void 0 : _c$parents.some(function (p) {
|
|
342
320
|
return p.key === _toolbar.AI_PASTE_MENU_SECTION.key;
|
|
343
321
|
}));
|
|
344
|
-
})
|
|
322
|
+
});
|
|
323
|
+
var visibleAiActionKeys = (0, _hasVisibleButton.getVisibleKeys)(aiMenuItems, ['menu-item']);
|
|
324
|
+
|
|
325
|
+
// Two positioning modes:
|
|
326
|
+
// 1. Inline: no AI actions visible — menu appears to the right of the cursor,
|
|
327
|
+
// vertically centered with the text line.
|
|
328
|
+
// 2. Block-anchored: AI actions are visible — menu appears at the right edge
|
|
329
|
+
// of the content block, aligned with paste start.
|
|
330
|
+
var hasVisibleAiActions = visibleAiActionKeys.length > 0;
|
|
331
|
+
(0, _react.useEffect)(function () {
|
|
332
|
+
if (!prevShowToolbarRef.current && isToolbarShown) {
|
|
333
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent({
|
|
334
|
+
action: _analytics.ACTION.OPENED,
|
|
335
|
+
actionSubject: _analytics.ACTION_SUBJECT.PASTE_ACTIONS_MENU,
|
|
336
|
+
eventType: _analytics.EVENT_TYPE.UI,
|
|
337
|
+
attributes: {
|
|
338
|
+
visibleAiActions: visibleAiActionKeys
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
prevShowToolbarRef.current = isToolbarShown;
|
|
343
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
344
|
+
}, [isToolbarShown, editorAnalyticsAPI]);
|
|
345
345
|
var useInlinePosition = !hasVisibleAiActions;
|
|
346
346
|
if (!isToolbarShown) {
|
|
347
347
|
return null;
|
|
@@ -215,7 +215,7 @@ export const PasteActionsMenu = ({
|
|
|
215
215
|
boundariesElement,
|
|
216
216
|
scrollableElement
|
|
217
217
|
}) => {
|
|
218
|
-
var _api$analytics, _api$uiControlRegistr, _api$uiControlRegistr2
|
|
218
|
+
var _api$analytics, _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
219
219
|
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
220
220
|
const {
|
|
221
221
|
lastContentPasted
|
|
@@ -266,22 +266,6 @@ export const PasteActionsMenu = ({
|
|
|
266
266
|
pasteEndPos: (_pluginState$pasteEnd = pluginState === null || pluginState === void 0 ? void 0 : pluginState.pasteEndPos) !== null && _pluginState$pasteEnd !== void 0 ? _pluginState$pasteEnd : 0
|
|
267
267
|
};
|
|
268
268
|
});
|
|
269
|
-
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 : [];
|
|
270
|
-
const visibleAiActionKeys = getVisibleKeys(aiSurfaceComponents, ['button', 'menu-item']);
|
|
271
|
-
useEffect(() => {
|
|
272
|
-
if (!prevShowToolbarRef.current && isToolbarShown) {
|
|
273
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.fireAnalyticsEvent({
|
|
274
|
-
action: ACTION.OPENED,
|
|
275
|
-
actionSubject: ACTION_SUBJECT.PASTE_ACTIONS_MENU,
|
|
276
|
-
eventType: EVENT_TYPE.UI,
|
|
277
|
-
attributes: {
|
|
278
|
-
visibleAiActions: visibleAiActionKeys
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
prevShowToolbarRef.current = isToolbarShown;
|
|
283
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
284
|
-
}, [isToolbarShown, editorAnalyticsAPI]);
|
|
285
269
|
const preventEditorFocusLoss = useCallback(e => {
|
|
286
270
|
e.preventDefault();
|
|
287
271
|
}, []);
|
|
@@ -313,20 +297,36 @@ export const PasteActionsMenu = ({
|
|
|
313
297
|
// onPositionCalculated with fresh viewport coordinates.
|
|
314
298
|
const overflowScrollParent = isToolbarShown ? findOverflowScrollParent(editorView.dom) : false;
|
|
315
299
|
const effectiveScrollableElement = overflowScrollParent || scrollableElement;
|
|
316
|
-
const pasteMenuComponents = (_api$
|
|
300
|
+
const pasteMenuComponents = (_api$uiControlRegistr = api === null || api === void 0 ? void 0 : (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(PASTE_MENU.key)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
|
|
317
301
|
const anyComponentVisible = hasVisibleButton(pasteMenuComponents);
|
|
318
302
|
|
|
303
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- pasteMenuComponents changes by reference each render; filter is small (< 10 items)
|
|
304
|
+
const aiMenuItems = pasteMenuComponents.filter(c => {
|
|
305
|
+
var _c$parents;
|
|
306
|
+
return c.type === 'menu-item' && ((_c$parents = c.parents) === null || _c$parents === void 0 ? void 0 : _c$parents.some(p => p.key === AI_PASTE_MENU_SECTION.key));
|
|
307
|
+
});
|
|
308
|
+
const visibleAiActionKeys = getVisibleKeys(aiMenuItems, ['menu-item']);
|
|
309
|
+
|
|
319
310
|
// Two positioning modes:
|
|
320
311
|
// 1. Inline: no AI actions visible — menu appears to the right of the cursor,
|
|
321
312
|
// vertically centered with the text line.
|
|
322
313
|
// 2. Block-anchored: AI actions are visible — menu appears at the right edge
|
|
323
314
|
// of the content block, aligned with paste start.
|
|
324
|
-
const hasVisibleAiActions =
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
315
|
+
const hasVisibleAiActions = visibleAiActionKeys.length > 0;
|
|
316
|
+
useEffect(() => {
|
|
317
|
+
if (!prevShowToolbarRef.current && isToolbarShown) {
|
|
318
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.fireAnalyticsEvent({
|
|
319
|
+
action: ACTION.OPENED,
|
|
320
|
+
actionSubject: ACTION_SUBJECT.PASTE_ACTIONS_MENU,
|
|
321
|
+
eventType: EVENT_TYPE.UI,
|
|
322
|
+
attributes: {
|
|
323
|
+
visibleAiActions: visibleAiActionKeys
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
prevShowToolbarRef.current = isToolbarShown;
|
|
328
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
329
|
+
}, [isToolbarShown, editorAnalyticsAPI]);
|
|
330
330
|
const useInlinePosition = !hasVisibleAiActions;
|
|
331
331
|
if (!isToolbarShown) {
|
|
332
332
|
return null;
|
|
@@ -210,7 +210,7 @@ export function onPositionCalculated(editorView, pasteStartPos, pasteEndPos, tar
|
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
212
|
export var PasteActionsMenu = function PasteActionsMenu(_ref) {
|
|
213
|
-
var _api$analytics, _api$uiControlRegistr, _api$uiControlRegistr2
|
|
213
|
+
var _api$analytics, _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
214
214
|
var api = _ref.api,
|
|
215
215
|
editorView = _ref.editorView,
|
|
216
216
|
mountTo = _ref.mountTo,
|
|
@@ -264,22 +264,6 @@ export var PasteActionsMenu = function PasteActionsMenu(_ref) {
|
|
|
264
264
|
isToolbarShown = _useSharedPluginState2.showToolbar,
|
|
265
265
|
pasteStartPos = _useSharedPluginState2.pasteStartPos,
|
|
266
266
|
pasteEndPos = _useSharedPluginState2.pasteEndPos;
|
|
267
|
-
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 : [];
|
|
268
|
-
var visibleAiActionKeys = getVisibleKeys(aiSurfaceComponents, ['button', 'menu-item']);
|
|
269
|
-
useEffect(function () {
|
|
270
|
-
if (!prevShowToolbarRef.current && isToolbarShown) {
|
|
271
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent({
|
|
272
|
-
action: ACTION.OPENED,
|
|
273
|
-
actionSubject: ACTION_SUBJECT.PASTE_ACTIONS_MENU,
|
|
274
|
-
eventType: EVENT_TYPE.UI,
|
|
275
|
-
attributes: {
|
|
276
|
-
visibleAiActions: visibleAiActionKeys
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
prevShowToolbarRef.current = isToolbarShown;
|
|
281
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
282
|
-
}, [isToolbarShown, editorAnalyticsAPI]);
|
|
283
267
|
var preventEditorFocusLoss = useCallback(function (e) {
|
|
284
268
|
e.preventDefault();
|
|
285
269
|
}, []);
|
|
@@ -311,22 +295,38 @@ export var PasteActionsMenu = function PasteActionsMenu(_ref) {
|
|
|
311
295
|
// onPositionCalculated with fresh viewport coordinates.
|
|
312
296
|
var overflowScrollParent = isToolbarShown ? findOverflowScrollParent(editorView.dom) : false;
|
|
313
297
|
var effectiveScrollableElement = overflowScrollParent || scrollableElement;
|
|
314
|
-
var pasteMenuComponents = (_api$
|
|
298
|
+
var pasteMenuComponents = (_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(PASTE_MENU.key)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
|
|
315
299
|
var anyComponentVisible = hasVisibleButton(pasteMenuComponents);
|
|
316
300
|
|
|
317
|
-
// Two positioning modes:
|
|
318
|
-
// 1. Inline: no AI actions visible — menu appears to the right of the cursor,
|
|
319
|
-
// vertically centered with the text line.
|
|
320
|
-
// 2. Block-anchored: AI actions are visible — menu appears at the right edge
|
|
321
|
-
// of the content block, aligned with paste start.
|
|
322
|
-
var hasVisibleAiActions = getVisibleKeys(
|
|
323
301
|
// eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- pasteMenuComponents changes by reference each render; filter is small (< 10 items)
|
|
324
|
-
pasteMenuComponents.filter(function (c) {
|
|
302
|
+
var aiMenuItems = pasteMenuComponents.filter(function (c) {
|
|
325
303
|
var _c$parents;
|
|
326
304
|
return c.type === 'menu-item' && ((_c$parents = c.parents) === null || _c$parents === void 0 ? void 0 : _c$parents.some(function (p) {
|
|
327
305
|
return p.key === AI_PASTE_MENU_SECTION.key;
|
|
328
306
|
}));
|
|
329
|
-
})
|
|
307
|
+
});
|
|
308
|
+
var visibleAiActionKeys = getVisibleKeys(aiMenuItems, ['menu-item']);
|
|
309
|
+
|
|
310
|
+
// Two positioning modes:
|
|
311
|
+
// 1. Inline: no AI actions visible — menu appears to the right of the cursor,
|
|
312
|
+
// vertically centered with the text line.
|
|
313
|
+
// 2. Block-anchored: AI actions are visible — menu appears at the right edge
|
|
314
|
+
// of the content block, aligned with paste start.
|
|
315
|
+
var hasVisibleAiActions = visibleAiActionKeys.length > 0;
|
|
316
|
+
useEffect(function () {
|
|
317
|
+
if (!prevShowToolbarRef.current && isToolbarShown) {
|
|
318
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent({
|
|
319
|
+
action: ACTION.OPENED,
|
|
320
|
+
actionSubject: ACTION_SUBJECT.PASTE_ACTIONS_MENU,
|
|
321
|
+
eventType: EVENT_TYPE.UI,
|
|
322
|
+
attributes: {
|
|
323
|
+
visibleAiActions: visibleAiActionKeys
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
prevShowToolbarRef.current = isToolbarShown;
|
|
328
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
329
|
+
}, [isToolbarShown, editorAnalyticsAPI]);
|
|
330
330
|
var useInlinePosition = !hasVisibleAiActions;
|
|
331
331
|
if (!isToolbarShown) {
|
|
332
332
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste-options-toolbar",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.8",
|
|
4
4
|
"description": "Paste options toolbar for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"@atlaskit/icon": "^33.1.0",
|
|
43
43
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
44
44
|
"@atlaskit/primitives": "^18.1.0",
|
|
45
|
-
"@atlaskit/tokens": "^11.
|
|
45
|
+
"@atlaskit/tokens": "^11.4.0",
|
|
46
46
|
"@babel/runtime": "^7.0.0",
|
|
47
47
|
"@compiled/react": "^0.20.0",
|
|
48
48
|
"@emotion/react": "^11.7.1",
|
|
49
49
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@atlaskit/editor-common": "^112.
|
|
52
|
+
"@atlaskit/editor-common": "^112.12.0",
|
|
53
53
|
"react": "^18.2.0",
|
|
54
54
|
"react-dom": "^18.2.0"
|
|
55
55
|
},
|