@innovastudio/contentbuilder 1.5.29 → 1.5.31

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.29",
4
+ "version": "1.5.31",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "files": [
@@ -17314,19 +17314,27 @@ const renderSnippetPanel = (builder, snippetOpen) => {
17314
17314
  if (activeBuilderArea) {
17315
17315
  dom.addClass(activeBuilderArea, 'builder-active');
17316
17316
  }
17317
-
17318
- // destroy
17319
- if (builder.sortableOnCanvas) {
17320
- builder.sortableOnCanvas.forEach(obj => {
17321
- if (obj) {
17322
- obj.destroy();
17323
- }
17324
- });
17325
- builder.sortableOnCanvas = [];
17326
- }
17327
- if (builder.sortableOnPage) builder.sortableOnPage.destroy();
17328
- let dummies = builder.doc.querySelectorAll('.block-dummy');
17329
- dummies.forEach(elm => elm.parentNode.removeChild(elm));
17317
+ },
17318
+ onUnchoose: () => {
17319
+ setTimeout(() => {
17320
+ // Give time for onAdd to finish
17321
+ // Destroy placed in onUnchoose in case a snippet is just clicked (no drag/drop) so that onAdd is not triggered.
17322
+ // destroy
17323
+ if (builder.sortableOnCanvas) {
17324
+ builder.sortableOnCanvas.forEach(obj => {
17325
+ if (obj) {
17326
+ obj.destroy();
17327
+ }
17328
+ });
17329
+ builder.sortableOnCanvas = [];
17330
+ }
17331
+ if (builder.sortableOnPage) {
17332
+ builder.sortableOnPage.destroy();
17333
+ builder.sortableOnPage = null;
17334
+ }
17335
+ let dummies = builder.doc.querySelectorAll('.block-dummy');
17336
+ dummies.forEach(elm => elm.parentNode.removeChild(elm));
17337
+ }, 10);
17330
17338
  }
17331
17339
  });
17332
17340
  if (builder.opts.snippetList === '#divSnippetList') {
@@ -83403,6 +83411,37 @@ class Draggable {
83403
83411
  }
83404
83412
  }
83405
83413
  updateBlockStyle(target) {
83414
+ // Block placement should must not 50% outside the container
83415
+ const container = target.closest('.box-canvas');
83416
+ let containerHeight = container.offsetHeight;
83417
+ let containerWidth = container.offsetWidth;
83418
+ /*
83419
+ if(target.offsetTop + target.offsetHeight>=containerHeight) {
83420
+ target.style.top = containerHeight-target.offsetHeight +'px';
83421
+ }
83422
+ if(target.offsetTop<=0) {
83423
+ target.style.top = '0px';
83424
+ }
83425
+ if(target.offsetLeft + target.offsetWidth>=åcontainerWidth) {
83426
+ target.style.left = (containerWidth-target.offsetWidth) +'px';
83427
+ }
83428
+ if(target.offsetLeft<=0) {
83429
+ target.style.left = '0px';
83430
+ }
83431
+ */
83432
+ if (target.offsetTop + target.offsetHeight <= target.offsetHeight / 2) {
83433
+ target.style.top = '0px';
83434
+ }
83435
+ if (containerHeight - target.offsetTop <= target.offsetHeight / 2) {
83436
+ target.style.top = containerHeight - target.offsetHeight + 'px';
83437
+ }
83438
+ if (target.offsetLeft + target.offsetWidth <= target.offsetWidth / 2) {
83439
+ target.style.left = '0px';
83440
+ }
83441
+ if (containerWidth - target.offsetLeft <= target.offsetWidth / 2) {
83442
+ target.style.left = containerWidth - target.offsetWidth + 'px';
83443
+ }
83444
+
83406
83445
  // Replace with ruler's alignment
83407
83446
  if (this.ruler.rulerTop !== null) target.style.top = this.ruler.rulerTop + 'px';
83408
83447
  if (this.ruler.rulerBottom !== null) target.style.top = this.ruler.rulerBottom - target.offsetHeight + 'px'; //new
@@ -89159,7 +89198,10 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
89159
89198
  dummies.forEach(elm => elm.parentNode.removeChild(elm));
89160
89199
  this.sortableOnCanvas = [];
89161
89200
  }
89162
- if (this.sortableOnPage) this.sortableOnPage.destroy();
89201
+ if (this.sortableOnPage) {
89202
+ this.sortableOnPage.destroy();
89203
+ this.sortableOnPage = null;
89204
+ }
89163
89205
  }
89164
89206
  }
89165
89207
  });
@@ -92417,7 +92459,10 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
92417
92459
  dummies.forEach(elm => elm.parentNode.removeChild(elm));
92418
92460
  this.sortableOnCanvas = [];
92419
92461
  }
92420
- if (this.sortableOnPage) this.sortableOnPage.destroy();
92462
+ if (this.sortableOnPage) {
92463
+ this.sortableOnPage.destroy();
92464
+ this.sortableOnPage = null;
92465
+ }
92421
92466
  }
92422
92467
  });
92423
92468
  this.sortableOnCanvas.push(obj);
@@ -92493,7 +92538,10 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
92493
92538
  dummies.forEach(elm => elm.parentNode.removeChild(elm));
92494
92539
  this.sortableOnCanvas = [];
92495
92540
  }
92496
- if (this.sortableOnPage) this.sortableOnPage.destroy();
92541
+ if (this.sortableOnPage) {
92542
+ this.sortableOnPage.destroy();
92543
+ this.sortableOnPage = null;
92544
+ }
92497
92545
  return;
92498
92546
  }
92499
92547
  if (itemEl.getAttribute('data-id')) {
@@ -92647,7 +92695,10 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
92647
92695
  dummies.forEach(elm => elm.parentNode.removeChild(elm));
92648
92696
  this.sortableOnCanvas = [];
92649
92697
  }
92650
- if (this.sortableOnPage) this.sortableOnPage.destroy();
92698
+ if (this.sortableOnPage) {
92699
+ this.sortableOnPage.destroy();
92700
+ this.sortableOnPage = null;
92701
+ }
92651
92702
  }
92652
92703
  });
92653
92704
  }