@atlaskit/editor-card-provider 3.8.2 → 3.10.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/editor-card-provider
2
2
 
3
+ ## 3.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#144036](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/144036)
8
+ [`0509cf0b76664`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0509cf0b76664) -
9
+ [ux] Update editor card provider to return embed card for backlog and board links
10
+
11
+ ## 3.9.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#139456](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/139456)
16
+ [`a788f5ceac7a2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a788f5ceac7a2) -
17
+ [ux] Add optional forth optional parameter to EditorCardProvider.resolve method called
18
+ `isEmbedFriendlyLocation` which when given `false` value will prevent auto-conversion (on link
19
+ paste) to an embed based on FE speciafied regexp rules. If value is not given it will act as true
20
+ and remain old behaviour
21
+
3
22
  ## 3.8.2
4
23
 
5
24
  ### Patch Changes
@@ -65,6 +65,12 @@ var isLoomUrl = function isLoomUrl(url) {
65
65
  var isJiraDashboard = function isJiraDashboard(url) {
66
66
  return url.match(/^https:\/\/.*?\/jira\/dashboards\/[0-9]+.*/);
67
67
  };
68
+ var isJiraBacklog = function isJiraBacklog(url) {
69
+ return url.match(/https:\/\/.*?\/jira\/software\/(c\/)?projects\/[^\/]+?\/boards\/\d\/backlog\??.*/);
70
+ };
71
+ var isJiraBoard = function isJiraBoard(url) {
72
+ return url.match(/https:\/\/.*?\/jira\/software\/(c\/)?projects\/[^\/]+?\/boards\/\d\??.*/);
73
+ };
68
74
  var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
69
75
  function EditorCardProvider(envKey, baseUrlOverride, product) {
70
76
  var _this = this;
@@ -346,7 +352,7 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
346
352
  }, {
347
353
  key: "getHardCodedAppearance",
348
354
  value: function getHardCodedAppearance(url) {
349
- if (isJiraRoadmapOrTimeline(url) || isPolarisView(url) || isJwmView(url) || isJiraList(url) || isGiphyMedia(url) || isProformaView(url) || isConfluenceWhiteboard(url) || isConfluenceDatabase(url) || isYoutubeVideo(url) || isLoomUrl(url) || isJiraDashboard(url)) {
355
+ if (isJiraRoadmapOrTimeline(url) || isPolarisView(url) || isJwmView(url) || isJiraList(url) || isGiphyMedia(url) || isProformaView(url) || isConfluenceWhiteboard(url) || isConfluenceDatabase(url) || isYoutubeVideo(url) || isLoomUrl(url) || isJiraDashboard(url) || isJiraBacklog(url) || isJiraBoard(url)) {
350
356
  return 'embed';
351
357
  }
352
358
  }
@@ -441,7 +447,7 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
441
447
  }, {
442
448
  key: "resolve",
443
449
  value: function () {
444
- var _resolve = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(url, appearance, shouldForceAppearance) {
450
+ var _resolve = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(url, appearance, shouldForceAppearance, isEmbedFriendlyLocation) {
445
451
  var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, isSupported, providerDefaultAppearance, preferredAppearance, canItBeEmbed, datasource, id, parameters;
446
452
  return _regenerator.default.wrap(function _callee10$(_context10) {
447
453
  while (1) switch (_context10.prev = _context10.next) {
@@ -491,7 +497,7 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
491
497
  userPreference ||
492
498
  // If user's default choice is "inline" or user hasn't specified preferences at all,
493
499
  // we check whatever one of the hardcoded providers match url (jira /timeline, polaris, etc)
494
- hardCodedAppearance ||
500
+ (isEmbedFriendlyLocation || isEmbedFriendlyLocation === undefined) && hardCodedAppearance ||
495
501
  // If non match, we see if this provider has default appearance for this particular regexp
496
502
  providerDefaultAppearance ||
497
503
  // If not, we pick what editor (or any other client) requested
@@ -544,7 +550,7 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
544
550
  }
545
551
  }, _callee10, this, [[0, 35]]);
546
552
  }));
547
- function resolve(_x8, _x9, _x10) {
553
+ function resolve(_x8, _x9, _x10, _x11) {
548
554
  return _resolve.apply(this, arguments);
549
555
  }
550
556
  return resolve;
@@ -24,6 +24,12 @@ const isLoomUrl = url => {
24
24
  const isJiraDashboard = url => {
25
25
  return url.match(/^https:\/\/.*?\/jira\/dashboards\/[0-9]+.*/);
26
26
  };
27
+ const isJiraBacklog = url => {
28
+ return url.match(/https:\/\/.*?\/jira\/software\/(c\/)?projects\/[^\/]+?\/boards\/\d\/backlog\??.*/);
29
+ };
30
+ const isJiraBoard = url => {
31
+ return url.match(/https:\/\/.*?\/jira\/software\/(c\/)?projects\/[^\/]+?\/boards\/\d\??.*/);
32
+ };
27
33
  export class EditorCardProvider {
28
34
  constructor(envKey, baseUrlOverride, product) {
29
35
  this.baseUrl = baseUrlOverride || getBaseUrl(envKey);
@@ -128,7 +134,7 @@ export class EditorCardProvider {
128
134
  * @returns 'embed' for the card appearance to embed by default
129
135
  */
130
136
  getHardCodedAppearance(url) {
131
- if (isJiraRoadmapOrTimeline(url) || isPolarisView(url) || isJwmView(url) || isJiraList(url) || isGiphyMedia(url) || isProformaView(url) || isConfluenceWhiteboard(url) || isConfluenceDatabase(url) || isYoutubeVideo(url) || isLoomUrl(url) || isJiraDashboard(url)) {
137
+ if (isJiraRoadmapOrTimeline(url) || isPolarisView(url) || isJwmView(url) || isJiraList(url) || isGiphyMedia(url) || isProformaView(url) || isConfluenceWhiteboard(url) || isConfluenceDatabase(url) || isYoutubeVideo(url) || isLoomUrl(url) || isJiraDashboard(url) || isJiraBacklog(url) || isJiraBoard(url)) {
132
138
  return 'embed';
133
139
  }
134
140
  }
@@ -173,7 +179,7 @@ export class EditorCardProvider {
173
179
  return undefined;
174
180
  }
175
181
  }
176
- async resolve(url, appearance, shouldForceAppearance) {
182
+ async resolve(url, appearance, shouldForceAppearance, isEmbedFriendlyLocation) {
177
183
  try {
178
184
  if (shouldForceAppearance === true) {
179
185
  // At this point we don't need to check pattern nor call `check` because manual change means
@@ -197,7 +203,7 @@ export class EditorCardProvider {
197
203
  userPreference ||
198
204
  // If user's default choice is "inline" or user hasn't specified preferences at all,
199
205
  // we check whatever one of the hardcoded providers match url (jira /timeline, polaris, etc)
200
- hardCodedAppearance ||
206
+ (isEmbedFriendlyLocation || isEmbedFriendlyLocation === undefined) && hardCodedAppearance ||
201
207
  // If non match, we see if this provider has default appearance for this particular regexp
202
208
  providerDefaultAppearance ||
203
209
  // If not, we pick what editor (or any other client) requested
@@ -57,6 +57,12 @@ var isLoomUrl = function isLoomUrl(url) {
57
57
  var isJiraDashboard = function isJiraDashboard(url) {
58
58
  return url.match(/^https:\/\/.*?\/jira\/dashboards\/[0-9]+.*/);
59
59
  };
60
+ var isJiraBacklog = function isJiraBacklog(url) {
61
+ return url.match(/https:\/\/.*?\/jira\/software\/(c\/)?projects\/[^\/]+?\/boards\/\d\/backlog\??.*/);
62
+ };
63
+ var isJiraBoard = function isJiraBoard(url) {
64
+ return url.match(/https:\/\/.*?\/jira\/software\/(c\/)?projects\/[^\/]+?\/boards\/\d\??.*/);
65
+ };
60
66
  export var EditorCardProvider = /*#__PURE__*/function () {
61
67
  function EditorCardProvider(envKey, baseUrlOverride, product) {
62
68
  var _this = this;
@@ -338,7 +344,7 @@ export var EditorCardProvider = /*#__PURE__*/function () {
338
344
  }, {
339
345
  key: "getHardCodedAppearance",
340
346
  value: function getHardCodedAppearance(url) {
341
- if (isJiraRoadmapOrTimeline(url) || isPolarisView(url) || isJwmView(url) || isJiraList(url) || isGiphyMedia(url) || isProformaView(url) || isConfluenceWhiteboard(url) || isConfluenceDatabase(url) || isYoutubeVideo(url) || isLoomUrl(url) || isJiraDashboard(url)) {
347
+ if (isJiraRoadmapOrTimeline(url) || isPolarisView(url) || isJwmView(url) || isJiraList(url) || isGiphyMedia(url) || isProformaView(url) || isConfluenceWhiteboard(url) || isConfluenceDatabase(url) || isYoutubeVideo(url) || isLoomUrl(url) || isJiraDashboard(url) || isJiraBacklog(url) || isJiraBoard(url)) {
342
348
  return 'embed';
343
349
  }
344
350
  }
@@ -433,7 +439,7 @@ export var EditorCardProvider = /*#__PURE__*/function () {
433
439
  }, {
434
440
  key: "resolve",
435
441
  value: function () {
436
- var _resolve = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(url, appearance, shouldForceAppearance) {
442
+ var _resolve = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(url, appearance, shouldForceAppearance, isEmbedFriendlyLocation) {
437
443
  var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, isSupported, providerDefaultAppearance, preferredAppearance, canItBeEmbed, datasource, id, parameters;
438
444
  return _regeneratorRuntime.wrap(function _callee10$(_context10) {
439
445
  while (1) switch (_context10.prev = _context10.next) {
@@ -483,7 +489,7 @@ export var EditorCardProvider = /*#__PURE__*/function () {
483
489
  userPreference ||
484
490
  // If user's default choice is "inline" or user hasn't specified preferences at all,
485
491
  // we check whatever one of the hardcoded providers match url (jira /timeline, polaris, etc)
486
- hardCodedAppearance ||
492
+ (isEmbedFriendlyLocation || isEmbedFriendlyLocation === undefined) && hardCodedAppearance ||
487
493
  // If non match, we see if this provider has default appearance for this particular regexp
488
494
  providerDefaultAppearance ||
489
495
  // If not, we pick what editor (or any other client) requested
@@ -536,7 +542,7 @@ export var EditorCardProvider = /*#__PURE__*/function () {
536
542
  }
537
543
  }, _callee10, this, [[0, 35]]);
538
544
  }));
539
- function resolve(_x8, _x9, _x10) {
545
+ function resolve(_x8, _x9, _x10, _x11) {
540
546
  return _resolve.apply(this, arguments);
541
547
  }
542
548
  return resolve;
@@ -36,7 +36,7 @@ export declare class EditorCardProvider implements CardProvider {
36
36
  * Make a /resolve call and find out if result has datasource capability
37
37
  */
38
38
  private getDatasourceFromResolveResponse;
39
- resolve(url: string, appearance: CardAppearance, shouldForceAppearance?: boolean): Promise<CardAdf | DatasourceAdf>;
39
+ resolve(url: string, appearance: CardAppearance, shouldForceAppearance?: boolean, isEmbedFriendlyLocation?: boolean): Promise<CardAdf | DatasourceAdf>;
40
40
  }
41
41
  export declare const editorCardProvider: EditorCardProvider;
42
42
  export type { CardProvider } from './types';
@@ -1,6 +1,6 @@
1
1
  import { type CardAppearance } from '@atlaskit/linking-common';
2
2
  export interface CardProvider {
3
- resolve(url: string, appearance: CardAppearance, shouldForceAppearance?: boolean): Promise<any>;
3
+ resolve(url: string, appearance: CardAppearance, shouldForceAppearance?: boolean, isEmbedFriendlyLocation?: boolean): Promise<any>;
4
4
  }
5
5
  export type ORSCheckResponse = {
6
6
  isSupported: boolean;
@@ -36,7 +36,7 @@ export declare class EditorCardProvider implements CardProvider {
36
36
  * Make a /resolve call and find out if result has datasource capability
37
37
  */
38
38
  private getDatasourceFromResolveResponse;
39
- resolve(url: string, appearance: CardAppearance, shouldForceAppearance?: boolean): Promise<CardAdf | DatasourceAdf>;
39
+ resolve(url: string, appearance: CardAppearance, shouldForceAppearance?: boolean, isEmbedFriendlyLocation?: boolean): Promise<CardAdf | DatasourceAdf>;
40
40
  }
41
41
  export declare const editorCardProvider: EditorCardProvider;
42
42
  export type { CardProvider } from './types';
@@ -1,6 +1,6 @@
1
1
  import { type CardAppearance } from '@atlaskit/linking-common';
2
2
  export interface CardProvider {
3
- resolve(url: string, appearance: CardAppearance, shouldForceAppearance?: boolean): Promise<any>;
3
+ resolve(url: string, appearance: CardAppearance, shouldForceAppearance?: boolean, isEmbedFriendlyLocation?: boolean): Promise<any>;
4
4
  }
5
5
  export type ORSCheckResponse = {
6
6
  isSupported: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-card-provider",
3
- "version": "3.8.2",
3
+ "version": "3.10.0",
4
4
  "description": "Contains the EditorCardProvider, for determining smart card behaviour in the editor.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",