@innovastudio/contentbuilder 1.4.24 → 1.4.25

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbuilder",
3
3
  "type": "module",
4
- "version": "1.4.24",
4
+ "version": "1.4.25",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "files": [
@@ -77187,7 +77187,28 @@ class LivePreview {
77187
77187
  if (!this.builder.doc.querySelector('.is-wrapper')) {
77188
77188
  // ContentBuilder
77189
77189
  if (this.builder.previewURL) {
77190
- iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77190
+ if (this.builder.livePreviewAlwaysReload) {
77191
+ iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77192
+ } else {
77193
+ let iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
77194
+
77195
+ if (iframeDocument) {
77196
+ if (iframeDocument.body.innerHTML === '') {
77197
+ iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77198
+ } else {
77199
+ // sync. html
77200
+ let html = this.builder.html();
77201
+ let container = iframeDocument.querySelector('.container');
77202
+ if (!container) container = iframeDocument.querySelector('.is-container');
77203
+
77204
+ if (container) {
77205
+ container.innerHTML = html;
77206
+ } else {
77207
+ iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77208
+ }
77209
+ }
77210
+ }
77211
+ }
77191
77212
  } else {
77192
77213
  try {
77193
77214
  this.writeHtml(iframe);
@@ -77196,87 +77217,90 @@ class LivePreview {
77196
77217
  }
77197
77218
  } else {
77198
77219
  // ContentBox
77199
- // iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77200
- let iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
77220
+ if (this.builder.livePreviewAlwaysReload) {
77221
+ iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77222
+ } else {
77223
+ let iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
77201
77224
 
77202
- if (iframeDocument) {
77203
- if (iframeDocument.body.innerHTML === '') {
77204
- iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77205
- } else {
77206
- // sync. html
77207
- let html = localStorage.getItem('preview-html');
77208
- let wrapper = iframeDocument.querySelector('.is-wrapper');
77209
- wrapper.innerHTML = html; // sync. styles
77210
- // let mainCss = localStorage.getItem('preview-maincss');
77211
- // let sectionCss = localStorage.getItem('preview-sectioncss');
77212
-
77213
- let elms = iframeDocument.querySelectorAll('link');
77214
- let links = this.builder.doc.getElementsByTagName('link');
77215
- Array.from(links).map(link => {
77216
- let href = link.href.toLowerCase();
77217
-
77218
- if (href.indexOf('/basetype-') !== -1 || href.indexOf('/type-') !== -1) {
77219
- // check
77220
- let exist = false;
77221
- elms.forEach(elm => {
77222
- let elmHref = elm.href.toLowerCase();
77223
-
77224
- if (elmHref) {
77225
- if (elmHref.indexOf('/basetype-') !== -1 || elmHref.indexOf('/type-') !== -1) {
77226
- if (href === elmHref) {
77227
- exist = true;
77225
+ if (iframeDocument) {
77226
+ if (iframeDocument.body.innerHTML === '') {
77227
+ iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77228
+ } else {
77229
+ // sync. html
77230
+ let html = localStorage.getItem('preview-html');
77231
+ let wrapper = iframeDocument.querySelector('.is-wrapper');
77232
+ wrapper.innerHTML = html; // sync. styles
77233
+ // let mainCss = localStorage.getItem('preview-maincss');
77234
+ // let sectionCss = localStorage.getItem('preview-sectioncss');
77235
+
77236
+ let elms = iframeDocument.querySelectorAll('link');
77237
+ let links = this.builder.doc.getElementsByTagName('link');
77238
+ Array.from(links).map(link => {
77239
+ let href = link.href.toLowerCase();
77240
+
77241
+ if (href.indexOf('/basetype-') !== -1 || href.indexOf('/type-') !== -1) {
77242
+ // check
77243
+ let exist = false;
77244
+ elms.forEach(elm => {
77245
+ let elmHref = elm.href.toLowerCase();
77246
+
77247
+ if (elmHref) {
77248
+ if (elmHref.indexOf('/basetype-') !== -1 || elmHref.indexOf('/type-') !== -1) {
77249
+ if (href === elmHref) {
77250
+ exist = true;
77251
+ }
77228
77252
  }
77229
77253
  }
77230
- }
77231
- });
77254
+ });
77232
77255
 
77233
- if (!exist) {
77234
- // clone is needed, otherwise, parent resource may dissapear when loading on iframe
77235
- const clone = link.cloneNode(true);
77236
- iframeDocument.head.appendChild(clone); // ADD
77256
+ if (!exist) {
77257
+ // clone is needed, otherwise, parent resource may dissapear when loading on iframe
77258
+ const clone = link.cloneNode(true);
77259
+ iframeDocument.head.appendChild(clone); // ADD
77260
+ }
77237
77261
  }
77238
- }
77239
- });
77240
- elms.forEach(elm => {
77241
- let href = elm.href.toLowerCase();
77242
-
77243
- if (href.indexOf('/basetype-') !== -1 || href.indexOf('/type-') !== -1) {
77244
- // check
77245
- let exist = false;
77246
- Array.from(links).map(link => {
77247
- let elmHref = link.href.toLowerCase();
77248
-
77249
- if (elmHref) {
77250
- if (elmHref.indexOf('/basetype-') !== -1 || elmHref.indexOf('/type-') !== -1) {
77251
- if (href === elmHref) {
77252
- exist = true;
77262
+ });
77263
+ elms.forEach(elm => {
77264
+ let href = elm.href.toLowerCase();
77265
+
77266
+ if (href.indexOf('/basetype-') !== -1 || href.indexOf('/type-') !== -1) {
77267
+ // check
77268
+ let exist = false;
77269
+ Array.from(links).map(link => {
77270
+ let elmHref = link.href.toLowerCase();
77271
+
77272
+ if (elmHref) {
77273
+ if (elmHref.indexOf('/basetype-') !== -1 || elmHref.indexOf('/type-') !== -1) {
77274
+ if (href === elmHref) {
77275
+ exist = true;
77276
+ }
77253
77277
  }
77254
77278
  }
77255
- }
77256
- });
77279
+ });
77257
77280
 
77258
- if (!exist) {
77259
- iframeDocument.head.removeChild(elm); // REMOVE
77281
+ if (!exist) {
77282
+ iframeDocument.head.removeChild(elm); // REMOVE
77283
+ }
77260
77284
  }
77261
- }
77262
- }); // reload box js
77263
-
77264
- elms = iframeDocument.querySelectorAll('script');
77265
- elms.forEach(elm => {
77266
- let src = elm.getAttribute('src');
77267
-
77268
- if (src) {
77269
- if (src.indexOf('box-flex.js') !== -1 || src.indexOf('box.js') !== -1) {
77270
- elm.parentElement.removeChild(elm);
77271
- let scriptElm = document.createElement('script');
77272
- scriptElm.setAttribute('src', src);
77273
- iframeDocument.body.appendChild(scriptElm);
77285
+ }); // reload box js
77286
+
77287
+ elms = iframeDocument.querySelectorAll('script');
77288
+ elms.forEach(elm => {
77289
+ let src = elm.getAttribute('src');
77290
+
77291
+ if (src) {
77292
+ if (src.indexOf('box-flex.js') !== -1 || src.indexOf('box.js') !== -1) {
77293
+ elm.parentElement.removeChild(elm);
77294
+ let scriptElm = document.createElement('script');
77295
+ scriptElm.setAttribute('src', src);
77296
+ iframeDocument.body.appendChild(scriptElm);
77297
+ }
77274
77298
  }
77275
- }
77276
- });
77299
+ });
77300
+ }
77301
+ } else {
77302
+ iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77277
77303
  }
77278
- } else {
77279
- iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77280
77304
  }
77281
77305
  }
77282
77306
 
@@ -77412,6 +77436,7 @@ class ContentBuilder {
77412
77436
  // onPreviewClose: ()=>{},
77413
77437
  previewStyle: 'top:auto;bottom:50px;left:50px;right:auto;',
77414
77438
  livePreviewOpen: false,
77439
+ livePreviewAlwaysReload: false,
77415
77440
  scriptPath: '',
77416
77441
  // Deprecated
77417
77442
  // Old way: