@twreporter/react-article-components 2.1.0 → 2.1.1-beta.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.
@@ -78,7 +78,8 @@ var _ = {
78
78
  };
79
79
  var embedNamespace = {
80
80
  infogram: 'infogram',
81
- twreporter: '__twreporterEmbeddedData'
81
+ twreporter: '__twreporterEmbeddedData',
82
+ storyTellingReporter: '@story-telling-reporter'
82
83
  };
83
84
 
84
85
  var Block = /*#__PURE__*/_styledComponents["default"].div.withConfig({
@@ -207,17 +208,23 @@ var EmbeddedCode = /*#__PURE__*/function (_React$PureComponent) {
207
208
  _createClass(EmbeddedCode, [{
208
209
  key: "componentDidMount",
209
210
  value: function componentDidMount() {
210
- var _this$_embeddedCodeWi, _this$_embeddedCode;
211
-
212
- // Delay loading infogram in loadEmbed()
213
- if (!((_this$_embeddedCodeWi = this._embeddedCodeWithoutScript) !== null && _this$_embeddedCodeWi !== void 0 && _this$_embeddedCodeWi.includes(embedNamespace.infogram))) {
214
- this.setState({
215
- isLoaded: true
216
- }, this.executeScript);
217
- } // Deliberately set z-index for embeded from @twreporter
218
-
219
-
220
- if ((_this$_embeddedCode = this._embeddedCode) !== null && _this$_embeddedCode !== void 0 && _this$_embeddedCode.includes(embedNamespace.twreporter)) {
211
+ var _this$_embeddedCode, _this$_embeddedCode2;
212
+
213
+ // !! WORKAROUND !!
214
+ // After upgrading to react v18,
215
+ // `EmbeddedCode` component becomes abnormal.
216
+ // One case is that `EmbeddedCode` will `executeScript()` twice.
217
+ // Therefore, the embedded code will generate duplicate contents.
218
+ //
219
+ // To avoid `executeScript()` twice,
220
+ // temporarily comment out the following condition.
221
+ //
222
+ // Delay loading infogram in loadEmbed()
223
+ // if (!this._embeddedCodeWithoutScript?.includes(embedNamespace.infogram)) {
224
+ // this.setState({ isLoaded: true }, this.executeScript)
225
+ // }
226
+ // Deliberately set z-index for embeded from @twreporter
227
+ if ((_this$_embeddedCode = this._embeddedCode) !== null && _this$_embeddedCode !== void 0 && _this$_embeddedCode.includes(embedNamespace.twreporter) || (_this$_embeddedCode2 = this._embeddedCode) !== null && _this$_embeddedCode2 !== void 0 && _this$_embeddedCode2.includes(embedNamespace.storyTellingReporter)) {
221
228
  this.setState({
222
229
  shouldEscalateZIndex: true
223
230
  });
@@ -234,7 +241,7 @@ var EmbeddedCode = /*#__PURE__*/function (_React$PureComponent) {
234
241
  }, {
235
242
  key: "render",
236
243
  value: function render() {
237
- var _this$_embeddedCodeWi2;
244
+ var _this$_embeddedCodeWi;
238
245
 
239
246
  var className = this.props.className;
240
247
  var shouldEscalateZIndex = this.state.shouldEscalateZIndex;
@@ -249,7 +256,7 @@ var EmbeddedCode = /*#__PURE__*/function (_React$PureComponent) {
249
256
  }
250
257
  }), this._caption ? /*#__PURE__*/_react["default"].createElement(Caption, null, this._caption) : null);
251
258
 
252
- if ((_this$_embeddedCodeWi2 = this._embeddedCodeWithoutScript) !== null && _this$_embeddedCodeWi2 !== void 0 && _this$_embeddedCodeWi2.includes(embedNamespace.infogram)) {
259
+ if ((_this$_embeddedCodeWi = this._embeddedCodeWithoutScript) !== null && _this$_embeddedCodeWi !== void 0 && _this$_embeddedCodeWi.includes(embedNamespace.infogram)) {
253
260
  return this.state.isLoaded ? embed : null;
254
261
  }
255
262
 
@@ -309,7 +316,7 @@ var WayPointWrapper = function WayPointWrapper(props) {
309
316
  onEnter: onEnter,
310
317
  onLeave: onLeave,
311
318
  fireOnRapidScroll: false,
312
- topOffset: 5
319
+ topOffset: "-150%"
313
320
  }, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(EmbeddedCode, _extends({}, props, {
314
321
  ref: embedRef
315
322
  }))))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twreporter/react-article-components",
3
- "version": "2.1.0",
3
+ "version": "2.1.1-beta.0",
4
4
  "description": "The Reporter react article components, which are used in article page",
5
5
  "main": "lib/components/article-page.js",
6
6
  "repository": "https://github.com/twreporter/twreporter-npm-packages.git",
@@ -40,6 +40,5 @@
40
40
  },
41
41
  "files": [
42
42
  "lib"
43
- ],
44
- "gitHead": "140b33e61fd76615028d242dc55a63f9a1792a36"
43
+ ]
45
44
  }