@atlaskit/smart-card 25.9.1 → 25.9.2
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 +6 -0
- package/dist/cjs/extractors/flexible/extract-state.js +4 -1
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/EmbedModal/components/analytics/index.js +9 -9
- package/dist/cjs/view/EmbedModal/utils.js +111 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +7 -83
- package/dist/cjs/view/FlexibleCard/components/common/lozenge-action/index.js +24 -18
- package/dist/cjs/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/index.js +35 -5
- package/dist/cjs/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/styled.js +6 -4
- package/dist/es2019/extractors/flexible/extract-state.js +4 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/EmbedModal/components/analytics/index.js +9 -9
- package/dist/es2019/view/EmbedModal/utils.js +77 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +7 -56
- package/dist/es2019/view/FlexibleCard/components/common/lozenge-action/index.js +11 -7
- package/dist/es2019/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/index.js +35 -5
- package/dist/es2019/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/styled.js +9 -1
- package/dist/esm/extractors/flexible/extract-state.js +4 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/EmbedModal/components/analytics/index.js +9 -9
- package/dist/esm/view/EmbedModal/utils.js +98 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +7 -78
- package/dist/esm/view/FlexibleCard/components/common/lozenge-action/index.js +24 -18
- package/dist/esm/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/index.js +37 -5
- package/dist/esm/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/styled.js +4 -3
- package/dist/types/state/hooks/use-invoke/types.d.ts +5 -0
- package/dist/types/view/EmbedModal/components/analytics/types.d.ts +1 -1
- package/dist/types/view/EmbedModal/utils.d.ts +10 -0
- package/dist/types/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +1 -2
- package/dist/types/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/styled.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/types.d.ts +18 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,7 @@ var _lozenge = require("../common/lozenge");
|
|
|
10
10
|
var _helpers = require("../../state/helpers");
|
|
11
11
|
var _extractServerAction = _interopRequireDefault(require("./extract-server-action"));
|
|
12
12
|
var _extractors = require("@atlaskit/linking-common/extractors");
|
|
13
|
+
var _extractPreviewAction = require("./actions/extract-preview-action");
|
|
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 toInvokeRequest = function toInvokeRequest(extensionKey, resourceIdentifiers, actionType, details) {
|
|
@@ -41,9 +42,11 @@ var extractAction = function extractAction(response, id) {
|
|
|
41
42
|
}
|
|
42
43
|
var read = toInvokeRequest(extensionKey, action.resourceIdentifiers, (_action$dataRetrieval = action.dataRetrievalAction) === null || _action$dataRetrieval === void 0 ? void 0 : _action$dataRetrieval.name);
|
|
43
44
|
var url = (0, _extractors.extractLink)(data);
|
|
45
|
+
var previewData = response ? (0, _extractPreviewAction.extractPreviewAction)(response) : null;
|
|
44
46
|
var details = {
|
|
45
47
|
id: id,
|
|
46
|
-
url: url
|
|
48
|
+
url: url,
|
|
49
|
+
previewData: previewData
|
|
47
50
|
};
|
|
48
51
|
var update = toInvokeRequest(extensionKey, action.resourceIdentifiers, (_action$dataUpdateAct = action.dataUpdateAction) === null || _action$dataUpdateAct === void 0 ? void 0 : _action$dataUpdateAct.name, details);
|
|
49
52
|
return read || update ? {
|
package/dist/cjs/version.json
CHANGED
|
@@ -24,23 +24,23 @@ var withAnalytics = function withAnalytics(Component) {
|
|
|
24
24
|
onResize = props.onResize,
|
|
25
25
|
origin = props.origin;
|
|
26
26
|
var handleOnOpen = (0, _react.useCallback)(function (context) {
|
|
27
|
-
analytics.screen.modalViewedEvent({
|
|
27
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.screen.modalViewedEvent({
|
|
28
28
|
name: 'embedPreviewModal',
|
|
29
29
|
attributes: {
|
|
30
30
|
origin: origin,
|
|
31
31
|
size: context.size
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
analytics.ui.renderSuccessEvent({
|
|
34
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.renderSuccessEvent({
|
|
35
35
|
status: 'resolved',
|
|
36
36
|
display: _constants.CardDisplay.EmbedPreview
|
|
37
37
|
});
|
|
38
38
|
if (onOpen) {
|
|
39
39
|
onOpen(context);
|
|
40
40
|
}
|
|
41
|
-
}, [analytics.screen, analytics.ui, onOpen, origin]);
|
|
41
|
+
}, [analytics === null || analytics === void 0 ? void 0 : analytics.screen, analytics === null || analytics === void 0 ? void 0 : analytics.ui, onOpen, origin]);
|
|
42
42
|
var handleOnOpenFailed = (0, _react.useCallback)(function (error, errorInfo) {
|
|
43
|
-
analytics.ui.renderFailedEvent({
|
|
43
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.renderFailedEvent({
|
|
44
44
|
display: _constants.CardDisplay.EmbedPreview,
|
|
45
45
|
error: error,
|
|
46
46
|
errorInfo: errorInfo
|
|
@@ -48,9 +48,9 @@ var withAnalytics = function withAnalytics(Component) {
|
|
|
48
48
|
if (onOpenFailed) {
|
|
49
49
|
onOpenFailed(error, errorInfo);
|
|
50
50
|
}
|
|
51
|
-
}, [analytics.ui, onOpenFailed]);
|
|
51
|
+
}, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, onOpenFailed]);
|
|
52
52
|
var handleOnClose = (0, _react.useCallback)(function (context) {
|
|
53
|
-
analytics.ui.modalClosedEvent({
|
|
53
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.modalClosedEvent({
|
|
54
54
|
actionSubjectId: 'embedPreview',
|
|
55
55
|
attributes: {
|
|
56
56
|
origin: origin,
|
|
@@ -61,9 +61,9 @@ var withAnalytics = function withAnalytics(Component) {
|
|
|
61
61
|
if (onClose) {
|
|
62
62
|
onClose(context);
|
|
63
63
|
}
|
|
64
|
-
}, [analytics.ui, onClose, origin]);
|
|
64
|
+
}, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, onClose, origin]);
|
|
65
65
|
var handleOnResize = (0, _react.useCallback)(function (context) {
|
|
66
|
-
analytics.ui.buttonClickedEvent({
|
|
66
|
+
analytics === null || analytics === void 0 ? void 0 : analytics.ui.buttonClickedEvent({
|
|
67
67
|
actionSubjectId: 'embedPreviewResize',
|
|
68
68
|
attributes: {
|
|
69
69
|
newSize: context.size,
|
|
@@ -74,7 +74,7 @@ var withAnalytics = function withAnalytics(Component) {
|
|
|
74
74
|
if (onResize) {
|
|
75
75
|
onResize(context);
|
|
76
76
|
}
|
|
77
|
-
}, [analytics.ui, onResize, origin]);
|
|
77
|
+
}, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, onResize, origin]);
|
|
78
78
|
return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, props, {
|
|
79
79
|
onClose: handleOnClose,
|
|
80
80
|
onOpen: handleOnOpen,
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.openPreviewModal = void 0;
|
|
9
|
+
exports.previewFunction = previewFunction;
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
var _react = _interopRequireDefault(require("react"));
|
|
14
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
15
|
+
var _reactIntlNext = require("react-intl-next");
|
|
16
|
+
var _icon = _interopRequireDefault(require("../FlexibleCard/components/elements/icon"));
|
|
17
|
+
var _excluded = ["popupMountPointId", "onClose"];
|
|
18
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
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); }
|
|
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; }
|
|
21
|
+
var openPreviewModal = function openPreviewModal(_ref) {
|
|
22
|
+
var analytics = _ref.analytics,
|
|
23
|
+
download = _ref.downloadUrl,
|
|
24
|
+
isSupportTheming = _ref.isSupportTheming,
|
|
25
|
+
linkIcon = _ref.linkIcon,
|
|
26
|
+
_ref$onClose = _ref.onClose,
|
|
27
|
+
onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose,
|
|
28
|
+
providerName = _ref.providerName,
|
|
29
|
+
src = _ref.src,
|
|
30
|
+
title = _ref.title,
|
|
31
|
+
url = _ref.url;
|
|
32
|
+
var EmbedIcon = {
|
|
33
|
+
icon: /*#__PURE__*/_react.default.createElement(_icon.default, linkIcon),
|
|
34
|
+
isFlexibleUi: true
|
|
35
|
+
};
|
|
36
|
+
return previewFunction({
|
|
37
|
+
popupMountPointId: 'twp-editor-preview-iframe',
|
|
38
|
+
showModal: true,
|
|
39
|
+
iframeName: 'twp-editor-preview-iframe',
|
|
40
|
+
onClose: onClose,
|
|
41
|
+
download: download,
|
|
42
|
+
icon: EmbedIcon,
|
|
43
|
+
providerName: providerName || 'Preview',
|
|
44
|
+
src: src,
|
|
45
|
+
title: title,
|
|
46
|
+
url: url,
|
|
47
|
+
analytics: analytics,
|
|
48
|
+
origin: 'smartLinkCard',
|
|
49
|
+
isSupportTheming: isSupportTheming
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
Explanatory note:
|
|
55
|
+
Actions don't have access to the react tree of whatever is rendered them
|
|
56
|
+
(and this concept is fraught inside editor anyway) so we want to ensure
|
|
57
|
+
it is mounting to a new unique place. This function manages that, including
|
|
58
|
+
creating an element if it doesn't exist, as well as tidying up the react tree
|
|
59
|
+
(but not the element) upon closing the modal.
|
|
60
|
+
|
|
61
|
+
This may strike you as really uncomfortable as you read it, so I wanted to note
|
|
62
|
+
that a) this was discussed and agreed upon, and b) it's definitely odd, and if
|
|
63
|
+
you find an elegant solution around this, you should definitely feel free to
|
|
64
|
+
refactor it.
|
|
65
|
+
*/
|
|
66
|
+
exports.openPreviewModal = openPreviewModal;
|
|
67
|
+
function previewFunction(_x) {
|
|
68
|
+
return _previewFunction.apply(this, arguments);
|
|
69
|
+
}
|
|
70
|
+
function _previewFunction() {
|
|
71
|
+
_previewFunction = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref2) {
|
|
72
|
+
var popupMountPointId, onEmbedClose, rest, popupMountPoint, Modal;
|
|
73
|
+
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
74
|
+
while (1) {
|
|
75
|
+
switch (_context2.prev = _context2.next) {
|
|
76
|
+
case 0:
|
|
77
|
+
popupMountPointId = _ref2.popupMountPointId, onEmbedClose = _ref2.onClose, rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
|
|
78
|
+
popupMountPoint = document.getElementById(popupMountPointId);
|
|
79
|
+
if (!popupMountPoint) {
|
|
80
|
+
popupMountPoint = document.createElement('div');
|
|
81
|
+
popupMountPoint.id = popupMountPointId;
|
|
82
|
+
popupMountPoint.setAttribute('data-testid', 'preview-modal');
|
|
83
|
+
document.body.appendChild(popupMountPoint);
|
|
84
|
+
}
|
|
85
|
+
_context2.next = 5;
|
|
86
|
+
return Promise.resolve().then(function () {
|
|
87
|
+
return _interopRequireWildcard(require('./index'));
|
|
88
|
+
});
|
|
89
|
+
case 5:
|
|
90
|
+
Modal = _context2.sent;
|
|
91
|
+
_reactDom.default.render( /*#__PURE__*/_react.default.createElement(_reactIntlNext.IntlProvider, {
|
|
92
|
+
locale: "en"
|
|
93
|
+
}, /*#__PURE__*/_react.default.createElement(Modal.default, (0, _extends2.default)({}, rest, {
|
|
94
|
+
onClose: function onClose(_context) {
|
|
95
|
+
if (popupMountPoint) {
|
|
96
|
+
_reactDom.default.unmountComponentAtNode(popupMountPoint);
|
|
97
|
+
}
|
|
98
|
+
if (onEmbedClose) {
|
|
99
|
+
onEmbedClose(_context);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}))), popupMountPoint);
|
|
103
|
+
case 7:
|
|
104
|
+
case "end":
|
|
105
|
+
return _context2.stop();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}, _callee);
|
|
109
|
+
}));
|
|
110
|
+
return _previewFunction.apply(this, arguments);
|
|
111
|
+
}
|
|
@@ -1,27 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
exports.previewFunction = previewFunction;
|
|
10
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
10
|
var _react = _interopRequireDefault(require("react"));
|
|
15
11
|
var _index = _interopRequireDefault(require("../index"));
|
|
16
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
17
|
-
var _reactIntlNext = require("react-intl-next");
|
|
18
12
|
var _flexibleUiContext = require("../../../../../../state/flexible-ui-context");
|
|
19
13
|
var _state = require("../../../../../../state");
|
|
20
|
-
var
|
|
21
|
-
var _excluded = ["popupMountPointId"];
|
|
22
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
23
|
-
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); }
|
|
24
|
-
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; }
|
|
14
|
+
var _utils = require("../../../../../EmbedModal/utils");
|
|
25
15
|
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; }
|
|
26
16
|
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; }
|
|
27
17
|
var PreviewAction = function PreviewAction(props) {
|
|
@@ -38,26 +28,16 @@ var PreviewAction = function PreviewAction(props) {
|
|
|
38
28
|
isSupportTheming = props.isSupportTheming;
|
|
39
29
|
var defaultAnalytics = (0, _state.useSmartLinkAnalytics)(url, function () {});
|
|
40
30
|
var analytics = (0, _flexibleUiContext.useFlexibleUiAnalyticsContext)() || defaultAnalytics;
|
|
41
|
-
var EmbedIcon = {
|
|
42
|
-
icon: /*#__PURE__*/_react.default.createElement(_icon.default, linkIcon),
|
|
43
|
-
isFlexibleUi: true
|
|
44
|
-
};
|
|
45
31
|
if (src && url) {
|
|
46
32
|
var embedModal = function embedModal() {
|
|
47
|
-
return
|
|
48
|
-
popupMountPointId: 'twp-editor-preview-iframe',
|
|
49
|
-
showModal: true,
|
|
50
|
-
iframeName: 'twp-editor-preview-iframe',
|
|
51
|
-
onClose: function onClose() {},
|
|
52
|
-
download: downloadUrl,
|
|
53
|
-
icon: EmbedIcon,
|
|
54
|
-
providerName: providerName || 'Preview',
|
|
55
|
-
src: src,
|
|
33
|
+
return (0, _utils.openPreviewModal)({
|
|
56
34
|
title: title,
|
|
57
|
-
|
|
35
|
+
providerName: providerName,
|
|
36
|
+
downloadUrl: downloadUrl,
|
|
37
|
+
isSupportTheming: isSupportTheming,
|
|
58
38
|
analytics: analytics,
|
|
59
|
-
|
|
60
|
-
|
|
39
|
+
linkIcon: linkIcon,
|
|
40
|
+
src: src
|
|
61
41
|
});
|
|
62
42
|
};
|
|
63
43
|
var action = _objectSpread(_objectSpread({}, props), {}, {
|
|
@@ -77,61 +57,5 @@ var PreviewAction = function PreviewAction(props) {
|
|
|
77
57
|
return null;
|
|
78
58
|
}
|
|
79
59
|
};
|
|
80
|
-
|
|
81
|
-
/*
|
|
82
|
-
Explanatory note:
|
|
83
|
-
Actions don't have access to the react tree of whatever is rendered them
|
|
84
|
-
(and this concept is fraught inside editor anyway) so we want to ensure
|
|
85
|
-
it is mounting to a new unique place. This function manages that, including
|
|
86
|
-
creating an element if it doesn't exist, as well as tidying up the react tree
|
|
87
|
-
(but not the element) upon closing the modal.
|
|
88
|
-
|
|
89
|
-
This may strike you as really uncomfortable as you read it, so I wanted to note
|
|
90
|
-
that a) this was discussed and agreed upon, and b) it's definitely odd, and if
|
|
91
|
-
you find an elegant solution around this, you should definitely feel free to
|
|
92
|
-
refactor it.
|
|
93
|
-
*/
|
|
94
|
-
function previewFunction(_x) {
|
|
95
|
-
return _previewFunction.apply(this, arguments);
|
|
96
|
-
}
|
|
97
|
-
function _previewFunction() {
|
|
98
|
-
_previewFunction = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
99
|
-
var popupMountPointId, rest, popupMountPoint, Modal;
|
|
100
|
-
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
101
|
-
while (1) {
|
|
102
|
-
switch (_context2.prev = _context2.next) {
|
|
103
|
-
case 0:
|
|
104
|
-
popupMountPointId = _ref.popupMountPointId, rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
105
|
-
popupMountPoint = document.getElementById(popupMountPointId);
|
|
106
|
-
if (!popupMountPoint) {
|
|
107
|
-
popupMountPoint = document.createElement('div');
|
|
108
|
-
popupMountPoint.id = popupMountPointId;
|
|
109
|
-
popupMountPoint.setAttribute('data-testid', 'preview-modal');
|
|
110
|
-
document.body.appendChild(popupMountPoint);
|
|
111
|
-
}
|
|
112
|
-
_context2.next = 5;
|
|
113
|
-
return Promise.resolve().then(function () {
|
|
114
|
-
return _interopRequireWildcard(require('../../../../../EmbedModal'));
|
|
115
|
-
});
|
|
116
|
-
case 5:
|
|
117
|
-
Modal = _context2.sent;
|
|
118
|
-
_reactDom.default.render( /*#__PURE__*/_react.default.createElement(_reactIntlNext.IntlProvider, {
|
|
119
|
-
locale: "en"
|
|
120
|
-
}, /*#__PURE__*/_react.default.createElement(Modal.default, (0, _extends2.default)({}, rest, {
|
|
121
|
-
onClose: function onClose(_context) {
|
|
122
|
-
if (popupMountPoint) {
|
|
123
|
-
_reactDom.default.unmountComponentAtNode(popupMountPoint);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}))), popupMountPoint);
|
|
127
|
-
case 7:
|
|
128
|
-
case "end":
|
|
129
|
-
return _context2.stop();
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}, _callee);
|
|
133
|
-
}));
|
|
134
|
-
return _previewFunction.apply(this, arguments);
|
|
135
|
-
}
|
|
136
60
|
var _default = PreviewAction;
|
|
137
61
|
exports.default = _default;
|
|
@@ -36,6 +36,7 @@ var isInvokeCustomError = function isInvokeCustomError(err) {
|
|
|
36
36
|
return err.message !== undefined && err.errorCode !== undefined;
|
|
37
37
|
};
|
|
38
38
|
var LozengeAction = function LozengeAction(_ref) {
|
|
39
|
+
var _action$update;
|
|
39
40
|
var action = _ref.action,
|
|
40
41
|
appearance = _ref.appearance,
|
|
41
42
|
_ref$testId = _ref.testId,
|
|
@@ -64,8 +65,12 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
64
65
|
setErrorMessage = _useState10[1];
|
|
65
66
|
var invoke = (0, _useInvoke.default)();
|
|
66
67
|
var reload = (0, _useResolve.default)();
|
|
68
|
+
var _ref2 = (action === null || action === void 0 ? void 0 : (_action$update = action.update) === null || _action$update === void 0 ? void 0 : _action$update.details) || {},
|
|
69
|
+
url = _ref2.url,
|
|
70
|
+
linkId = _ref2.id,
|
|
71
|
+
previewData = _ref2.previewData;
|
|
67
72
|
var handleOpenChange = (0, _react2.useCallback)( /*#__PURE__*/function () {
|
|
68
|
-
var
|
|
73
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(args) {
|
|
69
74
|
var responseItems, validItems;
|
|
70
75
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
71
76
|
while (1) {
|
|
@@ -112,7 +117,7 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
112
117
|
}, _callee, null, [[2, 13, 17, 20]]);
|
|
113
118
|
}));
|
|
114
119
|
return function (_x) {
|
|
115
|
-
return
|
|
120
|
+
return _ref3.apply(this, arguments);
|
|
116
121
|
};
|
|
117
122
|
}(), [action === null || action === void 0 ? void 0 : action.read, invoke, isLoaded, text]);
|
|
118
123
|
var trigger = (0, _react2.useCallback)(function (props) {
|
|
@@ -123,8 +128,8 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
123
128
|
}));
|
|
124
129
|
}, [appearance, testId, text]);
|
|
125
130
|
var handleItemClick = (0, _react2.useCallback)( /*#__PURE__*/function () {
|
|
126
|
-
var
|
|
127
|
-
var updateAction, request
|
|
131
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(id) {
|
|
132
|
+
var updateAction, request;
|
|
128
133
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
129
134
|
while (1) {
|
|
130
135
|
switch (_context2.prev = _context2.next) {
|
|
@@ -132,7 +137,7 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
132
137
|
_context2.prev = 0;
|
|
133
138
|
updateAction = action === null || action === void 0 ? void 0 : action.update;
|
|
134
139
|
if (!(updateAction && id)) {
|
|
135
|
-
_context2.next =
|
|
140
|
+
_context2.next = 14;
|
|
136
141
|
break;
|
|
137
142
|
}
|
|
138
143
|
setIsLoading(true);
|
|
@@ -144,18 +149,17 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
144
149
|
setIsLoaded(false);
|
|
145
150
|
setIsOpen(false);
|
|
146
151
|
setItems([]);
|
|
147
|
-
_ref4 = updateAction.details || {}, url = _ref4.url, linkId = _ref4.id;
|
|
148
152
|
if (!url) {
|
|
149
|
-
_context2.next =
|
|
153
|
+
_context2.next = 14;
|
|
150
154
|
break;
|
|
151
155
|
}
|
|
152
|
-
_context2.next =
|
|
156
|
+
_context2.next = 14;
|
|
153
157
|
return reload(url, true, undefined, linkId);
|
|
154
|
-
case
|
|
155
|
-
_context2.next =
|
|
158
|
+
case 14:
|
|
159
|
+
_context2.next = 20;
|
|
156
160
|
break;
|
|
157
|
-
case
|
|
158
|
-
_context2.prev =
|
|
161
|
+
case 16:
|
|
162
|
+
_context2.prev = 16;
|
|
159
163
|
_context2.t0 = _context2["catch"](0);
|
|
160
164
|
setIsLoading(false);
|
|
161
165
|
if (isInvokeCustomError(_context2.t0)) {
|
|
@@ -163,22 +167,24 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
163
167
|
} else {
|
|
164
168
|
setErrorMessage(_types.LozengeActionErrorMessages.updateFailed);
|
|
165
169
|
}
|
|
166
|
-
case
|
|
170
|
+
case 20:
|
|
167
171
|
case "end":
|
|
168
172
|
return _context2.stop();
|
|
169
173
|
}
|
|
170
174
|
}
|
|
171
|
-
}, _callee2, null, [[0,
|
|
175
|
+
}, _callee2, null, [[0, 16]]);
|
|
172
176
|
}));
|
|
173
177
|
return function (_x2) {
|
|
174
|
-
return
|
|
178
|
+
return _ref4.apply(this, arguments);
|
|
175
179
|
};
|
|
176
|
-
}(), [action === null || action === void 0 ? void 0 : action.update, invoke, reload]);
|
|
180
|
+
}(), [action === null || action === void 0 ? void 0 : action.update, invoke, linkId, reload, url]);
|
|
177
181
|
var dropdownItemGroup = (0, _react2.useMemo)(function () {
|
|
178
182
|
if (errorMessage) {
|
|
179
183
|
return (0, _react.jsx)(_lozengeActionError.default, {
|
|
180
184
|
errorMessage: errorMessage,
|
|
181
|
-
testId: testId
|
|
185
|
+
testId: testId,
|
|
186
|
+
url: url,
|
|
187
|
+
previewData: previewData
|
|
182
188
|
});
|
|
183
189
|
}
|
|
184
190
|
if (items && items.length > 0) {
|
|
@@ -193,7 +199,7 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
193
199
|
}));
|
|
194
200
|
})));
|
|
195
201
|
}
|
|
196
|
-
}, [errorMessage, handleItemClick, items, testId]);
|
|
202
|
+
}, [errorMessage, handleItemClick, items, previewData, testId, url]);
|
|
197
203
|
return (0, _react.jsx)(_dropdownMenu.default, {
|
|
198
204
|
isLoading: isLoading,
|
|
199
205
|
isOpen: isOpen,
|
package/dist/cjs/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/index.js
CHANGED
|
@@ -5,21 +5,45 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
9
|
var _react = require("@emotion/react");
|
|
9
10
|
var _react2 = require("react");
|
|
11
|
+
var _reactIntlNext = require("react-intl-next");
|
|
10
12
|
var _dropdownMenu = require("@atlaskit/dropdown-menu");
|
|
11
13
|
var _colors = require("@atlaskit/theme/colors");
|
|
12
14
|
var _error = _interopRequireDefault(require("@atlaskit/icon/glyph/error"));
|
|
13
15
|
var _styled = require("./styled");
|
|
14
16
|
var _utils = require("../../../utils");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
var _messages = require("../../../../../../messages");
|
|
18
|
+
var _flexibleUiContext = require("../../../../../../state/flexible-ui-context");
|
|
19
|
+
var _utils2 = require("../../../../../EmbedModal/utils");
|
|
20
|
+
var _useResolve = _interopRequireDefault(require("../../../../../../state/hooks/use-resolve"));
|
|
21
|
+
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; }
|
|
22
|
+
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; } /** @jsx jsx */
|
|
17
23
|
var MAX_LINE_NUMBER = 8;
|
|
18
24
|
var LozengeActionError = function LozengeActionError(_ref) {
|
|
19
25
|
var errorMessage = _ref.errorMessage,
|
|
20
26
|
testId = _ref.testId,
|
|
21
27
|
_ref$maxLineNumber = _ref.maxLineNumber,
|
|
22
|
-
maxLineNumber = _ref$maxLineNumber === void 0 ? MAX_LINE_NUMBER : _ref$maxLineNumber
|
|
28
|
+
maxLineNumber = _ref$maxLineNumber === void 0 ? MAX_LINE_NUMBER : _ref$maxLineNumber,
|
|
29
|
+
url = _ref.url,
|
|
30
|
+
previewData = _ref.previewData;
|
|
31
|
+
var reload = (0, _useResolve.default)();
|
|
32
|
+
var analytics = (0, _flexibleUiContext.useFlexibleUiAnalyticsContext)();
|
|
33
|
+
var isPreviewAvailable = previewData && previewData.src !== undefined;
|
|
34
|
+
var handlePreviewClose = (0, _react2.useCallback)(function () {
|
|
35
|
+
if (url) {
|
|
36
|
+
reload(url, true);
|
|
37
|
+
}
|
|
38
|
+
}, [reload, url]);
|
|
39
|
+
var handlePreviewOpen = (0, _react2.useCallback)(function () {
|
|
40
|
+
if (isPreviewAvailable) {
|
|
41
|
+
return (0, _utils2.openPreviewModal)(_objectSpread(_objectSpread({}, previewData), {}, {
|
|
42
|
+
analytics: analytics,
|
|
43
|
+
onClose: handlePreviewClose
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
}, [analytics, handlePreviewClose, isPreviewAvailable, previewData]);
|
|
23
47
|
var content = (0, _react2.useMemo)(function () {
|
|
24
48
|
return (0, _react.jsx)(_react2.Fragment, null, (0, _react.jsx)("div", {
|
|
25
49
|
css: _styled.contentStyles
|
|
@@ -32,8 +56,14 @@ var LozengeActionError = function LozengeActionError(_ref) {
|
|
|
32
56
|
}), (0, _react.jsx)("span", {
|
|
33
57
|
css: (0, _styled.textStyles)(maxLineNumber),
|
|
34
58
|
"data-testid": "".concat(testId, "-error-message")
|
|
35
|
-
}, typeof errorMessage === 'string' ? errorMessage : (0, _utils.getFormattedMessage)(errorMessage))))
|
|
36
|
-
|
|
59
|
+
}, typeof errorMessage === 'string' ? errorMessage : (0, _utils.getFormattedMessage)(errorMessage))), isPreviewAvailable ? (0, _react.jsx)("div", {
|
|
60
|
+
css: _styled.linkStyles
|
|
61
|
+
}, (0, _react.jsx)("a", {
|
|
62
|
+
target: "_blank",
|
|
63
|
+
"data-testid": "".concat(testId, "-open-embed"),
|
|
64
|
+
onClick: handlePreviewOpen
|
|
65
|
+
}, (0, _react.jsx)(_reactIntlNext.FormattedMessage, _messages.messages.open_issue_in_jira))) : null);
|
|
66
|
+
}, [errorMessage, handlePreviewOpen, isPreviewAvailable, maxLineNumber, testId]);
|
|
37
67
|
return (0, _react.jsx)("span", {
|
|
38
68
|
css: _styled.dropdownItemGroupStyles,
|
|
39
69
|
"data-testid": "".concat(testId, "-error-item-group")
|
package/dist/cjs/view/FlexibleCard/components/common/lozenge-action/lozenge-action-error/styled.js
CHANGED
|
@@ -4,18 +4,20 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.textStyles = exports.dropdownItemGroupStyles = exports.contentStyles = void 0;
|
|
7
|
+
exports.textStyles = exports.linkStyles = exports.dropdownItemGroupStyles = exports.contentStyles = void 0;
|
|
8
8
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
9
|
var _react = require("@emotion/react");
|
|
10
10
|
var _colors = require("@atlaskit/theme/colors");
|
|
11
11
|
var _utils = require("../../../utils");
|
|
12
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
12
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
13
13
|
var dropdownItemGroupStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n button {\n width: 220px;\n\n &:hover {\n background-color: inherit;\n cursor: default;\n }\n }\n"])));
|
|
14
14
|
exports.dropdownItemGroupStyles = dropdownItemGroupStyles;
|
|
15
15
|
var sharedBlockStyles = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n gap: 0.5rem;\n line-height: 1rem;\n min-width: 0;\n overflow: hidden;\n flex-direction: row;\n align-items: center;\n"])));
|
|
16
|
-
var contentStyles = (0, _react.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n ", ";\n\n margin-top:
|
|
16
|
+
var contentStyles = (0, _react.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n ", ";\n\n margin-top: ", ";\n align-items: flex-start;\n\n > span,\n > div {\n &[data-smart-element-text] {\n font-size: 0.875rem;\n color: ", ";\n }\n }\n"])), sharedBlockStyles, "var(--ds-space-025, 2px)", "var(--ds-text, ".concat(_colors.N800, ")"));
|
|
17
17
|
exports.contentStyles = contentStyles;
|
|
18
|
+
var linkStyles = (0, _react.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n ", ";\n\n font-size: 0.875rem;\n margin-top: 10px;\n margin-left: ", ";\n margin-bottom: ", ";\n"])), sharedBlockStyles, "var(--ds-space-400, 32px)", "var(--ds-space-025, 2px)");
|
|
19
|
+
exports.linkStyles = linkStyles;
|
|
18
20
|
var textStyles = function textStyles(maxLines) {
|
|
19
|
-
return (0, _react.css)(
|
|
21
|
+
return (0, _react.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n line-height: 1rem;\n white-space: normal;\n ", ";\n"])), (0, _utils.getTruncateStyles)(maxLines));
|
|
20
22
|
};
|
|
21
23
|
exports.textStyles = textStyles;
|
|
@@ -2,6 +2,7 @@ import { extractLozenge } from '../common/lozenge';
|
|
|
2
2
|
import { getExtensionKey } from '../../state/helpers';
|
|
3
3
|
import extractServerAction from './extract-server-action';
|
|
4
4
|
import { extractLink } from '@atlaskit/linking-common/extractors';
|
|
5
|
+
import { extractPreviewAction } from './actions/extract-preview-action';
|
|
5
6
|
const toInvokeRequest = (extensionKey, resourceIdentifiers, actionType, details) => {
|
|
6
7
|
if (!actionType) {
|
|
7
8
|
return;
|
|
@@ -29,9 +30,11 @@ const extractAction = (response, id) => {
|
|
|
29
30
|
}
|
|
30
31
|
const read = toInvokeRequest(extensionKey, action.resourceIdentifiers, (_action$dataRetrieval = action.dataRetrievalAction) === null || _action$dataRetrieval === void 0 ? void 0 : _action$dataRetrieval.name);
|
|
31
32
|
const url = extractLink(data);
|
|
33
|
+
const previewData = response ? extractPreviewAction(response) : null;
|
|
32
34
|
const details = {
|
|
33
35
|
id,
|
|
34
|
-
url
|
|
36
|
+
url,
|
|
37
|
+
previewData
|
|
35
38
|
};
|
|
36
39
|
const update = toInvokeRequest(extensionKey, action.resourceIdentifiers, (_action$dataUpdateAct = action.dataUpdateAction) === null || _action$dataUpdateAct === void 0 ? void 0 : _action$dataUpdateAct.name, details);
|
|
37
40
|
return read || update ? {
|
package/dist/es2019/version.json
CHANGED