@atlaskit/editor-plugin-card 0.16.2 → 0.16.3

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,12 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 0.16.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#66961](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/66961) [`2e4913393f85`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2e4913393f85) - Add logic to prevent showing datasource edit button in toolbar if datasource does not support editing.
8
+ - Updated dependencies
9
+
3
10
  ## 0.16.2
4
11
 
5
12
  ### Patch Changes
@@ -348,20 +348,23 @@ var getSettingsButtonGroup = function getSettingsButtonGroup(intl, editorAnalyti
348
348
  };
349
349
  var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state) {
350
350
  var _node$attrs3;
351
- var toolbarItems = [{
352
- id: 'editor.edit.datasource',
353
- type: 'button',
354
- icon: _ui.SmallerEditIcon,
355
- metadata: metadata,
356
- className: 'datasource-edit',
357
- title: intl.formatMessage(_messages.linkToolbarMessages.editDatasource),
358
- onClick: (0, _EditDatasourceButton.editDatasource)(datasourceId, editorAnalyticsApi),
359
- testId: 'datasource-edit-button'
360
- }];
361
- if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
351
+ var toolbarItems = [];
352
+ if ((0, _utils3.isDatasourceConfigEditable)(datasourceId)) {
362
353
  toolbarItems.push({
363
- type: 'separator'
354
+ id: 'editor.edit.datasource',
355
+ type: 'button',
356
+ icon: _ui.SmallerEditIcon,
357
+ metadata: metadata,
358
+ className: 'datasource-edit',
359
+ title: intl.formatMessage(_messages.linkToolbarMessages.editDatasource),
360
+ onClick: (0, _EditDatasourceButton.editDatasource)(datasourceId, editorAnalyticsApi),
361
+ testId: 'datasource-edit-button'
364
362
  }, {
363
+ type: 'separator'
364
+ });
365
+ }
366
+ if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
367
+ toolbarItems.push({
365
368
  id: 'editor.link.openLink',
366
369
  type: 'button',
367
370
  icon: _shortcut.default,
@@ -369,11 +372,11 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
369
372
  className: 'hyperlink-open-link',
370
373
  title: intl.formatMessage(_messages.linkMessages.openLink),
371
374
  onClick: visitCardLink(editorAnalyticsApi)
375
+ }, {
376
+ type: 'separator'
372
377
  });
373
378
  }
