@atlaskit/editor-plugin-card 38.0.0 → 39.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/ui/DatasourceAppearanceButton.js +4 -8
  3. package/dist/cjs/ui/EditToolbarButton/EditToolbarButtonPresentation.js +11 -26
  4. package/dist/cjs/ui/EditToolbarButton/index.js +12 -24
  5. package/dist/cjs/ui/HyperlinkToolbarAppearanceDropdown.js +6 -13
  6. package/dist/cjs/ui/LinkToolbarAppearanceDropdown.js +39 -13
  7. package/dist/cjs/ui/OpenLinkToolbarButton/index.js +1 -3
  8. package/dist/cjs/ui/OpenPreviewButton/index.js +3 -26
  9. package/dist/cjs/ui/toolbar.js +127 -364
  10. package/dist/es2019/ui/DatasourceAppearanceButton.js +4 -8
  11. package/dist/es2019/ui/EditToolbarButton/EditToolbarButtonPresentation.js +11 -26
  12. package/dist/es2019/ui/EditToolbarButton/index.js +12 -24
  13. package/dist/es2019/ui/HyperlinkToolbarAppearanceDropdown.js +6 -13
  14. package/dist/es2019/ui/LinkToolbarAppearanceDropdown.js +36 -10
  15. package/dist/es2019/ui/OpenLinkToolbarButton/index.js +1 -3
  16. package/dist/es2019/ui/OpenPreviewButton/index.js +3 -26
  17. package/dist/es2019/ui/toolbar.js +125 -352
  18. package/dist/esm/ui/DatasourceAppearanceButton.js +4 -8
  19. package/dist/esm/ui/EditToolbarButton/EditToolbarButtonPresentation.js +11 -26
  20. package/dist/esm/ui/EditToolbarButton/index.js +12 -24
  21. package/dist/esm/ui/HyperlinkToolbarAppearanceDropdown.js +6 -13
  22. package/dist/esm/ui/LinkToolbarAppearanceDropdown.js +36 -10
  23. package/dist/esm/ui/OpenLinkToolbarButton/index.js +1 -3
  24. package/dist/esm/ui/OpenPreviewButton/index.js +3 -26
  25. package/dist/esm/ui/toolbar.js +126 -361
  26. package/dist/types/ui/DatasourceAppearanceButton.d.ts +1 -2
  27. package/dist/types/ui/EditToolbarButton/EditToolbarButtonPresentation.d.ts +1 -1
  28. package/dist/types/ui/EditToolbarButton/types.d.ts +0 -1
  29. package/dist/types/ui/HyperlinkToolbarAppearanceDropdown.d.ts +16 -1
  30. package/dist/types/ui/LinkToolbarAppearanceDropdown.d.ts +24 -2
  31. package/dist/types/ui/OpenLinkToolbarButton/index.d.ts +1 -2
  32. package/dist/types/ui/OpenPreviewButton/index.d.ts +1 -2
  33. package/dist/types/ui/toolbar.d.ts +1 -2
  34. package/package.json +18 -18
  35. package/dist/cjs/ui/HyperlinkToolbarAppearance.js +0 -162
  36. package/dist/cjs/ui/LinkToolbarAppearance.js +0 -174
  37. package/dist/es2019/ui/HyperlinkToolbarAppearance.js +0 -86
  38. package/dist/es2019/ui/LinkToolbarAppearance.js +0 -145
  39. package/dist/esm/ui/HyperlinkToolbarAppearance.js +0 -153
  40. package/dist/esm/ui/LinkToolbarAppearance.js +0 -167
  41. package/dist/types/ui/HyperlinkToolbarAppearance.d.ts +0 -18
  42. package/dist/types/ui/LinkToolbarAppearance.d.ts +0 -25
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { isSafeUrl } from '@atlaskit/adf-schema/is-safe-url';
3
3
  import { buildOpenedSettingsPayload, buildVisitedNonHyperLinkPayload } from '@atlaskit/editor-common/analytics/linking-utils';
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID as ACTION_SUBJECTID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics/types/enums';
5
- import buildLayoutButtons, { buildLayoutDropdown } from '@atlaskit/editor-common/card/MediaAndEmbedsToolbar';
5
+ import { buildLayoutDropdown } from '@atlaskit/editor-common/card/MediaAndEmbedsToolbar';
6
6
  import { commandWithMetadata } from '@atlaskit/editor-common/card/utils';
7
7
  import { isOfflineMode } from '@atlaskit/editor-common/connectivity/isOfflineMode';
8
8
  import { getLinkPreferencesURLFromENV } from '@atlaskit/editor-common/link/utils';
@@ -13,7 +13,6 @@ import { linkMessages } from '@atlaskit/editor-common/messages/link';
13
13
  import { linkToolbarMessages } from '@atlaskit/editor-common/messages/link-toolbar';
14
14
  import { richMediaClassName } from '@atlaskit/editor-common/styles/media-single';
15
15
  import { FLOATING_TOOLBAR_LINKPICKER_CLASSNAME } from '@atlaskit/editor-common/styles/smartCard';
16
- import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
17
16
  import { canRenderDatasource } from '@atlaskit/editor-common/utils/datasource';
18
17
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
19
18
  import { findDomRefAtPos, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
@@ -30,12 +29,9 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment
30
29
  import { changeSelectedCardToText } from '../pm-plugins/doc';
31
30
  import { pluginKey } from '../pm-plugins/plugin-key';
32
31
  import { appearanceForNodeType, displayInfoForCard, findCardInfo, isDatasourceNode, titleUrlPairFromNode } from '../pm-plugins/utils';
33
- import { DatasourceAppearanceButton } from './DatasourceAppearanceButton';
34
32
  import { buildEditLinkToolbar, editLinkToolbarConfig, getEditLinkCallback } from './EditLinkToolbar';
35
33
  import { EditToolbarButton } from './EditToolbarButton';
36
- import { HyperlinkToolbarAppearance } from './HyperlinkToolbarAppearance';
37
34
  import { getCustomHyperlinkAppearanceDropdown } from './HyperlinkToolbarAppearanceDropdown';
38
- import { LinkToolbarAppearance } from './LinkToolbarAppearance';
39
35
  import { getLinkAppearanceDropdown } from './LinkToolbarAppearanceDropdown';
40
36
  import { OpenLinkToolbarButton } from './OpenLinkToolbarButton';
41
37
  import { OpenPreviewPanelToolbarButton } from './OpenPreviewButton';
@@ -208,11 +204,8 @@ const unlinkCard = (node, state, editorAnalyticsApi, pluginInjectionApi) => {
208
204
  return () => false;
209
205
  }
210
206
  };
211
- const buildAlignmentOptions = (state, intl, widthPluginDependencyApi, analyticsApi, cardOptions, areAnyNewToolbarFlagsEnabled) => {
212
- if (areAnyNewToolbarFlagsEnabled) {
213
- return buildLayoutDropdown(state, intl, state.schema.nodes.embedCard, widthPluginDependencyApi, analyticsApi, true, true, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowWrapping, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowAlignment);
214
- }
215
- return buildLayoutButtons(state, intl, state.schema.nodes.embedCard, widthPluginDependencyApi, analyticsApi, true, true, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowWrapping, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowAlignment);
207
+ const buildAlignmentOptions = (state, intl, widthPluginDependencyApi, analyticsApi, cardOptions) => {
208
+ return buildLayoutDropdown(state, intl, state.schema.nodes.embedCard, widthPluginDependencyApi, analyticsApi, true, true, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowWrapping, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowAlignment);
216
209
  };
217
210
  const withToolbarMetadata = command => commandWithMetadata(command, {
218
211
  inputMethod: INPUT_METHOD.FLOATING_TB
@@ -252,7 +245,6 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
252
245
  title: title
253
246
  };
254
247
  }
255
- const areAllNewToolbarFlagsDisabled = !areToolbarFlagsEnabled(Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.toolbar));
256
248
  const currentAppearance = appearanceForNodeType(node.type);
257
249
  const {
258
250
  hoverDecoration
@@ -300,31 +292,6 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
300
292
  const {
301
293
  inlineCard
302
294
  } = state.schema.nodes;
303
- const editItems = cardOptions.allowDatasource ? [{
304
- type: 'custom',
305
- fallback: [],
306
- render: editorView => /*#__PURE__*/React.createElement(EditToolbarButton, {
307
- key: "edit-toolbar-item",
308
- url: url,
309
- intl: intl,
310
- editorAnalyticsApi: editorAnalyticsApi,
311
- editorView: editorView,
312
- onLinkEditClick: getEditLinkCallback(editorAnalyticsApi, true),
313
- currentAppearance: currentAppearance,
314
- areAnyNewToolbarFlagsEnabled: !areAllNewToolbarFlagsDisabled
315
- })
316
- }] : [{
317
- id: 'editor.link.edit',
318
- type: 'button',
319
- selected: false,
320
- metadata: metadata,
321
- title: intl.formatMessage(linkToolbarMessages.editLink),
322
- showTitle: true,
323
- testId: 'link-toolbar-edit-link-button',
324
- onClick: getEditLinkCallback(editorAnalyticsApi, true)
325
- }, {
326
- type: 'separator'
327
- }];
328
295
  const commentItems = isCommentEnabled ? [{
329
296
  id: 'editor.link.commentLink',
330
297
  type: 'button',
@@ -349,8 +316,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
349
316
  editorAnalyticsApi: editorAnalyticsApi,
350
317
  editorView: editorView,
351
318
  onLinkEditClick: getEditLinkCallback(editorAnalyticsApi, true),
352
- currentAppearance: currentAppearance,
353
- areAnyNewToolbarFlagsEnabled: !areAllNewToolbarFlagsDisabled
319
+ currentAppearance: currentAppearance
354
320
  })
355
321
  }] : [{
356
322
  id: 'editor.link.edit',
@@ -368,8 +334,7 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
368
334
  render: () => /*#__PURE__*/React.createElement(OpenPreviewPanelToolbarButton, {
369
335
  node: node,
370
336
  intl: intl,
371
- editorAnalyticsApi: editorAnalyticsApi,
372
- areAnyNewToolbarFlagsEnabled: !areAllNewToolbarFlagsDisabled
337
+ editorAnalyticsApi: editorAnalyticsApi
373
338
  })
374
339
  }];
375
340
  const resolvedToolbarAttributes = url ? (_pluginState$resolved = pluginState === null || pluginState === void 0 ? void 0 : pluginState.resolvedToolbarAttributesByUrl[url]) !== null && _pluginState$resolved !== void 0 ? _pluginState$resolved : {} : {};
@@ -392,37 +357,10 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
392
357
  url: url,
393
358
  title: intl.formatMessage(linkMessages.openLink),
394
359
  editorView: editorView,
395
- onClick: fireOpenLinkToolbarAnalytics(editorAnalyticsApi, openLinkInputMethod, resolvedToolbarAttributes),
396
- areAnyNewToolbarFlagsEnabled: !areAllNewToolbarFlagsDisabled
360
+ onClick: fireOpenLinkToolbarAnalytics(editorAnalyticsApi, openLinkInputMethod, resolvedToolbarAttributes)
397
361
  }) : null
398
362
  };
399
- const toolbarItems = areAllNewToolbarFlagsDisabled ? [...editItems, ...commentItems, ...openPreviewPanelItems, openLinkToolbarItem, {
400
- type: 'separator'
401
- }, ...getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled, pluginInjectionApi), {
402
- type: 'copy-button',
403
- items: [{
404
- state,
405
- formatMessage: intl.formatMessage,
406
- nodeType: node.type
407
- }]
408
- }, {
409
- type: 'separator'
410
- }, getSettingsButton(intl, editorAnalyticsApi, cardOptions.userPreferencesLink), {
411
- type: 'separator'
412
- }, {
413
- id: 'editor.link.delete',
414
- focusEditoronEnter: true,
415
- type: 'button',
416
- appearance: 'danger',
417
- icon: DeleteIcon,
418
- iconFallback: DeleteIcon,
419
- onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
420
- onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
421
- onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
422
- onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
423
- title: intl.formatMessage(commonMessages.remove),
424
- onClick: withToolbarMetadata(removeCard(editorAnalyticsApi))
425
- }] : [...editButtonItems, ...[...getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, !areAllNewToolbarFlagsDisabled, pluginInjectionApi), {
363
+ const toolbarItems = [...editButtonItems, ...[...getUnlinkButtonGroup(state, intl, node, inlineCard, editorAnalyticsApi, pluginInjectionApi), {
426
364
  type: 'separator',
427
365
  fullHeight: true
428
366
  }], ...openPreviewPanelItems, openLinkToolbarItem, ...(commentItems.length > 1 ? [{
@@ -431,41 +369,18 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
431
369
  }, commentItems[0]] : commentItems)];
432
370
  if (currentAppearance === 'embed') {
433
371
  var _pluginInjectionApi$a5;
434
- const alignmentOptions = buildAlignmentOptions(state, intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 ? void 0 : _pluginInjectionApi$a5.actions, cardOptions, !areAllNewToolbarFlagsDisabled);
435
- if (alignmentOptions.length && areAllNewToolbarFlagsDisabled) {
436
- alignmentOptions.push({
437
- type: 'separator'
438
- });
439
- }
372
+ const alignmentOptions = buildAlignmentOptions(state, intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 ? void 0 : _pluginInjectionApi$a5.actions, cardOptions);
440
373
  toolbarItems.unshift(...alignmentOptions);
441
374
  }
442
375
  const {
443
376
  allowBlockCards,
444
377
  allowEmbeds,
445
- allowDatasource,
446
378
  showUpgradeDiscoverability
447
379
  } = cardOptions;
448
380
  // This code will be executed only for appearances such as "inline", "block" & "embed"
449
381
  // For url appearance, please see HyperlinkToolbarAppearanceProps
450
382
  if (currentAppearance) {
451
- const showDatasourceAppearance = allowDatasource && url;
452
- toolbarItems.unshift(...getToolbarViewedItem(url, currentAppearance), areAllNewToolbarFlagsDisabled ? {
453
- type: 'custom',
454
- fallback: [],
455
- render: editorView => /*#__PURE__*/React.createElement(LinkToolbarAppearance, {
456
- key: "link-appearance",
457
- url: url,
458
- intl: intl,
459
- currentAppearance: currentAppearance,
460
- editorView: editorView,
461
- editorState: state,
462
- allowEmbeds: allowEmbeds,
463
- allowBlockCards: allowBlockCards,
464
- editorAnalyticsApi: editorAnalyticsApi,
465
- showUpgradeDiscoverability: showUpgradeDiscoverability,
466
- areAnyNewToolbarFlagsEnabled: false
467
- })
468
- } : getLinkAppearanceDropdown({
383
+ toolbarItems.unshift(...getToolbarViewedItem(url, currentAppearance), getLinkAppearanceDropdown({
469
384
  url,
470
385
  intl,
471
386
  currentAppearance,
@@ -476,66 +391,49 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
476
391
  allowDatasource: cardOptions.allowDatasource,
477
392
  showUpgradeDiscoverability: showUpgradeDiscoverability,
478
393
  settingsConfig: getSettingsButton(intl, editorAnalyticsApi, cardOptions.userPreferencesLink),
479
- isDatasourceView: isDatasource,
480
- areAnyNewToolbarFlagsEnabled: !areAllNewToolbarFlagsDisabled
481
- }), ...(showDatasourceAppearance && areAllNewToolbarFlagsDisabled ? [{
482
- type: 'custom',
483
- fallback: [],
484
- render: editorView => /*#__PURE__*/React.createElement(DatasourceAppearanceButton, {
485
- intl: intl,
486
- editorAnalyticsApi: editorAnalyticsApi,
487
- url: url,
488
- editorView: editorView,
489
- editorState: state,
490
- inputMethod: INPUT_METHOD.FLOATING_TB,
491
- areAnyNewToolbarFlagsEnabled: !areAllNewToolbarFlagsDisabled
492
- })
493
- }] : []), ...(!areAllNewToolbarFlagsDisabled ? [] : [{
494
- type: 'separator'
495
- }]));
394
+ isDatasourceView: isDatasource
395
+ }));
496
396
  }
497
- if (!areAllNewToolbarFlagsDisabled) {
498
- const hoverDecorationProps = (nodeType, className) => ({
499
- onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true, className),
500
- onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false, className),
501
- onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true, className),
502
- onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false, className)
503
- });
504
- // testId is required to show focus on trigger button on ESC key press
505
- // see hideOnEsc in platform/packages/editor/editor-plugin-floating-toolbar/src/ui/Dropdown.tsx
506
- const testId = 'card-overflow-dropdown-trigger';
507
- const overflowMenuConfig = [{
508
- type: 'separator',
509
- fullHeight: true
397
+ const hoverDecorationProps = (nodeType, className) => ({
398
+ onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true, className),
399
+ onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false, className),
400
+ onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true, className),
401
+ onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false, className)
402
+ });
403
+ // testId is required to show focus on trigger button on ESC key press
404
+ // see hideOnEsc in platform/packages/editor/editor-plugin-floating-toolbar/src/ui/Dropdown.tsx
405
+ const testId = 'card-overflow-dropdown-trigger';
406
+ const overflowMenuConfig = [{
407
+ type: 'separator',
408
+ fullHeight: true
409
+ }, {
410
+ type: 'overflow-dropdown',
411
+ testId,
412
+ options: [{
413
+ title: intl.formatMessage(commonMessages.copyToClipboard),
414
+ onClick: () => {
415
+ var _pluginInjectionApi$c5, _pluginInjectionApi$f;
416
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c5 = pluginInjectionApi.core) === null || _pluginInjectionApi$c5 === void 0 ? void 0 : _pluginInjectionApi$c5.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.commands.copyNode(node.type, INPUT_METHOD.FLOATING_TB));
417
+ return true;
418
+ },
419
+ icon: /*#__PURE__*/React.createElement(CopyIcon, {
420
+ label: intl.formatMessage(commonMessages.copyToClipboard)
421
+ }),
422
+ ...hoverDecorationProps(node.type, akEditorSelectedNodeClassName)
510
423
  }, {
511
- type: 'overflow-dropdown',
512
- testId,
513
- options: [{
514
- title: intl.formatMessage(commonMessages.copyToClipboard),
515
- onClick: () => {
516
- var _pluginInjectionApi$c5, _pluginInjectionApi$f;
517
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c5 = pluginInjectionApi.core) === null || _pluginInjectionApi$c5 === void 0 ? void 0 : _pluginInjectionApi$c5.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.commands.copyNode(node.type, INPUT_METHOD.FLOATING_TB));
518
- return true;
519
- },
520
- icon: /*#__PURE__*/React.createElement(CopyIcon, {
521
- label: intl.formatMessage(commonMessages.copyToClipboard)
522
- }),
523
- ...hoverDecorationProps(node.type, akEditorSelectedNodeClassName)
524
- }, {
525
- title: intl.formatMessage(commonMessages.delete),
526
- onClick: withToolbarMetadata(removeCard(editorAnalyticsApi)),
527
- icon: /*#__PURE__*/React.createElement(DeleteIcon, {
528
- label: intl.formatMessage(commonMessages.delete)
529
- }),
530
- ...hoverDecorationProps(node.type)
531
- }]
532
- }];
533
- toolbarItems.push(...overflowMenuConfig);
534
- }
424
+ title: intl.formatMessage(commonMessages.delete),
425
+ onClick: withToolbarMetadata(removeCard(editorAnalyticsApi)),
426
+ icon: /*#__PURE__*/React.createElement(DeleteIcon, {
427
+ label: intl.formatMessage(commonMessages.delete)
428
+ }),
429
+ ...hoverDecorationProps(node.type)
430
+ }]
431
+ }];
432
+ toolbarItems.push(...overflowMenuConfig);
535
433
  return toolbarItems;
