@atlaskit/editor-card-provider 4.2.3 → 4.2.4

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,14 @@
1
1
  # @atlaskit/editor-card-provider
2
2
 
3
+ ## 4.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#141229](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/141229)
8
+ [`9740656964ab1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9740656964ab1) -
9
+ Implement nounData embed preview extractors behind ff: smart_links_noun_support
10
+ - Updated dependencies
11
+
3
12
  ## 4.2.3
4
13
 
5
14
  ### Patch Changes
@@ -420,7 +420,7 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
420
420
  */
421
421
  function () {
422
422
  var _canBeResolvedAsEmbed = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(url) {
423
- var details, data, preview;
423
+ var details, embed, data, preview;
424
424
  return _regenerator.default.wrap(function _callee8$(_context8) {
425
425
  while (1) switch (_context8.prev = _context8.next) {
426
426
  case 0:
@@ -429,30 +429,43 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
429
429
  return this.cardClient.fetchData(url);
430
430
  case 3:
431
431
  details = _context8.sent;
432
- data = details && details.data;
433
- if (data) {
432
+ if (!(0, _platformFeatureFlags.fg)('smart_links_noun_support')) {
433
+ _context8.next = 9;
434
+ break;
435
+ }
436
+ if (details) {
434
437
  _context8.next = 7;
435
438
  break;
436
439
  }
437
440
  return _context8.abrupt("return", false);
438
441
  case 7:
442
+ embed = (0, _linkExtractors.extractSmartLinkEmbed)(details);
443
+ return _context8.abrupt("return", !!embed);
444
+ case 9:
445
+ data = details && details.data;
446
+ if (data) {
447
+ _context8.next = 12;
448
+ break;
449
+ }
450
+ return _context8.abrupt("return", false);
451
+ case 12:
439
452
  if (!((0, _linkingCommon.getStatus)(details) !== 'resolved')) {
440
- _context8.next = 9;
453
+ _context8.next = 14;
441
454
  break;
442
455
  }
443
456
  return _context8.abrupt("return", false);
444
- case 9:
457
+ case 14:
445
458
  preview = (0, _linkExtractors.extractPreview)(data, 'web');
446
459
  return _context8.abrupt("return", !!preview);
447
- case 13:
448
- _context8.prev = 13;
460
+ case 18:
461
+ _context8.prev = 18;
449
462
  _context8.t0 = _context8["catch"](0);
450
463
  return _context8.abrupt("return", false);
451
- case 16:
464
+ case 21:
452
465
  case "end":
453
466
  return _context8.stop();
454
467
  }
455
- }, _callee8, this, [[0, 13]]);
468
+ }, _callee8, this, [[0, 18]]);
456
469
  }));
457
470
  function canBeResolvedAsEmbed(_x6) {
458
471
  return _canBeResolvedAsEmbed.apply(this, arguments);
@@ -1,5 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import { extractPreview } from '@atlaskit/link-extractors';
2
+ import { extractPreview, extractSmartLinkEmbed } from '@atlaskit/link-extractors';
3
3
  import { getStatus } from '@atlaskit/linking-common';
4
4
  import DataLoader from 'dataloader';
5
5
  import { Transformer } from './transformer';
@@ -188,6 +188,15 @@ export class EditorCardProvider {
188
188
  async canBeResolvedAsEmbed(url) {
189
189
  try {
190
190
  const details = await this.cardClient.fetchData(url);
191
+
192
+ // Noun entities supported
193
+ if (fg('smart_links_noun_support')) {
194
+ if (!details) {
195
+ return false;
196
+ }
197
+ const embed = extractSmartLinkEmbed(details);
198
+ return !!embed;
199
+ }
191
200
  const data = details && details.data;
192
201
  if (!data) {
193
202
  return false;
@@ -8,7 +8,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
8
8
  import _setPrototypeOf from "@babel/runtime/helpers/setPrototypeOf";
9
9
  import _regeneratorRuntime from "@babel/runtime/regenerator";
10
10
  function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(e, r) { return new BabelRegExp(e, void 0, r); }; var e = RegExp.prototype, r = new WeakMap(); function BabelRegExp(e, t, p) { var o = RegExp(e, t); return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); } function buildGroups(e, t) { var p = r.get(t); return Object.keys(p).reduce(function (r, t) { var o = p[t]; if ("number" == typeof o) r[t] = e[o];else { for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; r[t] = e[o[i]]; } return r; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { var t = e.exec.call(this, r); if (t) { t.groups = buildGroups(t, this); var p = t.indices; p && (p.groups = buildGroups(p, this)); } return t; }, BabelRegExp.prototype[Symbol.replace] = function (t, p) { if ("string" == typeof p) { var o = r.get(this); return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)(>|$)/g, function (e, r, t) { if ("" === t) return e; var p = o[r]; return Array.isArray(p) ? "$" + p.join("$") : "number" == typeof p ? "$" + p : ""; })); } if ("function" == typeof p) { var i = this; return e[Symbol.replace].call(this, t, function () { var e = arguments; return "object" != _typeof(e[e.length - 1]) && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); }); } return e[Symbol.replace].call(this, t, p); }, _wrapRegExp.apply(this, arguments); }
11
- import { extractPreview } from '@atlaskit/link-extractors';
11
+ import { extractPreview, extractSmartLinkEmbed } from '@atlaskit/link-extractors';
12
12
  import { getStatus } from '@atlaskit/linking-common';
13
13
  import DataLoader from 'dataloader';
14
14
  import { Transformer } from './transformer';
@@ -412,7 +412,7 @@ export var EditorCardProvider = /*#__PURE__*/function () {
412
412
  */
413
413
  function () {
414
414
  var _canBeResolvedAsEmbed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(url) {
415
- var details, data, preview;
415
+ var details, embed, data, preview;
416
416
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
417
417
  while (1) switch (_context8.prev = _context8.next) {
418
418
  case 0:
@@ -421,30 +421,43 @@ export var EditorCardProvider = /*#__PURE__*/function () {
421
421
  return this.cardClient.fetchData(url);
422
422
  case 3:
423
423
  details = _context8.sent;
424
- data = details && details.data;
425
- if (data) {
424
+ if (!fg('smart_links_noun_support')) {
425
+ _context8.next = 9;
426
+ break;
427
+ }
428
+ if (details) {
426
429
  _context8.next = 7;
427
430
  break;
428
431
  }
429
432
  return _context8.abrupt("return", false);
430
433
  case 7:
434
+ embed = extractSmartLinkEmbed(details);
435
+ return _context8.abrupt("return", !!embed);
436
+ case 9:
437
+ data = details && details.data;
438
+ if (data) {
439
+ _context8.next = 12;
440
+ break;
441
+ }
442
+ return _context8.abrupt("return", false);
443
+ case 12:
431
444
  if (!(getStatus(details) !== 'resolved')) {
432
- _context8.next = 9;
445
+ _context8.next = 14;
433
446
  break;
434
447
  }
435
448
  return _context8.abrupt("return", false);
436
- case 9:
449
+ case 14:
437
450
  preview = extractPreview(data, 'web');
438
451
  return _context8.abrupt("return", !!preview);
439
- case 13:
440
- _context8.prev = 13;
452
+ case 18:
453
+ _context8.prev = 18;
441
454
  _context8.t0 = _context8["catch"](0);
442
455
  return _context8.abrupt("return", false);
443
- case 16:
456
+ case 21:
444
457
  case "end":
445
458
  return _context8.stop();
446
459
  }
447
- }, _callee8, this, [[0, 13]]);
460
+ }, _callee8, this, [[0, 18]]);
448
461
  }));
449
462
  function canBeResolvedAsEmbed(_x6) {
450
463
  return _canBeResolvedAsEmbed.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-card-provider",
3
- "version": "4.2.3",
3
+ "version": "4.2.4",
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",
@@ -35,19 +35,21 @@
35
35
  "dependencies": {
36
36
  "@atlaskit/eslint-plugin-platform": "^2.5.0",
37
37
  "@atlaskit/feature-gate-js-client": "^5.0.0",
38
- "@atlaskit/json-ld-types": "^1.0.0",
38
+ "@atlaskit/json-ld-types": "^1.1.0",
39
39
  "@atlaskit/link-client-extension": "^4.0.0",
40
- "@atlaskit/link-extractors": "^2.0.0",
40
+ "@atlaskit/link-extractors": "^2.1.0",
41
41
  "@atlaskit/linking-common": "^8.0.0",
42
+ "@atlaskit/linking-types": "^9.8.0",
42
43
  "@atlaskit/platform-feature-flags": "^1.1.0",
43
44
  "@babel/runtime": "^7.0.0",
44
45
  "dataloader": "^2.1.0"
45
46
  },
46
47
  "peerDependencies": {
47
- "@atlaskit/link-provider": "^2.0.0",
48
+ "@atlaskit/link-provider": "^2.1.0",
48
49
  "react": "^18.2.0"
49
50
  },
50
51
  "devDependencies": {
52
+ "@atlassian/feature-flags-test-utils": "^0.3.0",
51
53
  "typescript": "~5.4.2"
52
54
  },
53
55
  "platform-feature-flags": {
@@ -62,6 +64,9 @@
62
64
  },
63
65
  "plan_smart_link_base_url": {
64
66
  "type": "boolean"
67
+ },
68
+ "smart_links_noun_support": {
69
+ "type": "boolean"
65
70
  }
66
71
  }
67
72
  }