@innovastudio/contentbuilder 1.2.11 → 1.2.14

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbuilder",
3
- "version": "1.2.11",
3
+ "version": "1.2.14",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
@@ -16965,7 +16965,7 @@ const renderQuickAdd = builder => {
16965
16965
  elm = quickadd.querySelector('.add-audio');
16966
16966
  dom$H.addEventListener(elm, 'click', () => {
16967
16967
  const mode = quickadd.getAttribute('data-mode');
16968
- let html = `<div style="display:flex;position:relative;margin:15px 0;background:transparent;">
16968
+ let html = `<div style="display:flex;width:100%;position:relative;margin:15px 0;background:transparent;">
16969
16969
  <audio controls="" style="width:100%">
16970
16970
  <source src="${builder.opts.snippetPath}example.mp3" type="audio/mpeg">
16971
16971
  Your browser does not support the audio element.
@@ -16973,7 +16973,7 @@ const renderQuickAdd = builder => {
16973
16973
  </div>`;
16974
16974
 
16975
16975
  if (builder.opts.snippetSampleAudio) {
16976
- html = `<div style="display:flex;position:relative;margin:15px 0;background:transparent;">
16976
+ html = `<div style="display:flex;width:100%;position:relative;margin:15px 0;background:transparent;">
16977
16977
  <audio controls="" style="width:100%">
16978
16978
  <source src="${builder.opts.snippetSampleAudio}" type="audio/mpeg">
16979
16979
  Your browser does not support the audio element.
@@ -47385,7 +47385,7 @@ var loadImageOrientation = {exports: {}};
47385
47385
  var js = loadImage.exports;
47386
47386
 
47387
47387
  const dom$C = new Dom();
47388
- class Image {
47388
+ class Image$1 {
47389
47389
  constructor(builder) {
47390
47390
  this.builder = builder;
47391
47391
  const util = this.builder.util;
@@ -52320,7 +52320,7 @@ class Element$1 {
52320
52320
  this.builderStuff = builderStuff;
52321
52321
  this.hyperlink = new Hyperlink(builder);
52322
52322
  this.button = new Button(builder);
52323
- this.image = new Image(builder);
52323
+ this.image = new Image$1(builder);
52324
52324
  this.spacer = new Spacer(builder);
52325
52325
  this.module = new Module(builder);
52326
52326
  this.code = new Code(builder);
@@ -54917,27 +54917,30 @@ class ColumnTool {
54917
54917
 
54918
54918
  <div style="padding:0;margin-top:25px;">
54919
54919
 
54920
- <div style="padding-bottom:3px;">${util.out('Scale')}:</div>
54920
+ <div style="padding-bottom:3px;display:flex;">
54921
+ <span>${util.out('Scale')}:</span>
54922
+ </div>
54921
54923
  <div style="padding-top:4px">
54922
- <input type="range" min="0" max="100" value="0" class="image-scale-slider is-rangeslider">
54924
+ <input type="range" min="100" max="500" value="0" class="image-scale-slider is-rangeslider">
54923
54925
  </div>
54924
54926
 
54925
- <div style="padding-bottom:3px;padding-top: 20px;display:flex;justify-content:space-between;align-items:center;">
54927
+ <div style="padding-bottom:3px;padding-top: 20px;display:flex;">
54926
54928
  <span>${util.out('Horizontal')}:</span>
54927
- <button title="${util.out('Reset')}" class="image-hor-reset" style="display:flex;width:30px;height:20px;"><svg class="is-icon-flex" style="width:11px;height:11px;"><use xlink:href="#icon-clean"></use></svg></button>
54928
54929
  </div>
54929
54930
  <div style="padding-top:4px">
54930
- <input type="range" min="-100" max="100" value="0" class="image-hor-slider is-rangeslider">
54931
+ <input type="range" min="-150" max="150" value="0" class="image-hor-slider is-rangeslider">
54931
54932
  </div>
54932
54933
 
54933
- <div style="padding-bottom:3px;padding-top: 20px;display:flex;justify-content:space-between;align-items:center;">
54934
- <span>${util.out('Vertical')}:</span>
54935
- <button title="${util.out('Reset')}" class="image-vert-reset" style="display:flex;width:30px;height:20px;"><svg class="is-icon-flex" style="width:11px;height:11px;"><use xlink:href="#icon-clean"></use></svg></button>
54936
- </div>
54934
+ <div style="padding-bottom:3px;padding-top: 20px;display:flex;">
54935
+ <span>${util.out('Vertical')}:</span>
54936
+ </div>
54937
54937
  <div style="padding-top:4px">
54938
- <input type="range" min="-100" max="100" value="0" class="image-vert-slider is-rangeslider">
54938
+ <input type="range" min="-150" max="150" value="0" class="image-vert-slider is-rangeslider">
54939
54939
  </div>
54940
54940
 
54941
+ <div style="padding-bottom:3px;padding-top: 10px;display:flex;justify-content:right;align-items:center;">
54942
+ <button title="${util.out('Reset')}" class="image-reset" style="display:flex;width:30px;height:30px;"><svg class="is-icon-flex" style="width:11px;height:11px;"><use xlink:href="#icon-clean"></use></svg></button>
54943
+ </div>
54941
54944
  </div>
54942
54945
 
54943
54946
  </div>
@@ -55352,21 +55355,21 @@ class ColumnTool {
55352
55355
  };
55353
55356
 
55354
55357
  inpImageScaleSlider2.oninput = () => {
55355
- let cell = this.builder.elementSelected;
55356
- cell.style.backgroundSize = ''; //val: 0 - 100
55358
+ let cell = this.builder.elementSelected; //val: 100 - 500
55357
55359
 
55358
55360
  let val = inpImageScaleSlider2.value;
55359
- cell.setAttribute('data-scale', val); // vall => -100-100
55360
55361
 
55361
- if (val !== 0) {
55362
- cell.style.width = 'unset';
55363
- cell.style.left = `-${val}vw`;
55364
- cell.style.right = `-${val}vw`;
55362
+ if (this.scaleWidth) {
55363
+ cell.style.width = val + '%'; // cell.style.height = '';
55364
+
55365
+ cell.style.height = val * 100 / inpImageScaleSlider2.min + '%';
55365
55366
  } else {
55366
- cell.style.left = '';
55367
- cell.style.right = '';
55368
- cell.style.width = '';
55367
+ cell.style.height = val + '%'; // cell.style.width = '';
55368
+
55369
+ cell.style.width = val * 100 / inpImageScaleSlider2.min + '%';
55369
55370
  }
55371
+
55372
+ cell.setAttribute('data-scale', val);
55370
55373
  };
55371
55374
 
55372
55375
  inpImageScaleSlider2.onchange = () => {
@@ -55406,25 +55409,12 @@ class ColumnTool {
55406
55409
  };
55407
55410
 
55408
55411
  inpImageHorSlider2.oninput = () => {
55409
- let cell = this.builder.elementSelected;
55410
- let normalWidth = cell.parentNode.offsetWidth / window.innerWidth * 100; // vw
55411
-
55412
- let scaleInc = parseFloat(inpImageScaleSlider2.value);
55413
- const enlarge = (normalWidth + 2 * scaleInc) / normalWidth; //val: -100 - 100
55412
+ let cell = this.builder.elementSelected; //val: -100 - 100
55414
55413
 
55415
55414
  let val = parseFloat(inpImageHorSlider2.value);
55415
+ cell.style.left = `${val}%`;
55416
+ cell.style.right = '';
55416
55417
  cell.setAttribute('data-x', val);
55417
- let currentWidth = cell.parentNode.offsetWidth * enlarge;
55418
- currentWidth = currentWidth / window.innerWidth * 100; // vw
55419
-
55420
- let currentLeft = (currentWidth - normalWidth) / 2; // vw
55421
-
55422
- let currentRight = (currentWidth - normalWidth) / 2;
55423
- const left = -currentLeft + val;
55424
- const right = -currentRight - val;
55425
- cell.style.width = 'unset';
55426
- cell.style.left = `${left}vw`;
55427
- cell.style.right = `${right}vw`;
55428
55418
  };
55429
55419
 
55430
55420
  inpImageHorSlider2.onchange = () => {
@@ -55464,25 +55454,12 @@ class ColumnTool {
55464
55454
  };
55465
55455
 
55466
55456
  inpImageVertSlider2.oninput = () => {
55467
- let cell = this.builder.elementSelected;
55468
- let normalHeight = cell.parentNode.offsetHeight / window.innerHeight * 100; // vh
55469
-
55470
- let scaleInc = parseFloat(inpImageScaleSlider2.value);
55471
- const enlarge = (normalHeight + 2 * scaleInc) / normalHeight; //val: -100 - 100
55457
+ let cell = this.builder.elementSelected; //val: -100 - 100
55472
55458
 
55473
55459
  let val = parseFloat(inpImageVertSlider2.value);
55460
+ cell.style.top = `${val}%`;
55461
+ cell.style.bottom = '';
55474
55462
  cell.setAttribute('data-y', val);
55475
- let currentHeight = cell.parentNode.offsetHeight * enlarge;
55476
- currentHeight = currentHeight / window.innerHeight * 100; // vh
55477
-
55478
- let currentTop = (currentHeight - normalHeight) / 2; // vh
55479
-
55480
- let currentBottom = (currentHeight - normalHeight) / 2;
55481
- const top = -currentTop + val;
55482
- const bottom = -currentBottom - val;
55483
- cell.style.height = 'unset';
55484
- cell.style.top = `${top}vh`;
55485
- cell.style.bottom = `${bottom}vh`;
55486
55463
  };
55487
55464
 
55488
55465
  inpImageVertSlider2.onchange = () => {
@@ -55490,25 +55467,13 @@ class ColumnTool {
55490
55467
  this.builder.opts.onChange();
55491
55468
  };
55492
55469
 
55493
- const btnHorReset = imageAdjust2.querySelector('.image-hor-reset');
55494
- btnHorReset.addEventListener('click', () => {
55470
+ const btnImageReset = imageAdjust2.querySelector('.image-reset');
55471
+ btnImageReset.addEventListener('click', () => {
55495
55472
  this.builder.uo.saveForUndo();
55496
55473
  let cell = this.builder.elementSelected;
55497
- inpImageHorSlider2.value = 0;
55498
- cell.style.width = '';
55499
- cell.style.left = '';
55500
- cell.style.right = '';
55501
- cell.removeAttribute('data-x');
55502
- });
55503
- const btnVertReset = imageAdjust2.querySelector('.image-vert-reset');
55504
- btnVertReset.addEventListener('click', () => {
55505
- this.builder.uo.saveForUndo();
55506
- let cell = this.builder.elementSelected;
55507
- inpImageVertSlider2.value = 0;
55508
- cell.style.height = '';
55509
- cell.style.top = '';
55510
- cell.style.bottom = '';
55511
- cell.removeAttribute('data-y');
55474
+ this.resetImage(cell); //Trigger Change event
55475
+
55476
+ this.builder.opts.onChange();
55512
55477
  }); // Row Enlarge (Currently not used)
55513
55478
 
55514
55479
  elms = cellSettings.querySelectorAll('.input-row-enlarge');
@@ -56481,6 +56446,81 @@ class ColumnTool {
56481
56446
  if (btn) btn.setAttribute('data-focus', true);
56482
56447
  }
56483
56448
 
56449
+ resetImage(elm) {
56450
+ //Current value
56451
+ const imageAdjust2 = this.imageAdjust2;
56452
+ const inpImageScaleSlider = imageAdjust2.querySelector('.image-scale-slider');
56453
+ const inpImageHorSlider = imageAdjust2.querySelector('.image-hor-slider');
56454
+ const inpImageVertSlider = imageAdjust2.querySelector('.image-vert-slider');
56455
+ let overlayDimension = {
56456
+ width: elm.parentNode.offsetWidth,
56457
+ height: elm.parentNode.offsetHeight
56458
+ };
56459
+ let dimension, image;
56460
+ image = new Image();
56461
+ image.src = elm.style.backgroundImage.replace(/"/g, '').replace(/url\(|\)$/ig, '');
56462
+
56463
+ image.onload = () => {
56464
+ dimension = {
56465
+ width: image.naturalWidth,
56466
+ height: image.naturalHeight
56467
+ };
56468
+ this.dimension = dimension;
56469
+
56470
+ if (overlayDimension.width / overlayDimension.height <= dimension.width / dimension.height) {
56471
+ this.scaleWidth = true;
56472
+ this.scaleHeight = false; // let h = overlayDimension.height; //px
56473
+
56474
+ let w = overlayDimension.height * (dimension.width / dimension.height);
56475
+ w = w / overlayDimension.width * 100; //%
56476
+
56477
+ if (!elm.style.width) {
56478
+ elm.style.width = w + '%';
56479
+ elm.style.height = '';
56480
+ }
56481
+
56482
+ inpImageScaleSlider.min = w;
56483
+ let val = -(w - 100) * 0.5;
56484
+ inpImageHorSlider.value = val; //50%
56485
+
56486
+ elm.style.left = val + '%';
56487
+ elm.setAttribute('data-x', val);
56488
+ inpImageVertSlider.value = 0;
56489
+ elm.style.top = '0%';
56490
+ elm.setAttribute('data-y', 0);
56491
+ inpImageScaleSlider.value = w;
56492
+ elm.style.width = w + '%';
56493
+ elm.setAttribute('data-scale', w);
56494
+ elm.style.height = '100%'; //((w*this.dimension.height)/this.dimension.width) + '%';
56495
+ } else {
56496
+ this.scaleHeight = true;
56497
+ this.scaleWidth = false; // let w = overlayDimension.width;
56498
+
56499
+ let h = overlayDimension.width * (dimension.height / dimension.width);
56500
+ h = h / overlayDimension.height * 100; //%
56501
+
56502
+ if (!elm.style.height) {
56503
+ elm.style.height = h + '%';
56504
+ elm.style.width = '';
56505
+ }
56506
+
56507
+ inpImageScaleSlider.min = h;
56508
+ let val = -(h - 100) * 0.6;
56509
+ inpImageVertSlider.value = val; //60%
56510
+
56511
+ elm.style.top = val + '%';
56512
+ elm.setAttribute('data-y', val);
56513
+ inpImageHorSlider.value = 0;
56514
+ elm.style.left = '0%';
56515
+ elm.setAttribute('data-x', 0);
56516
+ inpImageScaleSlider.value = h;
56517
+ elm.style.height = h + '%';
56518
+ elm.setAttribute('data-scale', h);
56519
+ elm.style.width = '100%'; //((h*this.dimension.width)/this.dimension.height) + '%';
56520
+ }
56521
+ };
56522
+ }
56523
+
56484
56524
  openImageAdjust2(elm, btn) {
56485
56525
  //Current value
56486
56526
  const imageAdjust2 = this.imageAdjust2;
@@ -56489,11 +56529,11 @@ class ColumnTool {
56489
56529
  const inpImageVertSlider = imageAdjust2.querySelector('.image-vert-slider');
56490
56530
  inpImageScaleSlider.value = 0;
56491
56531
  inpImageHorSlider.value = 0;
56492
- inpImageVertSlider.value = 0;
56532
+ inpImageVertSlider.value = 15;
56493
56533
  const scale = elm.getAttribute('data-scale');
56494
56534
 
56495
56535
  if (scale) {
56496
- inpImageScaleSlider.value = scale;
56536
+ inpImageHorSlider.value = scale;
56497
56537
  }
56498
56538
 
56499
56539
  const posX = elm.getAttribute('data-x');
@@ -56506,7 +56546,167 @@ class ColumnTool {
56506
56546
 
56507
56547
  if (posY) {
56508
56548
  inpImageVertSlider.value = posY;
56509
- } //elementSelected
56549
+ }
56550
+
56551
+ let overlayDimension = {
56552
+ width: elm.parentNode.offsetWidth,
56553
+ height: elm.parentNode.offsetHeight
56554
+ }; // console.log(overlayDimension);
56555
+
56556
+ let dimension, image;
56557
+ image = new Image();
56558
+ image.src = elm.style.backgroundImage.replace(/"/g, '').replace(/url\(|\)$/ig, '');
56559
+
56560
+ image.onload = () => {
56561
+ dimension = {
56562
+ width: image.naturalWidth,
56563
+ height: image.naturalHeight
56564
+ };
56565
+ this.dimension = dimension; // console.log(dimension)
56566
+
56567
+ if (overlayDimension.width / overlayDimension.height <= dimension.width / dimension.height) {
56568
+ this.scaleWidth = true;
56569
+ this.scaleHeight = false; // let h = overlayDimension.height; //px
56570
+
56571
+ let w = overlayDimension.height * (dimension.width / dimension.height);
56572
+ w = w / overlayDimension.width * 100; //%
56573
+
56574
+ if (!elm.style.width) {
56575
+ elm.style.width = w + '%';
56576
+ elm.style.height = '';
56577
+ }
56578
+
56579
+ inpImageScaleSlider.min = w;
56580
+
56581
+ if (!posX) {
56582
+ inpImageHorSlider.value = -(w - 100) * 0.5; //50%
56583
+
56584
+ elm.style.left = -(w - 100) * 0.5 + '%';
56585
+ inpImageVertSlider.value = 0;
56586
+ }
56587
+
56588
+ const scale = elm.getAttribute('data-scale');
56589
+
56590
+ if (!scale) {
56591
+ inpImageScaleSlider.value = w;
56592
+ }
56593
+ } else {
56594
+ this.scaleHeight = true;
56595
+ this.scaleWidth = false; // let w = overlayDimension.width;
56596
+
56597
+ let h = overlayDimension.width * (dimension.height / dimension.width);
56598
+ h = h / overlayDimension.height * 100; //%
56599
+
56600
+ if (!elm.style.height) {
56601
+ elm.style.height = h + '%';
56602
+ elm.style.width = '';
56603
+ }
56604
+
56605
+ inpImageScaleSlider.min = h;
56606
+
56607
+ if (!posY) {
56608
+ inpImageVertSlider.value = -(h - 100) * 0.6; //60%
56609
+
56610
+ elm.style.top = -(h - 100) * 0.6 + '%';
56611
+ inpImageHorSlider.value = 0;
56612
+ }
56613
+
56614
+ const scale = elm.getAttribute('data-scale');
56615
+
56616
+ if (!scale) {
56617
+ inpImageScaleSlider.value = h;
56618
+ }
56619
+ }
56620
+ }; // const imageAdjust2 = this.imageAdjust2;
56621
+ // const inpImageScaleSlider = imageAdjust2.querySelector('.image-scale-slider');
56622
+ // const inpImageHorSlider = imageAdjust2.querySelector('.image-hor-slider');
56623
+ // const inpImageVertSlider = imageAdjust2.querySelector('.image-vert-slider');
56624
+ // inpImageScaleSlider.value = 100;
56625
+ // inpImageHorSlider.value = 0;
56626
+ // inpImageVertSlider.value = 0;
56627
+ // if(elm.style.backgroundSize) {
56628
+ // let val;
56629
+ // let bgSize = elm.style.backgroundSize;
56630
+ // if(isNaN(parseInt(bgSize))) {
56631
+ // val = 100;
56632
+ // } else {
56633
+ // val = parseInt(bgSize);
56634
+ // }
56635
+ // if(bgSize.indexOf('%')!==-1) {
56636
+ // inpImageScaleSlider.value = val;
56637
+ // }
56638
+ // }
56639
+ // if(elm.style.backgroundPositionX) {
56640
+ // let val;
56641
+ // let bgPosX = elm.style.backgroundPositionX;
56642
+ // if(isNaN(parseInt(bgPosX))) {
56643
+ // val = 0;
56644
+ // } else {
56645
+ // val = parseInt(bgPosX);
56646
+ // }
56647
+ // if(bgPosX.indexOf('%')!==-1) {
56648
+ // inpImageHorSlider.value = val;
56649
+ // }
56650
+ // }
56651
+ // if(elm.style.backgroundPositionY) {
56652
+ // let val;
56653
+ // let bgPosY = elm.style.backgroundPositionY;
56654
+ // if(isNaN(parseInt(bgPosY))) {
56655
+ // val = 0;
56656
+ // } else {
56657
+ // val = parseInt(bgPosY);
56658
+ // }
56659
+ // if(bgPosY.indexOf('%')!==-1) {
56660
+ // inpImageVertSlider.value = val;
56661
+ // }
56662
+ // }
56663
+ // let img = elm.querySelector('img');
56664
+ // if(!img) {
56665
+ // let oFitPosX = 0;
56666
+ // let oFitPosY = 0;
56667
+ // if(elm.style.backgroundPositionX) {
56668
+ // let val;
56669
+ // let bgPosX = elm.style.backgroundPositionX;
56670
+ // if(isNaN(parseInt(bgPosX))) {
56671
+ // val = 0;
56672
+ // } else {
56673
+ // val = parseInt(bgPosX);
56674
+ // }
56675
+ // if(bgPosX.indexOf('%')!==-1) {
56676
+ // inpImageHorSlider.value = val;
56677
+ // oFitPosX = val;
56678
+ // }
56679
+ // }
56680
+ // if(elm.style.backgroundPositionY) {
56681
+ // let val;
56682
+ // let bgPosY = elm.style.backgroundPositionY;
56683
+ // if(isNaN(parseInt(bgPosY))) {
56684
+ // val = 0;
56685
+ // } else {
56686
+ // val = parseInt(bgPosY);
56687
+ // }
56688
+ // if(bgPosY.indexOf('%')!==-1) {
56689
+ // inpImageVertSlider.value = val;
56690
+ // oFitPosY = val;
56691
+ // }
56692
+ // }
56693
+ // const src = elm.style.backgroundImage.replace(/"/g,"").replace(/url\(|\)$/ig, "");
56694
+ // elm.innerHTML = '';
56695
+ // img = document.createElement('img');
56696
+ // img.setAttribute('src', src);
56697
+ // elm.appendChild(img);
56698
+ // img.style.opacity = 0.0001;
56699
+ // img.style.width = '100%';
56700
+ // img.style.height = '100%';
56701
+ // img.style.objectFit = 'cover';
56702
+ // img.style.objectPosition = `${oFitPosX}% ${oFitPosY}%`
56703
+ // } else {
56704
+ // let x = img.style.objectPosition.split(' ')[0].replace('%','');
56705
+ // let y = img.style.objectPosition.split(' ')[1].replace('%','');
56706
+ // inpImageHorSlider.value = x;
56707
+ // inpImageVertSlider.value = y;
56708
+ // }
56709
+ //elementSelected
56510
56710
 
56511
56711
 
56512
56712
  this.builder.elementSelected = elm; //Show modal
@@ -70175,7 +70375,18 @@ class ContentBuilder {
70175
70375
  let builderStuff = this.util.builderStuff();
70176
70376
  if (!builderStuff) return; // in case the builder is destroyed
70177
70377
 
70178
- const htmlutil = new HtmlUtil(this);
70378
+ const htmlutil = new HtmlUtil(this); // Reset Zoom
70379
+
70380
+ if (this.opts.page !== '') {
70381
+ const wrapper = document.querySelector(this.opts.page);
70382
+ if (wrapper) wrapper.style.transform = '';
70383
+ } else {
70384
+ const builders = document.querySelectorAll(this.opts.container);
70385
+ builders.forEach(builder => {
70386
+ builder.style.transform = '';
70387
+ });
70388
+ }
70389
+
70179
70390
  const builders = document.querySelectorAll(this.opts.container);
70180
70391
  Array.prototype.forEach.call(builders, builder => {
70181
70392
  builder.innerHTML = htmlutil.readHtml(builder, true);
@@ -70192,17 +70403,7 @@ class ContentBuilder {
70192
70403
  });
70193
70404
  this.moveable.destroy();
70194
70405
  this.builderStuff.parentNode.removeChild(this.builderStuff);
70195
- this.builderStuff = null; // Reset Zoom
70196
-
70197
- if (this.opts.page !== '') {
70198
- const wrapper = document.querySelector(this.opts.page);
70199
- wrapper.style.transform = '';
70200
- } else {
70201
- const builders = document.querySelectorAll(this.opts.container);
70202
- builders.forEach(builder => {
70203
- builder.style.transform = '';
70204
- });
70205
- }
70406
+ this.builderStuff = null;
70206
70407
  }
70207
70408
 
70208
70409
  saveImages(handler, onComplete, onBase64Upload) {