@atlaskit/editor-card-provider 5.1.2 → 5.2.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 +19 -0
- package/dist/cjs/provider.js +166 -62
- package/dist/es2019/provider.js +52 -5
- package/dist/esm/provider.js +166 -62
- package/dist/types/provider.d.ts +10 -2
- package/dist/types-ts4.5/provider.d.ts +10 -2
- package/package.json +11 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-card-provider
|
|
2
2
|
|
|
3
|
+
## 5.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#191942](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/191942)
|
|
8
|
+
[`6b5ec599e6dfd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6b5ec599e6dfd) -
|
|
9
|
+
[https://product-fabric.atlassian.net/browse/ED-28596](ED-28596) - extend EditorCardProvider from
|
|
10
|
+
NodeDataProvider
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 5.1.3
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 5.1.2
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/cjs/provider.js
CHANGED
|
@@ -11,10 +11,14 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
11
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
14
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
17
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
16
18
|
var _setPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/setPrototypeOf"));
|
|
17
19
|
var _linkExtractors = require("@atlaskit/link-extractors");
|
|
20
|
+
var _nodeDataProvider = require("@atlaskit/node-data-provider");
|
|
21
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
18
22
|
var _linkingCommon = require("@atlaskit/linking-common");
|
|
19
23
|
var _dataloader = _interopRequireDefault(require("dataloader"));
|
|
20
24
|
var _transformer = require("./transformer");
|
|
@@ -23,6 +27,8 @@ var _linkProvider = require("@atlaskit/link-provider");
|
|
|
23
27
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
24
28
|
var api = _interopRequireWildcard(require("./api"));
|
|
25
29
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
30
|
+
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
31
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
26
32
|
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)), (0, _setPrototypeOf2.default)(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 (0, _inherits2.default)(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); }
|
|
27
33
|
var BATCH_WAIT_TIME = 50;
|
|
28
34
|
|
|
@@ -108,37 +114,63 @@ var isJiraIssueNavigator = function isJiraIssueNavigator(url) {
|
|
|
108
114
|
var isJiraWorkItem = exports.isJiraWorkItem = function isJiraWorkItem(url) {
|
|
109
115
|
return /\/browse\/((?:\w+)-(?:\d+))/i.test(url);
|
|
110
116
|
};
|
|
111
|
-
var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
117
|
+
var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
112
118
|
function EditorCardProvider(envKey, baseUrlOverride, product, onResolve) {
|
|
113
|
-
var _this
|
|
119
|
+
var _this;
|
|
114
120
|
(0, _classCallCheck2.default)(this, EditorCardProvider);
|
|
115
|
-
|
|
121
|
+
_this = _callSuper(this, EditorCardProvider);
|
|
122
|
+
(0, _defineProperty2.default)(_this, "getExperimentValue", function (experimentName, parameterName, defaultValue) {
|
|
116
123
|
try {
|
|
117
124
|
return _featureGateJsClient.default.getExperimentValue(experimentName, parameterName, defaultValue);
|
|
118
125
|
} catch (_unused) {
|
|
119
126
|
return defaultValue;
|
|
120
127
|
}
|
|
121
128
|
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
129
|
+
_this.name = 'editorCardProvider';
|
|
130
|
+
_this.baseUrl = baseUrlOverride || (0, _linkingCommon.getBaseUrl)(envKey);
|
|
131
|
+
_this.resolverUrl = (0, _linkingCommon.getResolverUrl)(envKey, baseUrlOverride);
|
|
132
|
+
_this.transformer = new _transformer.Transformer();
|
|
133
|
+
_this.onResolve = onResolve;
|
|
134
|
+
_this.requestHeaders = {
|
|
135
|
+
Origin: _this.baseUrl
|
|
128
136
|
};
|
|
129
|
-
|
|
137
|
+
_this.providersLoader = new _dataloader.default(function (keys) {
|
|
130
138
|
return _this.batchProviders(keys);
|
|
131
139
|
}, {
|
|
132
140
|
batchScheduleFn: function batchScheduleFn(callback) {
|
|
133
141
|
return setTimeout(callback, BATCH_WAIT_TIME);
|
|
134
142
|
}
|
|
135
143
|
});
|
|
136
|
-
|
|
144
|
+
_this.cardClient = new _linkProvider.CardClient(envKey, baseUrlOverride);
|
|
137
145
|
if (product) {
|
|
138
|
-
|
|
146
|
+
_this.cardClient.setProduct(product);
|
|
139
147
|
}
|
|
148
|
+
return _this;
|
|
140
149
|
}
|
|
150
|
+
(0, _inherits2.default)(EditorCardProvider, _ref);
|
|
141
151
|
return (0, _createClass2.default)(EditorCardProvider, [{
|
|
152
|
+
key: "nodeDataKey",
|
|
153
|
+
value: function nodeDataKey(node) {
|
|
154
|
+
// We can use URL as a key here, because CardClient returns the same data for the same URL
|
|
155
|
+
// regardless of the type of card (inline, block, embed).
|
|
156
|
+
return node.attrs.url;
|
|
157
|
+
}
|
|
158
|
+
}, {
|
|
159
|
+
key: "fetchNodesData",
|
|
160
|
+
value: function fetchNodesData(nodes) {
|
|
161
|
+
var _this2 = this;
|
|
162
|
+
var promises = nodes.map(function (node) {
|
|
163
|
+
var url = node.attrs.url;
|
|
164
|
+
return _this2.cardClient.fetchData(url);
|
|
165
|
+
});
|
|
166
|
+
return Promise.all(promises);
|
|
167
|
+
}
|
|
168
|
+
}, {
|
|
169
|
+
key: "isNodeSupported",
|
|
170
|
+
value: function isNodeSupported(node) {
|
|
171
|
+
return ['inlineCard', 'blockCard', 'embedCard'].includes(node.type) && !!node.attrs && 'url' in node.attrs && typeof node.attrs.url === 'string';
|
|
172
|
+
}
|
|
173
|
+
}, {
|
|
142
174
|
key: "batchProviders",
|
|
143
175
|
value: function () {
|
|
144
176
|
var _batchProviders = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(keys) {
|
|
@@ -173,27 +205,45 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
173
205
|
while (1) switch (_context2.prev = _context2.next) {
|
|
174
206
|
case 0:
|
|
175
207
|
_context2.prev = 0;
|
|
176
|
-
|
|
208
|
+
if (!(0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
209
|
+
_context2.next = 7;
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
_context2.next = 4;
|
|
213
|
+
return this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
214
|
+
type: 'inlineCard',
|
|
215
|
+
attrs: {
|
|
216
|
+
url: resourceUrl
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
case 4:
|
|
220
|
+
_context2.t0 = _context2.sent;
|
|
221
|
+
_context2.next = 10;
|
|
222
|
+
break;
|
|
223
|
+
case 7:
|
|
224
|
+
_context2.next = 9;
|
|
177
225
|
return this.cardClient.fetchData(resourceUrl);
|
|
178
|
-
case
|
|
179
|
-
|
|
226
|
+
case 9:
|
|
227
|
+
_context2.t0 = _context2.sent;
|
|
228
|
+
case 10:
|
|
229
|
+
response = _context2.t0;
|
|
180
230
|
if (!((0, _linkingCommon.getStatus)(response) !== 'not_found')) {
|
|
181
|
-
_context2.next =
|
|
231
|
+
_context2.next = 13;
|
|
182
232
|
break;
|
|
183
233
|
}
|
|
184
234
|
return _context2.abrupt("return", true);
|
|
185
|
-
case
|
|
186
|
-
_context2.next =
|
|
235
|
+
case 13:
|
|
236
|
+
_context2.next = 18;
|
|
187
237
|
break;
|
|
188
|
-
case
|
|
189
|
-
_context2.prev =
|
|
190
|
-
_context2.
|
|
238
|
+
case 15:
|
|
239
|
+
_context2.prev = 15;
|
|
240
|
+
_context2.t1 = _context2["catch"](0);
|
|
191
241
|
return _context2.abrupt("return", false);
|
|
192
|
-
case
|
|
242
|
+
case 18:
|
|
193
243
|
case "end":
|
|
194
244
|
return _context2.stop();
|
|
195
245
|
}
|
|
196
|
-
}, _callee2, this, [[0,
|
|
246
|
+
}, _callee2, this, [[0, 15]]);
|
|
197
247
|
}));
|
|
198
248
|
function checkLinkResolved(_x2) {
|
|
199
249
|
return _checkLinkResolved.apply(this, arguments);
|
|
@@ -209,27 +259,45 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
209
259
|
while (1) switch (_context3.prev = _context3.next) {
|
|
210
260
|
case 0:
|
|
211
261
|
_context3.prev = 0;
|
|
212
|
-
|
|
262
|
+
if (!(0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
263
|
+
_context3.next = 7;
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
_context3.next = 4;
|
|
267
|
+
return this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
268
|
+
type: 'inlineCard',
|
|
269
|
+
attrs: {
|
|
270
|
+
url: resourceUrl
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
case 4:
|
|
274
|
+
_context3.t0 = _context3.sent;
|
|
275
|
+
_context3.next = 10;
|
|
276
|
+
break;
|
|
277
|
+
case 7:
|
|
278
|
+
_context3.next = 9;
|
|
213
279
|
return this.cardClient.fetchData(resourceUrl);
|
|
214
|
-
case
|
|
215
|
-
|
|
280
|
+
case 9:
|
|
281
|
+
_context3.t0 = _context3.sent;
|
|
282
|
+
case 10:
|
|
283
|
+
response = _context3.t0;
|
|
216
284
|
if (!((0, _linkingCommon.getStatus)(response) !== 'not_found')) {
|
|
217
|
-
_context3.next =
|
|
285
|
+
_context3.next = 13;
|
|
218
286
|
break;
|
|
219
287
|
}
|
|
220
288
|
return _context3.abrupt("return", response);
|
|
221
|
-
case
|
|
222
|
-
_context3.next =
|
|
289
|
+
case 13:
|
|
290
|
+
_context3.next = 18;
|
|
223
291
|
break;
|
|
224
|
-
case
|
|
225
|
-
_context3.prev =
|
|
226
|
-
_context3.
|
|
292
|
+
case 15:
|
|
293
|
+
_context3.prev = 15;
|
|
294
|
+
_context3.t1 = _context3["catch"](0);
|
|
227
295
|
return _context3.abrupt("return", undefined);
|
|
228
|
-
case
|
|
296
|
+
case 18:
|
|
229
297
|
case "end":
|
|
230
298
|
return _context3.stop();
|
|
231
299
|
}
|
|
232
|
-
}, _callee3, this, [[0,
|
|
300
|
+
}, _callee3, this, [[0, 15]]);
|
|
233
301
|
}));
|
|
234
302
|
function fetchDataForResource(_x3) {
|
|
235
303
|
return _fetchDataForResource.apply(this, arguments);
|
|
@@ -353,7 +421,7 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
353
421
|
value: function () {
|
|
354
422
|
var _findUserPreference = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(url) {
|
|
355
423
|
var _this$providersData,
|
|
356
|
-
|
|
424
|
+
_this3 = this;
|
|
357
425
|
var userPreferences, defaultAppearance, appearances, allMatchedLabeledAppearances, longestMatchedLabeledAppearance;
|
|
358
426
|
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
359
427
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -371,9 +439,9 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
371
439
|
break;
|
|
372
440
|
}
|
|
373
441
|
defaultAppearance = userPreferences.defaultAppearance, appearances = userPreferences.appearances;
|
|
374
|
-
allMatchedLabeledAppearances = appearances.filter(function (
|
|
375
|
-
var urlSegment =
|
|
376
|
-
return
|
|
442
|
+
allMatchedLabeledAppearances = appearances.filter(function (_ref2) {
|
|
443
|
+
var urlSegment = _ref2.urlSegment;
|
|
444
|
+
return _this3.doesUrlMatchPath(urlSegment, url);
|
|
377
445
|
});
|
|
378
446
|
if (!(allMatchedLabeledAppearances.length > 0)) {
|
|
379
447
|
_context7.next = 10;
|
|
@@ -476,33 +544,51 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
476
544
|
while (1) switch (_context9.prev = _context9.next) {
|
|
477
545
|
case 0:
|
|
478
546
|
_context9.prev = 0;
|
|
479
|
-
|
|
547
|
+
if (!(0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
548
|
+
_context9.next = 7;
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
_context9.next = 4;
|
|
552
|
+
return this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
553
|
+
type: 'inlineCard',
|
|
554
|
+
attrs: {
|
|
555
|
+
url: url
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
case 4:
|
|
559
|
+
_context9.t0 = _context9.sent;
|
|
560
|
+
_context9.next = 10;
|
|
561
|
+
break;
|
|
562
|
+
case 7:
|
|
563
|
+
_context9.next = 9;
|
|
480
564
|
return this.cardClient.fetchData(url);
|
|
481
|
-
case
|
|
482
|
-
|
|
565
|
+
case 9:
|
|
566
|
+
_context9.t0 = _context9.sent;
|
|
567
|
+
case 10:
|
|
568
|
+
details = _context9.t0;
|
|
483
569
|
if (details) {
|
|
484
|
-
_context9.next =
|
|
570
|
+
_context9.next = 13;
|
|
485
571
|
break;
|
|
486
572
|
}
|
|
487
573
|
return _context9.abrupt("return", false);
|
|
488
|
-
case
|
|
574
|
+
case 13:
|
|
489
575
|
if (!((0, _linkingCommon.getStatus)(details) !== 'resolved')) {
|
|
490
|
-
_context9.next =
|
|
576
|
+
_context9.next = 15;
|
|
491
577
|
break;
|
|
492
578
|
}
|
|
493
579
|
return _context9.abrupt("return", false);
|
|
494
|
-
case
|
|
580
|
+
case 15:
|
|
495
581
|
embed = (0, _linkExtractors.extractSmartLinkEmbed)(details);
|
|
496
582
|
return _context9.abrupt("return", !!embed);
|
|
497
|
-
case
|
|
498
|
-
_context9.prev =
|
|
499
|
-
_context9.
|
|
583
|
+
case 19:
|
|
584
|
+
_context9.prev = 19;
|
|
585
|
+
_context9.t1 = _context9["catch"](0);
|
|
500
586
|
return _context9.abrupt("return", false);
|
|
501
|
-
case
|
|
587
|
+
case 22:
|
|
502
588
|
case "end":
|
|
503
589
|
return _context9.stop();
|
|
504
590
|
}
|
|
505
|
-
}, _callee9, this, [[0,
|
|
591
|
+
}, _callee9, this, [[0, 19]]);
|
|
506
592
|
}));
|
|
507
593
|
function canBeResolvedAsEmbed(_x7) {
|
|
508
594
|
return _canBeResolvedAsEmbed.apply(this, arguments);
|
|
@@ -522,28 +608,46 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
522
608
|
while (1) switch (_context0.prev = _context0.next) {
|
|
523
609
|
case 0:
|
|
524
610
|
_context0.prev = 0;
|
|
525
|
-
|
|
611
|
+
if (!(0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
612
|
+
_context0.next = 7;
|
|
613
|
+
break;
|
|
614
|
+
}
|
|
615
|
+
_context0.next = 4;
|
|
616
|
+
return this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
617
|
+
type: 'inlineCard',
|
|
618
|
+
attrs: {
|
|
619
|
+
url: url
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
case 4:
|
|
623
|
+
_context0.t0 = _context0.sent;
|
|
624
|
+
_context0.next = 10;
|
|
625
|
+
break;
|
|
626
|
+
case 7:
|
|
627
|
+
_context0.next = 9;
|
|
526
628
|
return this.cardClient.fetchData(url);
|
|
527
|
-
case
|
|
528
|
-
|
|
629
|
+
case 9:
|
|
630
|
+
_context0.t0 = _context0.sent;
|
|
631
|
+
case 10:
|
|
632
|
+
response = _context0.t0;
|
|
529
633
|
datasources = response && response.datasources || [];
|
|
530
634
|
if (!(datasources.length > 0)) {
|
|
531
|
-
_context0.next =
|
|
635
|
+
_context0.next = 14;
|
|
532
636
|
break;
|
|
533
637
|
}
|
|
534
638
|
return _context0.abrupt("return", datasources[0]);
|
|
535
|
-
case
|
|
536
|
-
_context0.next =
|
|
639
|
+
case 14:
|
|
640
|
+
_context0.next = 19;
|
|
537
641
|
break;
|
|
538
|
-
case
|
|
539
|
-
_context0.prev =
|
|
540
|
-
_context0.
|
|
642
|
+
case 16:
|
|
643
|
+
_context0.prev = 16;
|
|
644
|
+
_context0.t1 = _context0["catch"](0);
|
|
541
645
|
return _context0.abrupt("return", undefined);
|
|
542
|
-
case
|
|
646
|
+
case 19:
|
|
543
647
|
case "end":
|
|
544
648
|
return _context0.stop();
|
|
545
649
|
}
|
|
546
|
-
}, _callee0, this, [[0,
|
|
650
|
+
}, _callee0, this, [[0, 16]]);
|
|
547
651
|
}));
|
|
548
652
|
function getDatasourceFromResolveResponse(_x8) {
|
|
549
653
|
return _getDatasourceFromResolveResponse.apply(this, arguments);
|
|
@@ -690,5 +794,5 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function () {
|
|
|
690
794
|
return resolve;
|
|
691
795
|
}()
|
|
692
796
|
}]);
|
|
693
|
-
}();
|
|
797
|
+
}(_nodeDataProvider.NodeDataProvider);
|
|
694
798
|
var editorCardProvider = exports.editorCardProvider = new EditorCardProvider();
|
package/dist/es2019/provider.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { extractSmartLinkEmbed } from '@atlaskit/link-extractors';
|
|
3
|
+
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
4
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
5
|
import { getStatus } from '@atlaskit/linking-common';
|
|
4
6
|
import DataLoader from 'dataloader';
|
|
5
7
|
import { Transformer } from './transformer';
|
|
@@ -52,8 +54,9 @@ const isCustomer360LandingPage = url => url.match(/^https:\/\/customer\.atlassia
|
|
|
52
54
|
const isConfluenceTeamCalendars = url => url.match(/\/wiki\/spaces\/(?<resourceContext>[^\/]+)\/calendars\/(?<resourceId>[a-zA-Z0-9-]+)/);
|
|
53
55
|
const isJiraIssueNavigator = url => url.match(/^https:\/\/.*?\/jira\/software|core\/(c\/)?projects\/[^\/]+?\/issues\/?/);
|
|
54
56
|
export const isJiraWorkItem = url => /\/browse\/((?:\w+)-(?:\d+))/i.test(url);
|
|
55
|
-
export class EditorCardProvider {
|
|
57
|
+
export class EditorCardProvider extends NodeDataProvider {
|
|
56
58
|
constructor(envKey, baseUrlOverride, product, onResolve) {
|
|
59
|
+
super();
|
|
57
60
|
_defineProperty(this, "getExperimentValue", (experimentName, parameterName, defaultValue) => {
|
|
58
61
|
try {
|
|
59
62
|
return FeatureGates.getExperimentValue(experimentName, parameterName, defaultValue);
|
|
@@ -61,6 +64,7 @@ export class EditorCardProvider {
|
|
|
61
64
|
return defaultValue;
|
|
62
65
|
}
|
|
63
66
|
});
|
|
67
|
+
this.name = 'editorCardProvider';
|
|
64
68
|
this.baseUrl = baseUrlOverride || getBaseUrl(envKey);
|
|
65
69
|
this.resolverUrl = getResolverUrl(envKey, baseUrlOverride);
|
|
66
70
|
this.transformer = new Transformer();
|
|
@@ -76,6 +80,21 @@ export class EditorCardProvider {
|
|
|
76
80
|
this.cardClient.setProduct(product);
|
|
77
81
|
}
|
|
78
82
|
}
|
|
83
|
+
nodeDataKey(node) {
|
|
84
|
+
// We can use URL as a key here, because CardClient returns the same data for the same URL
|
|
85
|
+
// regardless of the type of card (inline, block, embed).
|
|
86
|
+
return node.attrs.url;
|
|
87
|
+
}
|
|
88
|
+
fetchNodesData(nodes) {
|
|
89
|
+
const promises = nodes.map(node => {
|
|
90
|
+
const url = node.attrs.url;
|
|
91
|
+
return this.cardClient.fetchData(url);
|
|
92
|
+
});
|
|
93
|
+
return Promise.all(promises);
|
|
94
|
+
}
|
|
95
|
+
isNodeSupported(node) {
|
|
96
|
+
return ['inlineCard', 'blockCard', 'embedCard'].includes(node.type) && !!node.attrs && 'url' in node.attrs && typeof node.attrs.url === 'string';
|
|
97
|
+
}
|
|
79
98
|
async batchProviders(keys) {
|
|
80
99
|
// EDM-2205: Batch requests in the case that user paste multiple links at
|
|
81
100
|
// once. This is so that only one /providersData is being called.
|
|
@@ -84,7 +103,14 @@ export class EditorCardProvider {
|
|
|
84
103
|
}
|
|
85
104
|
async checkLinkResolved(resourceUrl) {
|
|
86
105
|
try {
|
|
87
|
-
const response =
|
|
106
|
+
const response = expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) ?
|
|
107
|
+
// It's ok to cast any resourceUrl to inlineCard here, because only URL is important for the request.
|
|
108
|
+
await this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
109
|
+
type: 'inlineCard',
|
|
110
|
+
attrs: {
|
|
111
|
+
url: resourceUrl
|
|
112
|
+
}
|
|
113
|
+
}) : await this.cardClient.fetchData(resourceUrl);
|
|
88
114
|
if (getStatus(response) !== 'not_found') {
|
|
89
115
|
return true;
|
|
90
116
|
}
|
|
@@ -94,7 +120,14 @@ export class EditorCardProvider {
|
|
|
94
120
|
}
|
|
95
121
|
async fetchDataForResource(resourceUrl) {
|
|
96
122
|
try {
|
|
97
|
-
const response =
|
|
123
|
+
const response = expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) ?
|
|
124
|
+
// It's ok to cast any resourceUrl to inlineCard here, because only URL is important for the request.
|
|
125
|
+
await this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
126
|
+
type: 'inlineCard',
|
|
127
|
+
attrs: {
|
|
128
|
+
url: resourceUrl
|
|
129
|
+
}
|
|
130
|
+
}) : await this.cardClient.fetchData(resourceUrl);
|
|
98
131
|
if (getStatus(response) !== 'not_found') {
|
|
99
132
|
return response;
|
|
100
133
|
}
|
|
@@ -207,7 +240,14 @@ export class EditorCardProvider {
|
|
|
207
240
|
*/
|
|
208
241
|
async canBeResolvedAsEmbed(url) {
|
|
209
242
|
try {
|
|
210
|
-
const details =
|
|
243
|
+
const details = expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) ?
|
|
244
|
+
// It's ok to cast any resourceUrl to inlineCard here, because only URL is important for the request.
|
|
245
|
+
await this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
246
|
+
type: 'inlineCard',
|
|
247
|
+
attrs: {
|
|
248
|
+
url
|
|
249
|
+
}
|
|
250
|
+
}) : await this.cardClient.fetchData(url);
|
|
211
251
|
if (!details) {
|
|
212
252
|
return false;
|
|
213
253
|
}
|
|
@@ -231,7 +271,14 @@ export class EditorCardProvider {
|
|
|
231
271
|
*/
|
|
232
272
|
async getDatasourceFromResolveResponse(url) {
|
|
233
273
|
try {
|
|
234
|
-
const response =
|
|
274
|
+
const response = expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) ?
|
|
275
|
+
// It's ok to cast any resourceUrl to inlineCard here, because only URL is important for the request.
|
|
276
|
+
await this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
277
|
+
type: 'inlineCard',
|
|
278
|
+
attrs: {
|
|
279
|
+
url
|
|
280
|
+
}
|
|
281
|
+
}) : await this.cardClient.fetchData(url);
|
|
235
282
|
const datasources = response && response.datasources || [];
|
|
236
283
|
if (datasources.length > 0) {
|
|
237
284
|
// For now we only have one datasource expected even though it is in an array.
|
package/dist/esm/provider.js
CHANGED
|
@@ -3,12 +3,18 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
4
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
5
5
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
6
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
9
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
10
|
import _setPrototypeOf from "@babel/runtime/helpers/setPrototypeOf";
|
|
9
11
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
12
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
13
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
10
14
|
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
15
|
import { extractSmartLinkEmbed } from '@atlaskit/link-extractors';
|
|
16
|
+
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
17
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
18
|
import { getStatus } from '@atlaskit/linking-common';
|
|
13
19
|
import DataLoader from 'dataloader';
|
|
14
20
|
import { Transformer } from './transformer';
|
|
@@ -101,37 +107,63 @@ var isJiraIssueNavigator = function isJiraIssueNavigator(url) {
|
|
|
101
107
|
export var isJiraWorkItem = function isJiraWorkItem(url) {
|
|
102
108
|
return /\/browse\/((?:\w+)-(?:\d+))/i.test(url);
|
|
103
109
|
};
|
|
104
|
-
export var EditorCardProvider = /*#__PURE__*/function () {
|
|
110
|
+
export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
105
111
|
function EditorCardProvider(envKey, baseUrlOverride, product, onResolve) {
|
|
106
|
-
var _this
|
|
112
|
+
var _this;
|
|
107
113
|
_classCallCheck(this, EditorCardProvider);
|
|
108
|
-
|
|
114
|
+
_this = _callSuper(this, EditorCardProvider);
|
|
115
|
+
_defineProperty(_this, "getExperimentValue", function (experimentName, parameterName, defaultValue) {
|
|
109
116
|
try {
|
|
110
117
|
return FeatureGates.getExperimentValue(experimentName, parameterName, defaultValue);
|
|
111
118
|
} catch (_unused) {
|
|
112
119
|
return defaultValue;
|
|
113
120
|
}
|
|
114
121
|
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
_this.name = 'editorCardProvider';
|
|
123
|
+
_this.baseUrl = baseUrlOverride || getBaseUrl(envKey);
|
|
124
|
+
_this.resolverUrl = getResolverUrl(envKey, baseUrlOverride);
|
|
125
|
+
_this.transformer = new Transformer();
|
|
126
|
+
_this.onResolve = onResolve;
|
|
127
|
+
_this.requestHeaders = {
|
|
128
|
+
Origin: _this.baseUrl
|
|
121
129
|
};
|
|
122
|
-
|
|
130
|
+
_this.providersLoader = new DataLoader(function (keys) {
|
|
123
131
|
return _this.batchProviders(keys);
|
|
124
132
|
}, {
|
|
125
133
|
batchScheduleFn: function batchScheduleFn(callback) {
|
|
126
134
|
return setTimeout(callback, BATCH_WAIT_TIME);
|
|
127
135
|
}
|
|
128
136
|
});
|
|
129
|
-
|
|
137
|
+
_this.cardClient = new CardClient(envKey, baseUrlOverride);
|
|
130
138
|
if (product) {
|
|
131
|
-
|
|
139
|
+
_this.cardClient.setProduct(product);
|
|
132
140
|
}
|
|
141
|
+
return _this;
|
|
133
142
|
}
|
|
143
|
+
_inherits(EditorCardProvider, _ref);
|
|
134
144
|
return _createClass(EditorCardProvider, [{
|
|
145
|
+
key: "nodeDataKey",
|
|
146
|
+
value: function nodeDataKey(node) {
|
|
147
|
+
// We can use URL as a key here, because CardClient returns the same data for the same URL
|
|
148
|
+
// regardless of the type of card (inline, block, embed).
|
|
149
|
+
return node.attrs.url;
|
|
150
|
+
}
|
|
151
|
+
}, {
|
|
152
|
+
key: "fetchNodesData",
|
|
153
|
+
value: function fetchNodesData(nodes) {
|
|
154
|
+
var _this2 = this;
|
|
155
|
+
var promises = nodes.map(function (node) {
|
|
156
|
+
var url = node.attrs.url;
|
|
157
|
+
return _this2.cardClient.fetchData(url);
|
|
158
|
+
});
|
|
159
|
+
return Promise.all(promises);
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
key: "isNodeSupported",
|
|
163
|
+
value: function isNodeSupported(node) {
|
|
164
|
+
return ['inlineCard', 'blockCard', 'embedCard'].includes(node.type) && !!node.attrs && 'url' in node.attrs && typeof node.attrs.url === 'string';
|
|
165
|
+
}
|
|
166
|
+
}, {
|
|
135
167
|
key: "batchProviders",
|
|
136
168
|
value: function () {
|
|
137
169
|
var _batchProviders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(keys) {
|
|
@@ -166,27 +198,45 @@ export var EditorCardProvider = /*#__PURE__*/function () {
|
|
|
166
198
|
while (1) switch (_context2.prev = _context2.next) {
|
|
167
199
|
case 0:
|
|
168
200
|
_context2.prev = 0;
|
|
169
|
-
|
|
201
|
+
if (!expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
202
|
+
_context2.next = 7;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
_context2.next = 4;
|
|
206
|
+
return this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
207
|
+
type: 'inlineCard',
|
|
208
|
+
attrs: {
|
|
209
|
+
url: resourceUrl
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
case 4:
|
|
213
|
+
_context2.t0 = _context2.sent;
|
|
214
|
+
_context2.next = 10;
|
|
215
|
+
break;
|
|
216
|
+
case 7:
|
|
217
|
+
_context2.next = 9;
|
|
170
218
|
return this.cardClient.fetchData(resourceUrl);
|
|
171
|
-
case
|
|
172
|
-
|
|
219
|
+
case 9:
|
|
220
|
+
_context2.t0 = _context2.sent;
|
|
221
|
+
case 10:
|
|
222
|
+
response = _context2.t0;
|
|
173
223
|
if (!(getStatus(response) !== 'not_found')) {
|
|
174
|
-
_context2.next =
|
|
224
|
+
_context2.next = 13;
|
|
175
225
|
break;
|
|
176
226
|
}
|
|
177
227
|
return _context2.abrupt("return", true);
|
|
178
|
-
case
|
|
179
|
-
_context2.next =
|
|
228
|
+
case 13:
|
|
229
|
+
_context2.next = 18;
|
|
180
230
|
break;
|
|
181
|
-
case
|
|
182
|
-
_context2.prev =
|
|
183
|
-
_context2.
|
|
231
|
+
case 15:
|
|
232
|
+
_context2.prev = 15;
|
|
233
|
+
_context2.t1 = _context2["catch"](0);
|
|
184
234
|
return _context2.abrupt("return", false);
|
|
185
|
-
case
|
|
235
|
+
case 18:
|
|
186
236
|
case "end":
|
|
187
237
|
return _context2.stop();
|
|
188
238
|
}
|
|
189
|
-
}, _callee2, this, [[0,
|
|
239
|
+
}, _callee2, this, [[0, 15]]);
|
|
190
240
|
}));
|
|
191
241
|
function checkLinkResolved(_x2) {
|
|
192
242
|
return _checkLinkResolved.apply(this, arguments);
|
|
@@ -202,27 +252,45 @@ export var EditorCardProvider = /*#__PURE__*/function () {
|
|
|
202
252
|
while (1) switch (_context3.prev = _context3.next) {
|
|
203
253
|
case 0:
|
|
204
254
|
_context3.prev = 0;
|
|
205
|
-
|
|
255
|
+
if (!expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
256
|
+
_context3.next = 7;
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
_context3.next = 4;
|
|
260
|
+
return this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
261
|
+
type: 'inlineCard',
|
|
262
|
+
attrs: {
|
|
263
|
+
url: resourceUrl
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
case 4:
|
|
267
|
+
_context3.t0 = _context3.sent;
|
|
268
|
+
_context3.next = 10;
|
|
269
|
+
break;
|
|
270
|
+
case 7:
|
|
271
|
+
_context3.next = 9;
|
|
206
272
|
return this.cardClient.fetchData(resourceUrl);
|
|
207
|
-
case
|
|
208
|
-
|
|
273
|
+
case 9:
|
|
274
|
+
_context3.t0 = _context3.sent;
|
|
275
|
+
case 10:
|
|
276
|
+
response = _context3.t0;
|
|
209
277
|
if (!(getStatus(response) !== 'not_found')) {
|
|
210
|
-
_context3.next =
|
|
278
|
+
_context3.next = 13;
|
|
211
279
|
break;
|
|
212
280
|
}
|
|
213
281
|
return _context3.abrupt("return", response);
|
|
214
|
-
case
|
|
215
|
-
_context3.next =
|
|
282
|
+
case 13:
|
|
283
|
+
_context3.next = 18;
|
|
216
284
|
break;
|
|
217
|
-
case
|
|
218
|
-
_context3.prev =
|
|
219
|
-
_context3.
|
|
285
|
+
case 15:
|
|
286
|
+
_context3.prev = 15;
|
|
287
|
+
_context3.t1 = _context3["catch"](0);
|
|
220
288
|
return _context3.abrupt("return", undefined);
|
|
221
|
-
case
|
|
289
|
+
case 18:
|
|
222
290
|
case "end":
|
|
223
291
|
return _context3.stop();
|
|
224
292
|
}
|
|
225
|
-
}, _callee3, this, [[0,
|
|
293
|
+
}, _callee3, this, [[0, 15]]);
|
|
226
294
|
}));
|
|
227
295
|
function fetchDataForResource(_x3) {
|
|
228
296
|
return _fetchDataForResource.apply(this, arguments);
|
|
@@ -346,7 +414,7 @@ export var EditorCardProvider = /*#__PURE__*/function () {
|
|
|
346
414
|
value: function () {
|
|
347
415
|
var _findUserPreference = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(url) {
|
|
348
416
|
var _this$providersData,
|
|
349
|
-
|
|
417
|
+
_this3 = this;
|
|
350
418
|
var userPreferences, defaultAppearance, appearances, allMatchedLabeledAppearances, longestMatchedLabeledAppearance;
|
|
351
419
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
352
420
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -364,9 +432,9 @@ export var EditorCardProvider = /*#__PURE__*/function () {
|
|
|
364
432
|
break;
|
|
365
433
|
}
|
|
366
434
|
defaultAppearance = userPreferences.defaultAppearance, appearances = userPreferences.appearances;
|
|
367
|
-
allMatchedLabeledAppearances = appearances.filter(function (
|
|
368
|
-
var urlSegment =
|
|
369
|
-
return
|
|
435
|
+
allMatchedLabeledAppearances = appearances.filter(function (_ref2) {
|
|
436
|
+
var urlSegment = _ref2.urlSegment;
|
|
437
|
+
return _this3.doesUrlMatchPath(urlSegment, url);
|
|
370
438
|
});
|
|
371
439
|
if (!(allMatchedLabeledAppearances.length > 0)) {
|
|
372
440
|
_context7.next = 10;
|
|
@@ -469,33 +537,51 @@ export var EditorCardProvider = /*#__PURE__*/function () {
|
|
|
469
537
|
while (1) switch (_context9.prev = _context9.next) {
|
|
470
538
|
case 0:
|
|
471
539
|
_context9.prev = 0;
|
|
472
|
-
|
|
540
|
+
if (!expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
541
|
+
_context9.next = 7;
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
_context9.next = 4;
|
|
545
|
+
return this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
546
|
+
type: 'inlineCard',
|
|
547
|
+
attrs: {
|
|
548
|
+
url: url
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
case 4:
|
|
552
|
+
_context9.t0 = _context9.sent;
|
|
553
|
+
_context9.next = 10;
|
|
554
|
+
break;
|
|
555
|
+
case 7:
|
|
556
|
+
_context9.next = 9;
|
|
473
557
|
return this.cardClient.fetchData(url);
|
|
474
|
-
case
|
|
475
|
-
|
|
558
|
+
case 9:
|
|
559
|
+
_context9.t0 = _context9.sent;
|
|
560
|
+
case 10:
|
|
561
|
+
details = _context9.t0;
|
|
476
562
|
if (details) {
|
|
477
|
-
_context9.next =
|
|
563
|
+
_context9.next = 13;
|
|
478
564
|
break;
|
|
479
565
|
}
|
|
480
566
|
return _context9.abrupt("return", false);
|
|
481
|
-
case
|
|
567
|
+
case 13:
|
|
482
568
|
if (!(getStatus(details) !== 'resolved')) {
|
|
483
|
-
_context9.next =
|
|
569
|
+
_context9.next = 15;
|
|
484
570
|
break;
|
|
485
571
|
}
|
|
486
572
|
return _context9.abrupt("return", false);
|
|
487
|
-
case
|
|
573
|
+
case 15:
|
|
488
574
|
embed = extractSmartLinkEmbed(details);
|
|
489
575
|
return _context9.abrupt("return", !!embed);
|
|
490
|
-
case
|
|
491
|
-
_context9.prev =
|
|
492
|
-
_context9.
|
|
576
|
+
case 19:
|
|
577
|
+
_context9.prev = 19;
|
|
578
|
+
_context9.t1 = _context9["catch"](0);
|
|
493
579
|
return _context9.abrupt("return", false);
|
|
494
|
-
case
|
|
580
|
+
case 22:
|
|
495
581
|
case "end":
|
|
496
582
|
return _context9.stop();
|
|
497
583
|
}
|
|
498
|
-
}, _callee9, this, [[0,
|
|
584
|
+
}, _callee9, this, [[0, 19]]);
|
|
499
585
|
}));
|
|
500
586
|
function canBeResolvedAsEmbed(_x7) {
|
|
501
587
|
return _canBeResolvedAsEmbed.apply(this, arguments);
|
|
@@ -515,28 +601,46 @@ export var EditorCardProvider = /*#__PURE__*/function () {
|
|
|
515
601
|
while (1) switch (_context0.prev = _context0.next) {
|
|
516
602
|
case 0:
|
|
517
603
|
_context0.prev = 0;
|
|
518
|
-
|
|
604
|
+
if (!expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
605
|
+
_context0.next = 7;
|
|
606
|
+
break;
|
|
607
|
+
}
|
|
608
|
+
_context0.next = 4;
|
|
609
|
+
return this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
610
|
+
type: 'inlineCard',
|
|
611
|
+
attrs: {
|
|
612
|
+
url: url
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
case 4:
|
|
616
|
+
_context0.t0 = _context0.sent;
|
|
617
|
+
_context0.next = 10;
|
|
618
|
+
break;
|
|
619
|
+
case 7:
|
|
620
|
+
_context0.next = 9;
|
|
519
621
|
return this.cardClient.fetchData(url);
|
|
520
|
-
case
|
|
521
|
-
|
|
622
|
+
case 9:
|
|
623
|
+
_context0.t0 = _context0.sent;
|
|
624
|
+
case 10:
|
|
625
|
+
response = _context0.t0;
|
|
522
626
|
datasources = response && response.datasources || [];
|
|
523
627
|
if (!(datasources.length > 0)) {
|
|
524
|
-
_context0.next =
|
|
628
|
+
_context0.next = 14;
|
|
525
629
|
break;
|
|
526
630
|
}
|
|
527
631
|
return _context0.abrupt("return", datasources[0]);
|
|
528
|
-
case
|
|
529
|
-
_context0.next =
|
|
632
|
+
case 14:
|
|
633
|
+
_context0.next = 19;
|
|
530
634
|
break;
|
|
531
|
-
case
|
|
532
|
-
_context0.prev =
|
|
533
|
-
_context0.
|
|
635
|
+
case 16:
|
|
636
|
+
_context0.prev = 16;
|
|
637
|
+
_context0.t1 = _context0["catch"](0);
|
|
534
638
|
return _context0.abrupt("return", undefined);
|
|
535
|
-
case
|
|
639
|
+
case 19:
|
|
536
640
|
case "end":
|
|
537
641
|
return _context0.stop();
|
|
538
642
|
}
|
|
539
|
-
}, _callee0, this, [[0,
|
|
643
|
+
}, _callee0, this, [[0, 16]]);
|
|
540
644
|
}));
|
|
541
645
|
function getDatasourceFromResolveResponse(_x8) {
|
|
542
646
|
return _getDatasourceFromResolveResponse.apply(this, arguments);
|
|
@@ -683,5 +787,5 @@ export var EditorCardProvider = /*#__PURE__*/function () {
|
|
|
683
787
|
return resolve;
|
|
684
788
|
}()
|
|
685
789
|
}]);
|
|
686
|
-
}();
|
|
790
|
+
}(NodeDataProvider);
|
|
687
791
|
export var editorCardProvider = new EditorCardProvider();
|
package/dist/types/provider.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { JSONNode } from '@atlaskit/editor-json-transformer';
|
|
2
|
+
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
3
|
+
import { type BlockCardAdf, type EmbedCardAdf, type CardAdf, type InlineCardAdf, type CardAppearance, type DatasourceAdf, type ProductType } from '@atlaskit/linking-common';
|
|
2
4
|
import { type CardProvider } from './types';
|
|
3
5
|
import { type EnvironmentsKeys } from '@atlaskit/linking-common';
|
|
6
|
+
import { type JsonLd } from '@atlaskit/json-ld-types';
|
|
4
7
|
export declare const isJiraWorkItem: (url: string) => boolean;
|
|
5
|
-
|
|
8
|
+
type CardNode = InlineCardAdf | BlockCardAdf | EmbedCardAdf;
|
|
9
|
+
export declare class EditorCardProvider extends NodeDataProvider<CardNode, JsonLd.Response> implements CardProvider {
|
|
10
|
+
readonly name: string;
|
|
6
11
|
private baseUrl;
|
|
7
12
|
private resolverUrl;
|
|
8
13
|
private providersData?;
|
|
@@ -12,6 +17,9 @@ export declare class EditorCardProvider implements CardProvider {
|
|
|
12
17
|
private cardClient;
|
|
13
18
|
private onResolve;
|
|
14
19
|
constructor(envKey?: EnvironmentsKeys, baseUrlOverride?: string, product?: ProductType, onResolve?: (url: string) => void);
|
|
20
|
+
nodeDataKey(node: CardNode): string;
|
|
21
|
+
fetchNodesData(nodes: CardNode[]): Promise<JsonLd.Response[]>;
|
|
22
|
+
isNodeSupported(node: JSONNode): node is CardNode;
|
|
15
23
|
private batchProviders;
|
|
16
24
|
private checkLinkResolved;
|
|
17
25
|
private fetchDataForResource;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { JSONNode } from '@atlaskit/editor-json-transformer';
|
|
2
|
+
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
3
|
+
import { type BlockCardAdf, type EmbedCardAdf, type CardAdf, type InlineCardAdf, type CardAppearance, type DatasourceAdf, type ProductType } from '@atlaskit/linking-common';
|
|
2
4
|
import { type CardProvider } from './types';
|
|
3
5
|
import { type EnvironmentsKeys } from '@atlaskit/linking-common';
|
|
6
|
+
import { type JsonLd } from '@atlaskit/json-ld-types';
|
|
4
7
|
export declare const isJiraWorkItem: (url: string) => boolean;
|
|
5
|
-
|
|
8
|
+
type CardNode = InlineCardAdf | BlockCardAdf | EmbedCardAdf;
|
|
9
|
+
export declare class EditorCardProvider extends NodeDataProvider<CardNode, JsonLd.Response> implements CardProvider {
|
|
10
|
+
readonly name: string;
|
|
6
11
|
private baseUrl;
|
|
7
12
|
private resolverUrl;
|
|
8
13
|
private providersData?;
|
|
@@ -12,6 +17,9 @@ export declare class EditorCardProvider implements CardProvider {
|
|
|
12
17
|
private cardClient;
|
|
13
18
|
private onResolve;
|
|
14
19
|
constructor(envKey?: EnvironmentsKeys, baseUrlOverride?: string, product?: ProductType, onResolve?: (url: string) => void);
|
|
20
|
+
nodeDataKey(node: CardNode): string;
|
|
21
|
+
fetchNodesData(nodes: CardNode[]): Promise<JsonLd.Response[]>;
|
|
22
|
+
isNodeSupported(node: JSONNode): node is CardNode;
|
|
15
23
|
private batchProviders;
|
|
16
24
|
private checkLinkResolved;
|
|
17
25
|
private fetchDataForResource;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-card-provider",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.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",
|
|
@@ -8,11 +8,10 @@
|
|
|
8
8
|
"registry": "https://registry.npmjs.org/"
|
|
9
9
|
},
|
|
10
10
|
"atlassian": {
|
|
11
|
-
"team": "Linking Platform",
|
|
11
|
+
"team": "Navigation Experiences - Linking Platform",
|
|
12
12
|
"website": {
|
|
13
13
|
"name": "EditorCardProvider"
|
|
14
|
-
}
|
|
15
|
-
"runReact18": true
|
|
14
|
+
}
|
|
16
15
|
},
|
|
17
16
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
18
17
|
"main": "dist/cjs/index.js",
|
|
@@ -33,18 +32,21 @@
|
|
|
33
32
|
".": "./src/index.ts"
|
|
34
33
|
},
|
|
35
34
|
"dependencies": {
|
|
36
|
-
"@atlaskit/
|
|
37
|
-
"@atlaskit/
|
|
35
|
+
"@atlaskit/editor-json-transformer": "^8.24.0",
|
|
36
|
+
"@atlaskit/feature-gate-js-client": "^5.5.0",
|
|
37
|
+
"@atlaskit/json-ld-types": "^1.4.0",
|
|
38
38
|
"@atlaskit/link-client-extension": "^5.0.0",
|
|
39
39
|
"@atlaskit/link-extractors": "^2.4.0",
|
|
40
|
-
"@atlaskit/linking-common": "^9.
|
|
41
|
-
"@atlaskit/linking-types": "^
|
|
40
|
+
"@atlaskit/linking-common": "^9.2.0",
|
|
41
|
+
"@atlaskit/linking-types": "^14.0.0",
|
|
42
|
+
"@atlaskit/node-data-provider": "^4.4.0",
|
|
42
43
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
44
|
+
"@atlaskit/tmp-editor-statsig": "^9.17.0",
|
|
43
45
|
"@babel/runtime": "^7.0.0",
|
|
44
46
|
"dataloader": "^2.1.0"
|
|
45
47
|
},
|
|
46
48
|
"peerDependencies": {
|
|
47
|
-
"@atlaskit/link-provider": "^3.
|
|
49
|
+
"@atlaskit/link-provider": "^3.4.0",
|
|
48
50
|
"react": "^18.2.0"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|