374
379
  toolbarItems.push({
375
- type: 'separator'
376
- }, {
377
380
  type: 'copy-button',
378
381
  items: [{
379
382
  state: state,
package/dist/cjs/utils.js CHANGED
@@ -3,10 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.titleUrlPairFromNode = exports.selectedCardAppearance = exports.mergeCardInfo = exports.isEmbedSupportedAtPosition = exports.isBlockSupportedAtPosition = exports.getResolvedAttributesFromStore = exports.findCardInfo = exports.displayInfoForCard = exports.appearanceForNodeType = void 0;
6
+ exports.titleUrlPairFromNode = exports.selectedCardAppearance = exports.mergeCardInfo = exports.isEmbedSupportedAtPosition = exports.isDatasourceConfigEditable = exports.isBlockSupportedAtPosition = exports.getResolvedAttributesFromStore = exports.findCardInfo = exports.displayInfoForCard = exports.appearanceForNodeType = void 0;
7
7
  var _model = require("@atlaskit/editor-prosemirror/model");
8
8
  var _state = require("@atlaskit/editor-prosemirror/state");
9
9
  var _resolvedAttributes = require("@atlaskit/link-analytics/resolved-attributes");
10
+ var _linkDatasource = require("@atlaskit/link-datasource");
10
11
  var _pluginKey = require("./pm-plugins/plugin-key");
11
12
  var appearanceForNodeType = exports.appearanceForNodeType = function appearanceForNodeType(spec) {
12
13
  if (spec.name === 'inlineCard') {
@@ -75,4 +76,8 @@ var getResolvedAttributesFromStore = exports.getResolvedAttributesFromStore = fu
75
76
  url: url,
76
77
  displayCategory: displayCategory
77
78
  }, urlState === null || urlState === void 0 ? void 0 : urlState.details);
79
+ };
80
+ var isDatasourceConfigEditable = exports.isDatasourceConfigEditable = function isDatasourceConfigEditable(datasourceId) {
81
+ var datasourcesWithConfigModal = [_linkDatasource.JIRA_LIST_OF_LINKS_DATASOURCE_ID, _linkDatasource.ASSETS_LIST_OF_LINKS_DATASOURCE_ID];
82
+ return datasourcesWithConfigModal.includes(datasourceId);
78
83
  };
@@ -19,7 +19,7 @@ import { editDatasource, EditDatasourceButton } from './ui/EditDatasourceButton'
19
19
  import { buildEditLinkToolbar, editLink, editLinkToolbarConfig } from './ui/EditLinkToolbar';
20
20
  import { LinkToolbarAppearance } from './ui/LinkToolbarAppearance';
21
21
  import { ToolbarViewedEvent } from './ui/ToolbarViewedEvent';
22
- import { appearanceForNodeType, displayInfoForCard, findCardInfo, titleUrlPairFromNode } from './utils';
22
+ import { appearanceForNodeType, displayInfoForCard, findCardInfo, isDatasourceConfigEditable, titleUrlPairFromNode } from './utils';
23
23
  export const removeCard = editorAnalyticsApi => commandWithMetadata((state, dispatch) => {
24
24
  if (!(state.selection instanceof NodeSelection)) {
25
25
  return false;
@@ -341,20 +341,23 @@ const getSettingsButtonGroup = (intl, editorAnalyticsApi) => {
341
341
  };
342
342
  const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state) => {
343
343
  var _node$attrs3;
344
- const toolbarItems = [{
345
- id: 'editor.edit.datasource',
346
- type: 'button',
347
- icon: SmallerEditIcon,
348
- metadata: metadata,
349
- className: 'datasource-edit',
350
- title: intl.formatMessage(linkToolbarMessages.editDatasource),
351
- onClick: editDatasource(datasourceId, editorAnalyticsApi),
352
- testId: 'datasource-edit-button'
353
- }];
354
- if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
344
+ const toolbarItems = [];
345
+ if (isDatasourceConfigEditable(datasourceId)) {
355
346
  toolbarItems.push({
356
- type: 'separator'
347
+ id: 'editor.edit.datasource',
348
+ type: 'button',
349
+ icon: SmallerEditIcon,
350
+ metadata: metadata,
351
+ className: 'datasource-edit',
352
+ title: intl.formatMessage(linkToolbarMessages.editDatasource),
353
+ onClick: editDatasource(datasourceId, editorAnalyticsApi),
354
+ testId: 'datasource-edit-button'
357
355
  }, {
356
+ type: 'separator'
357
+ });
358
+ }
359
+ if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
360
+ toolbarItems.push({
358
361
  id: 'editor.link.openLink',
359
362
  type: 'button',
360
363
  icon: OpenIcon,
@@ -362,11 +365,11 @@ const getDatasourceButtonGroup = (metadata, intl, editorAnalyticsApi, node, hove
362
365
  className: 'hyperlink-open-link',
363
366
  title: intl.formatMessage(linkMessages.openLink),
364
367
  onClick: visitCardLink(editorAnalyticsApi)
368
+ }, {
369
+ type: 'separator'
365
370
  });
366
371
  }
367
372
  toolbarItems.push({
368
- type: 'separator'
369
- }, {
370
373
  type: 'copy-button',
371
374
  items: [{
372
375
  state,
@@ -1,6 +1,7 @@
1
1
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
2
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { getResolvedAttributes } from '@atlaskit/link-analytics/resolved-attributes';
4
+ import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, JIRA_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource';
4
5
  import { pluginKey } from './pm-plugins/plugin-key';
5
6
  export const appearanceForNodeType = spec => {
6
7
  if (spec.name === 'inlineCard') {
@@ -63,4 +64,8 @@ export const getResolvedAttributesFromStore = (url, display, store) => {
63
64
  url,
64
65
  displayCategory
65
66
  }, urlState === null || urlState === void 0 ? void 0 : urlState.details);
67
+ };
68
+ export const isDatasourceConfigEditable = datasourceId => {
69
+ const datasourcesWithConfigModal = [JIRA_LIST_OF_LINKS_DATASOURCE_ID, ASSETS_LIST_OF_LINKS_DATASOURCE_ID];
70
+ return datasourcesWithConfigModal.includes(datasourceId);
66
71
  };
@@ -23,7 +23,7 @@ import { editDatasource, EditDatasourceButton } from './ui/EditDatasourceButton'
23
23
  import { buildEditLinkToolbar, editLink, editLinkToolbarConfig } from './ui/EditLinkToolbar';
24
24
  import { LinkToolbarAppearance } from './ui/LinkToolbarAppearance';
25
25
  import { ToolbarViewedEvent } from './ui/ToolbarViewedEvent';
26
- import { appearanceForNodeType, displayInfoForCard, findCardInfo, titleUrlPairFromNode } from './utils';
26
+ import { appearanceForNodeType, displayInfoForCard, findCardInfo, isDatasourceConfigEditable, titleUrlPairFromNode } from './utils';
27
27
  export var removeCard = function removeCard(editorAnalyticsApi) {
28
28
  return commandWithMetadata(function (state, dispatch) {
29
29
  if (!(state.selection instanceof NodeSelection)) {
@@ -338,20 +338,23 @@ var getSettingsButtonGroup = function getSettingsButtonGroup(intl, editorAnalyti
338
338
  };
339
339
  var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl, editorAnalyticsApi, node, hoverDecoration, datasourceId, state) {
340
340
  var _node$attrs3;
341
- var toolbarItems = [{
342
- id: 'editor.edit.datasource',
343
- type: 'button',
344
- icon: SmallerEditIcon,
345
- metadata: metadata,
346
- className: 'datasource-edit',
347
- title: intl.formatMessage(linkToolbarMessages.editDatasource),
348
- onClick: editDatasource(datasourceId, editorAnalyticsApi),
349
- testId: 'datasource-edit-button'
350
- }];
351
- if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
341
+ var toolbarItems = [];
342
+ if (isDatasourceConfigEditable(datasourceId)) {
352
343
  toolbarItems.push({
353
- type: 'separator'
344
+ id: 'editor.edit.datasource',
345
+ type: 'button',
346
+ icon: SmallerEditIcon,
347
+ metadata: metadata,
348
+ className: 'datasource-edit',
349
+ title: intl.formatMessage(linkToolbarMessages.editDatasource),
350
+ onClick: editDatasource(datasourceId, editorAnalyticsApi),
351
+ testId: 'datasource-edit-button'
354
352
  }, {
353
+ type: 'separator'
354
+ });
355
+ }
356
+ if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
357
+ toolbarItems.push({
355
358
  id: 'editor.link.openLink',
356
359
  type: 'button',
357
360
  icon: OpenIcon,
@@ -359,11 +362,11 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(metadata, intl,
359
362
  className: 'hyperlink-open-link',
360
363
  title: intl.formatMessage(linkMessages.openLink),
361
364
  onClick: visitCardLink(editorAnalyticsApi)
365
+ }, {
366
+ type: 'separator'
362
367
  });
363
368
  }
364
369
  toolbarItems.push({
365
- type: 'separator'
366
- }, {
367
370
  type: 'copy-button',
368
371
  items: [{
369
372
  state: state,
package/dist/esm/utils.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
2
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { getResolvedAttributes } from '@atlaskit/link-analytics/resolved-attributes';
4
+ import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, JIRA_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource';
4
5
  import { pluginKey } from './pm-plugins/plugin-key';
5
6
  export var appearanceForNodeType = function appearanceForNodeType(spec) {
6
7
  if (spec.name === 'inlineCard') {
@@ -69,4 +70,8 @@ export var getResolvedAttributesFromStore = function getResolvedAttributesFromSt
69
70
  url: url,
70
71
  displayCategory: displayCategory
71
72
  }, urlState === null || urlState === void 0 ? void 0 : urlState.details);
73
+ };
74
+ export var isDatasourceConfigEditable = function isDatasourceConfigEditable(datasourceId) {
75
+ var datasourcesWithConfigModal = [JIRA_LIST_OF_LINKS_DATASOURCE_ID, ASSETS_LIST_OF_LINKS_DATASOURCE_ID];
76
+ return datasourcesWithConfigModal.includes(datasourceId);
72
77
  };
@@ -21,3 +21,4 @@ export declare const findCardInfo: (state: EditorState) => CardInfo | undefined;
21
21
  export declare const isEmbedSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
22
22
  export declare const isBlockSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
23
23
  export declare const getResolvedAttributesFromStore: (url: string, display: string | null, store?: CardContext['store']) => {};
24
+ export declare const isDatasourceConfigEditable: (datasourceId: string) => boolean;
@@ -21,3 +21,4 @@ export declare const findCardInfo: (state: EditorState) => CardInfo | undefined;
21
21
  export declare const isEmbedSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
22
22
  export declare const isBlockSupportedAtPosition: (currentNodePosition: number, editorState: EditorState, currentAppearance?: CardAppearance) => boolean;
23
23
  export declare const getResolvedAttributesFromStore: (url: string, display: string | null, store?: CardContext['store']) => {};
24
+ export declare const isDatasourceConfigEditable: (datasourceId: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,7 +35,7 @@
35
35
  "@atlaskit/adf-schema": "^35.3.0",
36
36
  "@atlaskit/analytics-next": "^9.1.0",
37
37
  "@atlaskit/custom-steps": "^0.0.11",
38
- "@atlaskit/editor-common": "^76.39.0",
38
+ "@atlaskit/editor-common": "^76.41.0",
39
39
  "@atlaskit/editor-plugin-analytics": "^0.4.0",
40
40
  "@atlaskit/editor-plugin-decorations": "^0.2.0",
41
41
  "@atlaskit/editor-plugin-feature-flags": "^1.0.0",
@@ -53,10 +53,10 @@
53
53
  "@atlaskit/linking-common": "^5.3.0",
54
54
  "@atlaskit/linking-types": "^8.5.0",
55
55
  "@atlaskit/platform-feature-flags": "^0.2.0",
56
- "@atlaskit/primitives": "^1.17.0",
56
+ "@atlaskit/primitives": "^1.18.0",
57
57
  "@atlaskit/smart-card": "^26.44.0",
58
58
  "@atlaskit/theme": "^12.6.0",
59
- "@atlaskit/tokens": "^1.33.0",
59
+ "@atlaskit/tokens": "^1.34.0",
60
60
  "@babel/runtime": "^7.0.0",
61
61
  "@emotion/react": "^11.7.1",
62
62
  "lodash": "^4.17.21",