@innovastudio/contentbuilder 1.2.13 → 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.13",
3
+ "version": "1.2.14",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
@@ -54917,37 +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
54924
  <input type="range" min="100" max="500" value="0" class="image-scale-slider is-rangeslider">
54923
54925
  </div>
54924
54926
 
54925
- <div style="display:none;padding-bottom:3px;padding-top: 20px;">${util.out('Scale')} (${util.out('Width')}):</div>
54926
- <div style="display:none;padding-top:4px">
54927
- <input type="range" min="100" max="500" value="100" class="image-container-width-slider is-rangeslider">
54928
- </div>
54929
-
54930
- <div style="display:none;padding-bottom:3px;padding-top: 20px;">${util.out('Scale')} (${util.out('Height')}):</div>
54931
- <div style="display:none;padding-top:4px">
54932
- <input type="range" min="100" max="500" value="100" class="image-container-height-slider is-rangeslider">
54933
- </div>
54934
-
54935
- <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;">
54936
54928
  <span>${util.out('Horizontal')}:</span>
54937
- <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>
54938
54929
  </div>
54939
54930
  <div style="padding-top:4px">
54940
54931
  <input type="range" min="-150" max="150" value="0" class="image-hor-slider is-rangeslider">
54941
54932
  </div>
54942
54933
 
54943
- <div style="padding-bottom:3px;padding-top: 20px;display:flex;justify-content:space-between;align-items:center;">
54934
+ <div style="padding-bottom:3px;padding-top: 20px;display:flex;">
54944
54935
  <span>${util.out('Vertical')}:</span>
54945
- <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>
54946
54936
  </div>
54947
54937
  <div style="padding-top:4px">
54948
54938
  <input type="range" min="-150" max="150" value="0" class="image-vert-slider is-rangeslider">
54949
54939
  </div>
54950
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>
54951
54944
  </div>
54952
54945
 
54953
54946
  </div>
@@ -55367,38 +55360,16 @@ class ColumnTool {
55367
55360
  let val = inpImageScaleSlider2.value;
55368
55361
 
55369
55362
  if (this.scaleWidth) {
55370
- cell.style.width = val + '%';
55371
- cell.style.height = '';
55363
+ cell.style.width = val + '%'; // cell.style.height = '';
55364
+
55365
+ cell.style.height = val * 100 / inpImageScaleSlider2.min + '%';
55372
55366
  } else {
55373
- cell.style.height = val + '%';
55374
- cell.style.width = '';
55375
- }
55376
-
55377
- cell.setAttribute('data-scale', val); // let cell = this.builder.elementSelected;
55378
- // cell.style.backgroundSize = '';
55379
- // //val: 0 - 100
55380
- // let val = inpImageScaleSlider2.value;
55381
- // cell.setAttribute('data-scale', val);
55382
- // // vall => -100-100
55383
- // if(val!==0) {
55384
- // // cell.style.width = 'unset';
55385
- // // cell.style.height = 'unset';
55386
- // cell.style.left = `-${val}vw`;
55387
- // cell.style.right = `-${val}vw`;
55388
- // cell.style.top = `-${val}vh`;
55389
- // cell.style.bottom = `-${val}vh`;
55390
- // } else {
55391
- // // cell.style.width = '';
55392
- // // cell.style.height = '';
55393
- // cell.style.left = '';
55394
- // cell.style.right = '';
55395
- // cell.style.top = '';
55396
- // cell.style.bottom = '';
55397
- // }
55398
- // //val: 100 - 500
55399
- // let val = inpImageScaleSlider2.value;
55400
- // let cell = this.builder.elementSelected; //util.cellSelected();
55401
- // cell.style.backgroundSize = val + '%';
55367
+ cell.style.height = val + '%'; // cell.style.width = '';
55368
+
55369
+ cell.style.width = val * 100 / inpImageScaleSlider2.min + '%';
55370
+ }
55371
+
55372
+ cell.setAttribute('data-scale', val);
55402
55373
  };
55403
55374
 
