@innovastudio/contentbuilder 1.4.23 → 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
@@ -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
|
-
|
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);
|
@@ -77195,7 +77216,92 @@ class LivePreview {
|
|
77195
77216
|
}
|
77196
77217
|
}
|
77197
77218
|
} else {
|
77198
|
-
|
77219
|
+
// ContentBox
|
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;
|
77224
|
+
|
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
|
+
}
|
77252
|
+
}
|
77253
|
+
}
|
77254
|
+
});
|
77255
|
+
|
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
|
+
}
|
77261
|
+
}
|
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
|
+
}
|
77277
|
+
}
|
77278
|
+
}
|
77279
|
+
});
|
77280
|
+
|
77281
|
+
if (!exist) {
|
77282
|
+
iframeDocument.head.removeChild(elm); // REMOVE
|
77283
|
+
}
|
77284
|
+
}
|
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
|
+
}
|
77298
|
+
}
|
77299
|
+
});
|
77300
|
+
}
|
77301
|
+
} else {
|
77302
|
+
iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
|
77303
|
+
}
|
77304
|
+
}
|
77199
77305
|
}
|
77200
77306
|
|
77201
77307
|
iframe.onload = () => {
|
@@ -77330,6 +77436,7 @@ class ContentBuilder {
|
|
77330
77436
|
// onPreviewClose: ()=>{},
|
77331
77437
|
previewStyle: 'top:auto;bottom:50px;left:50px;right:auto;',
|
77332
77438
|
livePreviewOpen: false,
|
77439
|
+
livePreviewAlwaysReload: false,
|
77333
77440
|
scriptPath: '',
|
77334
77441
|
// Deprecated
|
77335
77442
|
// Old way:
|