@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
@@ -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);
|
@@ -77196,87 +77217,90 @@ class LivePreview {
|
|
77196
77217
|
}
|
77197
77218
|
} else {
|
77198
77219
|
// ContentBox
|
77199
|
-
|
77200
|
-
|
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
|
-
|
77203
|
-
|
77204
|
-
|
77205
|
-
|
77206
|
-
|
77207
|
-
|
77208
|
-
|
77209
|
-
|
77210
|
-
|
77211
|
-
|
77212
|
-
|
77213
|
-
|
77214
|
-
|
77215
|
-
|
77216
|
-
|
77217
|
-
|
77218
|
-
|
77219
|
-
|
77220
|
-
|
77221
|
-
|
77222
|
-
|
77223
|
-
|
77224
|
-
|
77225
|
-
|
77226
|
-
|
77227
|
-
|
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
|
-
|
77234
|
-
|
77235
|
-
|
77236
|
-
|
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
|
-
|
77241
|
-
|
77242
|
-
|
77243
|
-
|
77244
|
-
|
77245
|
-
|
77246
|
-
|
77247
|
-
|
77248
|
-
|
77249
|
-
|
77250
|
-
|
77251
|
-
|
77252
|
-
|
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
|
-
|
77259
|
-
|
77281
|
+
if (!exist) {
|
77282
|
+
iframeDocument.head.removeChild(elm); // REMOVE
|
77283
|
+
}
|
77260
77284
|
}
|
77261
|
-
}
|
77262
|
-
|
77263
|
-
|
77264
|
-
|
77265
|
-
|
77266
|
-
|
77267
|
-
|
77268
|
-
|
77269
|
-
|
77270
|
-
|
77271
|
-
|
77272
|
-
|
77273
|
-
|
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:
|