536
434
  }
537
435
  };
538
- const getUnlinkButtonGroup = (state, intl, node, inlineCard, editorAnalyticsApi, areAnyNewToolbarFlagsEnabled, pluginInjectionApi) => {
436
+ const getUnlinkButtonGroup = (state, intl, node, inlineCard, editorAnalyticsApi, pluginInjectionApi) => {
539
437
  return node.type === inlineCard ? [{
540
438
  id: 'editor.link.unlink',
541
439
  focusEditoronEnter: true,
@@ -544,9 +442,7 @@ const getUnlinkButtonGroup = (state, intl, node, inlineCard, editorAnalyticsApi,
544
442
  icon: LinkBrokenIcon,
545
443
  iconFallback: LinkBrokenIcon,
546
444
  onClick: withToolbarMetadata(unlinkCard(node, state, editorAnalyticsApi, pluginInjectionApi))
547
- }, ...(areAnyNewToolbarFlagsEnabled ? [] : [{
548
- type: 'separator'
549
- }])] : [];
445
+ }] : [];
550
446
  };
551
447
  export const getSettingsButton = (intl, editorAnalyticsApi, userPreferencesLink) => {
552
448
  return {
@@ -564,7 +460,6 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
564
460
  var _node$attrs2, _node$attrs3;
565
461
  const toolbarItems = [];
566
462
  toolbarItems.push(...getToolbarViewedItem(node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.url, currentAppearance !== null && currentAppearance !== void 0 ? currentAppearance : 'url'));
567
- const areAllNewToolbarFlagsDisabled = !areToolbarFlagsEnabled(Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.toolbar));
568
463
  const canShowAppearanceSwitch = () => {
569
464
  // we do not show smart-link or the datasource icons when the node does not have a url to resolve
570
465
  if (!metadata.url) {
@@ -581,60 +476,21 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
581
476
  const {
582
477
  url
583
478
  } = metadata;
584
- if (areAllNewToolbarFlagsDisabled) {
585
- toolbarItems.push({
586
- type: 'custom',
587
- fallback: [],
588
- render: editorView => {
589
- return /*#__PURE__*/React.createElement(LinkToolbarAppearance, {
590
- key: "link-appearance",
591
- url: url,
592
- intl: intl,
593
- currentAppearance: currentAppearance,
594
- editorView: editorView,
595
- editorState: state,
596
- allowEmbeds: allowEmbeds,
597
- allowBlockCards: allowBlockCards,
598
- editorAnalyticsApi: editorAnalyticsApi,
599
- showUpgradeDiscoverability: showUpgradeDiscoverability,
600
- isDatasourceView: true,
601
- areAnyNewToolbarFlagsEnabled: false
602
- });
603
- }
604
- }, {
605
- type: 'custom',
606
- fallback: [],
607
- render: editorView => /*#__PURE__*/React.createElement(DatasourceAppearanceButton, {
608
- intl: intl,
609
- editorAnalyticsApi: editorAnalyticsApi,
610
- url: url,
611
- editorView: editorView,
612
- editorState: state,
613
- selected: true,
614
- inputMethod: INPUT_METHOD.FLOATING_TB,
615
- areAnyNewToolbarFlagsEnabled: !areAllNewToolbarFlagsDisabled
616
- })
617
- }, {
618
- type: 'separator'
619
- });
620
- } else {
621
- toolbarItems.push(getLinkAppearanceDropdown({
622
- url,
623
- intl,
624
- currentAppearance,
625
- editorState: state,
626
- allowEmbeds,
627
- allowBlockCards: allowBlockCards,
628
- editorAnalyticsApi,
629
- allowDatasource: cardOptions.allowDatasource,
630
- showUpgradeDiscoverability: showUpgradeDiscoverability,
631
- settingsConfig: getSettingsButton(intl, editorAnalyticsApi, cardOptions.userPreferencesLink),
632
- isDatasourceView: true,
633
- areAnyNewToolbarFlagsEnabled: !areAllNewToolbarFlagsDisabled
634
- }), {
635
- type: 'separator'
636
- });
637
- }
479
+ toolbarItems.push(getLinkAppearanceDropdown({
480
+ url,
481
+ intl,
482
+ currentAppearance,
483
+ editorState: state,
484
+ allowEmbeds,
485
+ allowBlockCards: allowBlockCards,
486
+ editorAnalyticsApi,
487
+ allowDatasource: cardOptions.allowDatasource,
488
+ showUpgradeDiscoverability: showUpgradeDiscoverability,
489
+ settingsConfig: getSettingsButton(intl, editorAnalyticsApi, cardOptions.userPreferencesLink),
490
+ isDatasourceView: true
491
+ }), {
492
+ type: 'separator'
493
+ });
638
494
  }
639
495
  const openLinkInputMethod = INPUT_METHOD.FLOATING_TB;
640
496
  const pluginState = pluginKey.getState(state);
@@ -650,8 +506,7 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
650
506
  editorAnalyticsApi: editorAnalyticsApi,
651
507
  editorView: editorView,
652
508
  onLinkEditClick: getEditLinkCallback(editorAnalyticsApi, false),
653
- currentAppearance: "datasource",
654
- areAnyNewToolbarFlagsEnabled: !areAllNewToolbarFlagsDisabled
509
+ currentAppearance: "datasource"
655
510
  })
