@atlaskit/smart-card 23.14.2 → 23.14.3
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/dist/cjs/extractors/block/index.js +4 -3
- package/dist/cjs/extractors/common/actions/extractPreviewAction.js +5 -2
- package/dist/cjs/extractors/common/meta/extractIsSupportTheming.js +11 -0
- package/dist/cjs/extractors/constants.js +6 -2
- package/dist/cjs/extractors/embed/index.js +3 -1
- package/dist/cjs/extractors/flexible/actions/extract-preview-action.js +4 -1
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/BlockCard/views/ResolvedView.js +2 -1
- package/dist/cjs/view/EmbedCard/views/ResolvedView.js +10 -2
- package/dist/cjs/view/EmbedModal/index.js +10 -2
- package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +4 -2
- package/dist/es2019/extractors/block/index.js +4 -3
- package/dist/es2019/extractors/common/actions/extractPreviewAction.js +5 -2
- package/dist/es2019/extractors/common/meta/extractIsSupportTheming.js +4 -0
- package/dist/es2019/extractors/constants.js +4 -1
- package/dist/es2019/extractors/embed/index.js +3 -1
- package/dist/es2019/extractors/flexible/actions/extract-preview-action.js +4 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/BlockCard/views/ResolvedView.js +2 -1
- package/dist/es2019/view/EmbedCard/views/ResolvedView.js +11 -2
- package/dist/es2019/view/EmbedModal/index.js +11 -2
- package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +4 -2
- package/dist/esm/extractors/block/index.js +4 -3
- package/dist/esm/extractors/common/actions/extractPreviewAction.js +5 -2
- package/dist/esm/extractors/common/meta/extractIsSupportTheming.js +4 -0
- package/dist/esm/extractors/constants.js +4 -1
- package/dist/esm/extractors/embed/index.js +3 -1
- package/dist/esm/extractors/flexible/actions/extract-preview-action.js +4 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/BlockCard/views/ResolvedView.js +2 -1
- package/dist/esm/view/EmbedCard/views/ResolvedView.js +10 -2
- package/dist/esm/view/EmbedModal/index.js +10 -2
- package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +4 -2
- package/dist/types/extractors/block/index.d.ts +1 -1
- package/dist/types/extractors/common/actions/extractPreviewAction.d.ts +2 -1
- package/dist/types/extractors/common/meta/extractIsSupportTheming.d.ts +2 -0
- package/dist/types/extractors/constants.d.ts +1 -0
- package/dist/types/state/flexible-ui-context/types.d.ts +1 -0
- package/dist/types/view/BlockCard/actions/PreviewAction.d.ts +1 -0
- package/dist/types/view/BlockCard/views/ResolvedView.d.ts +3 -1
- package/dist/types/view/EmbedCard/views/ResolvedView.d.ts +1 -0
- package/dist/types/view/EmbedModal/index.d.ts +1 -0
- package/dist/types/view/EmbedModal/types.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +1 -0
- package/package.json +1 -1
- package/tmp/api-report-tmp.d.ts +0 -870
|
@@ -35,14 +35,15 @@ var extractBlockDetails = function extractBlockDetails(jsonLd) {
|
|
|
35
35
|
return !!detail;
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
|
-
var extractBlockActions = function extractBlockActions(props, jsonLd, opts, platform) {
|
|
38
|
+
var extractBlockActions = function extractBlockActions(props, jsonLd, opts, platform, meta) {
|
|
39
39
|
if (opts) {
|
|
40
40
|
var handleInvoke = opts.handleInvoke;
|
|
41
41
|
var actions = (0, _extractActions.extractActions)(jsonLd, handleInvoke);
|
|
42
42
|
var previewAction = (0, _extractPreviewAction.extractPreviewAction)(_objectSpread(_objectSpread({}, opts), {}, {
|
|
43
43
|
viewProps: props,
|
|
44
44
|
jsonLd: jsonLd,
|
|
45
|
-
platform: platform
|
|
45
|
+
platform: platform,
|
|
46
|
+
meta: meta
|
|
46
47
|
}));
|
|
47
48
|
|
|
48
49
|
// The previewAction should always be the last action
|
|
@@ -91,7 +92,7 @@ var extractBlockProps = function extractBlockProps(jsonLd, meta, opts, renderers
|
|
|
91
92
|
isTrusted: (0, _extractIsTrusted.extractIsTrusted)(meta)
|
|
92
93
|
};
|
|
93
94
|
return _objectSpread(_objectSpread({}, props), {}, {
|
|
94
|
-
actions: extractBlockActions(props, jsonLd, opts, platform)
|
|
95
|
+
actions: extractBlockActions(props, jsonLd, opts, platform, meta)
|
|
95
96
|
});
|
|
96
97
|
};
|
|
97
98
|
exports.extractBlockProps = extractBlockProps;
|
|
@@ -10,6 +10,7 @@ var _detail = require("../detail");
|
|
|
10
10
|
var _extractors = require("@atlaskit/linking-common/extractors");
|
|
11
11
|
var _BlockCard = require("../../../view/BlockCard");
|
|
12
12
|
var _constants = require("../../../constants");
|
|
13
|
+
var _extractIsSupportTheming = require("../../common/meta/extractIsSupportTheming");
|
|
13
14
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
15
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
16
|
var getMetadataFromJsonLd = function getMetadataFromJsonLd(jsonLd, platform) {
|
|
@@ -62,7 +63,8 @@ var extractPreviewAction = function extractPreviewAction(_ref) {
|
|
|
62
63
|
origin = _ref.origin,
|
|
63
64
|
_ref$source = _ref.source,
|
|
64
65
|
source = _ref$source === void 0 ? 'block' : _ref$source,
|
|
65
|
-
analytics = _ref.analytics
|
|
66
|
+
analytics = _ref.analytics,
|
|
67
|
+
meta = _ref.meta;
|
|
66
68
|
// Extract metadata from view props & raw JSON-LD.
|
|
67
69
|
var metadataFromJsonLd = getMetadataFromJsonLd(jsonLd, platform);
|
|
68
70
|
var metadataFromViewProps = getMetadataFromResolvedProps(viewProps);
|
|
@@ -80,7 +82,8 @@ var extractPreviewAction = function extractPreviewAction(_ref) {
|
|
|
80
82
|
},
|
|
81
83
|
onViewActionClick: function onViewActionClick() {
|
|
82
84
|
handleInvoke(getInvokeOpts(key, 'ViewAction'));
|
|
83
|
-
}
|
|
85
|
+
},
|
|
86
|
+
isSupportTheming: (0, _extractIsSupportTheming.extractIsSupportTheming)(meta)
|
|
84
87
|
}));
|
|
85
88
|
// Setup props to go through proper Redux 'invocation' flow
|
|
86
89
|
// for analytics, further state management if required in future.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.extractIsSupportTheming = void 0;
|
|
7
|
+
var _constants = require("../../constants");
|
|
8
|
+
var extractIsSupportTheming = function extractIsSupportTheming(meta) {
|
|
9
|
+
return Boolean((meta === null || meta === void 0 ? void 0 : meta.key) && _constants.PROVIDER_KEYS_WITH_THEMING.includes(meta.key));
|
|
10
|
+
};
|
|
11
|
+
exports.extractIsSupportTheming = extractIsSupportTheming;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.JIRA_TASK = exports.JIRA_SUB_TASK = exports.JIRA_STORY = exports.JIRA_SERVICE_REQUEST = exports.JIRA_PROBLEM = exports.JIRA_INCIDENT = exports.JIRA_GENERATOR_ID = exports.JIRA_EPIC = exports.JIRA_CUSTOM_TASK_TYPE = exports.JIRA_CHANGE = exports.JIRA_BUG = exports.CONFLUENCE_GENERATOR_ID = void 0;
|
|
6
|
+
exports.PROVIDER_KEYS_WITH_THEMING = exports.JIRA_TASK = exports.JIRA_SUB_TASK = exports.JIRA_STORY = exports.JIRA_SERVICE_REQUEST = exports.JIRA_PROBLEM = exports.JIRA_INCIDENT = exports.JIRA_GENERATOR_ID = exports.JIRA_EPIC = exports.JIRA_CUSTOM_TASK_TYPE = exports.JIRA_CHANGE = exports.JIRA_BUG = exports.CONFLUENCE_GENERATOR_ID = void 0;
|
|
7
7
|
var CONFLUENCE_GENERATOR_ID = 'https://www.atlassian.com/#Confluence';
|
|
8
8
|
exports.CONFLUENCE_GENERATOR_ID = CONFLUENCE_GENERATOR_ID;
|
|
9
9
|
var JIRA_GENERATOR_ID = 'https://www.atlassian.com/#Jira';
|
|
@@ -28,4 +28,8 @@ exports.JIRA_CHANGE = JIRA_CHANGE;
|
|
|
28
28
|
var JIRA_PROBLEM = 'JiraProblem';
|
|
29
29
|
exports.JIRA_PROBLEM = JIRA_PROBLEM;
|
|
30
30
|
var JIRA_CUSTOM_TASK_TYPE = 'JiraCustomTaskType';
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
//List of provider keys that support theme modes for the embedded content.
|
|
33
|
+
exports.JIRA_CUSTOM_TASK_TYPE = JIRA_CUSTOM_TASK_TYPE;
|
|
34
|
+
var PROVIDER_KEYS_WITH_THEMING = ['jira-object-provider', 'confluence-object-provider', 'watermelon-object-provider'];
|
|
35
|
+
exports.PROVIDER_KEYS_WITH_THEMING = PROVIDER_KEYS_WITH_THEMING;
|
|
@@ -8,6 +8,7 @@ exports.extractEmbedProps = void 0;
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _extractors = require("@atlaskit/linking-common/extractors");
|
|
10
10
|
var _extractIsTrusted = require("../common/meta/extractIsTrusted");
|
|
11
|
+
var _extractIsSupportTheming = require("../common/meta/extractIsSupportTheming");
|
|
11
12
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
14
|
var extractEmbedPreview = function extractEmbedPreview(jsonLd, platform) {
|
|
@@ -24,7 +25,8 @@ var extractEmbedProps = function extractEmbedProps(jsonLd, meta, platform) {
|
|
|
24
25
|
title: (0, _extractors.extractTitle)(jsonLd),
|
|
25
26
|
context: (0, _extractors.extractProvider)(jsonLd),
|
|
26
27
|
preview: extractEmbedPreview(jsonLd, platform),
|
|
27
|
-
isTrusted: (0, _extractIsTrusted.extractIsTrusted)(meta)
|
|
28
|
+
isTrusted: (0, _extractIsTrusted.extractIsTrusted)(meta),
|
|
29
|
+
isSupportTheming: (0, _extractIsSupportTheming.extractIsSupportTheming)(meta)
|
|
28
30
|
};
|
|
29
31
|
};
|
|
30
32
|
exports.extractEmbedProps = extractEmbedProps;
|
|
@@ -8,9 +8,11 @@ var _detail = require("../../common/detail");
|
|
|
8
8
|
var _linkingCommon = require("@atlaskit/linking-common");
|
|
9
9
|
var _extractors = require("@atlaskit/linking-common/extractors");
|
|
10
10
|
var _icon = require("../icon");
|
|
11
|
+
var _extractIsSupportTheming = require("../../common/meta/extractIsSupportTheming");
|
|
11
12
|
var extractPreviewAction = function extractPreviewAction(response) {
|
|
12
13
|
var _extractPreviewData;
|
|
13
14
|
var data = response.data;
|
|
15
|
+
var meta = response.meta;
|
|
14
16
|
var src = (_extractPreviewData = (0, _linkingCommon.extractPreview)(data, 'web')) === null || _extractPreviewData === void 0 ? void 0 : _extractPreviewData.src;
|
|
15
17
|
if (src) {
|
|
16
18
|
var _extractProvider;
|
|
@@ -20,7 +22,8 @@ var extractPreviewAction = function extractPreviewAction(response) {
|
|
|
20
22
|
src: src,
|
|
21
23
|
title: (0, _extractors.extractTitle)(data),
|
|
22
24
|
linkIcon: (0, _icon.extractLinkIcon)(response),
|
|
23
|
-
url: (0, _extractors.extractLink)(data)
|
|
25
|
+
url: (0, _extractors.extractLink)(data),
|
|
26
|
+
isSupportTheming: (0, _extractIsSupportTheming.extractIsSupportTheming)(meta)
|
|
24
27
|
};
|
|
25
28
|
}
|
|
26
29
|
};
|
package/dist/cjs/version.json
CHANGED
|
@@ -63,7 +63,8 @@ var ResolvedView = function ResolvedView(_ref) {
|
|
|
63
63
|
_ref$testId = _ref.testId,
|
|
64
64
|
testId = _ref$testId === void 0 ? 'block-card-resolved-view' : _ref$testId,
|
|
65
65
|
_ref$showActions = _ref.showActions,
|
|
66
|
-
showActions = _ref$showActions === void 0 ? true : _ref$showActions
|
|
66
|
+
showActions = _ref$showActions === void 0 ? true : _ref$showActions,
|
|
67
|
+
isSupportTheming = _ref.isSupportTheming;
|
|
67
68
|
var resolvedMetadata = details.length > 0 ? (0, _react.jsx)(_MetadataList.MetadataList, {
|
|
68
69
|
testId: testId ? "".concat(testId, "-meta") : undefined,
|
|
69
70
|
items: details
|
|
@@ -11,6 +11,7 @@ var _link = _interopRequireDefault(require("@atlaskit/icon/glyph/link"));
|
|
|
11
11
|
var _ExpandedFrame = require("../components/ExpandedFrame");
|
|
12
12
|
var _ImageIcon = require("../components/ImageIcon");
|
|
13
13
|
var _Frame = require("../components/Frame");
|
|
14
|
+
var _tokens = require("@atlaskit/tokens");
|
|
14
15
|
/** @jsx jsx */
|
|
15
16
|
|
|
16
17
|
var EmbedCardResolvedView = /*#__PURE__*/_react2.default.forwardRef(function (_ref, embedIframeRef) {
|
|
@@ -26,7 +27,8 @@ var EmbedCardResolvedView = /*#__PURE__*/_react2.default.forwardRef(function (_r
|
|
|
26
27
|
testId = _ref$testId === void 0 ? 'embed-card-resolved-view' : _ref$testId,
|
|
27
28
|
inheritDimensions = _ref.inheritDimensions,
|
|
28
29
|
onIframeDwell = _ref.onIframeDwell,
|
|
29
|
-
onIframeFocus = _ref.onIframeFocus
|
|
30
|
+
onIframeFocus = _ref.onIframeFocus,
|
|
31
|
+
isSupportTheming = _ref.isSupportTheming;
|
|
30
32
|
var iconFromContext = context === null || context === void 0 ? void 0 : context.icon;
|
|
31
33
|
var src = typeof iconFromContext === 'string' ? iconFromContext : undefined;
|
|
32
34
|
var text = title || (context === null || context === void 0 ? void 0 : context.text);
|
|
@@ -46,6 +48,12 @@ var EmbedCardResolvedView = /*#__PURE__*/_react2.default.forwardRef(function (_r
|
|
|
46
48
|
default: linkGlyph
|
|
47
49
|
});
|
|
48
50
|
}, [src, linkGlyph, iconFromContext]);
|
|
51
|
+
var _useThemeObserver = (0, _tokens.useThemeObserver)(),
|
|
52
|
+
colorMode = _useThemeObserver.colorMode;
|
|
53
|
+
var previewUrl = preview === null || preview === void 0 ? void 0 : preview.src;
|
|
54
|
+
if (previewUrl && isSupportTheming && colorMode) {
|
|
55
|
+
previewUrl = "".concat(previewUrl).concat(previewUrl.includes('?') ? '&' : '?', "themeMode=").concat(colorMode);
|
|
56
|
+
}
|
|
49
57
|
return (0, _react.jsx)(_ExpandedFrame.ExpandedFrame, {
|
|
50
58
|
isSelected: isSelected,
|
|
51
59
|
isFrameVisible: isFrameVisible,
|
|
@@ -56,7 +64,7 @@ var EmbedCardResolvedView = /*#__PURE__*/_react2.default.forwardRef(function (_r
|
|
|
56
64
|
onClick: onClick,
|
|
57
65
|
inheritDimensions: inheritDimensions
|
|
58
66
|
}, (0, _react.jsx)(_Frame.Frame, {
|
|
59
|
-
url:
|
|
67
|
+
url: previewUrl,
|
|
60
68
|
isTrusted: isTrusted,
|
|
61
69
|
testId: testId,
|
|
62
70
|
ref: embedIframeRef,
|
|
@@ -15,6 +15,7 @@ var _embedContent = _interopRequireDefault(require("./components/embed-content")
|
|
|
15
15
|
var _types = require("./types");
|
|
16
16
|
var _errorBoundary = _interopRequireDefault(require("./components/error-boundary"));
|
|
17
17
|
var _analytics = _interopRequireDefault(require("./components/analytics"));
|
|
18
|
+
var _tokens = require("@atlaskit/tokens");
|
|
18
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
21
|
var toSize = function toSize(width) {
|
|
@@ -42,7 +43,8 @@ var EmbedModal = function EmbedModal(_ref) {
|
|
|
42
43
|
_ref$testId = _ref.testId,
|
|
43
44
|
testId = _ref$testId === void 0 ? 'smart-embed-preview-modal' : _ref$testId,
|
|
44
45
|
title = _ref.title,
|
|
45
|
-
url = _ref.url
|
|
46
|
+
url = _ref.url,
|
|
47
|
+
isSupportTheming = _ref.isSupportTheming;
|
|
46
48
|
var defaultWidth = toWidth(size);
|
|
47
49
|
var _useState = (0, _react.useState)(showModal),
|
|
48
50
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -82,6 +84,12 @@ var EmbedModal = function EmbedModal(_ref) {
|
|
|
82
84
|
});
|
|
83
85
|
}
|
|
84
86
|
}, [onResize, width]);
|
|
87
|
+
var _useThemeObserver = (0, _tokens.useThemeObserver)(),
|
|
88
|
+
colorMode = _useThemeObserver.colorMode;
|
|
89
|
+
var previewUrl = src;
|
|
90
|
+
if (previewUrl && isSupportTheming && colorMode) {
|
|
91
|
+
previewUrl = "".concat(previewUrl).concat(previewUrl.includes('?') ? '&' : '?', "themeMode=").concat(colorMode);
|
|
92
|
+
}
|
|
85
93
|
return /*#__PURE__*/_react.default.createElement(_modalDialog.ModalTransition, null, isOpen && /*#__PURE__*/_react.default.createElement(_modalDialog.default, {
|
|
86
94
|
height: "100%",
|
|
87
95
|
onClose: handleOnClose,
|
|
@@ -103,7 +111,7 @@ var EmbedModal = function EmbedModal(_ref) {
|
|
|
103
111
|
}), /*#__PURE__*/_react.default.createElement(_modalDialog.ModalBody, null, /*#__PURE__*/_react.default.createElement(_embedContent.default, {
|
|
104
112
|
isTrusted: isTrusted,
|
|
105
113
|
name: iframeName,
|
|
106
|
-
src:
|
|
114
|
+
src: previewUrl,
|
|
107
115
|
testId: testId
|
|
108
116
|
}))));
|
|
109
117
|
};
|
|
@@ -34,7 +34,8 @@ var PreviewAction = function PreviewAction(props) {
|
|
|
34
34
|
url = props.url,
|
|
35
35
|
title = props.title,
|
|
36
36
|
providerName = props.providerName,
|
|
37
|
-
downloadUrl = props.downloadUrl
|
|
37
|
+
downloadUrl = props.downloadUrl,
|
|
38
|
+
isSupportTheming = props.isSupportTheming;
|
|
38
39
|
var defaultAnalytics = (0, _state.useSmartLinkAnalytics)(url, function () {});
|
|
39
40
|
var analytics = (0, _flexibleUiContext.useFlexibleUiAnalyticsContext)() || defaultAnalytics;
|
|
40
41
|
var EmbedIcon = {
|
|
@@ -55,7 +56,8 @@ var PreviewAction = function PreviewAction(props) {
|
|
|
55
56
|
title: title,
|
|
56
57
|
url: url,
|
|
57
58
|
analytics: analytics,
|
|
58
|
-
origin: 'smartLinkCard'
|
|
59
|
+
origin: 'smartLinkCard',
|
|
60
|
+
isSupportTheming: isSupportTheming
|
|
59
61
|
});
|
|
60
62
|
};
|
|
61
63
|
var action = _objectSpread(_objectSpread({}, props), {}, {
|
|
@@ -21,7 +21,7 @@ const extractBlockIcon = jsonLd => {
|
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
const extractBlockDetails = jsonLd => [extractCommentCount(jsonLd), extractProgrammingLanguage(jsonLd), extractSubscriberCount(jsonLd), extractAttachmentCount(jsonLd)].filter(detail => !!detail);
|
|
24
|
-
export const extractBlockActions = (props, jsonLd, opts, platform) => {
|
|
24
|
+
export const extractBlockActions = (props, jsonLd, opts, platform, meta) => {
|
|
25
25
|
if (opts) {
|
|
26
26
|
const {
|
|
27
27
|
handleInvoke
|
|
@@ -31,7 +31,8 @@ export const extractBlockActions = (props, jsonLd, opts, platform) => {
|
|
|
31
31
|
...opts,
|
|
32
32
|
viewProps: props,
|
|
33
33
|
jsonLd,
|
|
34
|
-
platform
|
|
34
|
+
platform,
|
|
35
|
+
meta
|
|
35
36
|
});
|
|
36
37
|
|
|
37
38
|
// The previewAction should always be the last action
|
|
@@ -79,6 +80,6 @@ export const extractBlockProps = (jsonLd, meta, opts, renderers, platform) => {
|
|
|
79
80
|
};
|
|
80
81
|
return {
|
|
81
82
|
...props,
|
|
82
|
-
actions: extractBlockActions(props, jsonLd, opts, platform)
|
|
83
|
+
actions: extractBlockActions(props, jsonLd, opts, platform, meta)
|
|
83
84
|
};
|
|
84
85
|
};
|
|
@@ -2,6 +2,7 @@ import { extractDownloadUrl } from '../detail';
|
|
|
2
2
|
import { extractPreview, extractProvider } from '@atlaskit/linking-common/extractors';
|
|
3
3
|
import { PreviewAction } from '../../../view/BlockCard';
|
|
4
4
|
import { CardDisplay } from '../../../constants';
|
|
5
|
+
import { extractIsSupportTheming } from '../../common/meta/extractIsSupportTheming';
|
|
5
6
|
const getMetadataFromJsonLd = (jsonLd, platform) => {
|
|
6
7
|
const download = extractDownloadUrl(jsonLd);
|
|
7
8
|
const provider = extractProvider(jsonLd);
|
|
@@ -44,7 +45,8 @@ export const extractPreviewAction = ({
|
|
|
44
45
|
platform,
|
|
45
46
|
origin,
|
|
46
47
|
source = 'block',
|
|
47
|
-
analytics
|
|
48
|
+
analytics,
|
|
49
|
+
meta
|
|
48
50
|
}) => {
|
|
49
51
|
// Extract metadata from view props & raw JSON-LD.
|
|
50
52
|
const metadataFromJsonLd = getMetadataFromJsonLd(jsonLd, platform);
|
|
@@ -67,7 +69,8 @@ export const extractPreviewAction = ({
|
|
|
67
69
|
},
|
|
68
70
|
onViewActionClick: () => {
|
|
69
71
|
handleInvoke(getInvokeOpts(key, 'ViewAction'));
|
|
70
|
-
}
|
|
72
|
+
},
|
|
73
|
+
isSupportTheming: extractIsSupportTheming(meta)
|
|
71
74
|
});
|
|
72
75
|
// Setup props to go through proper Redux 'invocation' flow
|
|
73
76
|
// for analytics, further state management if required in future.
|
|
@@ -10,4 +10,7 @@ export const JIRA_INCIDENT = 'JiraIncident';
|
|
|
10
10
|
export const JIRA_SERVICE_REQUEST = 'JiraServiceRequest';
|
|
11
11
|
export const JIRA_CHANGE = 'JiraChange';
|
|
12
12
|
export const JIRA_PROBLEM = 'JiraProblem';
|
|
13
|
-
export const JIRA_CUSTOM_TASK_TYPE = 'JiraCustomTaskType';
|
|
13
|
+
export const JIRA_CUSTOM_TASK_TYPE = 'JiraCustomTaskType';
|
|
14
|
+
|
|
15
|
+
//List of provider keys that support theme modes for the embedded content.
|
|
16
|
+
export const PROVIDER_KEYS_WITH_THEMING = ['jira-object-provider', 'confluence-object-provider', 'watermelon-object-provider'];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { extractLink, extractTitle, extractProvider, extractPreview } from '@atlaskit/linking-common/extractors';
|
|
2
2
|
import { extractIsTrusted } from '../common/meta/extractIsTrusted';
|
|
3
|
+
import { extractIsSupportTheming } from '../common/meta/extractIsSupportTheming';
|
|
3
4
|
const extractEmbedPreview = (jsonLd, platform) => {
|
|
4
5
|
const preview = extractPreview(jsonLd, platform);
|
|
5
6
|
if (preview && preview.src) {
|
|
@@ -14,5 +15,6 @@ export const extractEmbedProps = (jsonLd, meta, platform) => ({
|
|
|
14
15
|
title: extractTitle(jsonLd),
|
|
15
16
|
context: extractProvider(jsonLd),
|
|
16
17
|
preview: extractEmbedPreview(jsonLd, platform),
|
|
17
|
-
isTrusted: extractIsTrusted(meta)
|
|
18
|
+
isTrusted: extractIsTrusted(meta),
|
|
19
|
+
isSupportTheming: extractIsSupportTheming(meta)
|
|
18
20
|
});
|
|
@@ -2,9 +2,11 @@ import { extractDownloadUrl } from '../../common/detail';
|
|
|
2
2
|
import { extractPreview as extractPreviewData } from '@atlaskit/linking-common';
|
|
3
3
|
import { extractLink, extractProvider, extractTitle } from '@atlaskit/linking-common/extractors';
|
|
4
4
|
import { extractLinkIcon } from '../icon';
|
|
5
|
+
import { extractIsSupportTheming } from '../../common/meta/extractIsSupportTheming';
|
|
5
6
|
export const extractPreviewAction = response => {
|
|
6
7
|
var _extractPreviewData;
|
|
7
8
|
const data = response.data;
|
|
9
|
+
const meta = response.meta;
|
|
8
10
|
const src = (_extractPreviewData = extractPreviewData(data, 'web')) === null || _extractPreviewData === void 0 ? void 0 : _extractPreviewData.src;
|
|
9
11
|
if (src) {
|
|
10
12
|
var _extractProvider;
|
|
@@ -14,7 +16,8 @@ export const extractPreviewAction = response => {
|
|
|
14
16
|
src,
|
|
15
17
|
title: extractTitle(data),
|
|
16
18
|
linkIcon: extractLinkIcon(response),
|
|
17
|
-
url: extractLink(data)
|
|
19
|
+
url: extractLink(data),
|
|
20
|
+
isSupportTheming: extractIsSupportTheming(meta)
|
|
18
21
|
};
|
|
19
22
|
}
|
|
20
23
|
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -39,7 +39,8 @@ export const ResolvedView = ({
|
|
|
39
39
|
lozenge,
|
|
40
40
|
details = [],
|
|
41
41
|
testId = 'block-card-resolved-view',
|
|
42
|
-
showActions = true
|
|
42
|
+
showActions = true,
|
|
43
|
+
isSupportTheming
|
|
43
44
|
}) => {
|
|
44
45
|
const resolvedMetadata = details.length > 0 ? jsx(MetadataList, {
|
|
45
46
|
testId: testId ? `${testId}-meta` : undefined,
|
|
@@ -5,6 +5,7 @@ import LinkGlyph from '@atlaskit/icon/glyph/link';
|
|
|
5
5
|
import { ExpandedFrame } from '../components/ExpandedFrame';
|
|
6
6
|
import { ImageIcon } from '../components/ImageIcon';
|
|
7
7
|
import { Frame } from '../components/Frame';
|
|
8
|
+
import { useThemeObserver } from '@atlaskit/tokens';
|
|
8
9
|
export const EmbedCardResolvedView = /*#__PURE__*/React.forwardRef(({
|
|
9
10
|
link,
|
|
10
11
|
context,
|
|
@@ -17,7 +18,8 @@ export const EmbedCardResolvedView = /*#__PURE__*/React.forwardRef(({
|
|
|
17
18
|
testId = 'embed-card-resolved-view',
|
|
18
19
|
inheritDimensions,
|
|
19
20
|
onIframeDwell,
|
|
20
|
-
onIframeFocus
|
|
21
|
+
onIframeFocus,
|
|
22
|
+
isSupportTheming
|
|
21
23
|
}, embedIframeRef) => {
|
|
22
24
|
const iconFromContext = context === null || context === void 0 ? void 0 : context.icon;
|
|
23
25
|
const src = typeof iconFromContext === 'string' ? iconFromContext : undefined;
|
|
@@ -36,6 +38,13 @@ export const EmbedCardResolvedView = /*#__PURE__*/React.forwardRef(({
|
|
|
36
38
|
default: linkGlyph
|
|
37
39
|
});
|
|
38
40
|
}, [src, linkGlyph, iconFromContext]);
|
|
41
|
+
const {
|
|
42
|
+
colorMode
|
|
43
|
+
} = useThemeObserver();
|
|
44
|
+
let previewUrl = preview === null || preview === void 0 ? void 0 : preview.src;
|
|
45
|
+
if (previewUrl && isSupportTheming && colorMode) {
|
|
46
|
+
previewUrl = `${previewUrl}${previewUrl.includes('?') ? '&' : '?'}themeMode=${colorMode}`;
|
|
47
|
+
}
|
|
39
48
|
return jsx(ExpandedFrame, {
|
|
40
49
|
isSelected: isSelected,
|
|
41
50
|
isFrameVisible: isFrameVisible,
|
|
@@ -46,7 +55,7 @@ export const EmbedCardResolvedView = /*#__PURE__*/React.forwardRef(({
|
|
|
46
55
|
onClick: onClick,
|
|
47
56
|
inheritDimensions: inheritDimensions
|
|
48
57
|
}, jsx(Frame, {
|
|
49
|
-
url:
|
|
58
|
+
url: previewUrl,
|
|
50
59
|
isTrusted: isTrusted,
|
|
51
60
|
testId: testId,
|
|
52
61
|
ref: embedIframeRef,
|
|
@@ -6,6 +6,7 @@ import EmbedContent from './components/embed-content';
|
|
|
6
6
|
import { EmbedModalSize } from './types';
|
|
7
7
|
import withErrorBoundary from './components/error-boundary';
|
|
8
8
|
import withAnalytics from './components/analytics';
|
|
9
|
+
import { useThemeObserver } from '@atlaskit/tokens';
|
|
9
10
|
const toSize = width => width === MAX_MODAL_SIZE ? EmbedModalSize.Large : EmbedModalSize.Small;
|
|
10
11
|
const toWidth = size => size === EmbedModalSize.Large ? MAX_MODAL_SIZE : MIN_MODAL_SIZE;
|
|
11
12
|
const EmbedModal = ({
|
|
@@ -24,7 +25,8 @@ const EmbedModal = ({
|
|
|
24
25
|
src,
|
|
25
26
|
testId = 'smart-embed-preview-modal',
|
|
26
27
|
title,
|
|
27
|
-
url
|
|
28
|
+
url,
|
|
29
|
+
isSupportTheming
|
|
28
30
|
}) => {
|
|
29
31
|
const defaultWidth = toWidth(size);
|
|
30
32
|
const [isOpen, setIsOpen] = useState(showModal);
|
|
@@ -57,6 +59,13 @@ const EmbedModal = ({
|
|
|
57
59
|
});
|
|
58
60
|
}
|
|
59
61
|
}, [onResize, width]);
|
|
62
|
+
const {
|
|
63
|
+
colorMode
|
|
64
|
+
} = useThemeObserver();
|
|
65
|
+
let previewUrl = src;
|
|
66
|
+
if (previewUrl && isSupportTheming && colorMode) {
|
|
67
|
+
previewUrl = `${previewUrl}${previewUrl.includes('?') ? '&' : '?'}themeMode=${colorMode}`;
|
|
68
|
+
}
|
|
60
69
|
return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(ModalDialog, {
|
|
61
70
|
height: "100%",
|
|
62
71
|
onClose: handleOnClose,
|
|
@@ -78,7 +87,7 @@ const EmbedModal = ({
|
|
|
78
87
|
}), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(EmbedContent, {
|
|
79
88
|
isTrusted: isTrusted,
|
|
80
89
|
name: iframeName,
|
|
81
|
-
src:
|
|
90
|
+
src: previewUrl,
|
|
82
91
|
testId: testId
|
|
83
92
|
}))));
|
|
84
93
|
};
|
|
@@ -17,7 +17,8 @@ const PreviewAction = props => {
|
|
|
17
17
|
url,
|
|
18
18
|
title,
|
|
19
19
|
providerName,
|
|
20
|
-
downloadUrl
|
|
20
|
+
downloadUrl,
|
|
21
|
+
isSupportTheming
|
|
21
22
|
} = props;
|
|
22
23
|
const defaultAnalytics = useSmartLinkAnalytics(url, () => {});
|
|
23
24
|
const analytics = useFlexibleUiAnalyticsContext() || defaultAnalytics;
|
|
@@ -38,7 +39,8 @@ const PreviewAction = props => {
|
|
|
38
39
|
title,
|
|
39
40
|
url,
|
|
40
41
|
analytics,
|
|
41
|
-
origin: 'smartLinkCard'
|
|
42
|
+
origin: 'smartLinkCard',
|
|
43
|
+
isSupportTheming
|
|
42
44
|
});
|
|
43
45
|
const action = {
|
|
44
46
|
...props,
|
|
@@ -28,14 +28,15 @@ var extractBlockDetails = function extractBlockDetails(jsonLd) {
|
|
|
28
28
|
return !!detail;
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
|
-
export var extractBlockActions = function extractBlockActions(props, jsonLd, opts, platform) {
|
|
31
|
+
export var extractBlockActions = function extractBlockActions(props, jsonLd, opts, platform, meta) {
|
|
32
32
|
if (opts) {
|
|
33
33
|
var handleInvoke = opts.handleInvoke;
|
|
34
34
|
var actions = extractActions(jsonLd, handleInvoke);
|
|
35
35
|
var previewAction = extractPreviewAction(_objectSpread(_objectSpread({}, opts), {}, {
|
|
36
36
|
viewProps: props,
|
|
37
37
|
jsonLd: jsonLd,
|
|
38
|
-
platform: platform
|
|
38
|
+
platform: platform,
|
|
39
|
+
meta: meta
|
|
39
40
|
}));
|
|
40
41
|
|
|
41
42
|
// The previewAction should always be the last action
|
|
@@ -82,6 +83,6 @@ export var extractBlockProps = function extractBlockProps(jsonLd, meta, opts, re
|
|
|
82
83
|
isTrusted: extractIsTrusted(meta)
|
|
83
84
|
};
|
|
84
85
|
return _objectSpread(_objectSpread({}, props), {}, {
|
|
85
|
-
actions: extractBlockActions(props, jsonLd, opts, platform)
|
|
86
|
+
actions: extractBlockActions(props, jsonLd, opts, platform, meta)
|
|
86
87
|
});
|
|
87
88
|
};
|
|
@@ -5,6 +5,7 @@ import { extractDownloadUrl } from '../detail';
|
|
|
5
5
|
import { extractPreview, extractProvider } from '@atlaskit/linking-common/extractors';
|
|
6
6
|
import { PreviewAction } from '../../../view/BlockCard';
|
|
7
7
|
import { CardDisplay } from '../../../constants';
|
|
8
|
+
import { extractIsSupportTheming } from '../../common/meta/extractIsSupportTheming';
|
|
8
9
|
var getMetadataFromJsonLd = function getMetadataFromJsonLd(jsonLd, platform) {
|
|
9
10
|
var download = extractDownloadUrl(jsonLd);
|
|
10
11
|
var provider = extractProvider(jsonLd);
|
|
@@ -55,7 +56,8 @@ export var extractPreviewAction = function extractPreviewAction(_ref) {
|
|
|
55
56
|
origin = _ref.origin,
|
|
56
57
|
_ref$source = _ref.source,
|
|
57
58
|
source = _ref$source === void 0 ? 'block' : _ref$source,
|
|
58
|
-
analytics = _ref.analytics
|
|
59
|
+
analytics = _ref.analytics,
|
|
60
|
+
meta = _ref.meta;
|
|
59
61
|
// Extract metadata from view props & raw JSON-LD.
|
|
60
62
|
var metadataFromJsonLd = getMetadataFromJsonLd(jsonLd, platform);
|
|
61
63
|
var metadataFromViewProps = getMetadataFromResolvedProps(viewProps);
|
|
@@ -73,7 +75,8 @@ export var extractPreviewAction = function extractPreviewAction(_ref) {
|
|
|
73
75
|
},
|
|
74
76
|
onViewActionClick: function onViewActionClick() {
|
|
75
77
|
handleInvoke(getInvokeOpts(key, 'ViewAction'));
|
|
76
|
-
}
|
|
78
|
+
},
|
|
79
|
+
isSupportTheming: extractIsSupportTheming(meta)
|
|
77
80
|
}));
|
|
78
81
|
// Setup props to go through proper Redux 'invocation' flow
|
|
79
82
|
// for analytics, further state management if required in future.
|
|
@@ -10,4 +10,7 @@ export var JIRA_INCIDENT = 'JiraIncident';
|
|
|
10
10
|
export var JIRA_SERVICE_REQUEST = 'JiraServiceRequest';
|
|
11
11
|
export var JIRA_CHANGE = 'JiraChange';
|
|
12
12
|
export var JIRA_PROBLEM = 'JiraProblem';
|
|
13
|
-
export var JIRA_CUSTOM_TASK_TYPE = 'JiraCustomTaskType';
|
|
13
|
+
export var JIRA_CUSTOM_TASK_TYPE = 'JiraCustomTaskType';
|
|
14
|
+
|
|
15
|
+
//List of provider keys that support theme modes for the embedded content.
|
|
16
|
+
export var PROVIDER_KEYS_WITH_THEMING = ['jira-object-provider', 'confluence-object-provider', 'watermelon-object-provider'];
|
|
@@ -3,6 +3,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
4
|
import { extractLink, extractTitle, extractProvider, extractPreview } from '@atlaskit/linking-common/extractors';
|
|
5
5
|
import { extractIsTrusted } from '../common/meta/extractIsTrusted';
|
|
6
|
+
import { extractIsSupportTheming } from '../common/meta/extractIsSupportTheming';
|
|
6
7
|
var extractEmbedPreview = function extractEmbedPreview(jsonLd, platform) {
|
|
7
8
|
var preview = extractPreview(jsonLd, platform);
|
|
8
9
|
if (preview && preview.src) {
|
|
@@ -17,6 +18,7 @@ export var extractEmbedProps = function extractEmbedProps(jsonLd, meta, platform
|
|
|
17
18
|
title: extractTitle(jsonLd),
|
|
18
19
|
context: extractProvider(jsonLd),
|
|
19
20
|
preview: extractEmbedPreview(jsonLd, platform),
|
|
20
|
-
isTrusted: extractIsTrusted(meta)
|
|
21
|
+
isTrusted: extractIsTrusted(meta),
|
|
22
|
+
isSupportTheming: extractIsSupportTheming(meta)
|
|
21
23
|
};
|
|
22
24
|
};
|
|
@@ -2,9 +2,11 @@ import { extractDownloadUrl } from '../../common/detail';
|
|
|
2
2
|
import { extractPreview as extractPreviewData } from '@atlaskit/linking-common';
|
|
3
3
|
import { extractLink, extractProvider, extractTitle } from '@atlaskit/linking-common/extractors';
|
|
4
4
|
import { extractLinkIcon } from '../icon';
|
|
5
|
+
import { extractIsSupportTheming } from '../../common/meta/extractIsSupportTheming';
|
|
5
6
|
export var extractPreviewAction = function extractPreviewAction(response) {
|
|
6
7
|
var _extractPreviewData;
|
|
7
8
|
var data = response.data;
|
|
9
|
+
var meta = response.meta;
|
|
8
10
|
var src = (_extractPreviewData = extractPreviewData(data, 'web')) === null || _extractPreviewData === void 0 ? void 0 : _extractPreviewData.src;
|
|
9
11
|
if (src) {
|
|
10
12
|
var _extractProvider;
|
|
@@ -14,7 +16,8 @@ export var extractPreviewAction = function extractPreviewAction(response) {
|
|
|
14
16
|
src: src,
|
|
15
17
|
title: extractTitle(data),
|
|
16
18
|
linkIcon: extractLinkIcon(response),
|
|
17
|
-
url: extractLink(data)
|
|
19
|
+
url: extractLink(data),
|
|
20
|
+
isSupportTheming: extractIsSupportTheming(meta)
|
|
18
21
|
};
|
|
19
22
|
}
|
|
20
23
|
};
|
package/dist/esm/version.json
CHANGED
|
@@ -53,7 +53,8 @@ export var ResolvedView = function ResolvedView(_ref) {
|
|
|
53
53
|
_ref$testId = _ref.testId,
|
|
54
54
|
testId = _ref$testId === void 0 ? 'block-card-resolved-view' : _ref$testId,
|
|
55
55
|
_ref$showActions = _ref.showActions,
|
|
56
|
-
showActions = _ref$showActions === void 0 ? true : _ref$showActions
|
|
56
|
+
showActions = _ref$showActions === void 0 ? true : _ref$showActions,
|
|
57
|
+
isSupportTheming = _ref.isSupportTheming;
|
|
57
58
|
var resolvedMetadata = details.length > 0 ? jsx(MetadataList, {
|
|
58
59
|
testId: testId ? "".concat(testId, "-meta") : undefined,
|
|
59
60
|
items: details
|