55404
55375
  inpImageScaleSlider2.onchange = () => {
@@ -55438,31 +55409,12 @@ class ColumnTool {
55438
55409
  };
55439
55410
 
55440
55411
  inpImageHorSlider2.oninput = () => {
55441
- // let cell = this.builder.elementSelected;
55442
- // let normalWidth = (cell.parentNode.offsetWidth/window.innerWidth) * 100; // vw
55443
- // let scaleInc = parseFloat(inpImageScaleSlider2.value);
55444
- // const enlarge = (normalWidth + (2*scaleInc))/normalWidth;
55445
- // //val: -100 - 100
55446
- // let val = parseFloat(inpImageHorSlider2.value);
55447
- // cell.setAttribute('data-x', val);
55448
- // let currentWidth = cell.parentNode.offsetWidth*enlarge;
55449
- // currentWidth = (currentWidth/window.innerWidth) * 100; // vw
55450
- // let currentLeft = (currentWidth-normalWidth)/2; // vw
55451
- // let currentRight = (currentWidth-normalWidth)/2;
55452
- // const left = -currentLeft+val;
55453
- // const right = -currentRight-val;
55454
- // // cell.style.width = 'unset';
55455
- // cell.style.left = `${left}vw`;
55456
- // cell.style.right = `${right}vw`;
55457
55412
  let cell = this.builder.elementSelected; //val: -100 - 100
55458
55413
 
55459
55414
  let val = parseFloat(inpImageHorSlider2.value);
55460
55415
  cell.style.left = `${val}%`;
55461
55416
  cell.style.right = '';
55462
- cell.setAttribute('data-x', val); // //val: 0 - 100
55463
- // let val = inpImageHorSlider2.value;
55464
- // let cell = this.builder.elementSelected; //util.cellSelected();
55465
- // cell.style.backgroundPositionX = val + '%';
55417
+ cell.setAttribute('data-x', val);
55466
55418
  };
55467
55419
 
55468
55420
  inpImageHorSlider2.onchange = () => {
@@ -55502,103 +55454,24 @@ class ColumnTool {
55502
55454
  };
55503
55455
 
55504
55456
  inpImageVertSlider2.oninput = () => {
55505
- // let cell = this.builder.elementSelected;
55506
- // let normalHeight = (cell.parentNode.offsetHeight/window.innerHeight) * 100; // vh
55507
- // let scaleInc = parseFloat(inpImageScaleSlider2.value);
55508
- // const enlarge = (normalHeight + (2*scaleInc))/normalHeight;
55509
- // //val: -100 - 100
55510
- // let val = parseFloat(inpImageVertSlider2.value);
55511
- // cell.setAttribute('data-y', val);
55512
- // let currentHeight = cell.parentNode.offsetHeight*enlarge;
55513
- // currentHeight = (currentHeight/window.innerHeight) * 100; // vh
55514
- // let currentTop = (currentHeight-normalHeight)/2; // vh
55515
- // let currentBottom = (currentHeight-normalHeight)/2;
55516
- // const top = -currentTop+val;
55517
- // const bottom = -currentBottom-val;
55518
- // // cell.style.height = 'unset';
55519
- // cell.style.top = `${top}vh`;
55520
- // cell.style.bottom = `${bottom}vh`;
55521
55457
  let cell = this.builder.elementSelected; //val: -100 - 100
55522
55458
 
55523
55459
  let val = parseFloat(inpImageVertSlider2.value);
55524
55460
  cell.style.top = `${val}%`;
55525
55461
  cell.style.bottom = '';
55526
- cell.setAttribute('data-y', val); // //val: 0 - 100
55527
- // let val = inpImageVertSlider2.value;
55528
- // let cell = this.builder.elementSelected; //util.cellSelected();
55529
- // cell.style.backgroundPositionY = val + '%';
55462
+ cell.setAttribute('data-y', val);
55530
55463
  };
55531
55464
 
55532
55465
  inpImageVertSlider2.onchange = () => {
55533
55466
  //Trigger Change event
55534
55467
  this.builder.opts.onChange();
55535
- }; // Image Container Width
55536
-
55537
-
55538
- const inpImageConWidthSlider = imageAdjust2.querySelector('.image-container-width-slider');
55539
-
55540
- inpImageConWidthSlider.onfocus = () => {
55541
- this.builder.uo.saveForUndo(true);
55542
- };
55543
-
55544
- inpImageConWidthSlider.oninput = () => {
55545
- let cell = this.builder.elementSelected; //val: 100 - 500
55546
-
55547
- let val = parseFloat(inpImageConWidthSlider.value);
55548
- cell.setAttribute('data-con-w', val);
55549
- cell.style.width = `${val}%`;
55550
- };
55551
-
55552
- inpImageConWidthSlider.onchange = () => {
55553
- this.builder.opts.onChange();
55554
- }; // Image Container Height
55555
-
55556
-
55557
- const inpImageConHeightSlider = imageAdjust2.querySelector('.image-container-height-slider');
55558
-
55559
- inpImageConHeightSlider.onfocus = () => {
55560
- this.builder.uo.saveForUndo(true);
55561
- };
55562
-
55563
- inpImageConHeightSlider.oninput = () => {
55564
- let cell = this.builder.elementSelected; //val: 100 - 500
55565
-
55566
- let val = parseFloat(inpImageConHeightSlider.value);
55567
- cell.setAttribute('data-con-h', val);
55568
- cell.style.height = `${val}%`;
55569
- };
55570
-
55571
- inpImageConHeightSlider.onchange = () => {
55572
- this.builder.opts.onChange();
55573
55468
  };
55574
55469
 
55575
- const btnHorReset = imageAdjust2.querySelector('.image-hor-reset');
55576
- btnHorReset.addEventListener('click', () => {
55470
+ const btnImageReset = imageAdjust2.querySelector('.image-reset');
55471
+ btnImageReset.addEventListener('click', () => {
55577
55472
  this.builder.uo.saveForUndo();
55578
55473
  let cell = this.builder.elementSelected;
55579
- inpImageHorSlider2.value = 0; // cell.style.width = '';
55580
-
55581
- cell.style.left = '';
55582
- cell.style.right = '';
55583
- cell.removeAttribute('data-x'); // // fix
55584
- // cell.style.backgroundPositionX = '';
55585
- // inpImageHorSlider2.value = 50;
55586
- //Trigger Change event
55587
-
55588
- this.builder.opts.onChange();
55589
- });
55590
- const btnVertReset = imageAdjust2.querySelector('.image-vert-reset');
55591
- btnVertReset.addEventListener('click', () => {
55592
- this.builder.uo.saveForUndo();
55593
- let cell = this.builder.elementSelected;
55594
- inpImageVertSlider2.value = 0; // cell.style.height = '';
55595
-
55596
- cell.style.top = '';
55597
- cell.style.bottom = '';
55598
- cell.removeAttribute('data-y'); // // fix
55599
- // cell.style.backgroundPositionY = '';
55600
- // inpImageVertSlider2.value = 60;
55601
- //Trigger Change event
55474
+ this.resetImage(cell); //Trigger Change event
55602
55475
 
55603
55476
  this.builder.opts.onChange();
55604
55477
  }); // Row Enlarge (Currently not used)
@@ -56573,6 +56446,81 @@ class ColumnTool {
56573
56446
  if (btn) btn.setAttribute('data-focus', true);
56574
56447
  }
56575
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
+
56576
56524
  openImageAdjust2(elm, btn) {
56577
56525
  //Current value
56578
56526
  const imageAdjust2 = this.imageAdjust2;
@@ -56581,11 +56529,11 @@ class ColumnTool {
56581
56529
  const inpImageVertSlider = imageAdjust2.querySelector('.image-vert-slider');
56582
56530
  inpImageScaleSlider.value = 0;
56583
56531
  inpImageHorSlider.value = 0;
56584
- inpImageVertSlider.value = 0;
56532
+ inpImageVertSlider.value = 15;
56585
56533
  const scale = elm.getAttribute('data-scale');
56586
56534
 
56587
56535
  if (scale) {
56588
- inpImageScaleSlider.value = scale;
56536
+ inpImageHorSlider.value = scale;
56589
56537
  }
56590
56538
 
56591
56539
  const posX = elm.getAttribute('data-x');
@@ -56613,7 +56561,8 @@ class ColumnTool {
56613
56561
  dimension = {
56614
56562
  width: image.naturalWidth,
56615
56563
  height: image.naturalHeight
56616
- }; // console.log(dimension)
56564
+ };
56565
+ this.dimension = dimension; // console.log(dimension)
56617
56566
 
56618
56567
  if (overlayDimension.width / overlayDimension.height <= dimension.width / dimension.height) {
56619
56568
  this.scaleWidth = true;
@@ -56628,6 +56577,19 @@ class ColumnTool {
56628
56577
  }
56629
56578
 
56630
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
+ }
56631
56593
  } else {
56632
56594
  this.scaleHeight = true;
56633
56595
  this.scaleWidth = false; // let w = overlayDimension.width;
@@ -56641,6 +56603,19 @@ class ColumnTool {
56641
56603
  }
56642
56604
 
56643
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
+ }
56644
56619
  }
56645
56620
  }; // const imageAdjust2 = this.imageAdjust2;
56646
56621
  // const inpImageScaleSlider = imageAdjust2.querySelector('.image-scale-slider');