@atlaskit/editor-plugin-paste-options-toolbar 13.1.4 → 13.1.6
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,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste-options-toolbar
|
|
2
2
|
|
|
3
|
+
## 13.1.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`0f828d3590ec8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0f828d3590ec8) -
|
|
8
|
+
Fix the paste actions menu to remain visible for single Smart Link pastes when an AI action is
|
|
9
|
+
available.
|
|
10
|
+
|
|
11
|
+
## 13.1.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`c10f8b3827a81`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c10f8b3827a81) -
|
|
16
|
+
Add a `displayAsVisible` attribute to the paste actions menu `opened` analytics event, reporting
|
|
17
|
+
whether the Smart Link "Display as" section is shown when the menu opens. A shared
|
|
18
|
+
`SMART_LINK_DISPLAY_AS_PASTE_MENU_SECTION` key is exposed from `@atlaskit/editor-common/toolbar`
|
|
19
|
+
so the section can be identified without depending on the card plugin.
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 13.1.4
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -268,9 +268,22 @@ var PasteActionsMenu = exports.PasteActionsMenu = function PasteActionsMenu(_ref
|
|
|
268
268
|
}),
|
|
269
269
|
lastContentPasted = _useSharedPluginState.lastContentPasted;
|
|
270
270
|
var sliceForAgentMentionSuppression = lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.sourcePastedSlice;
|
|
271
|
+
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 : [];
|
|
272
|
+
|
|
273
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- pasteMenuComponents changes by reference each render; filter is small (< 10 items)
|
|
274
|
+
var aiMenuItems = pasteMenuComponents.filter(function (c) {
|
|
275
|
+
var _c$parents;
|
|
276
|
+
return c.type === 'menu-item' && ((_c$parents = c.parents) === null || _c$parents === void 0 ? void 0 : _c$parents.some(function (p) {
|
|
277
|
+
return p.key === _toolbar.AI_PASTE_MENU_SECTION.key;
|
|
278
|
+
}));
|
|
279
|
+
});
|
|
280
|
+
var visibleAiActionKeys = (0, _hasVisibleButton.getVisibleKeys)(aiMenuItems, ['menu-item']);
|
|
281
|
+
var hasVisibleAiActions = visibleAiActionKeys.length > 0;
|
|
271
282
|
var shouldSuppressPasteActions = (0, _react.useMemo)(function () {
|
|
272
|
-
|
|
273
|
-
|
|
283
|
+
var suppressForAgentMention = shouldSuppressPasteActionsForAgentMention(sliceForAgentMentionSuppression);
|
|
284
|
+
var suppressForSingleLink = shouldSuppressPasteActionsForSingleLink(sliceForAgentMentionSuppression) && !hasVisibleAiActions;
|
|
285
|
+
return suppressForAgentMention || suppressForSingleLink;
|
|
286
|
+
}, [sliceForAgentMentionSuppression, hasVisibleAiActions]);
|
|
274
287
|
var prevShowToolbarRef = (0, _react.useRef)(false);
|
|
275
288
|
var popupContentRef = (0, _react.useRef)(null);
|
|
276
289
|
(0, _react.useEffect)(function () {
|
|
@@ -347,24 +360,15 @@ var PasteActionsMenu = exports.PasteActionsMenu = function PasteActionsMenu(_ref
|
|
|
347
360
|
// onPositionCalculated with fresh viewport coordinates.
|
|
348
361
|
var overflowScrollParent = shouldRenderToolbar ? (0, _ui.findOverflowScrollParent)(editorView.dom) : false;
|
|
349
362
|
var effectiveScrollableElement = overflowScrollParent || scrollableElement;
|
|
350
|
-
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 : [];
|
|
351
363
|
var anyComponentVisible = (0, _hasVisibleButton.hasVisibleButton)(pasteMenuComponents);
|
|
352
364
|
|
|
353
|
-
//
|
|
354
|
-
var
|
|
355
|
-
var _c$parents;
|
|
356
|
-
return c.type === 'menu-item' && ((_c$parents = c.parents) === null || _c$parents === void 0 ? void 0 : _c$parents.some(function (p) {
|
|
357
|
-
return p.key === _toolbar.AI_PASTE_MENU_SECTION.key;
|
|
358
|
-
}));
|
|
359
|
-
});
|
|
360
|
-
var visibleAiActionKeys = (0, _hasVisibleButton.getVisibleKeys)(aiMenuItems, ['menu-item']);
|
|
361
|
-
|
|
365
|
+
// Whether the card plugin's "Display as" section is visible when the menu opens.
|
|
366
|
+
var displayAsVisible = (0, _hasVisibleButton.getVisibleKeys)(pasteMenuComponents, ['menu-section']).includes(_toolbar.SMART_LINK_DISPLAY_AS_PASTE_MENU_SECTION.key);
|
|
362
367
|
// Two positioning modes:
|
|
363
368
|
// 1. Inline: no AI actions visible — menu appears to the right of the cursor,
|
|
364
369
|
// vertically centered with the text line.
|
|
365
370
|
// 2. Block-anchored: AI actions are visible — menu appears at the right edge
|
|
366
371
|
// of the content block, aligned with paste start.
|
|
367
|
-
var hasVisibleAiActions = visibleAiActionKeys.length > 0;
|
|
368
372
|
(0, _react.useEffect)(function () {
|
|
369
373
|
if (!prevShowToolbarRef.current && shouldRenderToolbar) {
|
|
370
374
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent({
|
|
@@ -372,7 +376,8 @@ var PasteActionsMenu = exports.PasteActionsMenu = function PasteActionsMenu(_ref
|
|
|
372
376
|
actionSubject: _analytics.ACTION_SUBJECT.PASTE_ACTIONS_MENU,
|
|
373
377
|
eventType: _analytics.EVENT_TYPE.UI,
|
|
374
378
|
attributes: {
|
|
375
|
-
visibleAiActions: visibleAiActionKeys
|
|
379
|
+
visibleAiActions: visibleAiActionKeys,
|
|
380
|
+
displayAsVisible: displayAsVisible
|
|
376
381
|
}
|
|
377
382
|
});
|
|
378
383
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
|
-
import { AI_PASTE_MENU_SECTION, EditorToolbarProvider, PASTE_MENU } from '@atlaskit/editor-common/toolbar';
|
|
4
|
+
import { AI_PASTE_MENU_SECTION, EditorToolbarProvider, PASTE_MENU, SMART_LINK_DISPLAY_AS_PASTE_MENU_SECTION } from '@atlaskit/editor-common/toolbar';
|
|
5
5
|
import { findOverflowScrollParent, Popup } from '@atlaskit/editor-common/ui';
|
|
6
6
|
import { withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
7
7
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -247,7 +247,20 @@ export const PasteActionsMenu = ({
|
|
|
247
247
|
};
|
|
248
248
|
});
|
|
249
249
|
const sliceForAgentMentionSuppression = lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.sourcePastedSlice;
|
|
250
|
-
const
|
|
250
|
+
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 : [];
|
|
251
|
+
|
|
252
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- pasteMenuComponents changes by reference each render; filter is small (< 10 items)
|
|
253
|
+
const aiMenuItems = pasteMenuComponents.filter(c => {
|
|
254
|
+
var _c$parents;
|
|
255
|
+
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));
|
|
256
|
+
});
|
|
257
|
+
const visibleAiActionKeys = getVisibleKeys(aiMenuItems, ['menu-item']);
|
|
258
|
+
const hasVisibleAiActions = visibleAiActionKeys.length > 0;
|
|
259
|
+
const shouldSuppressPasteActions = useMemo(() => {
|
|
260
|
+
const suppressForAgentMention = shouldSuppressPasteActionsForAgentMention(sliceForAgentMentionSuppression);
|
|
261
|
+
const suppressForSingleLink = shouldSuppressPasteActionsForSingleLink(sliceForAgentMentionSuppression) && !hasVisibleAiActions;
|
|
262
|
+
return suppressForAgentMention || suppressForSingleLink;
|
|
263
|
+
}, [sliceForAgentMentionSuppression, hasVisibleAiActions]);
|
|
251
264
|
const prevShowToolbarRef = useRef(false);
|
|
252
265
|
const popupContentRef = useRef(null);
|
|
253
266
|
useEffect(() => {
|
|
@@ -325,22 +338,15 @@ export const PasteActionsMenu = ({
|
|
|
325
338
|
// onPositionCalculated with fresh viewport coordinates.
|
|
326
339
|
const overflowScrollParent = shouldRenderToolbar ? findOverflowScrollParent(editorView.dom) : false;
|
|
327
340
|
const effectiveScrollableElement = overflowScrollParent || scrollableElement;
|
|
328
|
-
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 : [];
|
|
329
341
|
const anyComponentVisible = hasVisibleButton(pasteMenuComponents);
|
|
330
342
|
|
|
331
|
-
//
|
|
332
|
-
const
|
|
333
|
-
var _c$parents;
|
|
334
|
-
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));
|
|
335
|
-
});
|
|
336
|
-
const visibleAiActionKeys = getVisibleKeys(aiMenuItems, ['menu-item']);
|
|
337
|
-
|
|
343
|
+
// Whether the card plugin's "Display as" section is visible when the menu opens.
|
|
344
|
+
const displayAsVisible = getVisibleKeys(pasteMenuComponents, ['menu-section']).includes(SMART_LINK_DISPLAY_AS_PASTE_MENU_SECTION.key);
|
|
338
345
|
// Two positioning modes:
|
|
339
346
|
// 1. Inline: no AI actions visible — menu appears to the right of the cursor,
|
|
340
347
|
// vertically centered with the text line.
|
|
341
348
|
// 2. Block-anchored: AI actions are visible — menu appears at the right edge
|
|
342
349
|
// of the content block, aligned with paste start.
|
|
343
|
-
const hasVisibleAiActions = visibleAiActionKeys.length > 0;
|
|
344
350
|
useEffect(() => {
|
|
345
351
|
if (!prevShowToolbarRef.current && shouldRenderToolbar) {
|
|
346
352
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.fireAnalyticsEvent({
|
|
@@ -348,7 +354,8 @@ export const PasteActionsMenu = ({
|
|
|
348
354
|
actionSubject: ACTION_SUBJECT.PASTE_ACTIONS_MENU,
|
|
349
355
|
eventType: EVENT_TYPE.UI,
|
|
350
356
|
attributes: {
|
|
351
|
-
visibleAiActions: visibleAiActionKeys
|
|
357
|
+
visibleAiActions: visibleAiActionKeys,
|
|
358
|
+
displayAsVisible
|
|
352
359
|
}
|
|
353
360
|
});
|
|
354
361
|
}
|
|
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
5
5
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
7
|
-
import { AI_PASTE_MENU_SECTION, EditorToolbarProvider, PASTE_MENU } from '@atlaskit/editor-common/toolbar';
|
|
7
|
+
import { AI_PASTE_MENU_SECTION, EditorToolbarProvider, PASTE_MENU, SMART_LINK_DISPLAY_AS_PASTE_MENU_SECTION } from '@atlaskit/editor-common/toolbar';
|
|
8
8
|
import { findOverflowScrollParent, Popup } from '@atlaskit/editor-common/ui';
|
|
9
9
|
import { withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
10
10
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -252,9 +252,22 @@ export var PasteActionsMenu = function PasteActionsMenu(_ref) {
|
|
|
252
252
|
}),
|
|
253
253
|
lastContentPasted = _useSharedPluginState.lastContentPasted;
|
|
254
254
|
var sliceForAgentMentionSuppression = lastContentPasted === null || lastContentPasted === void 0 ? void 0 : lastContentPasted.sourcePastedSlice;
|
|
255
|
+
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 : [];
|
|
256
|
+
|
|
257
|
+
// eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- pasteMenuComponents changes by reference each render; filter is small (< 10 items)
|
|
258
|
+
var aiMenuItems = pasteMenuComponents.filter(function (c) {
|
|
259
|
+
var _c$parents;
|
|
260
|
+
return c.type === 'menu-item' && ((_c$parents = c.parents) === null || _c$parents === void 0 ? void 0 : _c$parents.some(function (p) {
|
|
261
|
+
return p.key === AI_PASTE_MENU_SECTION.key;
|
|
262
|
+
}));
|
|
263
|
+
});
|
|
264
|
+
var visibleAiActionKeys = getVisibleKeys(aiMenuItems, ['menu-item']);
|
|
265
|
+
var hasVisibleAiActions = visibleAiActionKeys.length > 0;
|
|
255
266
|
var shouldSuppressPasteActions = useMemo(function () {
|
|
256
|
-
|
|
257
|
-
|
|
267
|
+
var suppressForAgentMention = shouldSuppressPasteActionsForAgentMention(sliceForAgentMentionSuppression);
|
|
268
|
+
var suppressForSingleLink = shouldSuppressPasteActionsForSingleLink(sliceForAgentMentionSuppression) && !hasVisibleAiActions;
|
|
269
|
+
return suppressForAgentMention || suppressForSingleLink;
|
|
270
|
+
}, [sliceForAgentMentionSuppression, hasVisibleAiActions]);
|
|
258
271
|
var prevShowToolbarRef = useRef(false);
|
|
259
272
|
var popupContentRef = useRef(null);
|
|
260
273
|
useEffect(function () {
|
|
@@ -331,24 +344,15 @@ export var PasteActionsMenu = function PasteActionsMenu(_ref) {
|
|
|
331
344
|
// onPositionCalculated with fresh viewport coordinates.
|
|
332
345
|
var overflowScrollParent = shouldRenderToolbar ? findOverflowScrollParent(editorView.dom) : false;
|
|
333
346
|
var effectiveScrollableElement = overflowScrollParent || scrollableElement;
|
|
334
|
-
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 : [];
|
|
335
347
|
var anyComponentVisible = hasVisibleButton(pasteMenuComponents);
|
|
336
348
|
|
|
337
|
-
//
|
|
338
|
-
var
|
|
339
|
-
var _c$parents;
|
|
340
|
-
return c.type === 'menu-item' && ((_c$parents = c.parents) === null || _c$parents === void 0 ? void 0 : _c$parents.some(function (p) {
|
|
341
|
-
return p.key === AI_PASTE_MENU_SECTION.key;
|
|
342
|
-
}));
|
|
343
|
-
});
|
|
344
|
-
var visibleAiActionKeys = getVisibleKeys(aiMenuItems, ['menu-item']);
|
|
345
|
-
|
|
349
|
+
// Whether the card plugin's "Display as" section is visible when the menu opens.
|
|
350
|
+
var displayAsVisible = getVisibleKeys(pasteMenuComponents, ['menu-section']).includes(SMART_LINK_DISPLAY_AS_PASTE_MENU_SECTION.key);
|
|
346
351
|
// Two positioning modes:
|
|
347
352
|
// 1. Inline: no AI actions visible — menu appears to the right of the cursor,
|
|
348
353
|
// vertically centered with the text line.
|
|
349
354
|
// 2. Block-anchored: AI actions are visible — menu appears at the right edge
|
|
350
355
|
// of the content block, aligned with paste start.
|
|
351
|
-
var hasVisibleAiActions = visibleAiActionKeys.length > 0;
|
|
352
356
|
useEffect(function () {
|
|
353
357
|
if (!prevShowToolbarRef.current && shouldRenderToolbar) {
|
|
354
358
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent({
|
|
@@ -356,7 +360,8 @@ export var PasteActionsMenu = function PasteActionsMenu(_ref) {
|
|
|
356
360
|
actionSubject: ACTION_SUBJECT.PASTE_ACTIONS_MENU,
|
|
357
361
|
eventType: EVENT_TYPE.UI,
|
|
358
362
|
attributes: {
|
|
359
|
-
visibleAiActions: visibleAiActionKeys
|
|
363
|
+
visibleAiActions: visibleAiActionKeys,
|
|
364
|
+
displayAsVisible: displayAsVisible
|
|
360
365
|
}
|
|
361
366
|
});
|
|
362
367
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste-options-toolbar",
|
|
3
|
-
"version": "13.1.
|
|
3
|
+
"version": "13.1.6",
|
|
4
4
|
"description": "Paste options toolbar for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,19 +29,19 @@
|
|
|
29
29
|
"@atlaskit/editor-plugin-ui-control-registry": "^6.0.0",
|
|
30
30
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
31
31
|
"@atlaskit/editor-shared-styles": "^4.0.0",
|
|
32
|
-
"@atlaskit/editor-toolbar": "^2.
|
|
32
|
+
"@atlaskit/editor-toolbar": "^2.2.0",
|
|
33
33
|
"@atlaskit/editor-ui-control-model": "^2.2.0",
|
|
34
34
|
"@atlaskit/icon": "^37.0.0",
|
|
35
35
|
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
36
|
-
"@atlaskit/primitives": "^20.
|
|
36
|
+
"@atlaskit/primitives": "^20.6.0",
|
|
37
37
|
"@atlaskit/tmp-editor-statsig": "^124.1.0",
|
|
38
|
-
"@atlaskit/tokens": "^15.
|
|
38
|
+
"@atlaskit/tokens": "^15.6.0",
|
|
39
39
|
"@babel/runtime": "^7.0.0",
|
|
40
40
|
"@compiled/react": "^0.20.0",
|
|
41
41
|
"@emotion/react": "^11.7.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@atlaskit/editor-common": "^116.
|
|
44
|
+
"@atlaskit/editor-common": "^116.26.0",
|
|
45
45
|
"react": "^18.2.0",
|
|
46
46
|
"react-dom": "^18.2.0",
|
|
47
47
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|