@innovastudio/contentbuilder 1.4.32 → 1.4.33
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
@@ -77496,20 +77496,26 @@ class LivePreview {
|
|
77496
77496
|
let iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
|
77497
77497
|
|
77498
77498
|
if (iframeDocument) {
|
77499
|
-
if (iframeDocument.body
|
77499
|
+
if (!iframeDocument.body) {
|
77500
77500
|
iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
|
77501
77501
|
} else {
|
77502
|
-
|
77503
|
-
let html = this.builder.html();
|
77504
|
-
let container = iframeDocument.querySelector('.container');
|
77505
|
-
if (!container) container = iframeDocument.querySelector('.is-container');
|
77506
|
-
|
77507
|
-
if (container) {
|
77508
|
-
container.innerHTML = html;
|
77509
|
-
} else {
|
77502
|
+
if (iframeDocument.body.innerHTML === '') {
|
77510
77503
|
iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
|
77504
|
+
} else {
|
77505
|
+
// sync. html
|
77506
|
+
let html = this.builder.html();
|
77507
|
+
let container = iframeDocument.querySelector('.container');
|
77508
|
+
if (!container) container = iframeDocument.querySelector('.is-container');
|
77509
|
+
|
77510
|
+
if (container) {
|
77511
|
+
container.innerHTML = html;
|
77512
|
+
} else {
|
77513
|
+
iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
|
77514
|
+
}
|
77511
77515
|
}
|
77512
77516
|
}
|
77517
|
+
} else {
|
77518
|
+
iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
|
77513
77519
|
}
|
77514
77520
|
}
|
77515
77521
|
} else {
|
@@ -77535,80 +77541,84 @@ class LivePreview {
|
|
77535
77541
|
let iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
|
77536
77542
|
|
77537
77543
|
if (iframeDocument) {
|
77538
|
-
if (iframeDocument.body
|
77544
|
+
if (!iframeDocument.body) {
|
77539
77545
|
iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
|
77540
77546
|
} else {
|
77541
|
-
|
77542
|
-
|
77543
|
-
|
77544
|
-
|
77545
|
-
|
77546
|
-
|
77547
|
-
|
77548
|
-
|
77549
|
-
|
77550
|
-
|
77551
|
-
let
|
77552
|
-
|
77553
|
-
|
77554
|
-
|
77555
|
-
|
77556
|
-
|
77557
|
-
|
77558
|
-
|
77559
|
-
|
77560
|
-
|
77561
|
-
|
77562
|
-
|
77547
|
+
if (iframeDocument.body.innerHTML === '') {
|
77548
|
+
iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
|
77549
|
+
} else {
|
77550
|
+
// sync. html
|
77551
|
+
let html = localStorage.getItem('preview-html');
|
77552
|
+
let wrapper = iframeDocument.querySelector('.is-wrapper');
|
77553
|
+
wrapper.innerHTML = html; // sync. styles
|
77554
|
+
// let mainCss = localStorage.getItem('preview-maincss');
|
77555
|
+
// let sectionCss = localStorage.getItem('preview-sectioncss');
|
77556
|
+
|
77557
|
+
let elms = iframeDocument.querySelectorAll('link');
|
77558
|
+
let links = this.builder.doc.getElementsByTagName('link');
|
77559
|
+
Array.from(links).map(link => {
|
77560
|
+
let href = link.href.toLowerCase();
|
77561
|
+
|
77562
|
+
if (href.indexOf('/basetype-') !== -1 || href.indexOf('/type-') !== -1) {
|
77563
|
+
// check
|
77564
|
+
let exist = false;
|
77565
|
+
elms.forEach(elm => {
|
77566
|
+
let elmHref = elm.href.toLowerCase();
|
77567
|
+
|
77568
|
+
if (elmHref) {
|
77569
|
+
if (elmHref.indexOf('/basetype-') !== -1 || elmHref.indexOf('/type-') !== -1) {
|
77570
|
+
if (href === elmHref) {
|
77571
|
+
exist = true;
|
77572
|
+
}
|
77563
77573
|
}
|
77564
77574
|
}
|
77565
|
-
}
|
77566
|
-
});
|
77575
|
+
});
|
77567
77576
|
|
77568
|
-
|
77569
|
-
|
77570
|
-
|
77571
|
-
|
77577
|
+
if (!exist) {
|
77578
|
+
// clone is needed, otherwise, parent resource may dissapear when loading on iframe
|
77579
|
+
const clone = link.cloneNode(true);
|
77580
|
+
iframeDocument.head.appendChild(clone); // ADD
|
77581
|
+
}
|
77572
77582
|
}
|
77573
|
-
}
|
77574
|
-
|
77575
|
-
|
77576
|
-
|
77577
|
-
|
77578
|
-
|
77579
|
-
|
77580
|
-
|
77581
|
-
|
77582
|
-
|
77583
|
-
|
77584
|
-
|
77585
|
-
|
77586
|
-
|
77587
|
-
|
77583
|
+
});
|
77584
|
+
elms.forEach(elm => {
|
77585
|
+
let href = elm.href.toLowerCase();
|
77586
|
+
|
77587
|
+
if (href.indexOf('/basetype-') !== -1 || href.indexOf('/type-') !== -1) {
|
77588
|
+
// check
|
77589
|
+
let exist = false;
|
77590
|
+
Array.from(links).map(link => {
|
77591
|
+
let elmHref = link.href.toLowerCase();
|
77592
|
+
|
77593
|
+
if (elmHref) {
|
77594
|
+
if (elmHref.indexOf('/basetype-') !== -1 || elmHref.indexOf('/type-') !== -1) {
|
77595
|
+
if (href === elmHref) {
|
77596
|
+
exist = true;
|
77597
|
+
}
|
77588
77598
|
}
|
77589
77599
|
}
|
77590
|
-
}
|
77591
|
-
});
|
77600
|
+
});
|
77592
77601
|
|
77593
|
-
|
77594
|
-
|
77602
|
+
if (!exist) {
|
77603
|
+
iframeDocument.head.removeChild(elm); // REMOVE
|
77604
|
+
}
|
77595
77605
|
}
|
77596
|
-
}
|
77597
|
-
|
77598
|
-
|
77599
|
-
|
77600
|
-
|
77601
|
-
|
77602
|
-
|
77603
|
-
|
77604
|
-
|
77605
|
-
|
77606
|
-
|
77607
|
-
|
77608
|
-
|
77606
|
+
}); // reload box js
|
77607
|
+
|
77608
|
+
elms = iframeDocument.querySelectorAll('script');
|
77609
|
+
elms.forEach(elm => {
|
77610
|
+
let src = elm.getAttribute('src');
|
77611
|
+
|
77612
|
+
if (src) {
|
77613
|
+
if (src.indexOf('box-flex.js') !== -1 || src.indexOf('box.js') !== -1) {
|
77614
|
+
elm.parentElement.removeChild(elm);
|
77615
|
+
let scriptElm = document.createElement('script');
|
77616
|
+
scriptElm.setAttribute('src', src);
|
77617
|
+
iframeDocument.body.appendChild(scriptElm);
|
77618
|
+
}
|
77609
77619
|
}
|
77610
|
-
}
|
77611
|
-
}
|
77620
|
+
});
|
77621
|
+
}
|
77612
77622
|
}
|
77613
77623
|
} else {
|
77614
77624
|
iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
|