@innovastudio/contentbuilder 1.5.50 → 1.5.52

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
  "name": "@innovastudio/contentbuilder",
3
3
  "type": "module",
4
- "version": "1.5.50",
4
+ "version": "1.5.52",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "types": "index.d.ts",
@@ -55,7 +55,6 @@
55
55
  "webpack-dev-server": "^4.2.1"
56
56
  },
57
57
  "dependencies": {
58
- "@innovastudio/contentbuilder": "^1.5.44",
59
58
  "@monaco-editor/loader": "^1.3.2",
60
59
  "blueimp-load-image": "^5.16.0",
61
60
  "cropperjs": "^1.5.12",
@@ -17122,6 +17122,24 @@ const renderSnippetPanel = (builder, snippetOpen) => {
17122
17122
  }
17123
17123
  });
17124
17124
  }
17125
+ let snippetid;
17126
+ if (isMobile && builder.isContentBox) {
17127
+ const items = snippetlist.querySelectorAll('.snippet-item');
17128
+ items.forEach(item => {
17129
+ if (item.classList.contains('data-click')) return;
17130
+ item.addEventListener('touchstart', () => {
17131
+ snippetid = item.getAttribute('data-id');
17132
+ }, {
17133
+ passive: false
17134
+ });
17135
+ item.addEventListener('touchend', () => {
17136
+ builder.dropSnippet(snippetid);
17137
+ }, {
17138
+ passive: false
17139
+ });
17140
+ item.classList.add('data-click');
17141
+ });
17142
+ }
17125
17143
  }
17126
17144
  });
17127
17145
  inpSnippet.setValue(defaultcatval + '');
@@ -17247,6 +17265,7 @@ const renderSnippetPanel = (builder, snippetOpen) => {
17247
17265
  if (isMobile && builder.isContentBox) {
17248
17266
  const items = snippetlist.querySelectorAll('.snippet-item');
17249
17267
  items.forEach(item => {
17268
+ if (item.classList.contains('data-click')) return;
17250
17269
  item.addEventListener('touchstart', () => {
17251
17270
  snippetid = item.getAttribute('data-id');
17252
17271
  }, {
@@ -17257,6 +17276,7 @@ const renderSnippetPanel = (builder, snippetOpen) => {
17257
17276
  }, {
17258
17277
  passive: false
17259
17278
  });
17279
+ item.classList.add('data-click');
17260
17280
  });
17261
17281
  useClick = true;
17262
17282
  }
@@ -72870,15 +72890,19 @@ class Resizeable {
72870
72890
  resizing();
72871
72891
  }
72872
72892
  getScale(container) {
72873
- let matrix = window.getComputedStyle(container).transform;
72874
- if (matrix === 'none') return false;
72875
- let values = matrix.split('(')[1];
72876
- values = values.split(')')[0];
72877
- values = values.split(',');
72878
- let a = values[0];
72879
- let b = values[1];
72880
- let scale = Math.sqrt(a * a + b * b);
72881
- return scale;
72893
+ try {
72894
+ let matrix = window.getComputedStyle(container).transform;
72895
+ if (matrix === 'none') return false;
72896
+ let values = matrix.split('(')[1];
72897
+ values = values.split(')')[0];
72898
+ values = values.split(',');
72899
+ let a = values[0];
72900
+ let b = values[1];
72901
+ let scale = Math.sqrt(a * a + b * b);
72902
+ return scale;
72903
+ } catch (e) {
72904
+ return 1;
72905
+ }
72882
72906
  }
72883
72907
  destroy() {
72884
72908
  const pane = this.pane;
@@ -92480,7 +92504,18 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
92480
92504
  html = snippet.innerHTML;
92481
92505
  }
92482
92506
  let activeBox = this.doc.querySelector('.box-select');
92483
- if (!activeBox) activeBox = this.activeBox;
92507
+ if (!activeBox) {
92508
+ activeBox = this.activeBox;
92509
+ if (!this.doc.body.contains(activeBox)) activeBox = null; // box deleted
92510
+ }
92511
+
92512
+ if (!activeBox) {
92513
+ this.doc.querySelectorAll('.is-box').forEach(box => {
92514
+ if (this.isMoreThan50PercentVisible(box)) {
92515
+ activeBox = box;
92516
+ }
92517
+ });
92518
+ }
92484
92519
  const activeRow = this.doc.querySelector('.row-active');
92485
92520
  if (activeRow) {
92486
92521
  if (html2) html = html2; // if it is canvas block, change it to normal using html2
@@ -92506,6 +92541,7 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
92506
92541
  });
92507
92542
  html = snippet.innerHTML;
92508
92543
  this.uo.saveForUndo();
92544
+ activeBox.querySelectorAll('.is-container.container-new').forEach(elm => elm.classList.remove('container-new'));
92509
92545
  if (isBlock) {
92510
92546
  this.eb.addBlock(html, activeBox);
92511
92547
  } else {
@@ -92519,17 +92555,17 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
92519
92555
  // html = blockTemplate.replace('[%CONTENT%]', html);
92520
92556
 
92521
92557
  this.eb.addBlock(blockTemplate, activeBox);
92522
- }
92523
- const builders = activeBox.querySelectorAll('.is-container.container-new');
92524
- builders.forEach(builder => {
92525
- // After snippet has been added, re-apply behavior on builder areas
92558
+ const builders = activeBox.querySelectorAll('.is-container.container-new');
92559
+ builders.forEach(builder => {
92560
+ // After snippet has been added, re-apply behavior on builder areas
92526
92561
 
92527
- var range = document.createRange();
92528
- range.setStart(builder, 0);
92529
- builder.appendChild(range.createContextualFragment(html));
92530
- this.applyBehaviorOn(builder);
92531
- builder.classList.remove('container-new');
92532
- });
92562
+ var range = document.createRange();
92563
+ range.setStart(builder, 0);
92564
+ builder.appendChild(range.createContextualFragment(html));
92565
+ this.applyBehaviorOn(builder);
92566
+ builder.classList.remove('container-new');
92567
+ });
92568
+ }
92533
92569
  this.opts.onChange();
