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