@atlaskit/editor-plugin-card 0.5.1 → 0.5.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,17 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 0.5.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`882e4e88358`](https://bitbucket.org/atlassian/atlassian-frontend/commits/882e4e88358) - Add playwright tests and add test ids to find elements
8
+
9
+ ## 0.5.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`386b8378aeb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/386b8378aeb) - Datasource ADF no longer included when feature flag call from canRenderDatasource returns false
14
+
3
15
  ## 0.5.1
4
16
 
5
17
  ### Patch Changes
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.resolveWithProvider = exports.handleProvider = void 0;
7
+ var _utils = require("@atlaskit/editor-common/utils");
7
8
  var _actions = require("../actions");
8
9
  var _doc = require("../doc");
9
10
  // ============================================================================ //
@@ -23,14 +24,19 @@ var resolveWithProvider = function resolveWithProvider(view, provider, request,
23
24
  };
24
25
  exports.resolveWithProvider = resolveWithProvider;
25
26
  var updateCardType = function updateCardType(resolvedCard, options) {
26
- var isDatasource = resolvedCard.type === 'blockCard' && 'datasource' in resolvedCard.attrs;
27
- if ((resolvedCard === null || resolvedCard === void 0 ? void 0 : resolvedCard.type) === 'blockCard' && !options.allowBlockCards || (resolvedCard === null || resolvedCard === void 0 ? void 0 : resolvedCard.type) === 'embedCard' && !options.allowEmbeds || isDatasource && !options.allowDatasource) {
27
+ if (resolvedCard.type === 'blockCard' && 'datasource' in resolvedCard.attrs) {
28
+ var datasourceId = resolvedCard.attrs.datasource.id;
29
+ if (!options.allowDatasource || !(0, _utils.canRenderDatasource)(datasourceId)) {
30
+ delete resolvedCard.attrs.datasource;
31
+ resolvedCard.type = 'inlineCard';
32
+ return;
33
+ }
34
+ }
35
+ if ((resolvedCard === null || resolvedCard === void 0 ? void 0 : resolvedCard.type) === 'blockCard' && !options.allowBlockCards || (resolvedCard === null || resolvedCard === void 0 ? void 0 : resolvedCard.type) === 'embedCard' && !options.allowEmbeds) {
28
36
  // clean out the 'layout' attr from an embedCard type that should be transformed into the inlineCard type.
29
37
  if (resolvedCard.type === 'embedCard') {
30
38
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
39
  delete resolvedCard.attrs.layout;
32
- } else if (isDatasource) {
33
- delete resolvedCard.attrs.datasource;
34
40
  }
35
41
  resolvedCard.type = 'inlineCard';
36
42
  }
@@ -352,7 +352,8 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(state, metadata
352
352
  metadata: metadata,
353
353
  className: 'datasource-edit',
354
354
  title: intl.formatMessage(_messages.linkToolbarMessages.editDatasource),
355
- onClick: (0, _EditLinkToolbar.editDatasource)(node, editorAnalyticsApi)
355
+ onClick: (0, _EditLinkToolbar.editDatasource)(node, editorAnalyticsApi),
356
+ testId: 'datasource-edit-button'
356
357
  }];
357
358
  if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
358
359
  toolbarItems.push({
@@ -1,3 +1,4 @@
1
+ import { canRenderDatasource } from '@atlaskit/editor-common/utils';
1
2
  import { setProvider } from '../actions';
2
3
  import { handleFallbackWithAnalytics, replaceQueuedUrlWithCard } from '../doc';
3
4
 
@@ -17,14 +18,19 @@ export const resolveWithProvider = (view, provider, request, options, editorAnal
17
18
  return handleResolve;
18
19
  };
19
20
  const updateCardType = (resolvedCard, options) => {
20
- const isDatasource = resolvedCard.type === 'blockCard' && 'datasource' in resolvedCard.attrs;
21
- if ((resolvedCard === null || resolvedCard === void 0 ? void 0 : resolvedCard.type) === 'blockCard' && !options.allowBlockCards || (resolvedCard === null || resolvedCard === void 0 ? void 0 : resolvedCard.type) === 'embedCard' && !options.allowEmbeds || isDatasource && !options.allowDatasource) {
21
+ if (resolvedCard.type === 'blockCard' && 'datasource' in resolvedCard.attrs) {
22
+ const datasourceId = resolvedCard.attrs.datasource.id;
23
+ if (!options.allowDatasource || !canRenderDatasource(datasourceId)) {
24
+ delete resolvedCard.attrs.datasource;
25
+ resolvedCard.type = 'inlineCard';
26
+ return;
27
+ }
28
+ }
29
+ if ((resolvedCard === null || resolvedCard === void 0 ? void 0 : resolvedCard.type) === 'blockCard' && !options.allowBlockCards || (resolvedCard === null || resolvedCard === void 0 ? void 0 : resolvedCard.type) === 'embedCard' && !options.allowEmbeds) {
22
30
  // clean out the 'layout' attr from an embedCard type that should be transformed into the inlineCard type.
23
31
  if (resolvedCard.type === 'embedCard') {
24
32
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
33
  delete resolvedCard.attrs.layout;
26
- } else if (isDatasource) {
27
- delete resolvedCard.attrs.datasource;
28
34
  }
29
35
  resolvedCard.type = 'inlineCard';
30
36
  }
@@ -345,7 +345,8 @@ const getDatasourceButtonGroup = (state, metadata, intl, editorAnalyticsApi, nod
345
345
  metadata: metadata,
346
346
  className: 'datasource-edit',
347
347
  title: intl.formatMessage(linkToolbarMessages.editDatasource),
348
- onClick: editDatasource(node, editorAnalyticsApi)
348
+ onClick: editDatasource(node, editorAnalyticsApi),
349
+ testId: 'datasource-edit-button'
349
350
  }];
350
351
  if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
351
352
  toolbarItems.push({
@@ -1,3 +1,4 @@
1
+ import { canRenderDatasource } from '@atlaskit/editor-common/utils';
1
2
  import { setProvider } from '../actions';
2
3
  import { handleFallbackWithAnalytics, replaceQueuedUrlWithCard } from '../doc';
3
4
 
@@ -17,14 +18,19 @@ export var resolveWithProvider = function resolveWithProvider(view, provider, re
17
18
  return handleResolve;
18
19
  };
19
20
  var updateCardType = function updateCardType(resolvedCard, options) {
20
- var isDatasource = resolvedCard.type === 'blockCard' && 'datasource' in resolvedCard.attrs;
21
- if ((resolvedCard === null || resolvedCard === void 0 ? void 0 : resolvedCard.type) === 'blockCard' && !options.allowBlockCards || (resolvedCard === null || resolvedCard === void 0 ? void 0 : resolvedCard.type) === 'embedCard' && !options.allowEmbeds || isDatasource && !options.allowDatasource) {
21
+ if (resolvedCard.type === 'blockCard' && 'datasource' in resolvedCard.attrs) {
22
+ var datasourceId = resolvedCard.attrs.datasource.id;
23
+ if (!options.allowDatasource || !canRenderDatasource(datasourceId)) {
24
+ delete resolvedCard.attrs.datasource;
25
+ resolvedCard.type = 'inlineCard';
26
+ return;
27
+ }
28
+ }
29
+ if ((resolvedCard === null || resolvedCard === void 0 ? void 0 : resolvedCard.type) === 'blockCard' && !options.allowBlockCards || (resolvedCard === null || resolvedCard === void 0 ? void 0 : resolvedCard.type) === 'embedCard' && !options.allowEmbeds) {
22
30
  // clean out the 'layout' attr from an embedCard type that should be transformed into the inlineCard type.
23
31
  if (resolvedCard.type === 'embedCard') {
24
32
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
33
  delete resolvedCard.attrs.layout;
26
- } else if (isDatasource) {
27
- delete resolvedCard.attrs.datasource;
28
34
  }
29
35
  resolvedCard.type = 'inlineCard';
30
36
  }
@@ -338,7 +338,8 @@ var getDatasourceButtonGroup = function getDatasourceButtonGroup(state, metadata
338
338
  metadata: metadata,
339
339
  className: 'datasource-edit',
340
340
  title: intl.formatMessage(linkToolbarMessages.editDatasource),
341
- onClick: editDatasource(node, editorAnalyticsApi)
341
+ onClick: editDatasource(node, editorAnalyticsApi),
342
+ testId: 'datasource-edit-button'
342
343
  }];
343
344
  if (node !== null && node !== void 0 && (_node$attrs3 = node.attrs) !== null && _node$attrs3 !== void 0 && _node$attrs3.url) {
344
345
  toolbarItems.push({
@@ -1,8 +1,8 @@
1
- import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
- import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
- import { CardOptions } from '@atlaskit/editor-common/card';
4
- import { CardProvider, DatasourceAdf } from '@atlaskit/editor-common/provider-factory';
5
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
6
- import { Request } from '../../types';
1
+ import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
+ import type { CardOptions } from '@atlaskit/editor-common/card';
4
+ import type { CardProvider, DatasourceAdf } from '@atlaskit/editor-common/provider-factory';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { Request } from '../../types';
7
7
  export declare const resolveWithProvider: (view: EditorView, provider: CardProvider, request: Request, options: CardOptions, editorAnalyticsApi: EditorAnalyticsAPI | undefined, createAnalyticsEvent: CreateUIAnalyticsEvent | undefined) => Promise<void | import("@atlaskit/linking-common").InlineCardAdf | import("@atlaskit/linking-common").BlockCardAdf | import("@atlaskit/linking-common").EmbedCardAdf | DatasourceAdf>;
8
8
  export declare const handleProvider: (_: 'cardProvider', provider: Promise<CardProvider> | undefined, view: EditorView) => void;
@@ -1,8 +1,8 @@
1
- import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
- import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
- import { CardOptions } from '@atlaskit/editor-common/card';
4
- import { CardProvider, DatasourceAdf } from '@atlaskit/editor-common/provider-factory';
5
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
6
- import { Request } from '../../types';
1
+ import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
+ import type { CardOptions } from '@atlaskit/editor-common/card';
4
+ import type { CardProvider, DatasourceAdf } from '@atlaskit/editor-common/provider-factory';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { Request } from '../../types';
7
7
  export declare const resolveWithProvider: (view: EditorView, provider: CardProvider, request: Request, options: CardOptions, editorAnalyticsApi: EditorAnalyticsAPI | undefined, createAnalyticsEvent: CreateUIAnalyticsEvent | undefined) => Promise<void | import("@atlaskit/linking-common").InlineCardAdf | import("@atlaskit/linking-common").BlockCardAdf | import("@atlaskit/linking-common").EmbedCardAdf | DatasourceAdf>;
8
8
  export declare const handleProvider: (_: 'cardProvider', provider: Promise<CardProvider> | undefined, view: EditorView) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -47,9 +47,9 @@
47
47
  "@atlaskit/link-analytics": "^8.2.0",
48
48
  "@atlaskit/link-datasource": "^1.0.0",
49
49
  "@atlaskit/platform-feature-flags": "^0.2.0",
50
- "@atlaskit/smart-card": "^26.19.0",
51
- "@atlaskit/theme": "^12.5.0",
52
- "@atlaskit/tokens": "^1.18.0",
50
+ "@atlaskit/smart-card": "^26.20.0",
51
+ "@atlaskit/theme": "^12.6.0",
52
+ "@atlaskit/tokens": "^1.20.0",
53
53
  "@babel/runtime": "^7.0.0",
54
54
  "@emotion/react": "^11.7.1",
55
55
  "lodash": "^4.17.21",