92534
92570
  this.opts.onRender();
92535
92571
  if (this.opts.onBlockCanvasAdd) this.opts.onBlockCanvasAdd();
@@ -92546,6 +92582,19 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
92546
92582
  }
92547
92583
  }
92548
92584
  }
92585
+ } else {
92586
+ // No Active Box => Add Section
92587
+
92588
+ let sectionTemplate = this.settings.sectionTemplate;
92589
+ const occurrences = this.dom.countOccurrences(html, 'column');
92590
+ if (occurrences === 1) {
92591
+ sectionTemplate = sectionTemplate.replace('is-content-1000', 'is-content-700');
92592
+ }
92593
+ html = sectionTemplate.replace('[%CONTENT%]', html);
92594
+ const wrapper = this.doc.querySelector(this.page);
92595
+ wrapper.insertAdjacentHTML('afterbegin', html);
92596
+ this.activeBox = wrapper.querySelector('.is-box');
92597
+ if (this.opts.onBlockSectionAdd) this.opts.onBlockSectionAdd();
92549
92598
  }
92550
92599
  }
92551
92600
  this.activeCol = null;
@@ -92599,6 +92648,16 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
92599
92648
  this.opts.onChange();
92600
92649
  this.opts.onRender();
92601
92650
  }
92651
+ isMoreThan50PercentVisible(el) {
92652
+ const rect = el.getBoundingClientRect();
92653
+ const windowHeight = this.win.innerHeight || this.doc.documentElement.clientHeight;
92654
+
92655
+ // Calculate the visible part of the element in the viewport
92656
+ const visibleHeight = Math.min(rect.bottom, windowHeight) - Math.max(rect.top, 0);
92657
+
92658
+ // Check if more than 50% of the element is visible
92659
+ return visibleHeight / rect.height > 0.5;
92660
+ }
92602
92661
  sectionDropSetup() {
92603
92662
  if (this.blockContainer) {
92604
92663
  this.sortableOnCanvas = [];