@innovastudio/contentbuilder 1.5.214 → 1.5.215
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
|
@@ -32222,11 +32222,23 @@ class Plugin {
|
|
|
32222
32222
|
}
|
|
32223
32223
|
};
|
|
32224
32224
|
if (!this.builder.handlePluginClick_) {
|
|
32225
|
-
document.addEventListener('click', handlePluginClick);
|
|
32226
|
-
if (this.builder.iframeDocument) {
|
|
32227
|
-
this.builder.doc.addEventListener('click', handlePluginClick);
|
|
32228
|
-
}
|
|
32229
32225
|
this.builder.handlePluginClick_ = true;
|
|
32226
|
+
// Register on the NEXT task, not now. showPluginEditor() can be
|
|
32227
|
+
// reached from a microtask inside the very click that opens the
|
|
32228
|
+
// panel: the RTE button runs convertSelectionToPlugin(), whose
|
|
32229
|
+
// runtime.reinitialize().then() resolves while that click is still
|
|
32230
|
+
// propagating towards document. A listener added mid-propagation
|
|
32231
|
+
// still receives that same click, so the panel was closed the
|
|
32232
|
+
// instant it opened — and only on a first open, because afterwards
|
|
32233
|
+
// the previous listener had already fired and removed itself.
|
|
32234
|
+
// Deferring means this listener can never see the click that
|
|
32235
|
+
// created it, whichever toolbar or panel opened the panel.
|
|
32236
|
+
setTimeout(() => {
|
|
32237
|
+
document.addEventListener('click', handlePluginClick);
|
|
32238
|
+
if (this.builder.iframeDocument) {
|
|
32239
|
+
this.builder.doc.addEventListener('click', handlePluginClick);
|
|
32240
|
+
}
|
|
32241
|
+
}, 0);
|
|
32230
32242
|
}
|
|
32231
32243
|
}
|
|
32232
32244
|
hidePluginEditor() {
|
|
@@ -69542,16 +69554,42 @@ class Resize {
|
|
|
69542
69554
|
enable() {
|
|
69543
69555
|
const col = this.element;
|
|
69544
69556
|
const row = col.parentNode;
|
|
69557
|
+
|
|
69558
|
+
// The builder injects its own elements into a row — tools, the add-row
|
|
69559
|
+
// bar, and the row overlay that appears once the row is selected in the
|
|
69560
|
+
// side panel. They are not columns, and measuring them as columns makes
|
|
69561
|
+
// the totals below nonsense. Filter them out in ONE place so a new
|
|
69562
|
+
// injected element can never silently break the maths again.
|
|
69563
|
+
const isBuilderUI = item => item.nodeType !== 1 || item.classList.contains('is-tool') || item.classList.contains('is-row-tool') || item.classList.contains('is-col-tool') || item.classList.contains('is-rowadd-tool') || item.classList.contains('is-row-overlay');
|
|
69564
|
+
const columnsOf = parent => Array.from(parent.children).filter(item => !isBuilderUI(item));
|
|
69565
|
+
|
|
69566
|
+
// A column width is only ever stored as a percentage; pixels are used
|
|
69567
|
+
// purely while a drag is in progress. resizeEnd normally converts them
|
|
69568
|
+
// back, but it does not run if the drag is interrupted — and pixel
|
|
69569
|
+
// widths saved into the page push content off screen on smaller
|
|
69570
|
+
// devices. This is the backstop for that: whatever happens to the drag,
|
|
69571
|
+
// a leftover pixel width is converted on the next tick. Capture phase,
|
|
69572
|
+
// so it still runs if something stops the event bubbling.
|
|
69573
|
+
const normalizeToPercent = () => {
|
|
69574
|
+
setTimeout(() => {
|
|
69575
|
+
if (!col.style.width || col.style.width.indexOf('px') === -1) return;
|
|
69576
|
+
const parent = col.parentNode;
|
|
69577
|
+
if (!parent || !parent.offsetWidth) return;
|
|
69578
|
+
const pct = col.offsetWidth / parent.offsetWidth * 100;
|
|
69579
|
+
if (isFinite(pct) && pct > 0) col.style.width = pct + '%';
|
|
69580
|
+
}, 0);
|
|
69581
|
+
};
|
|
69582
|
+
this.normalizeToPercent = normalizeToPercent;
|
|
69583
|
+
this.eventTarget = col.ownerDocument;
|
|
69584
|
+
this.eventTarget.addEventListener('mouseup', normalizeToPercent, true);
|
|
69585
|
+
this.eventTarget.addEventListener('touchend', normalizeToPercent, true);
|
|
69545
69586
|
this.resize = new Resizeable({
|
|
69546
69587
|
pane: col,
|
|
69547
69588
|
resizeHeight: this.builder.resizeHeight,
|
|
69548
69589
|
onResize: (width, height) => {
|
|
69549
69590
|
this.builder.util.hideControls();
|
|
69550
69591
|
let numOfCols = 1;
|
|
69551
|
-
|
|
69552
|
-
if (item.classList.contains('is-row-tool')) return;
|
|
69553
|
-
if (item.classList.contains('is-rowadd-tool')) return;
|
|
69554
|
-
if (item.classList.contains('is-col-tool')) return;
|
|
69592
|
+
columnsOf(col.parentNode).map(item => {
|
|
69555
69593
|
if (item === col) return;
|
|
69556
69594
|
numOfCols++;
|
|
69557
69595
|
});
|
|
@@ -69562,10 +69600,7 @@ class Resize {
|
|
|
69562
69600
|
// adjust others
|
|
69563
69601
|
const maxWidth = () => {
|
|
69564
69602
|
let otherWidth = 0;
|
|
69565
|
-
|
|
69566
|
-
if (item.classList.contains('is-row-tool')) return;
|
|
69567
|
-
if (item.classList.contains('is-rowadd-tool')) return;
|
|
69568
|
-
if (item.classList.contains('is-col-tool')) return;
|
|
69603
|
+
columnsOf(col.parentNode).map(item => {
|
|
69569
69604
|
// if(this.opts.filterSibling) if(item.classList.contains(this.opts.filterSibling)) return;
|
|
69570
69605
|
|
|
69571
69606
|
if (item === col) return;
|
|
@@ -69579,10 +69614,7 @@ class Resize {
|
|
|
69579
69614
|
// percentage = (max / row.offsetWidth) * 100;
|
|
69580
69615
|
// Or make others auto
|
|
69581
69616
|
|
|
69582
|
-
|
|
69583
|
-
if (item.classList.contains('is-row-tool')) return;
|
|
69584
|
-
if (item.classList.contains('is-rowadd-tool')) return;
|
|
69585
|
-
if (item.classList.contains('is-col-tool')) return;
|
|
69617
|
+
columnsOf(col.parentNode).map(item => {
|
|
69586
69618
|
// if(this.opts.filterSibling) if(item.classList.contains(this.opts.filterSibling)) return;
|
|
69587
69619
|
|
|
69588
69620
|
if (item === col) return;
|
|
@@ -69620,10 +69652,7 @@ class Resize {
|
|
|
69620
69652
|
}
|
|
69621
69653
|
} else {
|
|
69622
69654
|
// New: if other cols has no width, set to 100%
|
|
69623
|
-
|
|
69624
|
-
if (item.classList.contains('is-row-tool')) return;
|
|
69625
|
-
if (item.classList.contains('is-rowadd-tool')) return;
|
|
69626
|
-
if (item.classList.contains('is-col-tool')) return;
|
|
69655
|
+
columnsOf(col.parentNode).map(item => {
|
|
69627
69656
|
// if(this.opts.filterSibling) if(item.classList.contains(this.opts.filterSibling)) return;
|
|
69628
69657
|
|
|
69629
69658
|
if (item === col) return;
|
|
@@ -69653,10 +69682,7 @@ class Resize {
|
|
|
69653
69682
|
},
|
|
69654
69683
|
resizeEnd: () => {
|
|
69655
69684
|
let numOfCols = 1;
|
|
69656
|
-
|
|
69657
|
-
if (item.classList.contains('is-row-tool')) return;
|
|
69658
|
-
if (item.classList.contains('is-rowadd-tool')) return;
|
|
69659
|
-
if (item.classList.contains('is-col-tool')) return;
|
|
69685
|
+
columnsOf(col.parentNode).map(item => {
|
|
69660
69686
|
if (item === col) return;
|
|
69661
69687
|
numOfCols++;
|
|
69662
69688
|
});
|
|
@@ -69668,13 +69694,9 @@ class Resize {
|
|
|
69668
69694
|
// adjust others
|
|
69669
69695
|
const maxWidth = () => {
|
|
69670
69696
|
let otherWidth = 0;
|
|
69671
|
-
|
|
69672
|
-
if (item.classList.contains('is-row-tool')) return;
|
|
69673
|
-
if (item.classList.contains('is-rowadd-tool')) return;
|
|
69674
|
-
if (item.classList.contains('is-col-tool')) return;
|
|
69697
|
+
columnsOf(col.parentNode).map(item => {
|
|
69675
69698
|
// if(this.opts.filterSibling) if(item.classList.contains(this.opts.filterSibling)) return;
|
|
69676
69699
|
|
|
69677
|
-
if (item.classList.contains('row-tool')) return;
|
|
69678
69700
|
if (item === col) return;
|
|
69679
69701
|
otherWidth += item.offsetWidth;
|
|
69680
69702
|
});
|
|
@@ -69686,10 +69708,7 @@ class Resize {
|
|
|
69686
69708
|
// percentage = (max / row.offsetWidth) * 100;
|
|
69687
69709
|
// Or make others auto
|
|
69688
69710
|
|
|
69689
|
-
|
|
69690
|
-
if (item.classList.contains('is-row-tool')) return;
|
|
69691
|
-
if (item.classList.contains('is-rowadd-tool')) return;
|
|
69692
|
-
if (item.classList.contains('is-col-tool')) return;
|
|
69711
|
+
columnsOf(col.parentNode).map(item => {
|
|
69693
69712
|
// if(this.opts.filterSibling) if(item.classList.contains(this.opts.filterSibling)) return;
|
|
69694
69713
|
|
|
69695
69714
|
if (item === col) return;
|
|
@@ -69719,10 +69738,7 @@ class Resize {
|
|
|
69719
69738
|
// New: Final fix (if column resized exceeds its max)
|
|
69720
69739
|
let othersWidth = 0;
|
|
69721
69740
|
let activeColumnWidth = 0;
|
|
69722
|
-
|
|
69723
|
-
if (item.classList.contains('is-row-tool')) return;
|
|
69724
|
-
if (item.classList.contains('is-rowadd-tool')) return;
|
|
69725
|
-
if (item.classList.contains('is-col-tool')) return;
|
|
69741
|
+
columnsOf(col.parentNode).map(item => {
|
|
69726
69742
|
// if(this.opts.filterSibling) if(item.classList.contains(this.opts.filterSibling)) return;
|
|
69727
69743
|
|
|
69728
69744
|
// // Refresh Module
|
|
@@ -69740,13 +69756,23 @@ class Resize {
|
|
|
69740
69756
|
if (activeColumnWidth > maxResult) {
|
|
69741
69757
|
percentage = maxResult / row.offsetWidth * 100;
|
|
69742
69758
|
}
|
|
69743
|
-
|
|
69759
|
+
|
|
69760
|
+
// The column is carrying a pixel width at this point (set
|
|
69761
|
+
// just above, to measure it). A width is only ever stored as
|
|
69762
|
+
// a percentage, so if the maths produced something CSS will
|
|
69763
|
+
// reject — negative, zero, NaN, Infinity — the assignment
|
|
69764
|
+
// would silently fail and leave those pixels behind, which
|
|
69765
|
+
// then breaks the layout on smaller screens. Fall back to
|
|
69766
|
+
// the column's real share of the row instead.
|
|
69767
|
+
if (!isFinite(percentage) || percentage <= 0) {
|
|
69768
|
+
percentage = col.offsetWidth / row.offsetWidth * 100;
|
|
69769
|
+
}
|
|
69770
|
+
if (isFinite(percentage) && percentage > 0) {
|
|
69771
|
+
col.style.width = percentage + '%';
|
|
69772
|
+
}
|
|
69744
69773
|
|
|
69745
69774
|
// Refresh Module
|
|
69746
|
-
|
|
69747
|
-
if (item.classList.contains('is-row-tool')) return;
|
|
69748
|
-
if (item.classList.contains('is-rowadd-tool')) return;
|
|
69749
|
-
if (item.classList.contains('is-col-tool')) return;
|
|
69775
|
+
columnsOf(col.parentNode).map(item => {
|
|
69750
69776
|
if (item.getAttribute('data-html')) {
|
|
69751
69777
|
let moduleWidth = item.offsetWidth / row.offsetWidth * 100;
|
|
69752
69778
|
item.style.width = moduleWidth + '%';
|
|
@@ -69758,10 +69784,7 @@ class Resize {
|
|
|
69758
69784
|
if (col.style.height) {
|
|
69759
69785
|
col.style.minHeight = col.style.height;
|
|
69760
69786
|
col.style.height = '';
|
|
69761
|
-
|
|
69762
|
-
if (item.classList.contains('is-row-tool')) return;
|
|
69763
|
-
if (item.classList.contains('is-rowadd-tool')) return;
|
|
69764
|
-
if (item.classList.contains('is-col-tool')) return;
|
|
69787
|
+
columnsOf(col.parentNode).map(item => {
|
|
69765
69788
|
// if(this.opts.filterSibling) if(item.classList.contains(this.opts.filterSibling)) return;
|
|
69766
69789
|
|
|
69767
69790
|
if (item === col) return;
|
|
@@ -69781,6 +69804,10 @@ class Resize {
|
|
|
69781
69804
|
});
|
|
69782
69805
|
}
|
|
69783
69806
|
destroy() {
|
|
69807
|
+
if (this.eventTarget && this.normalizeToPercent) {
|
|
69808
|
+
this.eventTarget.removeEventListener('mouseup', this.normalizeToPercent, true);
|
|
69809
|
+
this.eventTarget.removeEventListener('touchend', this.normalizeToPercent, true);
|
|
69810
|
+
}
|
|
69784
69811
|
this.resize.destroy();
|
|
69785
69812
|
}
|
|
69786
69813
|
}
|