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