656
511
  });
657
512
  if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
@@ -677,105 +532,68 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
677
532
  url: node.attrs.url,
678
533
  title: intl.formatMessage(linkMessages.openLink),
679
534
  editorView: editorView,
680
- onClick: fireOpenLinkToolbarAnalytics(editorAnalyticsApi, openLinkInputMethod, (_pluginState$resolved3 = pluginState === null || pluginState === void 0 ? void 0 : pluginState.resolvedToolbarAttributesByUrl[node.attrs.url]) !== null && _pluginState$resolved3 !== void 0 ? _pluginState$resolved3 : {}),
681
- areAnyNewToolbarFlagsEnabled: !areAllNewToolbarFlagsDisabled
535
+ onClick: fireOpenLinkToolbarAnalytics(editorAnalyticsApi, openLinkInputMethod, (_pluginState$resolved3 = pluginState === null || pluginState === void 0 ? void 0 : pluginState.resolvedToolbarAttributesByUrl[node.attrs.url]) !== null && _pluginState$resolved3 !== void 0 ? _pluginState$resolved3 : {})
682
536
  }) : null;
683
537
  }
684
538
  });
685
- if (areAllNewToolbarFlagsDisabled) {
686
- toolbarItems.push({
687
- type: 'separator'
688
- });
689
- }
690
539
  }
