@atlaskit/editor-card-provider 6.8.23 → 6.8.24
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 +8 -0
- package/dist/cjs/provider.js +45 -19
- package/dist/es2019/provider.js +25 -0
- package/dist/esm/provider.js +45 -19
- package/dist/types/provider.d.ts +11 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-card-provider
|
|
2
2
|
|
|
3
|
+
## 6.8.24
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`027beb2f61316`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/027beb2f61316) -
|
|
8
|
+
Update smart link appearance, if and only if smart link is created from confluence editor quick
|
|
9
|
+
insert menu
|
|
10
|
+
|
|
3
11
|
## 6.8.23
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/cjs/provider.js
CHANGED
|
@@ -698,7 +698,23 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function (_No
|
|
|
698
698
|
return _canBeResolvedAsEmbed.apply(this, arguments);
|
|
699
699
|
}
|
|
700
700
|
return canBeResolvedAsEmbed;
|
|
701
|
-
}()
|
|
701
|
+
}()
|
|
702
|
+
/**
|
|
703
|
+
* Opt-in hook: when a caller explicitly requests an `'embed'` appearance and the
|
|
704
|
+
* user has no saved preference for the URL, honour that request as the default
|
|
705
|
+
* (above any provider default), validating embeddability first and falling back
|
|
706
|
+
* to a card (`'block'`) when the link cannot be embedded.
|
|
707
|
+
*
|
|
708
|
+
* Defaults to `false` so behaviour is unchanged for every existing consumer.
|
|
709
|
+
* Subclasses (e.g. Confluence) can override this to opt in, typically behind an
|
|
710
|
+
* experiment.
|
|
711
|
+
*/
|
|
712
|
+
)
|
|
713
|
+
}, {
|
|
714
|
+
key: "shouldHonorRequestedEmbedAsDefault",
|
|
715
|
+
value: function shouldHonorRequestedEmbedAsDefault() {
|
|
716
|
+
return false;
|
|
717
|
+
}
|
|
702
718
|
}, {
|
|
703
719
|
key: "getAuthStatusFromResolveResponse",
|
|
704
720
|
value: function () {
|
|
@@ -787,7 +803,7 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function (_No
|
|
|
787
803
|
key: "resolve",
|
|
788
804
|
value: function () {
|
|
789
805
|
var _resolve = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(url, appearance, shouldForceAppearance, isEmbedFriendlyLocation) {
|
|
790
|
-
var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, data, issueAri, _this$onResolve, isSupported, providerDefaultAppearance, isEmbedFriendlyLocationEvaluated, preferredAppearance, canItBeEmbed, datasource, id, parameters, authStatus, access, _t8, _t9;
|
|
806
|
+
var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, data, issueAri, _this$onResolve, isSupported, providerDefaultAppearance, isEmbedFriendlyLocationEvaluated, preferredAppearance, canItBeEmbed, _canItBeEmbed, datasource, id, parameters, authStatus, access, _t8, _t9;
|
|
791
807
|
return _regenerator.default.wrap(function (_context11) {
|
|
792
808
|
while (1) switch (_context11.prev = _context11.next) {
|
|
793
809
|
case 0:
|
|
@@ -843,7 +859,7 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function (_No
|
|
|
843
859
|
case 7:
|
|
844
860
|
isSupported = _t8;
|
|
845
861
|
if (!isSupported) {
|
|
846
|
-
_context11.next =
|
|
862
|
+
_context11.next = 16;
|
|
847
863
|
break;
|
|
848
864
|
}
|
|
849
865
|
providerDefaultAppearance = matchedProviderPattern === null || matchedProviderPattern === void 0 ? void 0 : matchedProviderPattern.defaultView;
|
|
@@ -873,12 +889,22 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function (_No
|
|
|
873
889
|
preferredAppearance = 'inline';
|
|
874
890
|
}
|
|
875
891
|
case 9:
|
|
892
|
+
if (!(!userPreference && appearance === 'embed' && isEmbedFriendlyLocationEvaluated && this.shouldHonorRequestedEmbedAsDefault())) {
|
|
893
|
+
_context11.next = 11;
|
|
894
|
+
break;
|
|
895
|
+
}
|
|
876
896
|
_context11.next = 10;
|
|
877
|
-
return this.
|
|
897
|
+
return this.canBeResolvedAsEmbed(url);
|
|
878
898
|
case 10:
|
|
899
|
+
_canItBeEmbed = _context11.sent;
|
|
900
|
+
preferredAppearance = _canItBeEmbed ? 'embed' : 'block';
|
|
901
|
+
case 11:
|
|
902
|
+
_context11.next = 12;
|
|
903
|
+
return this.getDatasourceFromResolveResponse(url);
|
|
904
|
+
case 12:
|
|
879
905
|
datasource = _context11.sent;
|
|
880
906
|
if (!datasource) {
|
|
881
|
-
_context11.next =
|
|
907
|
+
_context11.next = 13;
|
|
882
908
|
break;
|
|
883
909
|
}
|
|
884
910
|
id = datasource.id, parameters = datasource.parameters;
|
|
@@ -891,42 +917,42 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function (_No
|
|
|
891
917
|
type: 'table'
|
|
892
918
|
}]
|
|
893
919
|
}, url));
|
|
894
|
-
case
|
|
920
|
+
case 13:
|
|
895
921
|
if (!(isEmbedFriendlyLocationEvaluated && !userPreference)) {
|
|
896
|
-
_context11.next =
|
|
922
|
+
_context11.next = 15;
|
|
897
923
|
break;
|
|
898
924
|
}
|
|
899
|
-
_context11.next =
|
|
925
|
+
_context11.next = 14;
|
|
900
926
|
return this.getAuthStatusFromResolveResponse(url);
|
|
901
|
-
case
|
|
927
|
+
case 14:
|
|
902
928
|
authStatus = _context11.sent;
|
|
903
929
|
if (!authStatus) {
|
|
904
|
-
_context11.next =
|
|
930
|
+
_context11.next = 15;
|
|
905
931
|
break;
|
|
906
932
|
}
|
|
907
933
|
access = authStatus.access;
|
|
908
934
|
if (!(access === 'unauthorized')) {
|
|
909
|
-
_context11.next =
|
|
935
|
+
_context11.next = 15;
|
|
910
936
|
break;
|
|
911
937
|
}
|
|
912
938
|
return _context11.abrupt("return", this.transformer.toSmartlinkAdf(url, 'block'));
|
|
913
|
-
case
|
|
939
|
+
case 15:
|
|
914
940
|
return _context11.abrupt("return", this.transformer.toSmartlinkAdf(url, preferredAppearance));
|
|
915
|
-
case
|
|
916
|
-
_context11.next =
|
|
941
|
+
case 16:
|
|
942
|
+
_context11.next = 18;
|
|
917
943
|
break;
|
|
918
|
-
case
|
|
919
|
-
_context11.prev =
|
|
944
|
+
case 17:
|
|
945
|
+
_context11.prev = 17;
|
|
920
946
|
_t9 = _context11["catch"](0);
|
|
921
947
|
// eslint-disable-next-line
|
|
922
948
|
console.warn("Error when trying to check Smart Card url \"".concat(url, "\"").concat(_t9 instanceof Error ? " - ".concat(_t9.name, " ").concat(_t9.message) : ''), _t9);
|
|
923
|
-
case
|
|
949
|
+
case 18:
|
|
924
950
|
return _context11.abrupt("return", Promise.reject(undefined));
|
|
925
|
-
case
|
|
951
|
+
case 19:
|
|
926
952
|
case "end":
|
|
927
953
|
return _context11.stop();
|
|
928
954
|
}
|
|
929
|
-
}, _callee11, this, [[0,
|
|
955
|
+
}, _callee11, this, [[0, 17]]);
|
|
930
956
|
}));
|
|
931
957
|
function resolve(_x1, _x10, _x11, _x12) {
|
|
932
958
|
return _resolve.apply(this, arguments);
|
package/dist/es2019/provider.js
CHANGED
|
@@ -362,6 +362,20 @@ export class EditorCardProvider extends NodeDataProvider {
|
|
|
362
362
|
return false;
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Opt-in hook: when a caller explicitly requests an `'embed'` appearance and the
|
|
368
|
+
* user has no saved preference for the URL, honour that request as the default
|
|
369
|
+
* (above any provider default), validating embeddability first and falling back
|
|
370
|
+
* to a card (`'block'`) when the link cannot be embedded.
|
|
371
|
+
*
|
|
372
|
+
* Defaults to `false` so behaviour is unchanged for every existing consumer.
|
|
373
|
+
* Subclasses (e.g. Confluence) can override this to opt in, typically behind an
|
|
374
|
+
* experiment.
|
|
375
|
+
*/
|
|
376
|
+
shouldHonorRequestedEmbedAsDefault() {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
365
379
|
async getAuthStatusFromResolveResponse(url) {
|
|
366
380
|
try {
|
|
367
381
|
const {
|
|
@@ -450,6 +464,17 @@ export class EditorCardProvider extends NodeDataProvider {
|
|
|
450
464
|
preferredAppearance = 'inline';
|
|
451
465
|
}
|
|
452
466
|
}
|
|
467
|
+
|
|
468
|
+
// When a caller explicitly requested an embed (e.g. Confluence's quick-insert
|
|
469
|
+
// embed flow tags the inserted link) and the user has no saved preference for
|
|
470
|
+
// this URL, honour embed-by-default above the provider default — but only in an
|
|
471
|
+
// embed-friendly location (matching how hard-coded embeds are gated above) and
|
|
472
|
+
// only when the link can actually be embedded, otherwise fall back to a card.
|
|
473
|
+
// Gated behind a default-off opt-in hook so other consumers are unaffected.
|
|
474
|
+
if (!userPreference && appearance === 'embed' && isEmbedFriendlyLocationEvaluated && this.shouldHonorRequestedEmbedAsDefault()) {
|
|
475
|
+
const canItBeEmbed = await this.canBeResolvedAsEmbed(url);
|
|
476
|
+
preferredAppearance = canItBeEmbed ? 'embed' : 'block';
|
|
477
|
+
}
|
|
453
478
|
const datasource = await this.getDatasourceFromResolveResponse(url);
|
|
454
479
|
if (datasource) {
|
|
455
480
|
const {
|
package/dist/esm/provider.js
CHANGED
|
@@ -690,7 +690,23 @@ export var EditorCardProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
690
690
|
return _canBeResolvedAsEmbed.apply(this, arguments);
|
|
691
691
|
}
|
|
692
692
|
return canBeResolvedAsEmbed;
|
|
693
|
-
}()
|
|
693
|
+
}()
|
|
694
|
+
/**
|
|
695
|
+
* Opt-in hook: when a caller explicitly requests an `'embed'` appearance and the
|
|
696
|
+
* user has no saved preference for the URL, honour that request as the default
|
|
697
|
+
* (above any provider default), validating embeddability first and falling back
|
|
698
|
+
* to a card (`'block'`) when the link cannot be embedded.
|
|
699
|
+
*
|
|
700
|
+
* Defaults to `false` so behaviour is unchanged for every existing consumer.
|
|
701
|
+
* Subclasses (e.g. Confluence) can override this to opt in, typically behind an
|
|
702
|
+
* experiment.
|
|
703
|
+
*/
|
|
704
|
+
)
|
|
705
|
+
}, {
|
|
706
|
+
key: "shouldHonorRequestedEmbedAsDefault",
|
|
707
|
+
value: function shouldHonorRequestedEmbedAsDefault() {
|
|
708
|
+
return false;
|
|
709
|
+
}
|
|
694
710
|
}, {
|
|
695
711
|
key: "getAuthStatusFromResolveResponse",
|
|
696
712
|
value: function () {
|
|
@@ -779,7 +795,7 @@ export var EditorCardProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
779
795
|
key: "resolve",
|
|
780
796
|
value: function () {
|
|
781
797
|
var _resolve = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(url, appearance, shouldForceAppearance, isEmbedFriendlyLocation) {
|
|
782
|
-
var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, data, issueAri, _this$onResolve, isSupported, providerDefaultAppearance, isEmbedFriendlyLocationEvaluated, preferredAppearance, canItBeEmbed, datasource, id, parameters, authStatus, access, _t8, _t9;
|
|
798
|
+
var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, data, issueAri, _this$onResolve, isSupported, providerDefaultAppearance, isEmbedFriendlyLocationEvaluated, preferredAppearance, canItBeEmbed, _canItBeEmbed, datasource, id, parameters, authStatus, access, _t8, _t9;
|
|
783
799
|
return _regeneratorRuntime.wrap(function (_context11) {
|
|
784
800
|
while (1) switch (_context11.prev = _context11.next) {
|
|
785
801
|
case 0:
|
|
@@ -835,7 +851,7 @@ export var EditorCardProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
835
851
|
case 7:
|
|
836
852
|
isSupported = _t8;
|
|
837
853
|
if (!isSupported) {
|
|
838
|
-
_context11.next =
|
|
854
|
+
_context11.next = 16;
|
|
839
855
|
break;
|
|
840
856
|
}
|
|
841
857
|
providerDefaultAppearance = matchedProviderPattern === null || matchedProviderPattern === void 0 ? void 0 : matchedProviderPattern.defaultView;
|
|
@@ -865,12 +881,22 @@ export var EditorCardProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
865
881
|
preferredAppearance = 'inline';
|
|
866
882
|
}
|
|
867
883
|
case 9:
|
|
884
|
+
if (!(!userPreference && appearance === 'embed' && isEmbedFriendlyLocationEvaluated && this.shouldHonorRequestedEmbedAsDefault())) {
|
|
885
|
+
_context11.next = 11;
|
|
886
|
+
break;
|
|
887
|
+
}
|
|
868
888
|
_context11.next = 10;
|
|
869
|
-
return this.
|
|
889
|
+
return this.canBeResolvedAsEmbed(url);
|
|
870
890
|
case 10:
|
|
891
|
+
_canItBeEmbed = _context11.sent;
|
|
892
|
+
preferredAppearance = _canItBeEmbed ? 'embed' : 'block';
|
|
893
|
+
case 11:
|
|
894
|
+
_context11.next = 12;
|
|
895
|
+
return this.getDatasourceFromResolveResponse(url);
|
|
896
|
+
case 12:
|
|
871
897
|
datasource = _context11.sent;
|
|
872
898
|
if (!datasource) {
|
|
873
|
-
_context11.next =
|
|
899
|
+
_context11.next = 13;
|
|
874
900
|
break;
|
|
875
901
|
}
|
|
876
902
|
id = datasource.id, parameters = datasource.parameters;
|
|
@@ -883,42 +909,42 @@ export var EditorCardProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
883
909
|
type: 'table'
|
|
884
910
|
}]
|
|
885
911
|
}, url));
|
|
886
|
-
case
|
|
912
|
+
case 13:
|
|
887
913
|
if (!(isEmbedFriendlyLocationEvaluated && !userPreference)) {
|
|
888
|
-
_context11.next =
|
|
914
|
+
_context11.next = 15;
|
|
889
915
|
break;
|
|
890
916
|
}
|
|
891
|
-
_context11.next =
|
|
917
|
+
_context11.next = 14;
|
|
892
918
|
return this.getAuthStatusFromResolveResponse(url);
|
|
893
|
-
case
|
|
919
|
+
case 14:
|
|
894
920
|
authStatus = _context11.sent;
|
|
895
921
|
if (!authStatus) {
|
|
896
|
-
_context11.next =
|
|
922
|
+
_context11.next = 15;
|
|
897
923
|
break;
|
|
898
924
|
}
|
|
899
925
|
access = authStatus.access;
|
|
900
926
|
if (!(access === 'unauthorized')) {
|
|
901
|
-
_context11.next =
|
|
927
|
+
_context11.next = 15;
|
|
902
928
|
break;
|
|
903
929
|
}
|
|
904
930
|
return _context11.abrupt("return", this.transformer.toSmartlinkAdf(url, 'block'));
|
|
905
|
-
case
|
|
931
|
+
case 15:
|
|
906
932
|
return _context11.abrupt("return", this.transformer.toSmartlinkAdf(url, preferredAppearance));
|
|
907
|
-
case
|
|
908
|
-
_context11.next =
|
|
933
|
+
case 16:
|
|
934
|
+
_context11.next = 18;
|
|
909
935
|
break;
|
|
910
|
-
case
|
|
911
|
-
_context11.prev =
|
|
936
|
+
case 17:
|
|
937
|
+
_context11.prev = 17;
|
|
912
938
|
_t9 = _context11["catch"](0);
|
|
913
939
|
// eslint-disable-next-line
|
|
914
940
|
console.warn("Error when trying to check Smart Card url \"".concat(url, "\"").concat(_t9 instanceof Error ? " - ".concat(_t9.name, " ").concat(_t9.message) : ''), _t9);
|
|
915
|
-
case
|
|
941
|
+
case 18:
|
|
916
942
|
return _context11.abrupt("return", Promise.reject(undefined));
|
|
917
|
-
case
|
|
943
|
+
case 19:
|
|
918
944
|
case "end":
|
|
919
945
|
return _context11.stop();
|
|
920
946
|
}
|
|
921
|
-
}, _callee11, this, [[0,
|
|
947
|
+
}, _callee11, this, [[0, 17]]);
|
|
922
948
|
}));
|
|
923
949
|
function resolve(_x1, _x10, _x11, _x12) {
|
|
924
950
|
return _resolve.apply(this, arguments);
|
package/dist/types/provider.d.ts
CHANGED
|
@@ -65,6 +65,17 @@ export declare class EditorCardProvider extends NodeDataProvider<CardNode, JsonL
|
|
|
65
65
|
* Make a /resolve call and find out if result has embed capability
|
|
66
66
|
*/
|
|
67
67
|
private canBeResolvedAsEmbed;
|
|
68
|
+
/**
|
|
69
|
+
* Opt-in hook: when a caller explicitly requests an `'embed'` appearance and the
|
|
70
|
+
* user has no saved preference for the URL, honour that request as the default
|
|
71
|
+
* (above any provider default), validating embeddability first and falling back
|
|
72
|
+
* to a card (`'block'`) when the link cannot be embedded.
|
|
73
|
+
*
|
|
74
|
+
* Defaults to `false` so behaviour is unchanged for every existing consumer.
|
|
75
|
+
* Subclasses (e.g. Confluence) can override this to opt in, typically behind an
|
|
76
|
+
* experiment.
|
|
77
|
+
*/
|
|
78
|
+
protected shouldHonorRequestedEmbedAsDefault(): boolean;
|
|
68
79
|
private getAuthStatusFromResolveResponse;
|
|
69
80
|
/**
|
|
70
81
|
* Make a /resolve call and find out if result has datasource capability
|
package/package.json
CHANGED