@atlaskit/editor-plugin-card 0.1.0

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.
Files changed (200) hide show
  1. package/.eslintrc.js +15 -0
  2. package/CHANGELOG.md +1 -0
  3. package/LICENSE.md +13 -0
  4. package/README.md +7 -0
  5. package/dist/cjs/index.js +12 -0
  6. package/dist/cjs/messages.js +20 -0
  7. package/dist/cjs/nodeviews/blockCard.js +164 -0
  8. package/dist/cjs/nodeviews/datasource.js +173 -0
  9. package/dist/cjs/nodeviews/embedCard.js +398 -0
  10. package/dist/cjs/nodeviews/genericCard.js +118 -0
  11. package/dist/cjs/nodeviews/inlineCard.js +132 -0
  12. package/dist/cjs/plugin.js +138 -0
  13. package/dist/cjs/pm-plugins/actions.js +122 -0
  14. package/dist/cjs/pm-plugins/analytics/create-analytics-queue.js +48 -0
  15. package/dist/cjs/pm-plugins/analytics/events-from-tr.js +359 -0
  16. package/dist/cjs/pm-plugins/analytics/index.js +19 -0
  17. package/dist/cjs/pm-plugins/analytics/types.js +5 -0
  18. package/dist/cjs/pm-plugins/analytics/utils.js +178 -0
  19. package/dist/cjs/pm-plugins/doc.js +479 -0
  20. package/dist/cjs/pm-plugins/keymap.js +64 -0
  21. package/dist/cjs/pm-plugins/main.js +212 -0
  22. package/dist/cjs/pm-plugins/mountHyperlink.js +47 -0
  23. package/dist/cjs/pm-plugins/plugin-key.js +9 -0
  24. package/dist/cjs/pm-plugins/reducers.js +111 -0
  25. package/dist/cjs/pm-plugins/shouldReplaceLink.js +35 -0
  26. package/dist/cjs/pm-plugins/util/resolve.js +59 -0
  27. package/dist/cjs/pm-plugins/util/state.js +49 -0
  28. package/dist/cjs/toolbar.js +364 -0
  29. package/dist/cjs/types.js +5 -0
  30. package/dist/cjs/ui/DatasourceModal/ModalWithState.js +25 -0
  31. package/dist/cjs/ui/DatasourceModal/index.js +60 -0
  32. package/dist/cjs/ui/EditLinkToolbar.js +258 -0
  33. package/dist/cjs/ui/EditorSmartCardEvents.js +21 -0
  34. package/dist/cjs/ui/EditorSmartCardEventsNext.js +215 -0
  35. package/dist/cjs/ui/HyperlinkToolbarAppearance.js +174 -0
  36. package/dist/cjs/ui/LayoutButton/index.js +121 -0
  37. package/dist/cjs/ui/LayoutButton/types.js +5 -0
  38. package/dist/cjs/ui/LayoutButton/utils.js +19 -0
  39. package/dist/cjs/ui/LinkToolbarAppearance.js +152 -0
  40. package/dist/cjs/ui/ResizableEmbedCard.js +364 -0
  41. package/dist/cjs/ui/SmallerEditIcon.js +22 -0
  42. package/dist/cjs/utils.js +60 -0
  43. package/dist/cjs/version.json +5 -0
  44. package/dist/es2019/index.js +1 -0
  45. package/dist/es2019/messages.js +13 -0
  46. package/dist/es2019/nodeviews/blockCard.js +131 -0
  47. package/dist/es2019/nodeviews/datasource.js +137 -0
  48. package/dist/es2019/nodeviews/embedCard.js +370 -0
  49. package/dist/es2019/nodeviews/genericCard.js +92 -0
  50. package/dist/es2019/nodeviews/inlineCard.js +113 -0
  51. package/dist/es2019/plugin.js +129 -0
  52. package/dist/es2019/pm-plugins/actions.js +57 -0
  53. package/dist/es2019/pm-plugins/analytics/create-analytics-queue.js +38 -0
  54. package/dist/es2019/pm-plugins/analytics/events-from-tr.js +339 -0
  55. package/dist/es2019/pm-plugins/analytics/index.js +2 -0
  56. package/dist/es2019/pm-plugins/analytics/types.js +1 -0
  57. package/dist/es2019/pm-plugins/analytics/utils.js +160 -0
  58. package/dist/es2019/pm-plugins/doc.js +451 -0
  59. package/dist/es2019/pm-plugins/keymap.js +59 -0
  60. package/dist/es2019/pm-plugins/main.js +208 -0
  61. package/dist/es2019/pm-plugins/mountHyperlink.js +37 -0
  62. package/dist/es2019/pm-plugins/plugin-key.js +2 -0
  63. package/dist/es2019/pm-plugins/reducers.js +110 -0
  64. package/dist/es2019/pm-plugins/shouldReplaceLink.js +25 -0
  65. package/dist/es2019/pm-plugins/util/resolve.js +50 -0
  66. package/dist/es2019/pm-plugins/util/state.js +26 -0
  67. package/dist/es2019/toolbar.js +359 -0
  68. package/dist/es2019/types.js +1 -0
  69. package/dist/es2019/ui/DatasourceModal/ModalWithState.js +19 -0
  70. package/dist/es2019/ui/DatasourceModal/index.js +48 -0
  71. package/dist/es2019/ui/EditLinkToolbar.js +226 -0
  72. package/dist/es2019/ui/EditorSmartCardEvents.js +15 -0
  73. package/dist/es2019/ui/EditorSmartCardEventsNext.js +199 -0
  74. package/dist/es2019/ui/HyperlinkToolbarAppearance.js +86 -0
  75. package/dist/es2019/ui/LayoutButton/index.js +114 -0
  76. package/dist/es2019/ui/LayoutButton/types.js +1 -0
  77. package/dist/es2019/ui/LayoutButton/utils.js +15 -0
  78. package/dist/es2019/ui/LinkToolbarAppearance.js +118 -0
  79. package/dist/es2019/ui/ResizableEmbedCard.js +335 -0
  80. package/dist/es2019/ui/SmallerEditIcon.js +14 -0
  81. package/dist/es2019/utils.js +46 -0
  82. package/dist/es2019/version.json +5 -0
  83. package/dist/esm/index.js +1 -0
  84. package/dist/esm/messages.js +13 -0
  85. package/dist/esm/nodeviews/blockCard.js +156 -0
  86. package/dist/esm/nodeviews/datasource.js +165 -0
  87. package/dist/esm/nodeviews/embedCard.js +389 -0
  88. package/dist/esm/nodeviews/genericCard.js +111 -0
  89. package/dist/esm/nodeviews/inlineCard.js +124 -0
  90. package/dist/esm/plugin.js +130 -0
  91. package/dist/esm/pm-plugins/actions.js +102 -0
  92. package/dist/esm/pm-plugins/analytics/create-analytics-queue.js +41 -0
  93. package/dist/esm/pm-plugins/analytics/events-from-tr.js +350 -0
  94. package/dist/esm/pm-plugins/analytics/index.js +2 -0
  95. package/dist/esm/pm-plugins/analytics/types.js +1 -0
  96. package/dist/esm/pm-plugins/analytics/utils.js +160 -0
  97. package/dist/esm/pm-plugins/doc.js +460 -0
  98. package/dist/esm/pm-plugins/keymap.js +58 -0
  99. package/dist/esm/pm-plugins/main.js +199 -0
  100. package/dist/esm/pm-plugins/mountHyperlink.js +39 -0
  101. package/dist/esm/pm-plugins/plugin-key.js +2 -0
  102. package/dist/esm/pm-plugins/reducers.js +103 -0
  103. package/dist/esm/pm-plugins/shouldReplaceLink.js +29 -0
  104. package/dist/esm/pm-plugins/util/resolve.js +52 -0
  105. package/dist/esm/pm-plugins/util/state.js +40 -0
  106. package/dist/esm/toolbar.js +350 -0
  107. package/dist/esm/types.js +1 -0
  108. package/dist/esm/ui/DatasourceModal/ModalWithState.js +17 -0
  109. package/dist/esm/ui/DatasourceModal/index.js +49 -0
  110. package/dist/esm/ui/EditLinkToolbar.js +244 -0
  111. package/dist/esm/ui/EditorSmartCardEvents.js +14 -0
  112. package/dist/esm/ui/EditorSmartCardEventsNext.js +203 -0
  113. package/dist/esm/ui/HyperlinkToolbarAppearance.js +163 -0
  114. package/dist/esm/ui/LayoutButton/index.js +110 -0
  115. package/dist/esm/ui/LayoutButton/types.js +1 -0
  116. package/dist/esm/ui/LayoutButton/utils.js +12 -0
  117. package/dist/esm/ui/LinkToolbarAppearance.js +141 -0
  118. package/dist/esm/ui/ResizableEmbedCard.js +358 -0
  119. package/dist/esm/ui/SmallerEditIcon.js +14 -0
  120. package/dist/esm/utils.js +48 -0
  121. package/dist/esm/version.json +5 -0
  122. package/dist/types/index.d.ts +2 -0
  123. package/dist/types/messages.d.ts +12 -0
  124. package/dist/types/nodeviews/blockCard.d.ts +26 -0
  125. package/dist/types/nodeviews/datasource.d.ts +42 -0
  126. package/dist/types/nodeviews/embedCard.d.ts +46 -0
  127. package/dist/types/nodeviews/genericCard.d.ts +37 -0
  128. package/dist/types/nodeviews/inlineCard.d.ts +23 -0
  129. package/dist/types/plugin.d.ts +24 -0
  130. package/dist/types/pm-plugins/actions.d.ts +23 -0
  131. package/dist/types/pm-plugins/analytics/create-analytics-queue.d.ts +10 -0
  132. package/dist/types/pm-plugins/analytics/events-from-tr.d.ts +17 -0
  133. package/dist/types/pm-plugins/analytics/index.d.ts +2 -0
  134. package/dist/types/pm-plugins/analytics/types.d.ts +12 -0
  135. package/dist/types/pm-plugins/analytics/utils.d.ts +32 -0
  136. package/dist/types/pm-plugins/doc.d.ts +22 -0
  137. package/dist/types/pm-plugins/keymap.d.ts +3 -0
  138. package/dist/types/pm-plugins/main.d.ts +6 -0
  139. package/dist/types/pm-plugins/mountHyperlink.d.ts +5 -0
  140. package/dist/types/pm-plugins/plugin-key.d.ts +3 -0
  141. package/dist/types/pm-plugins/reducers.d.ts +3 -0
  142. package/dist/types/pm-plugins/shouldReplaceLink.d.ts +2 -0
  143. package/dist/types/pm-plugins/util/resolve.d.ts +8 -0
  144. package/dist/types/pm-plugins/util/state.d.ts +31 -0
  145. package/dist/types/toolbar.d.ts +9 -0
  146. package/dist/types/types.d.ts +163 -0
  147. package/dist/types/ui/DatasourceModal/ModalWithState.d.ts +9 -0
  148. package/dist/types/ui/DatasourceModal/index.d.ts +11 -0
  149. package/dist/types/ui/EditLinkToolbar.d.ts +47 -0
  150. package/dist/types/ui/EditorSmartCardEvents.d.ts +5 -0
  151. package/dist/types/ui/EditorSmartCardEventsNext.d.ts +18 -0
  152. package/dist/types/ui/HyperlinkToolbarAppearance.d.ts +32 -0
  153. package/dist/types/ui/LayoutButton/index.d.ts +9 -0
  154. package/dist/types/ui/LayoutButton/types.d.ts +19 -0
  155. package/dist/types/ui/LayoutButton/utils.d.ts +5 -0
  156. package/dist/types/ui/LinkToolbarAppearance.d.ts +29 -0
  157. package/dist/types/ui/ResizableEmbedCard.d.ts +61 -0
  158. package/dist/types/ui/SmallerEditIcon.d.ts +3 -0
  159. package/dist/types/utils.d.ts +19 -0
  160. package/dist/types-ts4.5/index.d.ts +2 -0
  161. package/dist/types-ts4.5/messages.d.ts +12 -0
  162. package/dist/types-ts4.5/nodeviews/blockCard.d.ts +26 -0
  163. package/dist/types-ts4.5/nodeviews/datasource.d.ts +42 -0
  164. package/dist/types-ts4.5/nodeviews/embedCard.d.ts +46 -0
  165. package/dist/types-ts4.5/nodeviews/genericCard.d.ts +37 -0
  166. package/dist/types-ts4.5/nodeviews/inlineCard.d.ts +23 -0
  167. package/dist/types-ts4.5/plugin.d.ts +24 -0
  168. package/dist/types-ts4.5/pm-plugins/actions.d.ts +23 -0
  169. package/dist/types-ts4.5/pm-plugins/analytics/create-analytics-queue.d.ts +10 -0
  170. package/dist/types-ts4.5/pm-plugins/analytics/events-from-tr.d.ts +17 -0
  171. package/dist/types-ts4.5/pm-plugins/analytics/index.d.ts +2 -0
  172. package/dist/types-ts4.5/pm-plugins/analytics/types.d.ts +12 -0
  173. package/dist/types-ts4.5/pm-plugins/analytics/utils.d.ts +32 -0
  174. package/dist/types-ts4.5/pm-plugins/doc.d.ts +22 -0
  175. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +3 -0
  176. package/dist/types-ts4.5/pm-plugins/main.d.ts +6 -0
  177. package/dist/types-ts4.5/pm-plugins/mountHyperlink.d.ts +5 -0
  178. package/dist/types-ts4.5/pm-plugins/plugin-key.d.ts +3 -0
  179. package/dist/types-ts4.5/pm-plugins/reducers.d.ts +3 -0
  180. package/dist/types-ts4.5/pm-plugins/shouldReplaceLink.d.ts +2 -0
  181. package/dist/types-ts4.5/pm-plugins/util/resolve.d.ts +8 -0
  182. package/dist/types-ts4.5/pm-plugins/util/state.d.ts +31 -0
  183. package/dist/types-ts4.5/toolbar.d.ts +9 -0
  184. package/dist/types-ts4.5/types.d.ts +163 -0
  185. package/dist/types-ts4.5/ui/DatasourceModal/ModalWithState.d.ts +9 -0
  186. package/dist/types-ts4.5/ui/DatasourceModal/index.d.ts +11 -0
  187. package/dist/types-ts4.5/ui/EditLinkToolbar.d.ts +47 -0
  188. package/dist/types-ts4.5/ui/EditorSmartCardEvents.d.ts +5 -0
  189. package/dist/types-ts4.5/ui/EditorSmartCardEventsNext.d.ts +18 -0
  190. package/dist/types-ts4.5/ui/HyperlinkToolbarAppearance.d.ts +32 -0
  191. package/dist/types-ts4.5/ui/LayoutButton/index.d.ts +9 -0
  192. package/dist/types-ts4.5/ui/LayoutButton/types.d.ts +19 -0
  193. package/dist/types-ts4.5/ui/LayoutButton/utils.d.ts +5 -0
  194. package/dist/types-ts4.5/ui/LinkToolbarAppearance.d.ts +29 -0
  195. package/dist/types-ts4.5/ui/ResizableEmbedCard.d.ts +61 -0
  196. package/dist/types-ts4.5/ui/SmallerEditIcon.d.ts +3 -0
  197. package/dist/types-ts4.5/utils.d.ts +19 -0
  198. package/package.json +126 -0
  199. package/report.api.md +146 -0
  200. package/tmp/api-report-tmp.d.ts +117 -0