691
- if (areAllNewToolbarFlagsDisabled) {
540
+
541
+ // testId is required to show focus on trigger button on ESC key press
542
+ // see hideOnEsc in platform/packages/editor/editor-plugin-floating-toolbar/src/ui/Dropdown.tsx
543
+ const testId = 'datasource-overflow-dropdown-trigger';
544
+
545
+ // When canShowAppearanceSwitch is true, the link appearance dropdown shows, which includes a link preference button
546
+ // So only add the link appearance button when canShowAppearanceSwitch is false
547
+ if (!canShowAppearanceSwitch()) {
548
+ const linkPreferenceButton = getSettingsButton(intl, editorAnalyticsApi, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.userPreferencesLink);
692
549
  toolbarItems.push({
693
- type: 'copy-button',
694
- supportsViewMode: true,
695
- items: [{
696
- state,
697
- formatMessage: intl.formatMessage,
698
- nodeType: node.type
699
- }]
700
- }, {
701
- type: 'separator'
702
- }, getSettingsButton(intl, editorAnalyticsApi, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.userPreferencesLink), {
703
- type: 'separator'
550
+ type: 'separator',
551
+ fullHeight: true
552
+ }, linkPreferenceButton, {
553
+ type: 'separator',
554
+ fullHeight: true
555
+ });
556
+ } else {
557
+ toolbarItems.push({
558
+ type: 'separator',
559
+ fullHeight: true
560
+ });
561
+ }
562
+ const overflowMenuConfig = [{
563
+ type: 'overflow-dropdown',
564
+ testId,
565
+ options: [{
566
+ title: intl.formatMessage(commonMessages.copyToClipboard),
567
+ onClick: () => {
568
+ var _pluginInjectionApi$c6, _pluginInjectionApi$f2;
569
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c6 = pluginInjectionApi.core) === null || _pluginInjectionApi$c6 === void 0 ? void 0 : _pluginInjectionApi$c6.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.commands.copyNode(node.type, INPUT_METHOD.FLOATING_TB));
570
+ return true;
571
+ },
572
+ onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true, akEditorSelectedNodeClassName),
573
+ onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false, akEditorSelectedNodeClassName),
574
+ onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true, akEditorSelectedNodeClassName),
575
+ onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false, akEditorSelectedNodeClassName),
576
+ icon: /*#__PURE__*/React.createElement(CopyIcon, {
577
+ label: intl.formatMessage(commonMessages.copyToClipboard)
578
+ })
704
579
  }, {
705
- id: 'editor.link.delete',
706
- focusEditoronEnter: true,
707
- type: 'button',
708
- appearance: 'danger',
709
- icon: DeleteIcon,
710
- iconFallback: DeleteIcon,
580
+ title: intl.formatMessage(commonMessages.delete),
581
+ onClick: withToolbarMetadata(removeCard(editorAnalyticsApi)),
711
582
  onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
712
583
  onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
713
584
  onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
714
585
  onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
715
- title: intl.formatMessage(commonMessages.remove),
716
- onClick: withToolbarMetadata(removeCard(editorAnalyticsApi))
717
- });
718
- } else {
719
- // testId is required to show focus on trigger button on ESC key press
720
- // see hideOnEsc in platform/packages/editor/editor-plugin-floating-toolbar/src/ui/Dropdown.tsx
721
- const testId = 'datasource-overflow-dropdown-trigger';
722
-
723
- // When canShowAppearanceSwitch is true, the link appearance dropdown shows, which includes a link preference button
724
- // So only add the link appearance button when canShowAppearanceSwitch is false
725
- if (!canShowAppearanceSwitch()) {
726
- const linkPreferenceButton = getSettingsButton(intl, editorAnalyticsApi, cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.userPreferencesLink);
727
- toolbarItems.push({
728
- type: 'separator',
729
- fullHeight: true
730
- }, linkPreferenceButton, {
731
- type: 'separator',
732
- fullHeight: true
733
- });
734
- } else {
735
- toolbarItems.push({
736
- type: 'separator',
737
- fullHeight: true
738
- });
739
- }
740
- const overflowMenuConfig = [{
741
- type: 'overflow-dropdown',
742
- testId,
743
- options: [{
744
- title: intl.formatMessage(commonMessages.copyToClipboard),
745
- onClick: () => {
746
- var _pluginInjectionApi$c6, _pluginInjectionApi$f2;
747
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c6 = pluginInjectionApi.core) === null || _pluginInjectionApi$c6 === void 0 ? void 0 : _pluginInjectionApi$c6.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.commands.copyNode(node.type, INPUT_METHOD.FLOATING_TB));
748
- return true;
749
- },
750
- onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true, akEditorSelectedNodeClassName),
751
- onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false, akEditorSelectedNodeClassName),
752
- onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true, akEditorSelectedNodeClassName),
753
- onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false, akEditorSelectedNodeClassName),
754
- icon: /*#__PURE__*/React.createElement(CopyIcon, {
755
- label: intl.formatMessage(commonMessages.copyToClipboard)
756
- })
757
- }, {
758
- title: intl.formatMessage(commonMessages.delete),
759
- onClick: withToolbarMetadata(removeCard(editorAnalyticsApi)),
760
- onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
761
- onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
762
- onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, true),
763
- onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(node.type, false),
764
- icon: /*#__PURE__*/React.createElement(DeleteIcon, {
765
- label: intl.formatMessage(commonMessages.delete)
766
- })
767
- }]
768
- }];
769
- toolbarItems.push(...overflowMenuConfig);
770
- }
586
+ icon: /*#__PURE__*/React.createElement(DeleteIcon, {
587
+ label: intl.formatMessage(commonMessages.delete)
588
+ })
589
+ }]
590
+ }];
591
+ toolbarItems.push(...overflowMenuConfig);
771
592
  return toolbarItems;
772
593
  };
773
- export const shouldRenderToolbarPulse = (embedEnabled, appearance, status, isDiscoverabilityEnabled) => {
774
- return embedEnabled && appearance === 'inline' && status === 'resolved' && isDiscoverabilityEnabled;
775
- };
776
594
  export const getStartingToolbarItems = (options, api) => {
777
595
  return (intl, link, onEditLink, metadata, _state) => {
778
- const areAllNewToolbarFlagsDisabled = !areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar));
596
+ var _api$analytics2, _api$analytics3;
779
597
  const editLinkItem = options.allowDatasource ? [{
780
598
  type: 'custom',
781
599
  fallback: [],
@@ -791,8 +609,7 @@ export const getStartingToolbarItems = (options, api) => {
791
609
  url: link,
792
610
  editorView: editorView,
793
611
  onLinkEditClick: onEditLink,
794
- currentAppearance: "url",
795
- areAnyNewToolbarFlagsEnabled: !areAllNewToolbarFlagsDisabled
612
+ currentAppearance: "url"
796
613
  });
797
614
  }
798
615
  }] : [{
@@ -807,29 +624,16 @@ export const getStartingToolbarItems = (options, api) => {
807
624
  }, {
808
625
  type: 'separator'
809
626
  }];
810
- if (!areAllNewToolbarFlagsDisabled) {
811
- var _api$analytics2, _api$analytics3;
812
- const hyperlinkAppearance = [getCustomHyperlinkAppearanceDropdown({
813
- url: link,
814
- intl,
815
- editorAnalyticsApi: api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
816
- allowDatasource: options.allowDatasource,
817
- editorPluginApi: api,
818
- cardOptions: options,
819
- settingsConfig: getSettingsButton(intl, api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, options.userPreferencesLink),
820
- isDatasourceView: false
821
- })];
822
- return [{
823
- type: 'custom',
824
- fallback: [],
825
- render: editorView => /*#__PURE__*/React.createElement(ToolbarViewedEvent, {
826
- key: "edit.link.menu.viewed",
827
- url: link,
828
- display: "url",
829
- editorView: editorView
830
- })
831
- }, ...hyperlinkAppearance, ...editLinkItem];
832
- }
627
+ const hyperlinkAppearance = [getCustomHyperlinkAppearanceDropdown({
628
+ url: link,
629
+ intl,
630
+ editorAnalyticsApi: api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
631
+ allowDatasource: options.allowDatasource,
632
+ editorPluginApi: api,
633
+ cardOptions: options,
634
+ settingsConfig: getSettingsButton(intl, api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, options.userPreferencesLink),
635
+ isDatasourceView: false
636
+ })];
833
637
  return [{
834
638
  type: 'custom',
835
639
  fallback: [],
@@ -839,38 +643,7 @@ export const getStartingToolbarItems = (options, api) => {
839
643
  display: "url",
840
644
  editorView: editorView
841
645
  })
842
- }, {
843
- type: 'custom',
844
- fallback: [],
845
- render: editorView => {
846
- var _api$analytics4;
847
- if (!editorView) {
848
- return null;
849
- }
850
- return /*#__PURE__*/React.createElement(HyperlinkToolbarAppearance, {
851
- key: "link-appearance",
852
- url: link,
853
- intl: intl,
854
- editorView: editorView,
855
- editorState: editorView.state,
856
- cardOptions: options,
857
- editorAnalyticsApi: api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions,
858
- editorPluginApi: api
859
- });
860
- }
861
- }, ...editLinkItem];
646
+ }, ...hyperlinkAppearance, ...editLinkItem];
862
647
  };
863
648
  };
864
- export const getEndingToolbarItems = (options, api) => (intl, _link) => {
865
- /**
866
- * Require either provider to be supplied (controls link preferences)
867
- * Or explicit user preferences config in order to enable button
868
- */
869
- if ((options.provider || options.userPreferencesLink) && !areToolbarFlagsEnabled(Boolean(api === null || api === void 0 ? void 0 : api.toolbar))) {
870
- var _api$analytics5;
871
- return [{
872
- type: 'separator'
873
- }, getSettingsButton(intl, api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions, options.userPreferencesLink)];
874
- }
875
- return [];
876
- };
649
+ export const getEndingToolbarItems = (_options, _api) => (_intl, _link) => [];