@quintype/components 3.4.7-test-version.0 → 3.5.1-jsembed-playerid-issue.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.
package/dist/cjs/index.js CHANGED
@@ -1055,6 +1055,21 @@ function _isNativeReflectConstruct$l() { if (typeof Reflect === "undefined" || !
1055
1055
  * onItemFocus={(item) => console.log(`Story In View: ${item.story.headline}`)}
1056
1056
  * doNotChangeUrl={true} />
1057
1057
  * ```
1058
+ *
1059
+ * #### Configuring the the url to change
1060
+ * When a story is focussed, the url is changed to the original slug of the story by default. To configure this, pass a prop called changeUrlTo as a function which returns the desired url.
1061
+ * This is typically used when you want to change the url but not to the original slug.
1062
+ *
1063
+ * Example:
1064
+ * ```javascript
1065
+ * <InfiniteStoryBase {...props}
1066
+ * render={StoryPageBase}
1067
+ * loadItems={storyPageLoadItems}
1068
+ * onItemFocus={(item) => console.log(`Story In View: ${item.story.headline}`)}
1069
+ changeUrlTo={(item) => item.currentPath || props.currentPath}
1070
+ * doNotChangeUrl={true} />
1071
+ * ```
1072
+ *
1058
1073
  * @component
1059
1074
  * @category Story Page
1060
1075
  */
@@ -1095,7 +1110,8 @@ var InfiniteStoryBase = /*#__PURE__*/function (_React$Component) {
1095
1110
  var storyPath = item.story.url ? new URL(item.story.url).pathname : "/" + item.story.slug;
1096
1111
  var metaTitle = get__default["default"](item, ['story', 'seo', 'meta-title'], item.story.headline);
1097
1112
  var title = get__default["default"](item, ["customSeo", "title"], metaTitle);
1098
- global.app.maybeSetUrl(storyPath, title);
1113
+ var path = this.props.changeUrlTo ? this.props.changeUrlTo(item) : storyPath;
1114
+ global.app.maybeSetUrl(path, title);
1099
1115
  }
1100
1116
 
1101
1117
  this.props.onItemFocus && this.props.onItemFocus(item, index);
@@ -2718,7 +2734,11 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
2718
2734
  _createClass__default["default"](CustomStoryElementDailyMotion, [{
2719
2735
  key: "componentDidMount",
2720
2736
  value: function componentDidMount() {
2721
- if (!this.props.loadIframeOnClick) {
2737
+ var _this$props, _this$props$element;
2738
+
2739
+ var metadata = ((_this$props = this.props) === null || _this$props === void 0 ? void 0 : (_this$props$element = _this$props.element) === null || _this$props$element === void 0 ? void 0 : _this$props$element.metadata) || {};
2740
+
2741
+ if (!this.props.loadIframeOnClick && metadata["player-id"]) {
2722
2742
  this.triggerIframe();
2723
2743
  }
2724
2744
  }
@@ -2728,6 +2748,19 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
2728
2748
  this._isMounted = false;
2729
2749
  disconnectObserver(this.intersectionObserver);
2730
2750
  }
2751
+ }, {
2752
+ key: "getEmbedJS",
2753
+ value: function getEmbedJS() {
2754
+ var embedJs = this.props.element["embed-js"];
2755
+ console.log("Embed JS Logs 555: ", embedJs);
2756
+ if (!embedJs) return null;
2757
+
2758
+ if (global) {
2759
+ return decodeURIComponent(escape(global.atob(embedJs)));
2760
+ }
2761
+
2762
+ return Buffer.from(embedJs, "base64").toString("utf-8");
2763
+ }
2731
2764
  }, {
2732
2765
  key: "render",
2733
2766
  value: function render() {
@@ -2770,7 +2803,14 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
2770
2803
  }, dailymotionIframe()));
2771
2804
  } else if (!this.props.loadIframeOnClick && isLibraryLoaded$1()) {
2772
2805
  return dailymotionIframe();
2773
- } else return /*#__PURE__*/React__default["default"].createElement("div", null);
2806
+ } else {
2807
+ var embedJs = this.getEmbedJS();
2808
+ return /*#__PURE__*/React__default["default"].createElement("div", {
2809
+ dangerouslySetInnerHTML: {
2810
+ __html: embedJs
2811
+ }
2812
+ });
2813
+ }
2774
2814
  }
2775
2815
  }]);
2776
2816
 
@@ -56,6 +56,21 @@ import { removeDuplicateStories } from '../utils';
56
56
  * onItemFocus={(item) => console.log(`Story In View: ${item.story.headline}`)}
57
57
  * doNotChangeUrl={true} />
58
58
  * ```
59
+ *
60
+ * #### Configuring the the url to change
61
+ * When a story is focussed, the url is changed to the original slug of the story by default. To configure this, pass a prop called changeUrlTo as a function which returns the desired url.
62
+ * This is typically used when you want to change the url but not to the original slug.
63
+ *
64
+ * Example:
65
+ * ```javascript
66
+ * <InfiniteStoryBase {...props}
67
+ * render={StoryPageBase}
68
+ * loadItems={storyPageLoadItems}
69
+ * onItemFocus={(item) => console.log(`Story In View: ${item.story.headline}`)}
70
+ changeUrlTo={(item) => item.currentPath || props.currentPath}
71
+ * doNotChangeUrl={true} />
72
+ * ```
73
+ *
59
74
  * @component
60
75
  * @category Story Page
61
76
  */
@@ -96,7 +111,8 @@ export var InfiniteStoryBase = /*#__PURE__*/function (_React$Component) {
96
111
  var storyPath = item.story.url ? new URL(item.story.url).pathname : "/" + item.story.slug;
97
112
  var metaTitle = get(item, ['story', 'seo', 'meta-title'], item.story.headline);
98
113
  var title = get(item, ["customSeo", "title"], metaTitle);
99
- global.app.maybeSetUrl(storyPath, title);
114
+ var path = this.props.changeUrlTo ? this.props.changeUrlTo(item) : storyPath;
115
+ global.app.maybeSetUrl(path, title);
100
116
  }
101
117
 
102
118
  this.props.onItemFocus && this.props.onItemFocus(item, index);
@@ -138,7 +138,11 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
138
138
  _createClass(CustomStoryElementDailyMotion, [{
139
139
  key: "componentDidMount",
140
140
  value: function componentDidMount() {
141
- if (!this.props.loadIframeOnClick) {
141
+ var _this$props, _this$props$element;
142
+
143
+ var metadata = ((_this$props = this.props) === null || _this$props === void 0 ? void 0 : (_this$props$element = _this$props.element) === null || _this$props$element === void 0 ? void 0 : _this$props$element.metadata) || {};
144
+
145
+ if (!this.props.loadIframeOnClick && metadata["player-id"]) {
142
146
  this.triggerIframe();
143
147
  }
144
148
  }
@@ -148,6 +152,19 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
148
152
  this._isMounted = false;
149
153
  disconnectObserver(this.intersectionObserver);
150
154
  }
155
+ }, {
156
+ key: "getEmbedJS",
157
+ value: function getEmbedJS() {
158
+ var embedJs = this.props.element["embed-js"];
159
+ console.log("Embed JS Logs 555: ", embedJs);
160
+ if (!embedJs) return null;
161
+
162
+ if (global) {
163
+ return decodeURIComponent(escape(global.atob(embedJs)));
164
+ }
165
+
166
+ return Buffer.from(embedJs, "base64").toString("utf-8");
167
+ }
151
168
  }, {
152
169
  key: "render",
153
170
  value: function render() {
@@ -190,7 +207,14 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
190
207
  }, dailymotionIframe()));
191
208
  } else if (!this.props.loadIframeOnClick && isLibraryLoaded()) {
192
209
  return dailymotionIframe();
193
- } else return /*#__PURE__*/React.createElement("div", null);
210
+ } else {
211
+ var embedJs = this.getEmbedJS();
212
+ return /*#__PURE__*/React.createElement("div", {
213
+ dangerouslySetInnerHTML: {
214
+ __html: embedJs
215
+ }
216
+ });
217
+ }
194
218
  }
195
219
  }]);
196
220
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/components",
3
- "version": "3.4.7-test-version.0",
3
+ "version": "3.5.1-jsembed-playerid-issue.0",
4
4
  "description": "Components to help build Quintype Node.js apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",