@@ -0,0 +1,398 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.EmbedCardComponent = exports.EmbedCard = void 0;
8
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
9
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
12
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
17
+ var _react = _interopRequireDefault(require("react"));
18
+ var _propTypes = _interopRequireDefault(require("prop-types"));
19
+ var _rafSchd = _interopRequireDefault(require("raf-schd"));
20
+ var _steps = require("@atlaskit/adf-schema/steps");
21
+ var _hooks = require("@atlaskit/editor-common/hooks");
22
+ var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
23
+ var _ui = require("@atlaskit/editor-common/ui");
24
+ var _utils = require("@atlaskit/editor-common/utils");
25
+ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
26
+ var _smartCard = require("@atlaskit/smart-card");
27
+ var _actions = require("../pm-plugins/actions");
28
+ var _ResizableEmbedCard = _interopRequireDefault(require("../ui/ResizableEmbedCard"));
29
+ var _genericCard = require("./genericCard");
30
+ 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; }
31
+ 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; }
32
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
33
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
34
+ var CardInner = function CardInner(_ref) {
35
+ var pluginInjectionApi = _ref.pluginInjectionApi,
36
+ getPosSafely = _ref.getPosSafely,
37
+ getLineLength = _ref.getLineLength,
38
+ view = _ref.view,
39
+ smartCard = _ref.smartCard,
40
+ eventDispatcher = _ref.eventDispatcher,
41
+ updateSize = _ref.updateSize,
42
+ getPos = _ref.getPos,
43
+ aspectRatio = _ref.aspectRatio,
44
+ allowResizing = _ref.allowResizing,
45
+ hasPreview = _ref.hasPreview,
46
+ heightAlone = _ref.heightAlone,
47
+ cardProps = _ref.cardProps,
48
+ dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
49
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['width']),
50
+ widthState = _useSharedPluginState.widthState;
51
+ var widthStateLineLength = (widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || 0;
52
+ var widthStateWidth = (widthState === null || widthState === void 0 ? void 0 : widthState.width) || 0;
53
+ var pos = getPosSafely();
54
+ if (pos === undefined) {
55
+ return null;
56
+ }
57
+ var lineLength = getLineLength(view, pos, widthStateLineLength);
58
+ var containerWidth = (0, _utils.isRichMediaInsideOfBlockNode)(view, pos) ? lineLength : widthStateWidth;
59
+ if (!allowResizing || !hasPreview) {
60
+ // There are two ways `width` and `height` can be defined here:
61
+ // 1) Either as `heightAlone` as height value and no width
62
+ // 2) or as `1` for height and aspectRation (defined or a default one) as a width
63
+ // See above for how aspectRation is calculated.
64
+ var defaultAspectRatio = _editorSharedStyles.DEFAULT_EMBED_CARD_WIDTH / _editorSharedStyles.DEFAULT_EMBED_CARD_HEIGHT;
65
+ var richMediaWrapperHeight = 1;
66
+ var richMediaWrapperWidth = aspectRatio || defaultAspectRatio;
67
+ if (heightAlone) {
68
+ richMediaWrapperHeight = heightAlone;
69
+ richMediaWrapperWidth = undefined;
70
+ }
71
+ return /*#__PURE__*/_react.default.createElement(_ui.MediaSingle, (0, _extends2.default)({}, cardProps, {
72
+ height: richMediaWrapperHeight,
73
+ width: richMediaWrapperWidth,
74
+ nodeType: "embedCard",
75
+ hasFallbackContainer: hasPreview,
76
+ lineLength: lineLength,
77
+ containerWidth: containerWidth
78
+ }), smartCard);
79
+ }
80
+ var displayGrid = function displayGrid(visible, gridType, highlight) {
81
+ var _pluginInjectionApi$d;
82
+ return pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.grid.actions) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.displayGrid(view)({
83
+ visible: visible,
84
+ gridType: gridType,
85
+ highlight: highlight
86
+ });
87
+ };
88
+ return /*#__PURE__*/_react.default.createElement(_ResizableEmbedCard.default, (0, _extends2.default)({}, cardProps, {
89
+ height: heightAlone,
90
+ aspectRatio: aspectRatio,
91
+ view: view,
92
+ getPos: getPos,
93
+ lineLength: lineLength,
94
+ gridSize: 12,
95
+ containerWidth: containerWidth,
96
+ displayGrid: displayGrid,
97
+ updateSize: updateSize,
98
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent
99
+ }), smartCard);
100
+ };
101
+ // eslint-disable-next-line @repo/internal/react/no-class-components
102
+ var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
103
+ (0, _inherits2.default)(EmbedCardComponent, _React$PureComponent);
104
+ var _super = _createSuper(EmbedCardComponent);
105
+ function EmbedCardComponent() {
106
+ var _this;
107
+ (0, _classCallCheck2.default)(this, EmbedCardComponent);
108
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
109
+ args[_key] = arguments[_key];
110
+ }
111
+ _this = _super.call.apply(_super, [this].concat(args));
112
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "embedIframeRef", /*#__PURE__*/_react.default.createRef());
113
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClick", function () {});
114
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
115
+ hasPreview: true
116
+ });
117
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getPosSafely", function () {
118
+ var getPos = _this.props.getPos;
119
+ if (!getPos || typeof getPos === 'boolean') {
120
+ return;
121
+ }
122
+ try {
123
+ return getPos();
124
+ } catch (e) {
125
+ // Can blow up in rare cases, when node has been removed.
126
+ }
127
+ });
128
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onResolve", function (data) {
129
+ var view = _this.props.view;
130
+ var title = data.title,
131
+ url = data.url,
132
+ aspectRatio = data.aspectRatio;
133
+ var _this$props$node$attr = _this.props.node.attrs,
134
+ originalHeight = _this$props$node$attr.originalHeight,
135
+ originalWidth = _this$props$node$attr.originalWidth;
136
+ if (aspectRatio && !originalHeight && !originalWidth) {
137
+ // Assumption here is if ADF already have both height and width set,
138
+ // we will going to use that later on in this class as aspectRatio
139
+ // Most likely we dealing with an embed that received aspectRatio via onResolve previously
140
+ // and now this information already stored in ADF.
141
+ _this.setState({
142
+ initialAspectRatio: aspectRatio
143
+ });
144
+ _this.saveOriginalDimensionsAttributes(_editorSharedStyles.DEFAULT_EMBED_CARD_HEIGHT, _editorSharedStyles.DEFAULT_EMBED_CARD_HEIGHT * aspectRatio);
145
+ }
146
+
147
+ // don't dispatch immediately since we might be in the middle of
148
+ // rendering a nodeview
149
+ (0, _rafSchd.default)(function () {
150
+ var pos = _this.getPosSafely();
151
+ if (pos === undefined) {
152
+ return;
153
+ }
154
+ return view.dispatch((0, _actions.registerCard)({
155
+ title: title,
156
+ url: url,
157
+ pos: pos
158
+ })(view.state.tr));
159
+ })();
160
+ try {
161
+ var cardContext = _this.context.contextAdapter ? _this.context.contextAdapter.card : undefined;
162
+ var hasPreview = cardContext && cardContext.value.extractors.getPreview(url, _this.props.platform);
163
+ if (!hasPreview) {
164
+ _this.setState({
165
+ hasPreview: false
166
+ });
167
+ }
168
+ } catch (e) {}
169
+ });
170
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateSize", function (pctWidth, layout) {
171
+ var _this$props$view = _this.props.view,
172
+ state = _this$props$view.state,
173
+ dispatch = _this$props$view.dispatch;
174
+ var pos = _this.getPosSafely();
175
+ if (pos === undefined) {
176
+ return;
177
+ }
178
+ var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, _this.props.node.attrs), {}, {
179
+ width: pctWidth,
180
+ layout: layout
181
+ }));
182
+ tr.setMeta('scrollIntoView', false);
183
+ dispatch(tr);
184
+ return true;
185
+ });
186
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getLineLength", function (view, pos, originalLineLength) {
187
+ if (typeof pos === 'number' && (0, _utils.isRichMediaInsideOfBlockNode)(view, pos)) {
188
+ var $pos = view.state.doc.resolve(pos);
189
+ var domNode = view.nodeDOM($pos.pos);
190
+ if ($pos.nodeAfter && _utils.floatingLayouts.indexOf($pos.nodeAfter.attrs.layout) > -1 && domNode && domNode.parentElement) {
191
+ return domNode.parentElement.offsetWidth;
192
+ }
193
+ if (domNode instanceof HTMLElement) {
194
+ return domNode.offsetWidth;
195
+ }
196
+ }
197
+ return originalLineLength;
198
+ });
199
+ /**
200
+ * Even though render is capable of listening and reacting to iframely wrapper iframe sent `resize` events
201
+ * it's good idea to store latest actual height in ADF, so that when renderer (well, editor as well) is loading
202
+ * we will show embed window of appropriate size and avoid unnecessary content jumping.
203
+ */
204
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "saveOriginalDimensionsAttributes", function (height, width) {
205
+ var view = _this.props.view;
206
+
207
+ // TODO: ED-15663
208
+ // Please, do not copy or use this kind of code below
209
+ // @ts-ignore
210
+ var fakeTableResizePluginKey = {
211
+ key: 'tableFlexiColumnResizing$',
212
+ getState: function getState(state) {
213
+ // eslint-disable-next-line
214
+ return state['tableFlexiColumnResizing$'];
215
+ }
216
+ };
217
+ var fakeTableResizeState = fakeTableResizePluginKey.getState(view.state);
218
+
219
+ // We are not updating ADF when this function fired while table is resizing.
220
+ // Changing ADF in the middle of resize will break table resize plugin logic
221
+ // (tables will be considered different at the end of the drag and cell size won't be stored)
222
+ // But this is not a big problem, editor user will be seeing latest height anyway (via updated state)
223
+ // And even if page to be saved with slightly outdated height, renderer is capable of reading latest height value
224
+ // when embed loads, and so it won't be a problem.
225
+ if (fakeTableResizeState !== null && fakeTableResizeState !== void 0 && fakeTableResizeState.dragging) {
226
+ return;
227
+ }
228
+ (0, _rafSchd.default)(function () {
229
+ var pos = _this.getPosSafely();
230
+ if (pos === undefined) {
231
+ return;
232
+ }
233
+ view.dispatch(view.state.tr.step(new _steps.SetAttrsStep(pos, {
234
+ originalHeight: height,
235
+ originalWidth: width
236
+ })).setMeta('addToHistory', false));
237
+ })();
238
+ });
239
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onHeightUpdate", function (height) {
240
+ _this.setState({
241
+ liveHeight: height
242
+ });
243
+ _this.saveOriginalDimensionsAttributes(height, undefined);
244
+ });
245
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onError", function (_ref2) {
246
+ var err = _ref2.err;
247
+ if (err) {
248
+ throw err;
249
+ }
250
+ });
251
+ return _this;
252
+ }
253
+ (0, _createClass2.default)(EmbedCardComponent, [{
254
+ key: "UNSAFE_componentWillMount",
255
+ value: function UNSAFE_componentWillMount() {
256
+ var view = this.props.view;
257
+ var scrollContainer = (0, _ui.findOverflowScrollParent)(view.dom);
258
+ this.scrollContainer = scrollContainer || undefined;
259
+ }
260
+ }, {
261
+ key: "render",
262
+ value: function render() {
263
+ var _this$props = this.props,
264
+ node = _this$props.node,
265
+ cardContext = _this$props.cardContext,
266
+ platform = _this$props.platform,
267
+ allowResizing = _this$props.allowResizing,
268
+ fullWidthMode = _this$props.fullWidthMode,
269
+ view = _this$props.view,
270
+ dispatchAnalyticsEvent = _this$props.dispatchAnalyticsEvent,
271
+ getPos = _this$props.getPos,
272
+ pluginInjectionApi = _this$props.pluginInjectionApi;
273
+ var _node$attrs = node.attrs,
274
+ url = _node$attrs.url,
275
+ pctWidth = _node$attrs.width,
276
+ layout = _node$attrs.layout,
277
+ originalHeight = _node$attrs.originalHeight,
278
+ originalWidth = _node$attrs.originalWidth;
279
+ var _this$state = this.state,
280
+ hasPreview = _this$state.hasPreview,
281
+ liveHeight = _this$state.liveHeight,
282
+ initialAspectRatio = _this$state.initialAspectRatio;
283
+
284
+ // We don't want to use `originalHeight` when `originalWidth` also present,
285
+ // since `heightAlone` is defined only when just height is available.
286
+ var heightAlone = liveHeight !== null && liveHeight !== void 0 ? liveHeight : !originalWidth && originalHeight || undefined;
287
+ var aspectRatio = !heightAlone && (
288
+ // No need getting aspectRatio if heightAlone defined already
289
+ initialAspectRatio ||
290
+ // If we have initialAspectRatio (coming from iframely) we should go with that
291
+ originalHeight && originalWidth && originalWidth / originalHeight) ||
292
+ // If ADF contains both width and height we get ratio from that
293
+ undefined;
294
+ var cardProps = {
295
+ layout: layout,
296
+ pctWidth: pctWidth,
297
+ fullWidthMode: fullWidthMode
298
+ };
299
+ var smartCard = /*#__PURE__*/_react.default.createElement(_smartCard.Card, {
300
+ key: url,
301
+ url: url,
302
+ appearance: "embed",
303
+ onClick: this.onClick,
304
+ onResolve: this.onResolve,
305
+ onError: this.onError,
306
+ showActions: platform === 'web',
307
+ isFrameVisible: true,
308
+ inheritDimensions: true,
309
+ platform: platform,
310
+ container: this.scrollContainer,
311
+ embedIframeRef: this.embedIframeRef
312
+ });
313
+ var cardInner = /*#__PURE__*/_react.default.createElement(_smartCard.EmbedResizeMessageListener, {
314
+ embedIframeRef: this.embedIframeRef,
315
+ onHeightUpdate: this.onHeightUpdate
316
+ }, /*#__PURE__*/_react.default.createElement(CardInner, {
317
+ pluginInjectionApi: pluginInjectionApi,
318
+ smartCard: smartCard,
319
+ hasPreview: hasPreview,
320
+ getPosSafely: this.getPosSafely,
321
+ view: view,
322
+ getLineLength: this.getLineLength,
323
+ eventDispatcher: this.props.eventDispatcher,
324
+ updateSize: this.updateSize,
325
+ getPos: getPos,
326
+ aspectRatio: aspectRatio,
327
+ allowResizing: allowResizing,
328
+ heightAlone: heightAlone,
329
+ cardProps: cardProps,
330
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent
331
+ }));
332
+
333
+ // [WS-2307]: we only render card wrapped into a Provider when the value is ready
334
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, cardContext && cardContext.value ? /*#__PURE__*/_react.default.createElement(cardContext.Provider, {
335
+ value: cardContext.value
336
+ }, cardInner) : null);
337
+ }
338
+ }]);
339
+ return EmbedCardComponent;
340
+ }(_react.default.PureComponent);
341
+ exports.EmbedCardComponent = EmbedCardComponent;
342
+ (0, _defineProperty2.default)(EmbedCardComponent, "contextTypes", {
343
+ contextAdapter: _propTypes.default.object
344
+ });
345
+ var WrappedBlockCard = (0, _genericCard.Card)(EmbedCardComponent, _ui.UnsupportedBlock);
346
+ var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
347
+ (0, _inherits2.default)(EmbedCard, _ReactNodeView);
348
+ var _super2 = _createSuper(EmbedCard);
349
+ function EmbedCard() {
350
+ (0, _classCallCheck2.default)(this, EmbedCard);
351
+ return _super2.apply(this, arguments);
352
+ }
353
+ (0, _createClass2.default)(EmbedCard, [{
354
+ key: "viewShouldUpdate",
355
+ value: function viewShouldUpdate(nextNode) {
356
+ if (this.node.attrs !== nextNode.attrs) {
357
+ return true;
358
+ }
359
+ return (0, _get2.default)((0, _getPrototypeOf2.default)(EmbedCard.prototype), "viewShouldUpdate", this).call(this, nextNode);
360
+ }
361
+ }, {
362
+ key: "createDomRef",
363
+ value: function createDomRef() {
364
+ var domRef = document.createElement('div');
365
+ if (this.reactComponentProps.platform !== 'mobile') {
366
+ // workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
367
+ // see also: https://github.com/ProseMirror/prosemirror/issues/884
368
+ domRef.contentEditable = 'true';
369
+ domRef.setAttribute('spellcheck', 'false');
370
+ }
371
+ return domRef;
372
+ }
373
+ }, {
374
+ key: "render",
375
+ value: function render() {
376
+ var _this$reactComponentP = this.reactComponentProps,
377
+ eventDispatcher = _this$reactComponentP.eventDispatcher,
378
+ allowResizing = _this$reactComponentP.allowResizing,
379
+ platform = _this$reactComponentP.platform,
380
+ fullWidthMode = _this$reactComponentP.fullWidthMode,
381
+ dispatchAnalyticsEvent = _this$reactComponentP.dispatchAnalyticsEvent,
382
+ pluginInjectionApi = _this$reactComponentP.pluginInjectionApi;
383
+ return /*#__PURE__*/_react.default.createElement(WrappedBlockCard, {
384
+ node: this.node,
385
+ view: this.view,
386
+ eventDispatcher: eventDispatcher,
387
+ getPos: this.getPos,
388
+ allowResizing: allowResizing,
389
+ platform: platform,
390
+ fullWidthMode: fullWidthMode,
391
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
392
+ pluginInjectionApi: pluginInjectionApi
393
+ });
394
+ }
395
+ }]);
396
+ return EmbedCard;
397
+ }(_reactNodeView.default);
398
+ exports.EmbedCard = EmbedCard;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.Card = Card;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
12
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
+ var _react = _interopRequireDefault(require("react"));
17
+ var _propTypes = _interopRequireDefault(require("prop-types"));
18
+ var _adfSchema = require("@atlaskit/adf-schema");
19
+ var _analyticsNext = require("@atlaskit/analytics-next");
20
+ var _utils = require("@atlaskit/editor-common/utils");
21
+ var _doc = require("../pm-plugins/doc");
22
+ var _state = require("../pm-plugins/util/state");
23
+ var _utils2 = require("../utils");
24
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
25
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
26
+ function Card(SmartCardComponent, UnsupportedComponent) {
27
+ var _class;
28
+ return _class = /*#__PURE__*/function (_React$Component) {
29
+ (0, _inherits2.default)(_class, _React$Component);
30
+ var _super = _createSuper(_class);
31
+ function _class() {
32
+ var _this;
33
+ (0, _classCallCheck2.default)(this, _class);
34
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
35
+ args[_key] = arguments[_key];
36
+ }
37
+ _this = _super.call.apply(_super, [this].concat(args));
38
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
39
+ isError: false
40
+ });
41
+ return _this;
42
+ }
43
+ (0, _createClass2.default)(_class, [{
44
+ key: "render",
45
+ value: function render() {
46
+ var _getPluginState;
47
+ var _titleUrlPairFromNode = (0, _utils2.titleUrlPairFromNode)(this.props.node),
48
+ url = _titleUrlPairFromNode.url;
49
+ if (url && !(0, _adfSchema.isSafeUrl)(url)) {
50
+ return /*#__PURE__*/_react.default.createElement(UnsupportedComponent, null);
51
+ }
52
+ if (this.state.isError) {
53
+ if (url) {
54
+ return /*#__PURE__*/_react.default.createElement("a", {
55
+ href: url,
56
+ onClick: function onClick(e) {
57
+ e.preventDefault();
58
+ }
59
+ }, url);
60
+ } else {
61
+ return /*#__PURE__*/_react.default.createElement(UnsupportedComponent, null);
62
+ }
63
+ }
64
+ var cardContext = this.context.contextAdapter ? this.context.contextAdapter.card : undefined;
65
+ var editorAppearance = (_getPluginState = (0, _state.getPluginState)(this.props.view.state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.editorAppearance;
66
+ var analyticsEditorAppearance = (0, _utils.getAnalyticsEditorAppearance)(editorAppearance);
67
+ return /*#__PURE__*/_react.default.createElement(_analyticsNext.AnalyticsContext, {
68
+ data: {
69
+ attributes: {
70
+ location: analyticsEditorAppearance
71
+ },
72
+ // Below is added for the future implementation of Linking Platform namespaced analytics context
73
+ location: analyticsEditorAppearance
74
+ }
75
+ }, /*#__PURE__*/_react.default.createElement(SmartCardComponent, (0, _extends2.default)({
76
+ key: url,
77
+ cardContext: cardContext
78
+ }, this.props)));
79
+ }
80
+ }, {
81
+ key: "componentDidCatch",
82
+ value: function componentDidCatch(error) {
83
+ var maybeAPIError = error;
84
+ // NB: errors received in this component are propagated by the `@atlaskit/smart-card` component.
85
+ // Depending on the kind of error, the expectation for this component is to either:
86
+ // (1) Render a blue link whilst retaining `inlineCard` in the ADF (non-fatal errs);
87
+ // (2) Render a blue link whilst downgrading to `link` in the ADF (fatal errs).
88
+
89
+ if (maybeAPIError.kind && maybeAPIError.kind === 'fatal') {
90
+ var _pluginInjectionApi$d;
91
+ this.setState({
92
+ isError: true
93
+ });
94
+ var _this$props = this.props,
95
+ view = _this$props.view,
96
+ node = _this$props.node,
97
+ getPos = _this$props.getPos,
98
+ pluginInjectionApi = _this$props.pluginInjectionApi;
99
+ var _titleUrlPairFromNode2 = (0, _utils2.titleUrlPairFromNode)(node),
100
+ url = _titleUrlPairFromNode2.url;
101
+ if (!getPos || typeof getPos === 'boolean') {
102
+ return;
103
+ }
104
+ (0, _doc.changeSelectedCardToLinkFallback)(undefined, url, true, node, getPos(), pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions)(view.state, view.dispatch);
105
+ return null;
106
+ } else {
107
+ // Otherwise, render a blue link as fallback (above in render()).
108
+ this.setState({
109
+ isError: true
110
+ });
111
+ }
112
+ }
113
+ }]);
114
+ return _class;
115
+ }(_react.default.Component), (0, _defineProperty2.default)(_class, "contextTypes", {
116
+ contextAdapter: _propTypes.default.object
117
+ }), _class;
118
+ }
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.InlineCardComponent = void 0;
8
+ exports.InlineCardNodeView = InlineCardNodeView;
9
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
12
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
+ var _react = _interopRequireDefault(require("react"));
17
+ var _propTypes = _interopRequireDefault(require("prop-types"));
18
+ var _rafSchd = _interopRequireDefault(require("raf-schd"));
19
+ var _ui = require("@atlaskit/editor-common/ui");
20
+ var _smartCard = require("@atlaskit/smart-card");
21
+ var _actions = require("../pm-plugins/actions");
22
+ var _genericCard = require("./genericCard");
23
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
24
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
25
+ // eslint-disable-next-line @repo/internal/react/no-class-components
26
+ var InlineCardComponent = /*#__PURE__*/function (_React$PureComponent) {
27
+ (0, _inherits2.default)(InlineCardComponent, _React$PureComponent);
28
+ var _super = _createSuper(InlineCardComponent);
29
+ function InlineCardComponent() {
30
+ var _this;
31
+ (0, _classCallCheck2.default)(this, InlineCardComponent);
32
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
33
+ args[_key] = arguments[_key];
34
+ }
35
+ _this = _super.call.apply(_super, [this].concat(args));
36
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClick", function () {});
37
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onResolve", function (data) {
38
+ var _this$props = _this.props,
39
+ getPos = _this$props.getPos,
40
+ view = _this$props.view;
41
+ if (!getPos || typeof getPos === 'boolean') {
42
+ return;
43
+ }
44
+ var title = data.title,
45
+ url = data.url;
46
+ // don't dispatch immediately since we might be in the middle of
47
+ // rendering a nodeview
48
+ (0, _rafSchd.default)(function () {
49
+ // prosemirror-bump-fix
50
+ var pos = getPos();
51
+ if (typeof pos !== 'number') {
52
+ return;
53
+ }
54
+ view.dispatch((0, _actions.registerCard)({
55
+ title: title,
56
+ url: url,
57
+ pos: pos
58
+ })(view.state.tr));
59
+ })();
60
+ });
61
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onError", function (data) {
62
+ var url = data.url,
63
+ err = data.err;
64
+ if (err) {
65
+ throw err;
66
+ }
67
+ _this.onResolve({
68
+ url: url
69
+ });
70
+ });
71
+ return _this;
72
+ }
73
+ (0, _createClass2.default)(InlineCardComponent, [{
74
+ key: "UNSAFE_componentWillMount",
75
+ value: function UNSAFE_componentWillMount() {
76
+ var view = this.props.view;
77
+ var scrollContainer = (0, _ui.findOverflowScrollParent)(view.dom);
78
+ this.scrollContainer = scrollContainer || undefined;
79
+ }
80
+ }, {
81
+ key: "render",
82
+ value: function render() {
83
+ var _this$props2 = this.props,
84
+ node = _this$props2.node,
85
+ cardContext = _this$props2.cardContext,
86
+ showServerActions = _this$props2.showServerActions,
87
+ useAlternativePreloader = _this$props2.useAlternativePreloader;
88
+ var _node$attrs = node.attrs,
89
+ url = _node$attrs.url,
90
+ data = _node$attrs.data;
91
+ var card = /*#__PURE__*/_react.default.createElement("span", {
92
+ className: "card"
93
+ }, /*#__PURE__*/_react.default.createElement(_smartCard.Card, {
94
+ key: url,
95
+ url: url,
96
+ data: data,
97
+ appearance: "inline",
98
+ onClick: this.onClick,
99
+ container: this.scrollContainer,
100
+ onResolve: this.onResolve,
101
+ onError: this.onError,
102
+ inlinePreloaderStyle: useAlternativePreloader ? 'on-right-without-skeleton' : undefined,
103
+ showServerActions: showServerActions
104
+ }));
105
+ // [WS-2307]: we only render card wrapped into a Provider when the value is ready,
106
+ // otherwise if we got data, we can render the card directly since it doesn't need the Provider
107
+ return cardContext && cardContext.value ? /*#__PURE__*/_react.default.createElement(cardContext.Provider, {
108
+ value: cardContext.value
109
+ }, card) : data ? card : null;
110
+ }
111
+ }]);
112
+ return InlineCardComponent;
113
+ }(_react.default.PureComponent);
114
+ exports.InlineCardComponent = InlineCardComponent;
115
+ (0, _defineProperty2.default)(InlineCardComponent, "contextTypes", {
116
+ contextAdapter: _propTypes.default.object
117
+ });
118
+ var WrappedInlineCard = (0, _genericCard.Card)(InlineCardComponent, _ui.UnsupportedInline);
119
+ function InlineCardNodeView(props) {
120
+ var useAlternativePreloader = props.useAlternativePreloader,
121
+ node = props.node,
122
+ view = props.view,
123
+ getPos = props.getPos,
124
+ showServerActions = props.showServerActions;
125
+ return /*#__PURE__*/_react.default.createElement(WrappedInlineCard, {
126
+ node: node,
127
+ view: view,
128
+ getPos: getPos,
129
+ showServerActions: showServerActions,
130
+ useAlternativePreloader: useAlternativePreloader
131
+ });
132
+ }