@innovastudio/contentbuilder 1.4.23 → 1.4.24
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
@@ -77195,7 +77195,89 @@ class LivePreview {
|
|
77195
77195
|
}
|
77196
77196
|
}
|
77197
77197
|
} else {
|
77198
|
-
|
77198
|
+
// ContentBox
|
77199
|
+
// iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
|
77200
|
+
let iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
|
77201
|
+
|
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;
|
77228
|
+
}
|
77229
|
+
}
|
77230
|
+
}
|
77231
|
+
});
|
77232
|
+
|
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
|
77237
|
+
}
|
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;
|
77253
|
+
}
|
77254
|
+
}
|
77255
|
+
}
|
77256
|
+
});
|
77257
|
+
|
77258
|
+
if (!exist) {
|
77259
|
+
iframeDocument.head.removeChild(elm); // REMOVE
|
77260
|
+
}
|
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);
|
77274
|
+
}
|
77275
|
+
}
|
77276
|
+
});
|
77277
|
+
}
|
77278
|
+
} else {
|
77279
|
+
iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
|
77280
|
+
}
|
77199
77281
|
}
|
77200
77282
|
|
77201
77283
|
iframe.onload = () => {
|