@atlaskit/editor-card-provider 7.0.27 → 7.0.28
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 +160 -107
- package/dist/es2019/provider.js +20 -1
- package/dist/esm/provider.js +161 -108
- package/dist/types/provider.d.ts +1 -0
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-card-provider
|
|
2
2
|
|
|
3
|
+
## 7.0.28
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`63e41faf180af`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/63e41faf180af) -
|
|
8
|
+
[ux] Resolve Confluence shortlinks to native embeds when their canonical URL matches an existing
|
|
9
|
+
native embed experience
|
|
10
|
+
|
|
3
11
|
## 7.0.27
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/cjs/provider.js
CHANGED
|
@@ -94,6 +94,10 @@ var AVP_VISUALIZATION_VIEW_REGEX = /^https:\/\/.*?\/avpviz\/c\/[^\/]+.*/;
|
|
|
94
94
|
var JIRA_WORK_ITEM_REGEX = /\/browse\/((?:\w+)-(?:\d+))/i;
|
|
95
95
|
var DOES_URL_MATCH_PATH_START_REGEX = /^[a-zA-Z0-9]/;
|
|
96
96
|
var DOES_URL_MATCH_PATH_END_REGEX = /[a-zA-Z0-9]$/;
|
|
97
|
+
var CONFLUENCE_SHORT_LINK_URL_REGEX = /^https:\/\/[^/?#]+\/wiki\/x\/[A-Za-z0-9_-]+\/?(?:[?#].*)?$/;
|
|
98
|
+
var isConfluenceShortLinkUrl = function isConfluenceShortLinkUrl(url) {
|
|
99
|
+
return url.match(CONFLUENCE_SHORT_LINK_URL_REGEX);
|
|
100
|
+
};
|
|
97
101
|
var isJiraRoadmapOrTimeline = function isJiraRoadmapOrTimeline(url) {
|
|
98
102
|
return url.match(JIRA_ROADMAP_OR_TIMELINE_REGEX);
|
|
99
103
|
};
|
|
@@ -673,47 +677,77 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function (_No
|
|
|
673
677
|
}
|
|
674
678
|
return fetchData;
|
|
675
679
|
}()
|
|
680
|
+
}, {
|
|
681
|
+
key: "resolvesToHardCodedEmbed",
|
|
682
|
+
value: function () {
|
|
683
|
+
var _resolvesToHardCodedEmbed = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee0(url) {
|
|
684
|
+
var response, resolvedUrl, _t5;
|
|
685
|
+
return _regenerator.default.wrap(function (_context0) {
|
|
686
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
687
|
+
case 0:
|
|
688
|
+
_context0.prev = 0;
|
|
689
|
+
_context0.next = 1;
|
|
690
|
+
return this.fetchData(url);
|
|
691
|
+
case 1:
|
|
692
|
+
response = _context0.sent;
|
|
693
|
+
resolvedUrl = (0, _linkExtractors.extractSmartLinkUrl)(response);
|
|
694
|
+
return _context0.abrupt("return", resolvedUrl !== undefined && this.getHardCodedAppearance(resolvedUrl) === 'embed');
|
|
695
|
+
case 2:
|
|
696
|
+
_context0.prev = 2;
|
|
697
|
+
_t5 = _context0["catch"](0);
|
|
698
|
+
return _context0.abrupt("return", false);
|
|
699
|
+
case 3:
|
|
700
|
+
case "end":
|
|
701
|
+
return _context0.stop();
|
|
702
|
+
}
|
|
703
|
+
}, _callee0, this, [[0, 2]]);
|
|
704
|
+
}));
|
|
705
|
+
function resolvesToHardCodedEmbed(_x8) {
|
|
706
|
+
return _resolvesToHardCodedEmbed.apply(this, arguments);
|
|
707
|
+
}
|
|
708
|
+
return resolvesToHardCodedEmbed;
|
|
709
|
+
}()
|
|
676
710
|
/**
|
|
677
711
|
* Make a /resolve call and find out if result has embed capability
|
|
678
712
|
*/
|
|
679
713
|
}, {
|
|
680
714
|
key: "canBeResolvedAsEmbed",
|
|
681
715
|
value: (function () {
|
|
682
|
-
var _canBeResolvedAsEmbed = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
683
|
-
var details, embed,
|
|
684
|
-
return _regenerator.default.wrap(function (
|
|
685
|
-
while (1) switch (
|
|
716
|
+
var _canBeResolvedAsEmbed = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee1(url) {
|
|
717
|
+
var details, embed, _t6;
|
|
718
|
+
return _regenerator.default.wrap(function (_context1) {
|
|
719
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
686
720
|
case 0:
|
|
687
|
-
|
|
688
|
-
|
|
721
|
+
_context1.prev = 0;
|
|
722
|
+
_context1.next = 1;
|
|
689
723
|
return this.fetchData(url);
|
|
690
724
|
case 1:
|
|
691
|
-
details =
|
|
725
|
+
details = _context1.sent;
|
|
692
726
|
if (details) {
|
|
693
|
-
|
|
727
|
+
_context1.next = 2;
|
|
694
728
|
break;
|
|
695
729
|
}
|
|
696
|
-
return
|
|
730
|
+
return _context1.abrupt("return", false);
|
|
697
731
|
case 2:
|
|
698
732
|
if (!((0, _linkingCommon.getStatus)(details) !== 'resolved')) {
|
|
699
|
-
|
|
733
|
+
_context1.next = 3;
|
|
700
734
|
break;
|
|
701
735
|
}
|
|
702
|
-
return
|
|
736
|
+
return _context1.abrupt("return", false);
|
|
703
737
|
case 3:
|
|
704
738
|
embed = (0, _linkExtractors.extractSmartLinkEmbed)(details);
|
|
705
|
-
return
|
|
739
|
+
return _context1.abrupt("return", !!embed);
|
|
706
740
|
case 4:
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
return
|
|
741
|
+
_context1.prev = 4;
|
|
742
|
+
_t6 = _context1["catch"](0);
|
|
743
|
+
return _context1.abrupt("return", false);
|
|
710
744
|
case 5:
|
|
711
745
|
case "end":
|
|
712
|
-
return
|
|
746
|
+
return _context1.stop();
|
|
713
747
|
}
|
|
714
|
-
},
|
|
748
|
+
}, _callee1, this, [[0, 4]]);
|
|
715
749
|
}));
|
|
716
|
-
function canBeResolvedAsEmbed(
|
|
750
|
+
function canBeResolvedAsEmbed(_x9) {
|
|
717
751
|
return _canBeResolvedAsEmbed.apply(this, arguments);
|
|
718
752
|
}
|
|
719
753
|
return canBeResolvedAsEmbed;
|
|
@@ -737,34 +771,34 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function (_No
|
|
|
737
771
|
}, {
|
|
738
772
|
key: "getAuthStatusFromResolveResponse",
|
|
739
773
|
value: function () {
|
|
740
|
-
var _getAuthStatusFromResolveResponse = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
741
|
-
var _yield$this$fetchData, _yield$this$fetchData2, access, visibility,
|
|
742
|
-
return _regenerator.default.wrap(function (
|
|
743
|
-
while (1) switch (
|
|
774
|
+
var _getAuthStatusFromResolveResponse = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(url) {
|
|
775
|
+
var _yield$this$fetchData, _yield$this$fetchData2, access, visibility, _t7;
|
|
776
|
+
return _regenerator.default.wrap(function (_context10) {
|
|
777
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
744
778
|
case 0:
|
|
745
|
-
|
|
746
|
-
|
|
779
|
+
_context10.prev = 0;
|
|
780
|
+
_context10.next = 1;
|
|
747
781
|
return this.fetchData(url);
|
|
748
782
|
case 1:
|
|
749
|
-
_yield$this$fetchData =
|
|
783
|
+
_yield$this$fetchData = _context10.sent;
|
|
750
784
|
_yield$this$fetchData2 = _yield$this$fetchData.meta;
|
|
751
785
|
access = _yield$this$fetchData2.access;
|
|
752
786
|
visibility = _yield$this$fetchData2.visibility;
|
|
753
|
-
return
|
|
787
|
+
return _context10.abrupt("return", {
|
|
754
788
|
access: access,
|
|
755
789
|
visibility: visibility
|
|
756
790
|
});
|
|
757
791
|
case 2:
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
return
|
|
792
|
+
_context10.prev = 2;
|
|
793
|
+
_t7 = _context10["catch"](0);
|
|
794
|
+
return _context10.abrupt("return", undefined);
|
|
761
795
|
case 3:
|
|
762
796
|
case "end":
|
|
763
|
-
return
|
|
797
|
+
return _context10.stop();
|
|
764
798
|
}
|
|
765
|
-
},
|
|
799
|
+
}, _callee10, this, [[0, 2]]);
|
|
766
800
|
}));
|
|
767
|
-
function getAuthStatusFromResolveResponse(
|
|
801
|
+
function getAuthStatusFromResolveResponse(_x0) {
|
|
768
802
|
return _getAuthStatusFromResolveResponse.apply(this, arguments);
|
|
769
803
|
}
|
|
770
804
|
return getAuthStatusFromResolveResponse;
|
|
@@ -775,36 +809,36 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function (_No
|
|
|
775
809
|
}, {
|
|
776
810
|
key: "getDatasourceFromResolveResponse",
|
|
777
811
|
value: (function () {
|
|
778
|
-
var _getDatasourceFromResolveResponse = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
779
|
-
var response, datasources,
|
|
780
|
-
return _regenerator.default.wrap(function (
|
|
781
|
-
while (1) switch (
|
|
812
|
+
var _getDatasourceFromResolveResponse = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(url) {
|
|
813
|
+
var response, datasources, _t8;
|
|
814
|
+
return _regenerator.default.wrap(function (_context11) {
|
|
815
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
782
816
|
case 0:
|
|
783
|
-
|
|
784
|
-
|
|
817
|
+
_context11.prev = 0;
|
|
818
|
+
_context11.next = 1;
|
|
785
819
|
return this.fetchData(url);
|
|
786
820
|
case 1:
|
|
787
|
-
response =
|
|
821
|
+
response = _context11.sent;
|
|
788
822
|
datasources = response && response.datasources || [];
|
|
789
823
|
if (!(datasources.length > 0)) {
|
|
790
|
-
|
|
824
|
+
_context11.next = 2;
|
|
791
825
|
break;
|
|
792
826
|
}
|
|
793
|
-
return
|
|
827
|
+
return _context11.abrupt("return", datasources[0]);
|
|
794
828
|
case 2:
|
|
795
|
-
|
|
829
|
+
_context11.next = 4;
|
|
796
830
|
break;
|
|
797
831
|
case 3:
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
return
|
|
832
|
+
_context11.prev = 3;
|
|
833
|
+
_t8 = _context11["catch"](0);
|
|
834
|
+
return _context11.abrupt("return", undefined);
|
|
801
835
|
case 4:
|
|
802
836
|
case "end":
|
|
803
|
-
return
|
|
837
|
+
return _context11.stop();
|
|
804
838
|
}
|
|
805
|
-
},
|
|
839
|
+
}, _callee11, this, [[0, 3]]);
|
|
806
840
|
}));
|
|
807
|
-
function getDatasourceFromResolveResponse(
|
|
841
|
+
function getDatasourceFromResolveResponse(_x1) {
|
|
808
842
|
return _getDatasourceFromResolveResponse.apply(this, arguments);
|
|
809
843
|
}
|
|
810
844
|
return getDatasourceFromResolveResponse;
|
|
@@ -821,38 +855,38 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function (_No
|
|
|
821
855
|
}, {
|
|
822
856
|
key: "resolve",
|
|
823
857
|
value: function () {
|
|
824
|
-
var _resolve = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
825
|
-
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,
|
|
826
|
-
return _regenerator.default.wrap(function (
|
|
827
|
-
while (1) switch (
|
|
858
|
+
var _resolve = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(url, appearance, shouldForceAppearance, isEmbedFriendlyLocation) {
|
|
859
|
+
var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, data, issueAri, _this$onResolve, isSupported, providerDefaultAppearance, isEmbedFriendlyLocationEvaluated, preferredAppearance, isNativeEmbedShortlinkResolutionEnabled, shouldResolveShortLinkForEmbed, canItBeEmbed, _canItBeEmbed, datasource, id, parameters, authStatus, access, _t9, _t0, _t1;
|
|
860
|
+
return _regenerator.default.wrap(function (_context12) {
|
|
861
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
828
862
|
case 0:
|
|
829
|
-
|
|
863
|
+
_context12.prev = 0;
|
|
830
864
|
if (!(shouldForceAppearance === true)) {
|
|
831
|
-
|
|
865
|
+
_context12.next = 1;
|
|
832
866
|
break;
|
|
833
867
|
}
|
|
834
|
-
return
|
|
868
|
+
return _context12.abrupt("return", this.transformer.toSmartlinkAdf(url, appearance));
|
|
835
869
|
case 1:
|
|
836
870
|
hardCodedAppearance = this.getHardCodedAppearance(url);
|
|
837
|
-
|
|
871
|
+
_context12.next = 2;
|
|
838
872
|
return Promise.all([this.findPatternData(url), this.findUserPreference(url)]);
|
|
839
873
|
case 2:
|
|
840
|
-
_yield$Promise$all =
|
|
874
|
+
_yield$Promise$all = _context12.sent;
|
|
841
875
|
_yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 2);
|
|
842
876
|
matchedProviderPattern = _yield$Promise$all2[0];
|
|
843
877
|
userPreference = _yield$Promise$all2[1];
|
|
844
878
|
if (!(0, _platformFeatureFlags.fg)('issue-link-suggestions-in-comments')) {
|
|
845
|
-
|
|
879
|
+
_context12.next = 4;
|
|
846
880
|
break;
|
|
847
881
|
}
|
|
848
882
|
if (!(isJiraWorkItem(url) && this.isLocalUrl(url))) {
|
|
849
|
-
|
|
883
|
+
_context12.next = 4;
|
|
850
884
|
break;
|
|
851
885
|
}
|
|
852
|
-
|
|
886
|
+
_context12.next = 3;
|
|
853
887
|
return this.fetchDataForResource(url);
|
|
854
888
|
case 3:
|
|
855
|
-
data =
|
|
889
|
+
data = _context12.sent;
|
|
856
890
|
if (data) {
|
|
857
891
|
issueAri = this.extractAriFromData(data);
|
|
858
892
|
if (issueAri) {
|
|
@@ -861,24 +895,24 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function (_No
|
|
|
861
895
|
}
|
|
862
896
|
case 4:
|
|
863
897
|
if (!(shouldForceAppearance === false && userPreference === 'url')) {
|
|
864
|
-
|
|
898
|
+
_context12.next = 5;
|
|
865
899
|
break;
|
|
866
900
|
}
|
|
867
|
-
return
|
|
901
|
+
return _context12.abrupt("return", Promise.reject(undefined));
|
|
868
902
|
case 5:
|
|
869
|
-
|
|
870
|
-
if (
|
|
871
|
-
|
|
903
|
+
_t9 = !!matchedProviderPattern;
|
|
904
|
+
if (_t9) {
|
|
905
|
+
_context12.next = 7;
|
|
872
906
|
break;
|
|
873
907
|
}
|
|
874
|
-
|
|
908
|
+
_context12.next = 6;
|
|
875
909
|
return this.checkLinkResolved(url);
|
|
876
910
|
case 6:
|
|
877
|
-
|
|
911
|
+
_t9 = _context12.sent;
|
|
878
912
|
case 7:
|
|
879
|
-
isSupported =
|
|
913
|
+
isSupported = _t9;
|
|
880
914
|
if (!isSupported) {
|
|
881
|
-
|
|
915
|
+
_context12.next = 19;
|
|
882
916
|
break;
|
|
883
917
|
}
|
|
884
918
|
providerDefaultAppearance = matchedProviderPattern === null || matchedProviderPattern === void 0 ? void 0 : matchedProviderPattern.defaultView;
|
|
@@ -896,38 +930,57 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function (_No
|
|
|
896
930
|
providerDefaultAppearance ||
|
|
897
931
|
// If not, we pick what editor (or any other client) requested
|
|
898
932
|
appearance;
|
|
933
|
+
isNativeEmbedShortlinkResolutionEnabled = (0, _platformFeatureFlags.fg)('platform_native_embeds_enable_shortlink_resolution');
|
|
934
|
+
shouldResolveShortLinkForEmbed = isNativeEmbedShortlinkResolutionEnabled && matchedProviderPattern !== undefined && isConfluenceShortLinkUrl(url) && userPreference === undefined && isEmbedFriendlyLocationEvaluated; // Confluence shortlinks do not identify their content type. Resolve the URL before
|
|
935
|
+
// deciding whether it should use one of the existing hardcoded embed appearances.
|
|
936
|
+
_t0 = shouldResolveShortLinkForEmbed;
|
|
937
|
+
if (!_t0) {
|
|
938
|
+
_context12.next = 9;
|
|
939
|
+
break;
|
|
940
|
+
}
|
|
941
|
+
_context12.next = 8;
|
|
942
|
+
return this.resolvesToHardCodedEmbed(url);
|
|
943
|
+
case 8:
|
|
944
|
+
_t0 = _context12.sent;
|
|
945
|
+
case 9:
|
|
946
|
+
if (!_t0) {
|
|
947
|
+
_context12.next = 10;
|
|
948
|
+
break;
|
|
949
|
+
}
|
|
950
|
+
preferredAppearance = 'embed';
|
|
951
|
+
case 10:
|
|
899
952
|
if (!(preferredAppearance === userPreference && userPreference === 'embed')) {
|
|
900
|
-
|
|
953
|
+
_context12.next = 12;
|
|
901
954
|
break;
|
|
902
955
|
}
|
|
903
|
-
|
|
956
|
+
_context12.next = 11;
|
|
904
957
|
return this.canBeResolvedAsEmbed(url);
|
|
905
|
-
case
|
|
906
|
-
canItBeEmbed =
|
|
958
|
+
case 11:
|
|
959
|
+
canItBeEmbed = _context12.sent;
|
|
907
960
|
if (!canItBeEmbed) {
|
|
908
961
|
preferredAppearance = 'inline';
|
|
909
962
|
}
|
|
910
|
-
case
|
|
963
|
+
case 12:
|
|
911
964
|
if (!(!userPreference && appearance === 'embed' && isEmbedFriendlyLocationEvaluated && this.shouldHonorRequestedEmbedAsDefault())) {
|
|
912
|
-
|
|
965
|
+
_context12.next = 14;
|
|
913
966
|
break;
|
|
914
967
|
}
|
|
915
|
-
|
|
968
|
+
_context12.next = 13;
|
|
916
969
|
return this.canBeResolvedAsEmbed(url);
|
|
917
|
-
case
|
|
918
|
-
_canItBeEmbed =
|
|
970
|
+
case 13:
|
|
971
|
+
_canItBeEmbed = _context12.sent;
|
|
919
972
|
preferredAppearance = _canItBeEmbed ? 'embed' : 'block';
|
|
920
|
-
case
|
|
921
|
-
|
|
973
|
+
case 14:
|
|
974
|
+
_context12.next = 15;
|
|
922
975
|
return this.getDatasourceFromResolveResponse(url);
|
|
923
|
-
case
|
|
924
|
-
datasource =
|
|
976
|
+
case 15:
|
|
977
|
+
datasource = _context12.sent;
|
|
925
978
|
if (!datasource) {
|
|
926
|
-
|
|
979
|
+
_context12.next = 16;
|
|
927
980
|
break;
|
|
928
981
|
}
|
|
929
982
|
id = datasource.id, parameters = datasource.parameters;
|
|
930
|
-
return
|
|
983
|
+
return _context12.abrupt("return", this.transformer.toDatasourceAdf({
|
|
931
984
|
id: id,
|
|
932
985
|
parameters: parameters,
|
|
933
986
|
// in the future when we support multiple views, we will need to pass this in as a parameter
|
|
@@ -936,44 +989,44 @@ var EditorCardProvider = exports.EditorCardProvider = /*#__PURE__*/function (_No
|
|
|
936
989
|
type: 'table'
|
|
937
990
|
}]
|
|
938
991
|
}, url));
|
|
939
|
-
case
|
|
992
|
+
case 16:
|
|
940
993
|
if (!(isEmbedFriendlyLocationEvaluated && !userPreference)) {
|
|
941
|
-
|
|
994
|
+
_context12.next = 18;
|
|
942
995
|
break;
|
|
943
996
|
}
|
|
944
|
-
|
|
997
|
+
_context12.next = 17;
|
|
945
998
|
return this.getAuthStatusFromResolveResponse(url);
|
|
946
|
-
case
|
|
947
|
-
authStatus =
|
|
999
|
+
case 17:
|
|
1000
|
+
authStatus = _context12.sent;
|
|
948
1001
|
if (!authStatus) {
|
|
949
|
-
|
|
1002
|
+
_context12.next = 18;
|
|
950
1003
|
break;
|
|
951
1004
|
}
|
|
952
1005
|
access = authStatus.access;
|
|
953
1006
|
if (!(access === 'unauthorized')) {
|
|
954
|
-
|
|
1007
|
+
_context12.next = 18;
|
|
955
1008
|
break;
|
|
956
1009
|
}
|
|
957
|
-
return
|
|
958
|
-
case 15:
|
|
959
|
-
return _context11.abrupt("return", this.transformer.toSmartlinkAdf(url, preferredAppearance));
|
|
960
|
-
case 16:
|
|
961
|
-
_context11.next = 18;
|
|
962
|
-
break;
|
|
963
|
-
case 17:
|
|
964
|
-
_context11.prev = 17;
|
|
965
|
-
_t9 = _context11["catch"](0);
|
|
966
|
-
// eslint-disable-next-line
|
|
967
|
-
console.warn("Error when trying to check Smart Card url \"".concat(url, "\"").concat(_t9 instanceof Error ? " - ".concat(_t9.name, " ").concat(_t9.message) : ''), _t9);
|
|
1010
|
+
return _context12.abrupt("return", this.transformer.toSmartlinkAdf(url, 'block'));
|
|
968
1011
|
case 18:
|
|
969
|
-
return
|
|
1012
|
+
return _context12.abrupt("return", this.transformer.toSmartlinkAdf(url, preferredAppearance));
|
|
970
1013
|
case 19:
|
|
1014
|
+
_context12.next = 21;
|
|
1015
|
+
break;
|
|
1016
|
+
case 20:
|
|
1017
|
+
_context12.prev = 20;
|
|
1018
|
+
_t1 = _context12["catch"](0);
|
|
1019
|
+
// eslint-disable-next-line
|
|
1020
|
+
console.warn("Error when trying to check Smart Card url \"".concat(url, "\"").concat(_t1 instanceof Error ? " - ".concat(_t1.name, " ").concat(_t1.message) : ''), _t1);
|
|
1021
|
+
case 21:
|
|
1022
|
+
return _context12.abrupt("return", Promise.reject(undefined));
|
|
1023
|
+
case 22:
|
|
971
1024
|
case "end":
|
|
972
|
-
return
|
|
1025
|
+
return _context12.stop();
|
|
973
1026
|
}
|
|
974
|
-
},
|
|
1027
|
+
}, _callee12, this, [[0, 20]]);
|
|
975
1028
|
}));
|
|
976
|
-
function resolve(
|
|
1029
|
+
function resolve(_x10, _x11, _x12, _x13) {
|
|
977
1030
|
return _resolve.apply(this, arguments);
|
|
978
1031
|
}
|
|
979
1032
|
return resolve;
|
package/dist/es2019/provider.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
/* eslint-disable require-unicode-regexp,prefer-regex-literals */
|
|
3
3
|
|
|
4
|
-
import { extractSmartLinkEmbed } from '@atlaskit/link-extractors';
|
|
4
|
+
import { extractSmartLinkEmbed, extractSmartLinkUrl } from '@atlaskit/link-extractors';
|
|
5
5
|
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
6
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
7
|
import { getStatus, getBaseUrl, getResolverUrl } from '@atlaskit/linking-common';
|
|
@@ -55,6 +55,8 @@ const AVP_VISUALIZATION_VIEW_REGEX = /^https:\/\/.*?\/avpviz\/c\/[^\/]+.*/;
|
|
|
55
55
|
const JIRA_WORK_ITEM_REGEX = /\/browse\/((?:\w+)-(?:\d+))/i;
|
|
56
56
|
const DOES_URL_MATCH_PATH_START_REGEX = /^[a-zA-Z0-9]/;
|
|
57
57
|
const DOES_URL_MATCH_PATH_END_REGEX = /[a-zA-Z0-9]$/;
|
|
58
|
+
const CONFLUENCE_SHORT_LINK_URL_REGEX = /^https:\/\/[^/?#]+\/wiki\/x\/[A-Za-z0-9_-]+\/?(?:[?#].*)?$/;
|
|
59
|
+
const isConfluenceShortLinkUrl = url => url.match(CONFLUENCE_SHORT_LINK_URL_REGEX);
|
|
58
60
|
const isJiraRoadmapOrTimeline = url => url.match(JIRA_ROADMAP_OR_TIMELINE_REGEX);
|
|
59
61
|
const isPolarisView = url => url.match(POLARIS_VIEW_REGEX);
|
|
60
62
|
const isJwmView = url => url.match(JWM_VIEW_REGEX);
|
|
@@ -363,6 +365,15 @@ export class EditorCardProvider extends NodeDataProvider {
|
|
|
363
365
|
}
|
|
364
366
|
});
|
|
365
367
|
}
|
|
368
|
+
async resolvesToHardCodedEmbed(url) {
|
|
369
|
+
try {
|
|
370
|
+
const response = await this.fetchData(url);
|
|
371
|
+
const resolvedUrl = extractSmartLinkUrl(response);
|
|
372
|
+
return resolvedUrl !== undefined && this.getHardCodedAppearance(resolvedUrl) === 'embed';
|
|
373
|
+
} catch {
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
366
377
|
|
|
367
378
|
/**
|
|
368
379
|
* Make a /resolve call and find out if result has embed capability
|
|
@@ -483,6 +494,14 @@ export class EditorCardProvider extends NodeDataProvider {
|
|
|
483
494
|
providerDefaultAppearance ||
|
|
484
495
|
// If not, we pick what editor (or any other client) requested
|
|
485
496
|
appearance;
|
|
497
|
+
const isNativeEmbedShortlinkResolutionEnabled = fg('platform_native_embeds_enable_shortlink_resolution');
|
|
498
|
+
const shouldResolveShortLinkForEmbed = isNativeEmbedShortlinkResolutionEnabled && matchedProviderPattern !== undefined && isConfluenceShortLinkUrl(url) && userPreference === undefined && isEmbedFriendlyLocationEvaluated;
|
|
499
|
+
|
|
500
|
+
// Confluence shortlinks do not identify their content type. Resolve the URL before
|
|
501
|
+
// deciding whether it should use one of the existing hardcoded embed appearances.
|
|
502
|
+
if (shouldResolveShortLinkForEmbed && (await this.resolvesToHardCodedEmbed(url))) {
|
|
503
|
+
preferredAppearance = 'embed';
|
|
504
|
+
}
|
|
486
505
|
if (preferredAppearance === userPreference && userPreference === 'embed') {
|
|
487
506
|
const canItBeEmbed = await this.canBeResolvedAsEmbed(url);
|
|
488
507
|
if (!canItBeEmbed) {
|
package/dist/esm/provider.js
CHANGED
|
@@ -16,7 +16,7 @@ function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prot
|
|
|
16
16
|
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); }
|
|
17
17
|
/* eslint-disable require-unicode-regexp,prefer-regex-literals */
|
|
18
18
|
|
|
19
|
-
import { extractSmartLinkEmbed } from '@atlaskit/link-extractors';
|
|
19
|
+
import { extractSmartLinkEmbed, extractSmartLinkUrl } from '@atlaskit/link-extractors';
|
|
20
20
|
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
21
21
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
22
22
|
import { getStatus, getBaseUrl, getResolverUrl } from '@atlaskit/linking-common';
|
|
@@ -86,6 +86,10 @@ var AVP_VISUALIZATION_VIEW_REGEX = /^https:\/\/.*?\/avpviz\/c\/[^\/]+.*/;
|
|
|
86
86
|
var JIRA_WORK_ITEM_REGEX = /\/browse\/((?:\w+)-(?:\d+))/i;
|
|
87
87
|
var DOES_URL_MATCH_PATH_START_REGEX = /^[a-zA-Z0-9]/;
|
|
88
88
|
var DOES_URL_MATCH_PATH_END_REGEX = /[a-zA-Z0-9]$/;
|
|
89
|
+
var CONFLUENCE_SHORT_LINK_URL_REGEX = /^https:\/\/[^/?#]+\/wiki\/x\/[A-Za-z0-9_-]+\/?(?:[?#].*)?$/;
|
|
90
|
+
var isConfluenceShortLinkUrl = function isConfluenceShortLinkUrl(url) {
|
|
91
|
+
return url.match(CONFLUENCE_SHORT_LINK_URL_REGEX);
|
|
92
|
+
};
|
|
89
93
|
var isJiraRoadmapOrTimeline = function isJiraRoadmapOrTimeline(url) {
|
|
90
94
|
return url.match(JIRA_ROADMAP_OR_TIMELINE_REGEX);
|
|
91
95
|
};
|
|
@@ -665,47 +669,77 @@ export var EditorCardProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
665
669
|
}
|
|
666
670
|
return fetchData;
|
|
667
671
|
}()
|
|
672
|
+
}, {
|
|
673
|
+
key: "resolvesToHardCodedEmbed",
|
|
674
|
+
value: function () {
|
|
675
|
+
var _resolvesToHardCodedEmbed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee0(url) {
|
|
676
|
+
var response, resolvedUrl, _t5;
|
|
677
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
678
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
679
|
+
case 0:
|
|
680
|
+
_context0.prev = 0;
|
|
681
|
+
_context0.next = 1;
|
|
682
|
+
return this.fetchData(url);
|
|
683
|
+
case 1:
|
|
684
|
+
response = _context0.sent;
|
|
685
|
+
resolvedUrl = extractSmartLinkUrl(response);
|
|
686
|
+
return _context0.abrupt("return", resolvedUrl !== undefined && this.getHardCodedAppearance(resolvedUrl) === 'embed');
|
|
687
|
+
case 2:
|
|
688
|
+
_context0.prev = 2;
|
|
689
|
+
_t5 = _context0["catch"](0);
|
|
690
|
+
return _context0.abrupt("return", false);
|
|
691
|
+
case 3:
|
|
692
|
+
case "end":
|
|
693
|
+
return _context0.stop();
|
|
694
|
+
}
|
|
695
|
+
}, _callee0, this, [[0, 2]]);
|
|
696
|
+
}));
|
|
697
|
+
function resolvesToHardCodedEmbed(_x8) {
|
|
698
|
+
return _resolvesToHardCodedEmbed.apply(this, arguments);
|
|
699
|
+
}
|
|
700
|
+
return resolvesToHardCodedEmbed;
|
|
701
|
+
}()
|
|
668
702
|
/**
|
|
669
703
|
* Make a /resolve call and find out if result has embed capability
|
|
670
704
|
*/
|
|
671
705
|
}, {
|
|
672
706
|
key: "canBeResolvedAsEmbed",
|
|
673
707
|
value: (function () {
|
|
674
|
-
var _canBeResolvedAsEmbed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
675
|
-
var details, embed,
|
|
676
|
-
return _regeneratorRuntime.wrap(function (
|
|
677
|
-
while (1) switch (
|
|
708
|
+
var _canBeResolvedAsEmbed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee1(url) {
|
|
709
|
+
var details, embed, _t6;
|
|
710
|
+
return _regeneratorRuntime.wrap(function (_context1) {
|
|
711
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
678
712
|
case 0:
|
|
679
|
-
|
|
680
|
-
|
|
713
|
+
_context1.prev = 0;
|
|
714
|
+
_context1.next = 1;
|
|
681
715
|
return this.fetchData(url);
|
|
682
716
|
case 1:
|
|
683
|
-
details =
|
|
717
|
+
details = _context1.sent;
|
|
684
718
|
if (details) {
|
|
685
|
-
|
|
719
|
+
_context1.next = 2;
|
|
686
720
|
break;
|
|
687
721
|
}
|
|
688
|
-
return
|
|
722
|
+
return _context1.abrupt("return", false);
|
|
689
723
|
case 2:
|
|
690
724
|
if (!(getStatus(details) !== 'resolved')) {
|
|
691
|
-
|
|
725
|
+
_context1.next = 3;
|
|
692
726
|
break;
|
|
693
727
|
}
|
|
694
|
-
return
|
|
728
|
+
return _context1.abrupt("return", false);
|
|
695
729
|
case 3:
|
|
696
730
|
embed = extractSmartLinkEmbed(details);
|
|
697
|
-
return
|
|
731
|
+
return _context1.abrupt("return", !!embed);
|
|
698
732
|
case 4:
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
return
|
|
733
|
+
_context1.prev = 4;
|
|
734
|
+
_t6 = _context1["catch"](0);
|
|
735
|
+
return _context1.abrupt("return", false);
|
|
702
736
|
case 5:
|
|
703
737
|
case "end":
|
|
704
|
-
return
|
|
738
|
+
return _context1.stop();
|
|
705
739
|
}
|
|
706
|
-
},
|
|
740
|
+
}, _callee1, this, [[0, 4]]);
|
|
707
741
|
}));
|
|
708
|
-
function canBeResolvedAsEmbed(
|
|
742
|
+
function canBeResolvedAsEmbed(_x9) {
|
|
709
743
|
return _canBeResolvedAsEmbed.apply(this, arguments);
|
|
710
744
|
}
|
|
711
745
|
return canBeResolvedAsEmbed;
|
|
@@ -729,34 +763,34 @@ export var EditorCardProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
729
763
|
}, {
|
|
730
764
|
key: "getAuthStatusFromResolveResponse",
|
|
731
765
|
value: function () {
|
|
732
|
-
var _getAuthStatusFromResolveResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
733
|
-
var _yield$this$fetchData, _yield$this$fetchData2, access, visibility,
|
|
734
|
-
return _regeneratorRuntime.wrap(function (
|
|
735
|
-
while (1) switch (
|
|
766
|
+
var _getAuthStatusFromResolveResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(url) {
|
|
767
|
+
var _yield$this$fetchData, _yield$this$fetchData2, access, visibility, _t7;
|
|
768
|
+
return _regeneratorRuntime.wrap(function (_context10) {
|
|
769
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
736
770
|
case 0:
|
|
737
|
-
|
|
738
|
-
|
|
771
|
+
_context10.prev = 0;
|
|
772
|
+
_context10.next = 1;
|
|
739
773
|
return this.fetchData(url);
|
|
740
774
|
case 1:
|
|
741
|
-
_yield$this$fetchData =
|
|
775
|
+
_yield$this$fetchData = _context10.sent;
|
|
742
776
|
_yield$this$fetchData2 = _yield$this$fetchData.meta;
|
|
743
777
|
access = _yield$this$fetchData2.access;
|
|
744
778
|
visibility = _yield$this$fetchData2.visibility;
|
|
745
|
-
return
|
|
779
|
+
return _context10.abrupt("return", {
|
|
746
780
|
access: access,
|
|
747
781
|
visibility: visibility
|
|
748
782
|
});
|
|
749
783
|
case 2:
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
return
|
|
784
|
+
_context10.prev = 2;
|
|
785
|
+
_t7 = _context10["catch"](0);
|
|
786
|
+
return _context10.abrupt("return", undefined);
|
|
753
787
|
case 3:
|
|
754
788
|
case "end":
|
|
755
|
-
return
|
|
789
|
+
return _context10.stop();
|
|
756
790
|
}
|
|
757
|
-
},
|
|
791
|
+
}, _callee10, this, [[0, 2]]);
|
|
758
792
|
}));
|
|
759
|
-
function getAuthStatusFromResolveResponse(
|
|
793
|
+
function getAuthStatusFromResolveResponse(_x0) {
|
|
760
794
|
return _getAuthStatusFromResolveResponse.apply(this, arguments);
|
|
761
795
|
}
|
|
762
796
|
return getAuthStatusFromResolveResponse;
|
|
@@ -767,36 +801,36 @@ export var EditorCardProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
767
801
|
}, {
|
|
768
802
|
key: "getDatasourceFromResolveResponse",
|
|
769
803
|
value: (function () {
|
|
770
|
-
var _getDatasourceFromResolveResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
771
|
-
var response, datasources,
|
|
772
|
-
return _regeneratorRuntime.wrap(function (
|
|
773
|
-
while (1) switch (
|
|
804
|
+
var _getDatasourceFromResolveResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(url) {
|
|
805
|
+
var response, datasources, _t8;
|
|
806
|
+
return _regeneratorRuntime.wrap(function (_context11) {
|
|
807
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
774
808
|
case 0:
|
|
775
|
-
|
|
776
|
-
|
|
809
|
+
_context11.prev = 0;
|
|
810
|
+
_context11.next = 1;
|
|
777
811
|
return this.fetchData(url);
|
|
778
812
|
case 1:
|
|
779
|
-
response =
|
|
813
|
+
response = _context11.sent;
|
|
780
814
|
datasources = response && response.datasources || [];
|
|
781
815
|
if (!(datasources.length > 0)) {
|
|
782
|
-
|
|
816
|
+
_context11.next = 2;
|
|
783
817
|
break;
|
|
784
818
|
}
|
|
785
|
-
return
|
|
819
|
+
return _context11.abrupt("return", datasources[0]);
|
|
786
820
|
case 2:
|
|
787
|
-
|
|
821
|
+
_context11.next = 4;
|
|
788
822
|
break;
|
|
789
823
|
case 3:
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
return
|
|
824
|
+
_context11.prev = 3;
|
|
825
|
+
_t8 = _context11["catch"](0);
|
|
826
|
+
return _context11.abrupt("return", undefined);
|
|
793
827
|
case 4:
|
|
794
828
|
case "end":
|
|
795
|
-
return
|
|
829
|
+
return _context11.stop();
|
|
796
830
|
}
|
|
797
|
-
},
|
|
831
|
+
}, _callee11, this, [[0, 3]]);
|
|
798
832
|
}));
|
|
799
|
-
function getDatasourceFromResolveResponse(
|
|
833
|
+
function getDatasourceFromResolveResponse(_x1) {
|
|
800
834
|
return _getDatasourceFromResolveResponse.apply(this, arguments);
|
|
801
835
|
}
|
|
802
836
|
return getDatasourceFromResolveResponse;
|
|
@@ -813,38 +847,38 @@ export var EditorCardProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
813
847
|
}, {
|
|
814
848
|
key: "resolve",
|
|
815
849
|
value: function () {
|
|
816
|
-
var _resolve = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
817
|
-
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,
|
|
818
|
-
return _regeneratorRuntime.wrap(function (
|
|
819
|
-
while (1) switch (
|
|
850
|
+
var _resolve = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(url, appearance, shouldForceAppearance, isEmbedFriendlyLocation) {
|
|
851
|
+
var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, data, issueAri, _this$onResolve, isSupported, providerDefaultAppearance, isEmbedFriendlyLocationEvaluated, preferredAppearance, isNativeEmbedShortlinkResolutionEnabled, shouldResolveShortLinkForEmbed, canItBeEmbed, _canItBeEmbed, datasource, id, parameters, authStatus, access, _t9, _t0, _t1;
|
|
852
|
+
return _regeneratorRuntime.wrap(function (_context12) {
|
|
853
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
820
854
|
case 0:
|
|
821
|
-
|
|
855
|
+
_context12.prev = 0;
|
|
822
856
|
if (!(shouldForceAppearance === true)) {
|
|
823
|
-
|
|
857
|
+
_context12.next = 1;
|
|
824
858
|
break;
|
|
825
859
|
}
|
|
826
|
-
return
|
|
860
|
+
return _context12.abrupt("return", this.transformer.toSmartlinkAdf(url, appearance));
|
|
827
861
|
case 1:
|
|
828
862
|
hardCodedAppearance = this.getHardCodedAppearance(url);
|
|
829
|
-
|
|
863
|
+
_context12.next = 2;
|
|
830
864
|
return Promise.all([this.findPatternData(url), this.findUserPreference(url)]);
|
|
831
865
|
case 2:
|
|
832
|
-
_yield$Promise$all =
|
|
866
|
+
_yield$Promise$all = _context12.sent;
|
|
833
867
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
834
868
|
matchedProviderPattern = _yield$Promise$all2[0];
|
|
835
869
|
userPreference = _yield$Promise$all2[1];
|
|
836
870
|
if (!fg('issue-link-suggestions-in-comments')) {
|
|
837
|
-
|
|
871
|
+
_context12.next = 4;
|
|
838
872
|
break;
|
|
839
873
|
}
|
|
840
874
|
if (!(isJiraWorkItem(url) && this.isLocalUrl(url))) {
|
|
841
|
-
|
|
875
|
+
_context12.next = 4;
|
|
842
876
|
break;
|
|
843
877
|
}
|
|
844
|
-
|
|
878
|
+
_context12.next = 3;
|
|
845
879
|
return this.fetchDataForResource(url);
|
|
846
880
|
case 3:
|
|
847
|
-
data =
|
|
881
|
+
data = _context12.sent;
|
|
848
882
|
if (data) {
|
|
849
883
|
issueAri = this.extractAriFromData(data);
|
|
850
884
|
if (issueAri) {
|
|
@@ -853,24 +887,24 @@ export var EditorCardProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
853
887
|
}
|
|
854
888
|
case 4:
|
|
855
889
|
if (!(shouldForceAppearance === false && userPreference === 'url')) {
|
|
856
|
-
|
|
890
|
+
_context12.next = 5;
|
|
857
891
|
break;
|
|
858
892
|
}
|
|
859
|
-
return
|
|
893
|
+
return _context12.abrupt("return", Promise.reject(undefined));
|
|
860
894
|
case 5:
|
|
861
|
-
|
|
862
|
-
if (
|
|
863
|
-
|
|
895
|
+
_t9 = !!matchedProviderPattern;
|
|
896
|
+
if (_t9) {
|
|
897
|
+
_context12.next = 7;
|
|
864
898
|
break;
|
|
865
899
|
}
|
|
866
|
-
|
|
900
|
+
_context12.next = 6;
|
|
867
901
|
return this.checkLinkResolved(url);
|
|
868
902
|
case 6:
|
|
869
|
-
|
|
903
|
+
_t9 = _context12.sent;
|
|
870
904
|
case 7:
|
|
871
|
-
isSupported =
|
|
905
|
+
isSupported = _t9;
|
|
872
906
|
if (!isSupported) {
|
|
873
|
-
|
|
907
|
+
_context12.next = 19;
|
|
874
908
|
break;
|
|
875
909
|
}
|
|
876
910
|
providerDefaultAppearance = matchedProviderPattern === null || matchedProviderPattern === void 0 ? void 0 : matchedProviderPattern.defaultView;
|
|
@@ -888,38 +922,57 @@ export var EditorCardProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
888
922
|
providerDefaultAppearance ||
|
|
889
923
|
// If not, we pick what editor (or any other client) requested
|
|
890
924
|
appearance;
|
|
925
|
+
isNativeEmbedShortlinkResolutionEnabled = fg('platform_native_embeds_enable_shortlink_resolution');
|
|
926
|
+
shouldResolveShortLinkForEmbed = isNativeEmbedShortlinkResolutionEnabled && matchedProviderPattern !== undefined && isConfluenceShortLinkUrl(url) && userPreference === undefined && isEmbedFriendlyLocationEvaluated; // Confluence shortlinks do not identify their content type. Resolve the URL before
|
|
927
|
+
// deciding whether it should use one of the existing hardcoded embed appearances.
|
|
928
|
+
_t0 = shouldResolveShortLinkForEmbed;
|
|
929
|
+
if (!_t0) {
|
|
930
|
+
_context12.next = 9;
|
|
931
|
+
break;
|
|
932
|
+
}
|
|
933
|
+
_context12.next = 8;
|
|
934
|
+
return this.resolvesToHardCodedEmbed(url);
|
|
935
|
+
case 8:
|
|
936
|
+
_t0 = _context12.sent;
|
|
937
|
+
case 9:
|
|
938
|
+
if (!_t0) {
|
|
939
|
+
_context12.next = 10;
|
|
940
|
+
break;
|
|
941
|
+
}
|
|
942
|
+
preferredAppearance = 'embed';
|
|
943
|
+
case 10:
|
|
891
944
|
if (!(preferredAppearance === userPreference && userPreference === 'embed')) {
|
|
892
|
-
|
|
945
|
+
_context12.next = 12;
|
|
893
946
|
break;
|
|
894
947
|
}
|
|
895
|
-
|
|
948
|
+
_context12.next = 11;
|
|
896
949
|
return this.canBeResolvedAsEmbed(url);
|
|
897
|
-
case
|
|
898
|
-
canItBeEmbed =
|
|
950
|
+
case 11:
|
|
951
|
+
canItBeEmbed = _context12.sent;
|
|
899
952
|
if (!canItBeEmbed) {
|
|
900
953
|
preferredAppearance = 'inline';
|
|
901
954
|
}
|
|
902
|
-
case
|
|
955
|
+
case 12:
|
|
903
956
|
if (!(!userPreference && appearance === 'embed' && isEmbedFriendlyLocationEvaluated && this.shouldHonorRequestedEmbedAsDefault())) {
|
|
904
|
-
|
|
957
|
+
_context12.next = 14;
|
|
905
958
|
break;
|
|
906
959
|
}
|
|
907
|
-
|
|
960
|
+
_context12.next = 13;
|
|
908
961
|
return this.canBeResolvedAsEmbed(url);
|
|
909
|
-
case
|
|
910
|
-
_canItBeEmbed =
|
|
962
|
+
case 13:
|
|
963
|
+
_canItBeEmbed = _context12.sent;
|
|
911
964
|
preferredAppearance = _canItBeEmbed ? 'embed' : 'block';
|
|
912
|
-
case
|
|
913
|
-
|
|
965
|
+
case 14:
|
|
966
|
+
_context12.next = 15;
|
|
914
967
|
return this.getDatasourceFromResolveResponse(url);
|
|
915
|
-
case
|
|
916
|
-
datasource =
|
|
968
|
+
case 15:
|
|
969
|
+
datasource = _context12.sent;
|
|
917
970
|
if (!datasource) {
|
|
918
|
-
|
|
971
|
+
_context12.next = 16;
|
|
919
972
|
break;
|
|
920
973
|
}
|
|
921
974
|
id = datasource.id, parameters = datasource.parameters;
|
|
922
|
-
return
|
|
975
|
+
return _context12.abrupt("return", this.transformer.toDatasourceAdf({
|
|
923
976
|
id: id,
|
|
924
977
|
parameters: parameters,
|
|
925
978
|
// in the future when we support multiple views, we will need to pass this in as a parameter
|
|
@@ -928,44 +981,44 @@ export var EditorCardProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
928
981
|
type: 'table'
|
|
929
982
|
}]
|
|
930
983
|
}, url));
|
|
931
|
-
case
|
|
984
|
+
case 16:
|
|
932
985
|
if (!(isEmbedFriendlyLocationEvaluated && !userPreference)) {
|
|
933
|
-
|
|
986
|
+
_context12.next = 18;
|
|
934
987
|
break;
|
|
935
988
|
}
|
|
936
|
-
|
|
989
|
+
_context12.next = 17;
|
|
937
990
|
return this.getAuthStatusFromResolveResponse(url);
|
|
938
|
-
case
|
|
939
|
-
authStatus =
|
|
991
|
+
case 17:
|
|
992
|
+
authStatus = _context12.sent;
|
|
940
993
|
if (!authStatus) {
|
|
941
|
-
|
|
994
|
+
_context12.next = 18;
|
|
942
995
|
break;
|
|
943
996
|
}
|
|
944
997
|
access = authStatus.access;
|
|
945
998
|
if (!(access === 'unauthorized')) {
|
|
946
|
-
|
|
999
|
+
_context12.next = 18;
|
|
947
1000
|
break;
|
|
948
1001
|
}
|
|
949
|
-
return
|
|
950
|
-
case 15:
|
|
951
|
-
return _context11.abrupt("return", this.transformer.toSmartlinkAdf(url, preferredAppearance));
|
|
952
|
-
case 16:
|
|
953
|
-
_context11.next = 18;
|
|
954
|
-
break;
|
|
955
|
-
case 17:
|
|
956
|
-
_context11.prev = 17;
|
|
957
|
-
_t9 = _context11["catch"](0);
|
|
958
|
-
// eslint-disable-next-line
|
|
959
|
-
console.warn("Error when trying to check Smart Card url \"".concat(url, "\"").concat(_t9 instanceof Error ? " - ".concat(_t9.name, " ").concat(_t9.message) : ''), _t9);
|
|
1002
|
+
return _context12.abrupt("return", this.transformer.toSmartlinkAdf(url, 'block'));
|
|
960
1003
|
case 18:
|
|
961
|
-
return
|
|
1004
|
+
return _context12.abrupt("return", this.transformer.toSmartlinkAdf(url, preferredAppearance));
|
|
962
1005
|
case 19:
|
|
1006
|
+
_context12.next = 21;
|
|
1007
|
+
break;
|
|
1008
|
+
case 20:
|
|
1009
|
+
_context12.prev = 20;
|
|
1010
|
+
_t1 = _context12["catch"](0);
|
|
1011
|
+
// eslint-disable-next-line
|
|
1012
|
+
console.warn("Error when trying to check Smart Card url \"".concat(url, "\"").concat(_t1 instanceof Error ? " - ".concat(_t1.name, " ").concat(_t1.message) : ''), _t1);
|
|
1013
|
+
case 21:
|
|
1014
|
+
return _context12.abrupt("return", Promise.reject(undefined));
|
|
1015
|
+
case 22:
|
|
963
1016
|
case "end":
|
|
964
|
-
return
|
|
1017
|
+
return _context12.stop();
|
|
965
1018
|
}
|
|
966
|
-
},
|
|
1019
|
+
}, _callee12, this, [[0, 20]]);
|
|
967
1020
|
}));
|
|
968
|
-
function resolve(
|
|
1021
|
+
function resolve(_x10, _x11, _x12, _x13) {
|
|
969
1022
|
return _resolve.apply(this, arguments);
|
|
970
1023
|
}
|
|
971
1024
|
return resolve;
|
package/dist/types/provider.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export declare class EditorCardProvider extends NodeDataProvider<CardNode, JsonL
|
|
|
61
61
|
*/
|
|
62
62
|
protected getHardCodedAppearance(url: string): CardAppearance | undefined;
|
|
63
63
|
private fetchData;
|
|
64
|
+
private resolvesToHardCodedEmbed;
|
|
64
65
|
/**
|
|
65
66
|
* Make a /resolve call and find out if result has embed capability
|
|
66
67
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-card-provider",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.28",
|
|
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",
|
|
@@ -58,6 +58,9 @@
|
|
|
58
58
|
},
|
|
59
59
|
"loom-support-screenshot-sl-resolution": {
|
|
60
60
|
"type": "boolean"
|
|
61
|
+
},
|
|
62
|
+
"platform_native_embeds_enable_shortlink_resolution": {
|
|
63
|
+
"type": "boolean"
|
|
61
64
|
}
|
|
62
65
|
},
|
|
63
66
|
"compassUnitTestMetricSourceId": "ari:cloud:compass:a436116f-02ce-4520-8fbb-7301462a1674:metric-source/c5751cc6-3513-4070-9deb-af31e86aed34/e145f3e3-514b-410f-a274-a92e6e6f9c47"
|