@atlaskit/editor-plugin-paste-options-toolbar 13.1.5 → 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,13 @@
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
+
3
11
  ## 13.1.5
4
12
 
5
13
  ### 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
- return shouldSuppressPasteActionsForAgentMention(sliceForAgentMentionSuppression) || shouldSuppressPasteActionsForSingleLink(sliceForAgentMentionSuppression);
273
- }, [sliceForAgentMentionSuppression]);
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,27 +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
- // eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- pasteMenuComponents changes by reference each render; filter is small (< 10 items)
354
- var aiMenuItems = pasteMenuComponents.filter(function (c) {
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
-
362
365
  // Whether the card plugin's "Display as" section is visible when the menu opens.
363
366
  var displayAsVisible = (0, _hasVisibleButton.getVisibleKeys)(pasteMenuComponents, ['menu-section']).includes(_toolbar.SMART_LINK_DISPLAY_AS_PASTE_MENU_SECTION.key);
364
-
365
367
  // Two positioning modes:
366
368
  // 1. Inline: no AI actions visible — menu appears to the right of the cursor,
367
369
  // vertically centered with the text line.
368
370
  // 2. Block-anchored: AI actions are visible — menu appears at the right edge
369
371
  // of the content block, aligned with paste start.
370
- var hasVisibleAiActions = visibleAiActionKeys.length > 0;
371
372
  (0, _react.useEffect)(function () {
372
373
  if (!prevShowToolbarRef.current && shouldRenderToolbar) {
373
374
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent({
@@ -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 shouldSuppressPasteActions = useMemo(() => shouldSuppressPasteActionsForAgentMention(sliceForAgentMentionSuppression) || shouldSuppressPasteActionsForSingleLink(sliceForAgentMentionSuppression), [sliceForAgentMentionSuppression]);
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,25 +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
- // eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- pasteMenuComponents changes by reference each render; filter is small (< 10 items)
332
- const aiMenuItems = pasteMenuComponents.filter(c => {
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
-
338
343
  // Whether the card plugin's "Display as" section is visible when the menu opens.
339
344
  const displayAsVisible = getVisibleKeys(pasteMenuComponents, ['menu-section']).includes(SMART_LINK_DISPLAY_AS_PASTE_MENU_SECTION.key);
340
-
341
345
  // Two positioning modes:
342
346
  // 1. Inline: no AI actions visible — menu appears to the right of the cursor,
343
347
  // vertically centered with the text line.
344
348
  // 2. Block-anchored: AI actions are visible — menu appears at the right edge
345
349
  // of the content block, aligned with paste start.
346
- const hasVisibleAiActions = visibleAiActionKeys.length > 0;
347
350
  useEffect(() => {
348
351
  if (!prevShowToolbarRef.current && shouldRenderToolbar) {
349
352
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.fireAnalyticsEvent({
@@ -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
- return shouldSuppressPasteActionsForAgentMention(sliceForAgentMentionSuppression) || shouldSuppressPasteActionsForSingleLink(sliceForAgentMentionSuppression);
257
- }, [sliceForAgentMentionSuppression]);
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,27 +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
- // eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- pasteMenuComponents changes by reference each render; filter is small (< 10 items)
338
- var aiMenuItems = pasteMenuComponents.filter(function (c) {
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
-
346
349
  // Whether the card plugin's "Display as" section is visible when the menu opens.
347
350
  var displayAsVisible = getVisibleKeys(pasteMenuComponents, ['menu-section']).includes(SMART_LINK_DISPLAY_AS_PASTE_MENU_SECTION.key);
348
-
349
351
  // Two positioning modes:
350
352
  // 1. Inline: no AI actions visible — menu appears to the right of the cursor,
351
353
  // vertically centered with the text line.
352
354
  // 2. Block-anchored: AI actions are visible — menu appears at the right edge
353
355
  // of the content block, aligned with paste start.
354
- var hasVisibleAiActions = visibleAiActionKeys.length > 0;
355
356
  useEffect(function () {
356
357
  if (!prevShowToolbarRef.current && shouldRenderToolbar) {
357
358
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste-options-toolbar",
3
- "version": "13.1.5",
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",