@innovastudio/contentbuilder 1.3.17 → 1.3.19

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.3.17",
4
+ "version": "1.3.19",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "files": [
@@ -1969,6 +1969,8 @@ button:focus-visible {
1969
1969
  text-align: center;
1970
1970
  cursor: pointer;
1971
1971
  box-shadow: none;
1972
+ background: transparent;
1973
+ border: none;
1972
1974
  }
1973
1975
  #_cbhtml .is-modal div.is-modal-footer button,
1974
1976
  .is-ui .is-modal div.is-modal-footer button {
@@ -2562,27 +2564,32 @@ button:focus-visible {
2562
2564
  font-size: 13px;
2563
2565
  line-height: 1.7;
2564
2566
  }
2565
- #_cbhtml .is-modal.imagesource .is-modal-content,
2566
- .is-ui .is-modal.imagesource .is-modal-content {
2567
+ #_cbhtml .is-modal.imagesource .is-modal-content, #_cbhtml .is-modal.mediasource .is-modal-content,
2568
+ .is-ui .is-modal.imagesource .is-modal-content,
2569
+ .is-ui .is-modal.mediasource .is-modal-content {
2567
2570
  padding: 20px;
2568
2571
  }
2569
- #_cbhtml .is-modal.imagesource .image-src,
2570
- .is-ui .is-modal.imagesource .image-src {
2572
+ #_cbhtml .is-modal.imagesource .image-src, #_cbhtml .is-modal.mediasource .image-src,
2573
+ .is-ui .is-modal.imagesource .image-src,
2574
+ .is-ui .is-modal.mediasource .image-src {
2571
2575
  display: flex;
2572
2576
  }
2573
- #_cbhtml .is-modal.imagesource .image-src > button,
2574
- .is-ui .is-modal.imagesource .image-src > button {
2577
+ #_cbhtml .is-modal.imagesource .image-src > button, #_cbhtml .is-modal.mediasource .image-src > button,
2578
+ .is-ui .is-modal.imagesource .image-src > button,
2579
+ .is-ui .is-modal.mediasource .image-src > button {
2575
2580
  background: transparent !important;
2576
2581
  width: 50px;
2577
2582
  height: 43px;
2578
2583
  }
2579
- #_cbhtml .is-modal.imagesource .input-select,
2580
- .is-ui .is-modal.imagesource .input-select {
2584
+ #_cbhtml .is-modal.imagesource .input-select, #_cbhtml .is-modal.mediasource .input-select,
2585
+ .is-ui .is-modal.imagesource .input-select,
2586
+ .is-ui .is-modal.mediasource .input-select {
2581
2587
  width: 50px;
2582
2588
  height: 43px;
2583
2589
  }
2584
- #_cbhtml .is-modal.imagesource .input-upload,
2585
- .is-ui .is-modal.imagesource .input-upload {
2590
+ #_cbhtml .is-modal.imagesource .input-upload, #_cbhtml .is-modal.mediasource .input-upload,
2591
+ .is-ui .is-modal.imagesource .input-upload,
2592
+ .is-ui .is-modal.mediasource .input-upload {
2586
2593
  width: 50px;
2587
2594
  height: 43px;
2588
2595
  }
@@ -5743,7 +5743,9 @@ class Util {
5743
5743
 
5744
5744
  repositionColumnTool(transition) {
5745
5745
  let columnTool = this.builder.colTool.columnTool;
5746
+ if (!columnTool) return;
5746
5747
  let col = this.builder.activeCol;
5748
+ if (!col) return;
5747
5749
 
5748
5750
  if (transition) {
5749
5751
  columnTool.style.transition = 'all 100ms ease';
@@ -73624,6 +73626,166 @@ class ContentStuff {
73624
73626
 
73625
73627
  }
73626
73628
 
73629
+ class MediaPicker {
73630
+ constructor(builder) {
73631
+ this.builder = builder;
73632
+ const util = this.builder.util;
73633
+ this.util = util;
73634
+ const builderStuff = this.builder.builderStuff;
73635
+ const dom = this.builder.dom;
73636
+ this.dom = dom;
73637
+ this.id = this.builder.util.makeId();
73638
+ const html = `
73639
+ <div class="is-modal mediasource" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true">
73640
+ <div class="is-modal-content" style="max-width:550px;">
73641
+
73642
+ <label for="inpMediaSource" style="display:block">${util.out('Source')}:</label>
73643
+ <div class="image-src">
73644
+ <input id="inpMediaSource" class="input-src" type="text">
73645
+ <button title="${util.out('Select')}" class="input-select" style="flex:none;"><svg class="is-icon-flex"><use xlink:href="#ion-more"></use></svg></button>
73646
+ <div class="input-upload" style="position: relative; flex: 0 0 auto;box-shadow: rgba(0, 0, 0, 0.32) 0px 3px 6px -6px;">
73647
+ <form class="form-upload-larger" target="frameTarget${this.id}" method="post" action="${this.builder.opts.onLargerImageUpload}" enctype="multipart/form-data" style="position:absolute;display:flex;justify-content: center;align-items: center;top:0;left:0;width:100%;height:100%;">
73648
+ <input name="hidRefId" class="input-ref-id" type="hidden" value="">
73649
+ <svg class="is-icon-flex" style="width:18px;height:18px;"><use xlink:href="#ion-ios-cloud-upload-outline"></use></svg>
73650
+ <input title="${util.out('Select')}" name="fileImage" class="input-file-select" type="file" accept="image/*,video/mp4" style="position:absolute;top:-30px;left:0;width:100%;height:80px;opacity: 0;cursor: pointer;">
73651
+ </form>
73652
+ <iframe tabIndex="0" id="frameTarget${this.id}" name="frameTarget${this.id}" src="about:blank" style="width:1px;height:1px;position:absolute;top:0;right:-100000px"></iframe>
73653
+ </div>
73654
+ </div>
73655
+
73656
+ <div style="text-align:right;margin-top:20px;">
73657
+ <button title="${util.out('Cancel')}" class="input-cancel classic-secondary">${util.out('Cancel')}</button>
73658
+ <button title="${util.out('Ok')}" class="input-ok classic-primary">${util.out('Ok')}</button>
73659
+ </div>
73660
+
73661
+ </div>
73662
+ </div>
73663
+ `;
73664
+ dom.appendHtml(builderStuff, html);
73665
+ const modalMediaSelect = document.querySelector('.mediasource');
73666
+ this.modalMediaSelect = modalMediaSelect;
73667
+
73668
+ if (this.builder.opts.largerImageHandler === '' && !this.builder.opts.onLargerImageUpload) {
73669
+ modalMediaSelect.querySelector('.input-upload').style.display = 'none';
73670
+ }
73671
+
73672
+ if (!this.builder.opts.onImageSelectClick && this.builder.opts.imageselect === '') {
73673
+ modalMediaSelect.querySelector('.input-select').style.display = 'none';
73674
+ }
73675
+
73676
+ if (this.builder.opts.onImageSelectClick || this.builder.opts.imageselect || this.builder.opts.onFileSelectClick || this.builder.opts.fileselect) {
73677
+ const inpSrc = modalMediaSelect.querySelector('.input-src');
73678
+ const elm = modalMediaSelect.querySelector('.input-select');
73679
+ if (elm) dom.addEventListener(elm, 'click', () => {
73680
+ if (this.builder.opts.onFileSelectClick) {
73681
+ this.builder.opts.onFileSelectClick({
73682
+ targetInput: inpSrc,
73683
+ theTrigger: elm
73684
+ });
73685
+ } else if (this.builder.opts.onImageSelectClick) {
73686
+ this.builder.opts.onImageSelectClick({
73687
+ targetInput: inpSrc,
73688
+ theTrigger: elm
73689
+ });
73690
+ } else if (this.builder.opts.fileselect) {
73691
+ let modalFileSelect = builderStuff.querySelector('.is-modal.fileselect');
73692
+ let iframe = modalFileSelect.querySelector('iframe');
73693
+
73694
+ if (this.builder.opts.assetRefresh) {
73695
+ iframe.src = this.builder.opts.fileselect;
73696
+ this.builder.opts.assetRefresh = false;
73697
+ }
73698
+
73699
+ if (iframe.src === 'about:blank') {
73700
+ iframe.src = this.builder.opts.fileselect;
73701
+ }
73702
+
73703
+ util.showModal(modalFileSelect, false, () => {
73704
+ elm.removeAttribute('data-focus');
73705
+ elm.focus();
73706
+ });
73707
+ elm.setAttribute('data-focus', true);
73708
+ this.builder.targetInput = inpSrc;
73709
+ this.builder.targetCallback = null;
73710
+ this.builder.targetAssetType = 'media';
73711
+ } else if (this.builder.opts.imageselect) {
73712
+ let modalImageSelect = builderStuff.querySelector('.is-modal.imageselect');
73713
+ let iframe = modalImageSelect.querySelector('iframe');
73714
+
73715
+ if (this.builder.opts.assetRefresh) {
73716
+ iframe.src = this.builder.opts.imageselect;
73717
+ this.builder.opts.assetRefresh = false;
73718
+ }
73719
+
73720
+ if (iframe.src === 'about:blank') {
73721
+ iframe.src = this.builder.opts.imageselect;
73722
+ }
73723
+
73724
+ util.showModal(modalImageSelect, false, () => {
73725
+ elm.removeAttribute('data-focus');
73726
+ elm.focus();
73727
+ });
73728
+ elm.setAttribute('data-focus', true);
73729
+ this.builder.targetInput = inpSrc;
73730
+ this.builder.targetCallback = null;
73731
+ this.builder.targetAssetType = 'media';
73732
+ }
73733
+ });
73734
+ }
73735
+
73736
+ let inputFileSelect = modalMediaSelect.querySelector('.input-file-select');
73737
+ dom.addEventListener(inputFileSelect, 'change', e => {
73738
+ let element = inputFileSelect;
73739
+
73740
+ while (element.nodeName.toLowerCase() !== 'form') {
73741
+ element = element.parentNode;
73742
+ }
73743
+
73744
+ let frmUpload = element;
73745
+ dom.addClass(frmUpload, 'please-wait');
73746
+ modalMediaSelect.querySelector('.input-ref-id').value = this.builder.opts.customval;
73747
+
73748
+ if (this.builder.opts.onLargerImageUpload) {
73749
+ this.builder.opts.onLargerImageUpload(e);
73750
+ } else {
73751
+ frmUpload.submit();
73752
+ }
73753
+
73754
+ inputFileSelect.value = ''; // Clear Input
73755
+ });
73756
+ const btnImageOk = modalMediaSelect.querySelector('.input-ok');
73757
+ dom.addEventListener(btnImageOk, 'click', () => {
73758
+ const inpSrc = modalMediaSelect.querySelector('.input-src');
73759
+ const url = inpSrc.value;
73760
+ if (this.builder.mediaSelectedCallback) this.builder.mediaSelectedCallback(url);
73761
+ this.builder.hideModal(modalMediaSelect);
73762
+ });
73763
+ const btnImageCancel = modalMediaSelect.querySelector('.input-cancel');
73764
+ dom.addEventListener(btnImageCancel, 'click', () => {
73765
+ this.builder.hideModal(modalMediaSelect);
73766
+ });
73767
+ }
73768
+
73769
+ openMediaPicker(currentUrl, callback, btn) {
73770
+ //Current value
73771
+ const modalMediaSelect = this.modalMediaSelect;
73772
+ const inpSrc = modalMediaSelect.querySelector('.input-src');
73773
+ inpSrc.value = currentUrl; //mediaSelectedCallback
73774
+
73775
+ this.builder.mediaSelectedCallback = callback; //Show modal
73776
+
73777
+ modalMediaSelect.style.zIndex = '10005';
73778
+ this.util.showModal(modalMediaSelect, false, () => {
73779
+ if (btn) {
73780
+ btn.removeAttribute('data-focus');
73781
+ btn.focus();
73782
+ }
73783
+ });
73784
+ if (btn) btn.setAttribute('data-focus', true);
73785
+ }
73786
+
73787
+ }
73788
+
73627
73789
  class ContentBuilder {
73628
73790
  constructor(opts = {}) {
73629
73791
  let defaults = {
@@ -74370,7 +74532,8 @@ class ContentBuilder {
74370
74532
  }
74371
74533
 
74372
74534
  this.colTool = new ColumnTool(this); // Render Column Tool
74373
- // Extend the onChange function
74535
+
74536
+ this.mediaPicker = new MediaPicker(this); // Extend the onChange function
74374
74537
 
74375
74538
  var oldget = this.opts.onChange;
74376
74539
 
@@ -75264,6 +75427,10 @@ class ContentBuilder {
75264
75427
  this.opts.assetRefresh = true; // After file upload, make open asset refreshed
75265
75428
  }
75266
75429
 
75430
+ openMediaPicker(currentUrl, callback, btn) {
75431
+ this.mediaPicker.openMediaPicker(currentUrl, callback, btn);
75432
+ }
75433
+
75267
75434
  openImagePicker(currentUrl, callback, btn) {
75268
75435
  this.colTool.openImagePicker(currentUrl, callback, btn);
75269
75436
  }