@atlaskit/editor-plugin-card 11.4.0 → 11.4.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 +16 -0
- package/dist/cjs/nodeviews/blockCard.js +23 -72
- package/dist/cjs/nodeviews/embedCard.js +21 -65
- package/dist/cjs/nodeviews/inlineCard.js +7 -51
- package/dist/cjs/pm-plugins/keymap.js +3 -2
- package/dist/es2019/nodeviews/blockCard.js +5 -28
- package/dist/es2019/nodeviews/embedCard.js +2 -23
- package/dist/es2019/nodeviews/inlineCard.js +4 -25
- package/dist/es2019/pm-plugins/keymap.js +3 -2
- package/dist/esm/nodeviews/blockCard.js +24 -72
- package/dist/esm/nodeviews/embedCard.js +21 -65
- package/dist/esm/nodeviews/inlineCard.js +8 -52
- package/dist/esm/pm-plugins/keymap.js +3 -2
- package/dist/types/nodeviews/blockCard.d.ts +1 -7
- package/dist/types/nodeviews/embedCard.d.ts +0 -2
- package/dist/types-ts4.5/nodeviews/blockCard.d.ts +1 -7
- package/dist/types-ts4.5/nodeviews/embedCard.d.ts +0 -2
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 11.4.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`57a9de1ebc5db`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/57a9de1ebc5db) -
|
|
8
|
+
fix: remove unnecessary re-renders in smart card node views
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 11.4.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`3660feecde98f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3660feecde98f) -
|
|
16
|
+
upgrade use of browser util
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 11.4.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.blockCardNodeView = exports.BlockCardComponent = exports.BlockCard = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
8
|
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
10
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
11
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
@@ -17,7 +15,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
17
15
|
var _react = _interopRequireDefault(require("react"));
|
|
18
16
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
19
17
|
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
20
|
-
var
|
|
18
|
+
var _browser = require("@atlaskit/editor-common/browser");
|
|
21
19
|
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
22
20
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
23
21
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
@@ -29,8 +27,6 @@ var _actions = require("../pm-plugins/actions");
|
|
|
29
27
|
var _utils2 = require("../pm-plugins/utils");
|
|
30
28
|
var _genericCard = require("./genericCard");
|
|
31
29
|
function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
|
|
32
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
33
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
34
30
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
35
31
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
36
32
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
@@ -41,9 +37,6 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
|
|
|
41
37
|
_this = _callSuper(this, BlockCardComponent, [props]);
|
|
42
38
|
// Ignored via go/ees005
|
|
43
39
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
44
|
-
(0, _defineProperty2.default)(_this, "state", {
|
|
45
|
-
isSSRDataAvailable: false
|
|
46
|
-
});
|
|
47
40
|
(0, _defineProperty2.default)(_this, "onResolve", function (data) {
|
|
48
41
|
var _this$props = _this.props,
|
|
49
42
|
getPos = _this$props.getPos,
|
|
@@ -71,9 +64,10 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
|
|
|
71
64
|
});
|
|
72
65
|
(0, _defineProperty2.default)(_this, "removeCardDispatched", false);
|
|
73
66
|
(0, _defineProperty2.default)(_this, "gapCursorSpan", function () {
|
|
67
|
+
var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
|
|
74
68
|
// Don't render in EdgeHTMl version <= 18 (Edge version 44)
|
|
75
69
|
// as it forces the edit popup to render 24px lower than it should
|
|
76
|
-
if (
|
|
70
|
+
if (browser.ie && browser.ie_version < 79) {
|
|
77
71
|
return;
|
|
78
72
|
}
|
|
79
73
|
|
|
@@ -90,53 +84,10 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
|
|
|
90
84
|
}
|
|
91
85
|
});
|
|
92
86
|
_this.scrollContainer = (0, _ui.findOverflowScrollParent)(props.view.dom) || undefined;
|
|
93
|
-
_this.state = {
|
|
94
|
-
isSSRDataAvailable: (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) && props.isPageSSRed
|
|
95
|
-
};
|
|
96
87
|
return _this;
|
|
97
88
|
}
|
|
98
89
|
(0, _inherits2.default)(BlockCardComponent, _React$PureComponent);
|
|
99
90
|
return (0, _createClass2.default)(BlockCardComponent, [{
|
|
100
|
-
key: "componentDidMount",
|
|
101
|
-
value: function componentDidMount() {
|
|
102
|
-
var _this2 = this;
|
|
103
|
-
if (!(0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
var provider = this.props.provider;
|
|
107
|
-
if (!provider) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
var updateSSRDataAvailability = /*#__PURE__*/function () {
|
|
111
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
112
|
-
var resolvedProvider;
|
|
113
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
114
|
-
while (1) switch (_context.prev = _context.next) {
|
|
115
|
-
case 0:
|
|
116
|
-
_context.next = 2;
|
|
117
|
-
return provider;
|
|
118
|
-
case 2:
|
|
119
|
-
resolvedProvider = _context.sent;
|
|
120
|
-
if (resolvedProvider instanceof _editorCardProvider.EditorCardProvider) {
|
|
121
|
-
_this2.setState(function (state) {
|
|
122
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
123
|
-
isSSRDataAvailable: resolvedProvider.getCacheStatusForNode(_this2.props.node) === 'ssr'
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
case 4:
|
|
128
|
-
case "end":
|
|
129
|
-
return _context.stop();
|
|
130
|
-
}
|
|
131
|
-
}, _callee);
|
|
132
|
-
}));
|
|
133
|
-
return function updateSSRDataAvailability() {
|
|
134
|
-
return _ref2.apply(this, arguments);
|
|
135
|
-
};
|
|
136
|
-
}();
|
|
137
|
-
void updateSSRDataAvailability();
|
|
138
|
-
}
|
|
139
|
-
}, {
|
|
140
91
|
key: "componentWillUnmount",
|
|
141
92
|
value: function componentWillUnmount() {
|
|
142
93
|
this.removeCard();
|
|
@@ -167,7 +118,7 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
|
|
|
167
118
|
var _node$attrs = node.attrs,
|
|
168
119
|
url = _node$attrs.url,
|
|
169
120
|
data = _node$attrs.data;
|
|
170
|
-
var cardInner = (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) &&
|
|
121
|
+
var cardInner = (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) && isPageSSRed ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ssr.CardSSR, {
|
|
171
122
|
key: url,
|
|
172
123
|
url: url !== null && url !== void 0 ? url : data.url,
|
|
173
124
|
container: this.scrollContainer,
|
|
@@ -202,31 +153,31 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
|
|
|
202
153
|
var WrappedBlockCard = (0, _genericCard.Card)(BlockCardComponent, _ui.UnsupportedBlock);
|
|
203
154
|
var BlockCard = exports.BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
204
155
|
function BlockCard() {
|
|
205
|
-
var
|
|
156
|
+
var _this2;
|
|
206
157
|
(0, _classCallCheck2.default)(this, BlockCard);
|
|
207
158
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
208
159
|
args[_key] = arguments[_key];
|
|
209
160
|
}
|
|
210
|
-
|
|
211
|
-
(0, _defineProperty2.default)(
|
|
212
|
-
(0, _defineProperty2.default)(
|
|
161
|
+
_this2 = _callSuper(this, BlockCard, [].concat(args));
|
|
162
|
+
(0, _defineProperty2.default)(_this2, "id", (0, _v.default)());
|
|
163
|
+
(0, _defineProperty2.default)(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
|
|
213
164
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
214
165
|
});
|
|
215
|
-
return
|
|
166
|
+
return _this2;
|
|
216
167
|
}
|
|
217
168
|
(0, _inherits2.default)(BlockCard, _ReactNodeView);
|
|
218
169
|
return (0, _createClass2.default)(BlockCard, [{
|
|
219
170
|
key: "createDomRef",
|
|
220
171
|
value: function createDomRef() {
|
|
221
172
|
var _this$reactComponentP,
|
|
222
|
-
|
|
173
|
+
_this3 = this,
|
|
223
174
|
_this$reactComponentP2;
|
|
224
175
|
var domRef = document.createElement('div');
|
|
225
176
|
// workaround Chrome bug in https://product-fabric.atlassian.net/browse/ED-5379
|
|
226
177
|
// see also: https://github.com/ProseMirror/prosemirror/issues/884
|
|
227
|
-
this.unsubscribe = (_this$reactComponentP = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.editorViewMode) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.sharedState.onChange(function (
|
|
228
|
-
var nextSharedState =
|
|
229
|
-
return
|
|
178
|
+
this.unsubscribe = (_this$reactComponentP = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.editorViewMode) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.sharedState.onChange(function (_ref2) {
|
|
179
|
+
var nextSharedState = _ref2.nextSharedState;
|
|
180
|
+
return _this3.updateContentEditable(nextSharedState, domRef);
|
|
230
181
|
});
|
|
231
182
|
this.updateContentEditable((_this$reactComponentP2 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP2 === void 0 || (_this$reactComponentP2 = _this$reactComponentP2.editorViewMode) === null || _this$reactComponentP2 === void 0 ? void 0 : _this$reactComponentP2.sharedState.currentState(), domRef);
|
|
232
183
|
domRef.setAttribute('spellcheck', 'false');
|
|
@@ -282,16 +233,16 @@ var BlockCard = exports.BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
282
233
|
}
|
|
283
234
|
}]);
|
|
284
235
|
}(_reactNodeView.default);
|
|
285
|
-
var blockCardNodeView = exports.blockCardNodeView = function blockCardNodeView(
|
|
286
|
-
var pmPluginFactoryParams =
|
|
287
|
-
actionOptions =
|
|
288
|
-
pluginInjectionApi =
|
|
289
|
-
onClickCallback =
|
|
290
|
-
allowDatasource =
|
|
291
|
-
inlineCardViewProducer =
|
|
292
|
-
CompetitorPrompt =
|
|
293
|
-
isPageSSRed =
|
|
294
|
-
provider =
|
|
236
|
+
var blockCardNodeView = exports.blockCardNodeView = function blockCardNodeView(_ref3) {
|
|
237
|
+
var pmPluginFactoryParams = _ref3.pmPluginFactoryParams,
|
|
238
|
+
actionOptions = _ref3.actionOptions,
|
|
239
|
+
pluginInjectionApi = _ref3.pluginInjectionApi,
|
|
240
|
+
onClickCallback = _ref3.onClickCallback,
|
|
241
|
+
allowDatasource = _ref3.allowDatasource,
|
|
242
|
+
inlineCardViewProducer = _ref3.inlineCardViewProducer,
|
|
243
|
+
CompetitorPrompt = _ref3.CompetitorPrompt,
|
|
244
|
+
isPageSSRed = _ref3.isPageSSRed,
|
|
245
|
+
provider = _ref3.provider;
|
|
295
246
|
return function (node, view, getPos, decorations) {
|
|
296
247
|
var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
|
|
297
248
|
eventDispatcher = pmPluginFactoryParams.eventDispatcher;
|
|
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.embedCardNodeView = exports.EmbedOrBlockCardComponent = exports.EmbedCardComponent = exports.EmbedCard = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
8
|
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
10
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
11
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
@@ -19,7 +17,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
19
17
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
20
18
|
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
21
19
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
22
|
-
var _editorCardProvider = require("@atlaskit/editor-card-provider");
|
|
23
20
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
24
21
|
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
25
22
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
@@ -268,53 +265,12 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
|
|
|
268
265
|
(0, _defineProperty2.default)(_this, "removeCardDispatched", false);
|
|
269
266
|
_this.scrollContainer = (0, _ui.findOverflowScrollParent)(props.view.dom) || undefined;
|
|
270
267
|
_this.state = {
|
|
271
|
-
hasPreview: true
|
|
272
|
-
isSSRDataAvailable: (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) && props.isPageSSRed
|
|
268
|
+
hasPreview: true
|
|
273
269
|
};
|
|
274
270
|
return _this;
|
|
275
271
|
}
|
|
276
272
|
(0, _inherits2.default)(EmbedCardComponent, _React$PureComponent);
|
|
277
273
|
return (0, _createClass2.default)(EmbedCardComponent, [{
|
|
278
|
-
key: "componentDidMount",
|
|
279
|
-
value: function componentDidMount() {
|
|
280
|
-
var _this2 = this;
|
|
281
|
-
if (!(0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
var provider = this.props.provider;
|
|
285
|
-
if (!provider) {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
var updateSSRDataAvailability = /*#__PURE__*/function () {
|
|
289
|
-
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
290
|
-
var resolvedProvider;
|
|
291
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
292
|
-
while (1) switch (_context.prev = _context.next) {
|
|
293
|
-
case 0:
|
|
294
|
-
_context.next = 2;
|
|
295
|
-
return provider;
|
|
296
|
-
case 2:
|
|
297
|
-
resolvedProvider = _context.sent;
|
|
298
|
-
if (resolvedProvider instanceof _editorCardProvider.EditorCardProvider) {
|
|
299
|
-
_this2.setState(function (state) {
|
|
300
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
301
|
-
isSSRDataAvailable: resolvedProvider.getCacheStatusForNode(_this2.props.node) === 'ssr'
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
case 4:
|
|
306
|
-
case "end":
|
|
307
|
-
return _context.stop();
|
|
308
|
-
}
|
|
309
|
-
}, _callee);
|
|
310
|
-
}));
|
|
311
|
-
return function updateSSRDataAvailability() {
|
|
312
|
-
return _ref3.apply(this, arguments);
|
|
313
|
-
};
|
|
314
|
-
}();
|
|
315
|
-
void updateSSRDataAvailability();
|
|
316
|
-
}
|
|
317
|
-
}, {
|
|
318
274
|
key: "componentWillUnmount",
|
|
319
275
|
value: function componentWillUnmount() {
|
|
320
276
|
this.removeCard();
|
|
@@ -373,7 +329,7 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
|
|
|
373
329
|
pctWidth: pctWidth,
|
|
374
330
|
fullWidthMode: fullWidthMode
|
|
375
331
|
};
|
|
376
|
-
var smartCard = (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) &&
|
|
332
|
+
var smartCard = (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) && isPageSSRed ? /*#__PURE__*/_react.default.createElement(_ssr.CardSSR, {
|
|
377
333
|
key: url,
|
|
378
334
|
url: url,
|
|
379
335
|
appearance: "embed",
|
|
@@ -478,17 +434,17 @@ var WrappedEmbedCardWithCondition = (0, _platformFeatureFlagsReact.componentWith
|
|
|
478
434
|
var WrappedEmbedCard = (0, _genericCard.Card)(WrappedEmbedCardWithCondition, _ui.UnsupportedBlock);
|
|
479
435
|
var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
480
436
|
function EmbedCard() {
|
|
481
|
-
var
|
|
437
|
+
var _this2;
|
|
482
438
|
(0, _classCallCheck2.default)(this, EmbedCard);
|
|
483
439
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
484
440
|
args[_key] = arguments[_key];
|
|
485
441
|
}
|
|
486
|
-
|
|
487
|
-
(0, _defineProperty2.default)(
|
|
488
|
-
(0, _defineProperty2.default)(
|
|
442
|
+
_this2 = _callSuper(this, EmbedCard, [].concat(args));
|
|
443
|
+
(0, _defineProperty2.default)(_this2, "id", (0, _v.default)());
|
|
444
|
+
(0, _defineProperty2.default)(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
|
|
489
445
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
490
446
|
});
|
|
491
|
-
return
|
|
447
|
+
return _this2;
|
|
492
448
|
}
|
|
493
449
|
(0, _inherits2.default)(EmbedCard, _ReactNodeView);
|
|
494
450
|
return (0, _createClass2.default)(EmbedCard, [{
|
|
@@ -503,13 +459,13 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
503
459
|
key: "createDomRef",
|
|
504
460
|
value: function createDomRef() {
|
|
505
461
|
var _this$reactComponentP,
|
|
506
|
-
|
|
462
|
+
_this3 = this,
|
|
507
463
|
_this$reactComponentP2;
|
|
508
464
|
var domRef = document.createElement('div');
|
|
509
465
|
// It is a tradeoff for the bug mentioned that occurs in Chrome: https://product-fabric.atlassian.net/browse/ED-5379, https://github.com/ProseMirror/prosemirror/issues/884
|
|
510
|
-
this.unsubscribe = (_this$reactComponentP = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.editorViewMode) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.sharedState.onChange(function (
|
|
511
|
-
var nextSharedState =
|
|
512
|
-
return
|
|
466
|
+
this.unsubscribe = (_this$reactComponentP = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.editorViewMode) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.sharedState.onChange(function (_ref3) {
|
|
467
|
+
var nextSharedState = _ref3.nextSharedState;
|
|
468
|
+
return _this3.updateContentEditable(nextSharedState, domRef);
|
|
513
469
|
});
|
|
514
470
|
this.updateContentEditable((_this$reactComponentP2 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP2 === void 0 || (_this$reactComponentP2 = _this$reactComponentP2.editorViewMode) === null || _this$reactComponentP2 === void 0 ? void 0 : _this$reactComponentP2.sharedState.currentState(), domRef);
|
|
515
471
|
domRef.setAttribute('spellcheck', 'false');
|
|
@@ -553,16 +509,16 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
553
509
|
}
|
|
554
510
|
}]);
|
|
555
511
|
}(_reactNodeView.default);
|
|
556
|
-
var embedCardNodeView = exports.embedCardNodeView = function embedCardNodeView(
|
|
557
|
-
var allowResizing =
|
|
558
|
-
fullWidthMode =
|
|
559
|
-
pmPluginFactoryParams =
|
|
560
|
-
pluginInjectionApi =
|
|
561
|
-
actionOptions =
|
|
562
|
-
onClickCallback =
|
|
563
|
-
CompetitorPrompt =
|
|
564
|
-
isPageSSRed =
|
|
565
|
-
provider =
|
|
512
|
+
var embedCardNodeView = exports.embedCardNodeView = function embedCardNodeView(_ref4) {
|
|
513
|
+
var allowResizing = _ref4.allowResizing,
|
|
514
|
+
fullWidthMode = _ref4.fullWidthMode,
|
|
515
|
+
pmPluginFactoryParams = _ref4.pmPluginFactoryParams,
|
|
516
|
+
pluginInjectionApi = _ref4.pluginInjectionApi,
|
|
517
|
+
actionOptions = _ref4.actionOptions,
|
|
518
|
+
onClickCallback = _ref4.onClickCallback,
|
|
519
|
+
CompetitorPrompt = _ref4.CompetitorPrompt,
|
|
520
|
+
isPageSSRed = _ref4.isPageSSRed,
|
|
521
|
+
provider = _ref4.provider;
|
|
566
522
|
return function (node, view, getPos) {
|
|
567
523
|
var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
|
|
568
524
|
eventDispatcher = pmPluginFactoryParams.eventDispatcher,
|
|
@@ -8,14 +8,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.InlineCard = void 0;
|
|
9
9
|
exports.InlineCardNodeView = InlineCardNodeView;
|
|
10
10
|
exports.inlineCardNodeView = void 0;
|
|
11
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
14
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
16
13
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
17
14
|
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
18
|
-
var _editorCardProvider = require("@atlaskit/editor-card-provider");
|
|
19
15
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
20
16
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
21
17
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
@@ -60,42 +56,6 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
|
|
|
60
56
|
view.dispatch(tr);
|
|
61
57
|
};
|
|
62
58
|
}, [getPos, view]);
|
|
63
|
-
var _useState = (0, _react.useState)((0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) && isPageSSRed),
|
|
64
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
65
|
-
isSSRDataAvailable = _useState2[0],
|
|
66
|
-
setIsSSRDataAvailable = _useState2[1];
|
|
67
|
-
(0, _react.useEffect)(function () {
|
|
68
|
-
if (!(0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (!provider) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
var updateSSRDataAvailability = /*#__PURE__*/function () {
|
|
75
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
76
|
-
var resolvedProvider;
|
|
77
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
78
|
-
while (1) switch (_context.prev = _context.next) {
|
|
79
|
-
case 0:
|
|
80
|
-
_context.next = 2;
|
|
81
|
-
return provider;
|
|
82
|
-
case 2:
|
|
83
|
-
resolvedProvider = _context.sent;
|
|
84
|
-
if (resolvedProvider instanceof _editorCardProvider.EditorCardProvider) {
|
|
85
|
-
setIsSSRDataAvailable(resolvedProvider.getCacheStatusForNode(node) === 'ssr');
|
|
86
|
-
}
|
|
87
|
-
case 4:
|
|
88
|
-
case "end":
|
|
89
|
-
return _context.stop();
|
|
90
|
-
}
|
|
91
|
-
}, _callee);
|
|
92
|
-
}));
|
|
93
|
-
return function updateSSRDataAvailability() {
|
|
94
|
-
return _ref2.apply(this, arguments);
|
|
95
|
-
};
|
|
96
|
-
}();
|
|
97
|
-
void updateSSRDataAvailability();
|
|
98
|
-
}, [provider, node]);
|
|
99
59
|
var scrollContainer = (0, _react.useMemo)(
|
|
100
60
|
// Ignored via go/ees005
|
|
101
61
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
@@ -140,8 +100,8 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
|
|
|
140
100
|
var handleOnClick = (0, _react.useCallback)(function (event) {
|
|
141
101
|
if (event.metaKey || event.ctrlKey) {
|
|
142
102
|
var _pluginInjectionApi$a;
|
|
143
|
-
var
|
|
144
|
-
editorAnalyticsApi =
|
|
103
|
+
var _ref2 = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {},
|
|
104
|
+
editorAnalyticsApi = _ref2.actions;
|
|
145
105
|
(0, _toolbar.visitCardLinkAnalytics)(editorAnalyticsApi, _analytics.INPUT_METHOD.META_CLICK)(view.state, view.dispatch);
|
|
146
106
|
window.open(url, '_blank');
|
|
147
107
|
} else {
|
|
@@ -151,10 +111,7 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
|
|
|
151
111
|
}, [propsOnClick, url, view, pluginInjectionApi]);
|
|
152
112
|
var onClick = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ? handleOnClick : propsOnClick;
|
|
153
113
|
var card = (0, _react.useMemo)(function () {
|
|
154
|
-
if (
|
|
155
|
-
// The `isSSRDataAvailable` check is only required when the OTP experiment is on,
|
|
156
|
-
// because inline smart card SSR is already implemented without OTP.
|
|
157
|
-
((0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) ? isSSRDataAvailable : true) && isPageSSRed && url) {
|
|
114
|
+
if (isPageSSRed && url) {
|
|
158
115
|
return /*#__PURE__*/_react.default.createElement(_ssr.CardSSR, {
|
|
159
116
|
key: url,
|
|
160
117
|
url: url,
|
|
@@ -170,9 +127,8 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
|
|
|
170
127
|
hoverPreviewOptions: hoverPreviewOptions,
|
|
171
128
|
disablePreviewPanel: disablePreviewPanel
|
|
172
129
|
// Durin `platform_editor_smart_card_otp` cleaning up, replace this with `true`.
|
|
173
|
-
// Ths `isSSRDataAvailable` should be checked in the `if` condition above.
|
|
174
130
|
,
|
|
175
|
-
hideIconLoadingSkeleton: (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true)
|
|
131
|
+
hideIconLoadingSkeleton: (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true)
|
|
176
132
|
});
|
|
177
133
|
}
|
|
178
134
|
return /*#__PURE__*/_react.default.createElement(_smartCard.Card, {
|
|
@@ -190,7 +146,7 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
|
|
|
190
146
|
hoverPreviewOptions: hoverPreviewOptions,
|
|
191
147
|
disablePreviewPanel: disablePreviewPanel
|
|
192
148
|
});
|
|
193
|
-
}, [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, disablePreviewPanel
|
|
149
|
+
}, [url, data, onClick, scrollContainer, onResolve, onError, useAlternativePreloader, actionOptions, isHovered, showHoverPreview, hoverPreviewOptions, isPageSSRed, disablePreviewPanel]);
|
|
194
150
|
|
|
195
151
|
// [WS-2307]: we only render card wrapped into a Provider when the value is ready,
|
|
196
152
|
// otherwise if we got data, we can render the card directly since it doesn't need the Provider
|
|
@@ -247,8 +203,8 @@ function InlineCardNodeView(props) {
|
|
|
247
203
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
248
204
|
}, enableInlineUpgradeFeatures && (0, _utils.getAwarenessProps)(view.state, getPos, allowEmbeds, allowBlockCards, mode === 'view'))), (0, _platformFeatureFlags.fg)('prompt_whiteboard_competitor_link_gate') && CompetitorPromptComponent);
|
|
249
205
|
}
|
|
250
|
-
var inlineCardNodeView = exports.inlineCardNodeView = function inlineCardNodeView(
|
|
251
|
-
var inlineCardViewProducer =
|
|
206
|
+
var inlineCardNodeView = exports.inlineCardNodeView = function inlineCardNodeView(_ref3) {
|
|
207
|
+
var inlineCardViewProducer = _ref3.inlineCardViewProducer;
|
|
252
208
|
return function (node, view, getPos, decorations) {
|
|
253
209
|
return inlineCardViewProducer(node, view, getPos, decorations);
|
|
254
210
|
};
|
|
@@ -9,6 +9,7 @@ var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
|
9
9
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
11
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
12
13
|
var lookupPixel = 10;
|
|
13
14
|
var getClosestInlineCardPos = function getClosestInlineCardPos(state, editorView, direction) {
|
|
14
15
|
var _editorView$posAtCoor;
|
|
@@ -54,9 +55,9 @@ var selectAboveBelowInlineCard = function selectAboveBelowInlineCard(direction)
|
|
|
54
55
|
};
|
|
55
56
|
function cardKeymap(featureFlags) {
|
|
56
57
|
var list = {};
|
|
57
|
-
|
|
58
|
+
var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
|
|
58
59
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=1227468 introduced since Chrome 91
|
|
59
|
-
if (
|
|
60
|
+
if (browser.chrome && browser.chrome_version > 90) {
|
|
60
61
|
// Ignored via go/ees005
|
|
61
62
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
62
63
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveUp.common, selectAboveBelowInlineCard('up'), list);
|
|
@@ -2,10 +2,10 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import rafSchedule from 'raf-schd';
|
|
4
4
|
import uuid from 'uuid/v4';
|
|
5
|
-
import {
|
|
5
|
+
import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
6
6
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
7
7
|
import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
|
|
8
|
-
import {
|
|
8
|
+
import { canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
10
10
|
import { CardSSR } from '@atlaskit/smart-card/ssr';
|
|
11
11
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
@@ -13,15 +13,13 @@ import { Datasource } from '../nodeviews/datasource';
|
|
|
13
13
|
import { registerCard, removeCard } from '../pm-plugins/actions';
|
|
14
14
|
import { isDatasourceNode } from '../pm-plugins/utils';
|
|
15
15
|
import { Card } from './genericCard';
|
|
16
|
+
|
|
16
17
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
17
18
|
export class BlockCardComponent extends React.PureComponent {
|
|
18
19
|
constructor(props) {
|
|
19
20
|
super(props);
|
|
20
21
|
// Ignored via go/ees005
|
|
21
22
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
22
|
-
_defineProperty(this, "state", {
|
|
23
|
-
isSSRDataAvailable: false
|
|
24
|
-
});
|
|
25
23
|
_defineProperty(this, "onResolve", data => {
|
|
26
24
|
const {
|
|
27
25
|
getPos,
|
|
@@ -52,6 +50,7 @@ export class BlockCardComponent extends React.PureComponent {
|
|
|
52
50
|
});
|
|
53
51
|
_defineProperty(this, "removeCardDispatched", false);
|
|
54
52
|
_defineProperty(this, "gapCursorSpan", () => {
|
|
53
|
+
const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
|
|
55
54
|
// Don't render in EdgeHTMl version <= 18 (Edge version 44)
|
|
56
55
|
// as it forces the edit popup to render 24px lower than it should
|
|
57
56
|
if (browser.ie && browser.ie_version < 79) {
|
|
@@ -72,28 +71,6 @@ export class BlockCardComponent extends React.PureComponent {
|
|
|
72
71
|
}
|
|
73
72
|
});
|
|
74
73
|
this.scrollContainer = findOverflowScrollParent(props.view.dom) || undefined;
|
|
75
|
-
this.state = {
|
|
76
|
-
isSSRDataAvailable: expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && props.isPageSSRed
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
componentDidMount() {
|
|
80
|
-
if (!expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const provider = this.props.provider;
|
|
84
|
-
if (!provider) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const updateSSRDataAvailability = async () => {
|
|
88
|
-
const resolvedProvider = await provider;
|
|
89
|
-
if (resolvedProvider instanceof EditorCardProvider) {
|
|
90
|
-
this.setState(state => ({
|
|
91
|
-
...state,
|
|
92
|
-
isSSRDataAvailable: resolvedProvider.getCacheStatusForNode(this.props.node) === 'ssr'
|
|
93
|
-
}));
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
void updateSSRDataAvailability();
|
|
97
74
|
}
|
|
98
75
|
componentWillUnmount() {
|
|
99
76
|
this.removeCard();
|
|
@@ -124,7 +101,7 @@ export class BlockCardComponent extends React.PureComponent {
|
|
|
124
101
|
url,
|
|
125
102
|
data
|
|
126
103
|
} = node.attrs;
|
|
127
|
-
const cardInner = expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) &&
|
|
104
|
+
const cardInner = expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && isPageSSRed ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardSSR, {
|
|
128
105
|
key: url,
|
|
129
106
|
url: url !== null && url !== void 0 ? url : data.url,
|
|
130
107
|
container: this.scrollContainer,
|
|
@@ -4,7 +4,6 @@ import React from 'react';
|
|
|
4
4
|
import rafSchedule from 'raf-schd';
|
|
5
5
|
import uuid from 'uuid/v4';
|
|
6
6
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
7
|
-
import { EditorCardProvider } from '@atlaskit/editor-card-provider';
|
|
8
7
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
9
8
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
10
9
|
import { findOverflowScrollParent, MediaSingle as RichMediaWrapper, UnsupportedBlock } from '@atlaskit/editor-common/ui';
|
|
@@ -260,29 +259,9 @@ export class EmbedCardComponent extends React.PureComponent {
|
|
|
260
259
|
_defineProperty(this, "removeCardDispatched", false);
|
|
261
260
|
this.scrollContainer = findOverflowScrollParent(props.view.dom) || undefined;
|
|
262
261
|
this.state = {
|
|
263
|
-
hasPreview: true
|
|
264
|
-
isSSRDataAvailable: expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && props.isPageSSRed
|
|
262
|
+
hasPreview: true
|
|
265
263
|
};
|
|
266
264
|
}
|
|
267
|
-
componentDidMount() {
|
|
268
|
-
if (!expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
const provider = this.props.provider;
|
|
272
|
-
if (!provider) {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
const updateSSRDataAvailability = async () => {
|
|
276
|
-
const resolvedProvider = await provider;
|
|
277
|
-
if (resolvedProvider instanceof EditorCardProvider) {
|
|
278
|
-
this.setState(state => ({
|
|
279
|
-
...state,
|
|
280
|
-
isSSRDataAvailable: resolvedProvider.getCacheStatusForNode(this.props.node) === 'ssr'
|
|
281
|
-
}));
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
void updateSSRDataAvailability();
|
|
285
|
-
}
|
|
286
265
|
componentWillUnmount() {
|
|
287
266
|
this.removeCard();
|
|
288
267
|
}
|
|
@@ -341,7 +320,7 @@ export class EmbedCardComponent extends React.PureComponent {
|
|
|
341
320
|
pctWidth,
|
|
342
321
|
fullWidthMode
|
|
343
322
|
};
|
|
344
|
-
const smartCard = expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) &&
|
|
323
|
+
const smartCard = expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && isPageSSRed ? /*#__PURE__*/React.createElement(CardSSR, {
|
|
345
324
|
key: url,
|
|
346
325
|
url: url,
|
|
347
326
|
appearance: "embed",
|