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