@innovastudio/contentbuilder 1.5.214 → 1.5.216

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@innovastudio/contentbuilder",
4
- "version": "1.5.214",
4
+ "version": "1.5.216",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "types": "index.d.ts",
@@ -7413,6 +7413,17 @@ class Util {
7413
7413
  hidePops() {
7414
7414
  const dom = this.dom;
7415
7415
  const builderStuff = this.builder.builderStuff;
7416
+
7417
+ /* Fast path. This runs on every scroll event (see the window 'scroll'
7418
+ * handler in contentbuilder.js — its 10ms debounce is shorter than the
7419
+ * ~16ms gap between scroll events, so it does not coalesce them), which
7420
+ * meant two full querySelectorAll sweeps plus their loops ~60x/second
7421
+ * even with nothing open. When nothing is showing, the loops below are
7422
+ * no-ops, so skip straight to the image handles. */
7423
+ if (!builderStuff.querySelector('.is-tool.active, .is-tool[style*="display"], .is-pop.active')) {
7424
+ if (this.builder.editingEngine) this.builder.editingEngine.hideImageHandles();
7425
+ return;
7426
+ }
7416
7427
  let tools = builderStuff.querySelectorAll('.is-tool');
7417
7428
  Array.prototype.forEach.call(tools, tool => {
7418
7429
  // if(tool.classList.contains('is-row-tool')||
@@ -32222,11 +32233,23 @@ class Plugin {
32222
32233
  }
32223
32234
  };
32224
32235
  if (!this.builder.handlePluginClick_) {
32225
- document.addEventListener('click', handlePluginClick);
32226
- if (this.builder.iframeDocument) {
32227
- this.builder.doc.addEventListener('click', handlePluginClick);
32228
- }
32229
32236
  this.builder.handlePluginClick_ = true;
32237
+ // Register on the NEXT task, not now. showPluginEditor() can be
32238
+ // reached from a microtask inside the very click that opens the
32239
+ // panel: the RTE button runs convertSelectionToPlugin(), whose
32240
+ // runtime.reinitialize().then() resolves while that click is still
32241
+ // propagating towards document. A listener added mid-propagation
32242
+ // still receives that same click, so the panel was closed the
32243
+ // instant it opened — and only on a first open, because afterwards
32244
+ // the previous listener had already fired and removed itself.
32245
+ // Deferring means this listener can never see the click that
32246
+ // created it, whichever toolbar or panel opened the panel.
32247
+ setTimeout(() => {
32248
+ document.addEventListener('click', handlePluginClick);
32249
+ if (this.builder.iframeDocument) {
32250
+ this.builder.doc.addEventListener('click', handlePluginClick);
32251
+ }
32252
+ }, 0);
32230
32253
  }
32231
32254
  }
32232
32255
  hidePluginEditor() {
@@ -69542,16 +69565,42 @@ class Resize {
69542
69565
  enable() {
69543
69566
  const col = this.element;
69544
69567
  const row = col.parentNode;
69568
+
69569
+ // The builder injects its own elements into a row — tools, the add-row
69570
+ // bar, and the row overlay that appears once the row is selected in the
69571
+ // side panel. They are not columns, and measuring them as columns makes
69572
+ // the totals below nonsense. Filter them out in ONE place so a new
69573
+ // injected element can never silently break the maths again.
69574
+ 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');
69575
+ const columnsOf = parent => Array.from(parent.children).filter(item => !isBuilderUI(item));
69576
+
69577
+ // A column width is only ever stored as a percentage; pixels are used
69578
+ // purely while a drag is in progress. resizeEnd normally converts them
69579
+ // back, but it does not run if the drag is interrupted — and pixel
69580
+ // widths saved into the page push content off screen on smaller
69581
+ // devices. This is the backstop for that: whatever happens to the drag,
69582
+ // a leftover pixel width is converted on the next tick. Capture phase,
69583
+ // so it still runs if something stops the event bubbling.
69584
+ const normalizeToPercent = () => {
69585
+ setTimeout(() => {
69586
+ if (!col.style.width || col.style.width.indexOf('px') === -1) return;
69587
+ const parent = col.parentNode;
69588
+ if (!parent || !parent.offsetWidth) return;
69589
+ const pct = col.offsetWidth / parent.offsetWidth * 100;
69590
+ if (isFinite(pct) && pct > 0) col.style.width = pct + '%';
69591
+ }, 0);
69592
+ };
69593
+ this.normalizeToPercent = normalizeToPercent;
69594
+ this.eventTarget = col.ownerDocument;
69595
+ this.eventTarget.addEventListener('mouseup', normalizeToPercent, true);
69596
+ this.eventTarget.addEventListener('touchend', normalizeToPercent, true);
69545
69597
  this.resize = new Resizeable({
69546
69598
  pane: col,
69547
69599
  resizeHeight: this.builder.resizeHeight,
69548
69600
  onResize: (width, height) => {
69549
69601
  this.builder.util.hideControls();
69550
69602
  let numOfCols = 1;
69551
- Array.from(col.parentNode.children).map(item => {
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;
69603
+ columnsOf(col.parentNode).map(item => {
69555
69604
  if (item === col) return;
69556
69605
  numOfCols++;
69557
69606
  });
@@ -69562,10 +69611,7 @@ class Resize {
69562
69611
  // adjust others
69563
69612
  const maxWidth = () => {
69564
69613
  let otherWidth = 0;
69565
- Array.from(col.parentNode.children).map(item => {
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;
69614
+ columnsOf(col.parentNode).map(item => {
69569
69615
  // if(this.opts.filterSibling) if(item.classList.contains(this.opts.filterSibling)) return;
69570
69616
 
69571
69617
  if (item === col) return;
@@ -69579,10 +69625,7 @@ class Resize {
69579
69625
  // percentage = (max / row.offsetWidth) * 100;
69580
69626
  // Or make others auto
69581
69627
 
69582
- Array.from(col.parentNode.children).map(item => {
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;
69628
+ columnsOf(col.parentNode).map(item => {
69586
69629
  // if(this.opts.filterSibling) if(item.classList.contains(this.opts.filterSibling)) return;
69587
69630
 
69588
69631
  if (item === col) return;
@@ -69620,10 +69663,7 @@ class Resize {
69620
69663
  }
69621
69664
  } else {
69622
69665
  // New: if other cols has no width, set to 100%
69623
- Array.from(col.parentNode.children).map(item => {
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;
69666
+ columnsOf(col.parentNode).map(item => {
69627
69667
  // if(this.opts.filterSibling) if(item.classList.contains(this.opts.filterSibling)) return;
69628
69668
 
69629
69669
  if (item === col) return;
@@ -69653,10 +69693,7 @@ class Resize {
69653
69693
  },
69654
69694
  resizeEnd: () => {
69655
69695
  let numOfCols = 1;
69656
- Array.from(col.parentNode.children).map(item => {
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;
69696
+ columnsOf(col.parentNode).map(item => {
69660
69697
  if (item === col) return;
69661
69698
  numOfCols++;
69662
69699
  });
@@ -69668,13 +69705,9 @@ class Resize {
69668
69705
  // adjust others
69669
69706
  const maxWidth = () => {
69670
69707
  let otherWidth = 0;
69671
- Array.from(col.parentNode.children).map(item => {
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;
69708
+ columnsOf(col.parentNode).map(item => {
69675
69709
  // if(this.opts.filterSibling) if(item.classList.contains(this.opts.filterSibling)) return;
69676
69710
 
69677
- if (item.classList.contains('row-tool')) return;
69678
69711
  if (item === col) return;
69679
69712
  otherWidth += item.offsetWidth;
69680
69713
  });
@@ -69686,10 +69719,7 @@ class Resize {
69686
69719
  // percentage = (max / row.offsetWidth) * 100;
69687
69720
  // Or make others auto
69688
69721
 
69689
- Array.from(col.parentNode.children).map(item => {
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;
69722
+ columnsOf(col.parentNode).map(item => {
69693
69723
  // if(this.opts.filterSibling) if(item.classList.contains(this.opts.filterSibling)) return;
69694
69724
 
69695
69725
  if (item === col) return;
@@ -69719,10 +69749,7 @@ class Resize {
69719
69749
  // New: Final fix (if column resized exceeds its max)
69720
69750
  let othersWidth = 0;
69721
69751
  let activeColumnWidth = 0;
69722
- Array.from(col.parentNode.children).map(item => {
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;
69752
+ columnsOf(col.parentNode).map(item => {
69726
69753
  // if(this.opts.filterSibling) if(item.classList.contains(this.opts.filterSibling)) return;
69727
69754
 
69728
69755
  // // Refresh Module
@@ -69740,13 +69767,23 @@ class Resize {
69740
69767
  if (activeColumnWidth > maxResult) {
69741
69768
  percentage = maxResult / row.offsetWidth * 100;
69742
69769
  }
69743
- col.style.width = percentage + '%';
69770
+
69771
+ // The column is carrying a pixel width at this point (set
69772
+ // just above, to measure it). A width is only ever stored as
69773
+ // a percentage, so if the maths produced something CSS will
69774
+ // reject — negative, zero, NaN, Infinity — the assignment
69775
+ // would silently fail and leave those pixels behind, which
69776
+ // then breaks the layout on smaller screens. Fall back to
69777
+ // the column's real share of the row instead.
69778
+ if (!isFinite(percentage) || percentage <= 0) {
69779
+ percentage = col.offsetWidth / row.offsetWidth * 100;
69780
+ }
69781
+ if (isFinite(percentage) && percentage > 0) {
69782
+ col.style.width = percentage + '%';
69783
+ }
69744
69784
 
69745
69785
  // Refresh Module
69746
- Array.from(col.parentNode.children).map(item => {
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;
69786
+ columnsOf(col.parentNode).map(item => {
69750
69787
  if (item.getAttribute('data-html')) {
69751
69788
  let moduleWidth = item.offsetWidth / row.offsetWidth * 100;
69752
69789
  item.style.width = moduleWidth + '%';
@@ -69758,10 +69795,7 @@ class Resize {
69758
69795
  if (col.style.height) {
69759
69796
  col.style.minHeight = col.style.height;
69760
69797
  col.style.height = '';
69761
- Array.from(col.parentNode.children).map(item => {
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;
69798
+ columnsOf(col.parentNode).map(item => {
69765
69799
  // if(this.opts.filterSibling) if(item.classList.contains(this.opts.filterSibling)) return;
69766
69800
 
69767
69801
  if (item === col) return;
@@ -69781,6 +69815,10 @@ class Resize {
69781
69815
  });
69782
69816
  }
69783
69817
  destroy() {
69818
+ if (this.eventTarget && this.normalizeToPercent) {
69819
+ this.eventTarget.removeEventListener('mouseup', this.normalizeToPercent, true);
69820
+ this.eventTarget.removeEventListener('touchend', this.normalizeToPercent, true);
69821
+ }
69784
69822
  this.resize.destroy();
69785
69823
  }
69786
69824
  }