@innovastudio/contentbox 1.0.21 → 1.0.25

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.
@@ -363,12 +363,23 @@ class SideBar {
363
363
  sideIndex++;
364
364
  });
365
365
  html += '</div>';
366
- html += '' + '<div id="divSidebarSections" class="is-sidebar-content" style="-webkit-transition-duration:0.2s;transition-duration:0.2s;">' + '<div>' + '<iframe id="ifrIdeasPanel" src="about:blank" style="width:100%;height:100%;box-sizing:border-box;border:none;">' + '</iframe>' + '</div>' + '</div>' + '<div id="divSidebarSnippets" class="is-sidebar-content scroll-darker"" style="max-width:275px;border-left: transparent 50px solid;box-sizing: border-box;">' + '' + '</div>' + '<div id="divSidebarSource" class="is-sidebar-content" style="-webkit-transition-duration:0.2s;transition-duration:0.2s;">' + '<div>' + '<div style="position:absolute;width:240px;height:35px;right:10px;top:5px;z-index:1;display:flex;">' + '<button title="' + out('Cancel') + '" id="btnViewHtmlCancel" style="height:38px" class="classic-secondary"> ' + out('Cancel') + ' </button>' + '<button title="' + out('Ok') + '" id="btnViewHtmlOk" style="height:38px" class="classic-primary"> ' + out('Ok') + ' </button>' + '</div>' + '<div style="height:100%;box-sizing:border-box;border-top:#f3f3f3 50px solid;position:relative">' + '<textarea id="inpViewHtml" style="width:100%;height:100%;resize: none;"></textarea>' + '<button title="' + out('Enlarge') + '" class="edit-html-larger" style="width:40px;height:40px;position:absolute;right:20px;top:5px;background:#fff;padding: 0;"><svg class="is-icon-flex" style="width:22px;height:22px;fill:rgb(170, 170, 170);"><use xlink:href="#ion-arrow-expand"></use></svg></button>' + '</div>' + '</div>' + '</div>' + '<div id="divSidebarTypography" class="is-sidebar-content" style="-webkit-transition-duration:0.2s;transition-duration:0.2s;">' + '<div class="scroll-darker">' + '<div id="divSelector" style="position:fixed;top:0;right:0;width:100%;z-index:2;padding: 0 0 0 50px;box-sizing: border-box;"></div>' + '<div id="divStyles"></div>' + '</div>' + '</div>' + '<div id="divCustomSidebarArea1" class="is-sidebar-content" style="max-width:500px;">' + '<div style="padding:0 0 0 50px;box-sizing:border-box;">' + '<iframe id="ifrCustomSidebarArea1" src="about:blank" style="width:100%;height:100%;box-sizing:border-box;border:none;">' + '</iframe>' + '</div>' + '</div>' + '<div id="divCustomSidebarArea2" class="is-sidebar-content" style="max-width:500px;">' + '<div style="padding:0 0 0 50px;box-sizing:border-box;">' + '<iframe id="ifrCustomSidebarArea2" src="about:blank" style="width:100%;height:100%;box-sizing:border-box;border:none;">' + '</iframe>' + '</div>' + '</div>';
366
+ html += '' + '<div id="divSidebarSections" class="is-sidebar-content" style="-webkit-transition-duration:0.2s;transition-duration:0.2s;">' + '<div>' + '<iframe id="ifrIdeasPanel" src="about:blank" style="width:100%;height:100%;box-sizing:border-box;border:none;">' + '</iframe>' + '</div>' + '</div>' + '<div id="divSidebarSnippets" class="is-sidebar-content scroll-darker"" style="max-width:275px;border-left: transparent 50px solid;box-sizing: border-box;">' + '' + '</div>' + '<div id="divSidebarSource" class="is-sidebar-content" style="-webkit-transition-duration:0.2s;transition-duration:0.2s;">' + '<div>' + '<div style="position:absolute;width:240px;height:35px;right:10px;top:5px;z-index:1;display:flex;">' + '<button title="' + out('Cancel') + '" id="btnViewHtmlCancel" style="height:38px" class="classic-secondary"> ' + out('Cancel') + ' </button>' + '<button title="' + out('Ok') + '" id="btnViewHtmlOk" style="height:38px" class="classic-primary"> ' + out('Ok') + ' </button>' + '</div>' + '<div style="height:100%;box-sizing:border-box;border-top:#f3f3f3 50px solid;position:relative">' + '<textarea id="inpViewHtml" style="width:100%;height:100%;resize: none;"></textarea>' + '<button title="' + out('Enlarge') + '" class="edit-html-larger" style="width:40px;height:40px;position:absolute;right:20px;top:5px;background:#fff;padding: 0;"><svg class="is-icon-flex" style="width:22px;height:22px;fill:rgb(170, 170, 170);"><use xlink:href="#ion-arrow-expand"></use></svg></button>' + '</div>' + '</div>' + '</div>' + '<div id="divSidebarTypography" class="is-sidebar-content" style="-webkit-transition-duration:0.2s;transition-duration:0.2s;">' + '<div class="scroll-darker">' + '<div style="padding: 15px 0 0 20px">' + '<div class="is-sidebar-title" style="margin-bottom:12px;">' + out('Typography Styles') + '</div>' + '<div>' + out('Apply to') + ':</div>' + '<div style="display:flex;justify-content:space-between;align-items: center;">' + '<div class="typo-target-default" style="display:flex">' + '<label><input type="radio" name="typoTarget" value="page"> <span>' + out('Page') + '</span></label>' + '<label><input type="radio" name="typoTarget" value="section" checked> <span>' + out('Section') + '</span></label>' + '</div>' + '<div class="typo-target-box" style="display: flex;">' + '<span>' + out('Active Box') + '</span>' + '</div>' + '<button title="' + out('Clear') + '" id="btnTypoClear"><svg class="is-icon-flex" style="width:11px;height:11px;"><use xlink:href="#icon-clean"></use></svg></button>' + '</div>' + '</div>' + '<div id="divSelector"></div>' + '<div id="divStyles"></div>' + '</div>' + '</div>' + '<div id="divCustomSidebarArea1" class="is-sidebar-content" style="max-width:500px;">' + '<div style="padding:0 0 0 50px;box-sizing:border-box;">' + '<iframe id="ifrCustomSidebarArea1" src="about:blank" style="width:100%;height:100%;box-sizing:border-box;border:none;">' + '</iframe>' + '</div>' + '</div>' + '<div id="divCustomSidebarArea2" class="is-sidebar-content" style="max-width:500px;">' + '<div style="padding:0 0 0 50px;box-sizing:border-box;">' + '<iframe id="ifrCustomSidebarArea2" src="about:blank" style="width:100%;height:100%;box-sizing:border-box;border:none;">' + '</iframe>' + '</div>' + '</div>';
367
367
  } else {
368
368
  html = '<div id="divSections" style="display:none"></div>' + '<div class="is-modal addsection">' + '<div style="max-width: 900px;">' + '<div id="divSectionList" class="is-section-list"></div>' + '</div>' + '</div>';
369
369
  }
370
+ /*
371
+ html += '<div class="is-modal applytypography">' +
372
+ '<div style="max-width: 400px;text-align:center;">' +
373
+ '<p>' + out('This page has one or more sections that have their own typography style.') + '</p>' +
374
+ '<label><input name="rdoApplyTypoStyle" type="radio" value="1">' + out('Replace all sections\' typography style.') + '</label><br>' +
375
+ '<label><input name="rdoApplyTypoStyle" type="radio" value="0">' + out('Keep sections\' specific typography style.') + '</label>' +
376
+ '<p><i>' + out('To apply typography style on a specific section, goto \'Content Style\' tab in Box Settings') + '</i></p>' +
377
+ '<button class="input-ok classic">' + out('Ok') + '</button>' +
378
+ '</div>' +
379
+ '</div>';
380
+ */
381
+
370
382
 
371
- html += '<div class="is-modal applytypography">' + '<div style="max-width: 400px;text-align:center;">' + '<p>' + out('This page has one or more sections that have their own typography style.') + '</p>' + '<label><input name="rdoApplyTypoStyle" type="radio" value="1">' + out('Replace all sections\' typography style.') + '</label><br>' + '<label><input name="rdoApplyTypoStyle" type="radio" value="0">' + out('Keep sections\' specific typography style.') + '</label>' + '<p><i>' + out('To apply typography style on a specific section, goto \'Content Style\' tab in Box Settings') + '</i></p>' + '<button class="input-ok classic">' + out('Ok') + '</button>' + '</div>' + '</div>';
372
383
  dom$I.appendHtml(builderStuff, html);
373
384
 
374
385
  if (this.builder.useSidebar) {
@@ -400,7 +411,8 @@ class SideBar {
400
411
  let panelId = btn.getAttribute('data-content');
401
412
 
402
413
  if (panelId) {
403
- if (panelId === 'divSidebarSections' || panelId === 'divSidebarTypography') {
414
+ if (panelId === 'divSidebarSections') {
415
+ // || panelId==='divSidebarTypography'
404
416
  const overlayHtml = '<div class="is-sidebar-overlay" style="position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(255,255,255,0.000001);z-index: 1000;"></div>';
405
417
  dom$I.appendHtml(builderStuff, overlayHtml);
406
418
  }
@@ -443,6 +455,8 @@ class SideBar {
443
455
 
444
456
  if (cmd == 'typography') {
445
457
  btn.setAttribute('data-applyto', 'page');
458
+ builderStuff.querySelector('.typo-target-default').style.display = 'flex';
459
+ builderStuff.querySelector('.typo-target-box').style.display = 'none';
446
460
  this.viewTypography();
447
461
  }
448
462
  }
@@ -537,63 +551,61 @@ class SideBar {
537
551
  textarea.setAttribute('data-source-ok', '#btnViewHtmlOk');
538
552
  textarea.setAttribute('data-source-cancel', '#btnViewHtmlCancel');
539
553
  this.builder.editor.viewHtmlLarger();
554
+ });
555
+ let btnTypoClear = document.querySelector('#btnTypoClear');
556
+ btnTypoClear.addEventListener('click', () => {
557
+ this.boxTypography('', '', '');
540
558
  }); // Apply Typography on Page
541
559
 
560
+ /*
542
561
  let modalTypography = builderStuff.querySelector('.is-modal.applytypography');
543
562
  const btnOk = modalTypography.querySelector('.input-ok');
544
- btnOk.addEventListener('click', () => {
545
- const contentStylePath = this.builder.settings.contentStylePath;
546
- let val = modalTypography.querySelector('input[name="rdoApplyTypoStyle"]:checked').value;
547
-
548
- if (val === '1') {
549
- // Replace all sections' style
563
+ btnOk.addEventListener('click', ()=>{
564
+ const contentStylePath = this.builder.settings.contentStylePath;
565
+ let val = modalTypography.querySelector('input[name="rdoApplyTypoStyle"]:checked').value;
566
+ if (val === '1') {
567
+ // Replace all sections' style
568
+ let links = document.getElementsByTagName('link');
569
+ for (let i = 0; i < links.length; i++) {
570
+ if (links[i].getAttribute('data-name') === 'contentstyle') {
571
+ let classname = links[i].getAttribute('data-class');
572
+ //check if classname used in content
573
+ if (this.builder.wrapperEl.querySelector('.' + classname)) {
574
+ let elms = this.builder.wrapperEl.querySelectorAll('.' + classname);
575
+ elms.forEach((elm)=>{
576
+ dom.removeClass(elm, classname);
577
+ });
578
+ links[i].setAttribute('data-rel', '_del');
579
+ }
580
+ }
581
+ }
582
+ let dels = document.querySelectorAll('[data-rel="_del"]');
583
+ dels.forEach((item)=>{
584
+ item.parentNode.removeChild(item);
585
+ });
586
+ }
587
+ //Cleanup (remove previous css that has prefix 'basetype-')
550
588
  let links = document.getElementsByTagName('link');
551
-
552
589
  for (let i = 0; i < links.length; i++) {
553
- if (links[i].getAttribute('data-name') === 'contentstyle') {
554
- let classname = links[i].getAttribute('data-class'); //check if classname used in content
555
-
556
- if (this.builder.wrapperEl.querySelector('.' + classname)) {
557
- let elms = this.builder.wrapperEl.querySelectorAll('.' + classname);
558
- elms.forEach(elm => {
559
- dom$I.removeClass(elm, classname);
560
- });
561
- links[i].setAttribute('data-rel', '_del');
590
+ let src = links[i].href.toLowerCase();
591
+ if (src.indexOf('basetype-') != -1) {
592
+ links[i].setAttribute('data-rel', '_del');
562
593
  }
563
- }
564
594
  }
565
-
566
595
  let dels = document.querySelectorAll('[data-rel="_del"]');
567
- dels.forEach(item => {
568
- item.parentNode.removeChild(item);
596
+ dels.forEach((item)=>{
597
+ item.parentNode.removeChild(item);
569
598
  });
570
- } //Cleanup (remove previous css that has prefix 'basetype-')
571
-
572
-
573
- let links = document.getElementsByTagName('link');
574
-
575
- for (let i = 0; i < links.length; i++) {
576
- let src = links[i].href.toLowerCase();
577
-
578
- if (src.indexOf('basetype-') != -1) {
579
- links[i].setAttribute('data-rel', '_del');
599
+ //Add new page css
600
+ if (this.pageCss != '') {
601
+ dom.appendHtml(document.head, '<link href="' + contentStylePath + this.pageCss + '" rel="stylesheet">');
580
602
  }
581
- }
582
-
583
- let dels = document.querySelectorAll('[data-rel="_del"]');
584
- dels.forEach(item => {
585
- item.parentNode.removeChild(item);
586
- }); //Add new page css
587
-
588
- if (this.pageCss != '') {
589
- dom$I.appendHtml(document.head, '<link href="' + contentStylePath + this.pageCss + '" rel="stylesheet">');
590
- } // this.builder.hideModal($modal);
591
-
592
-
593
- this.builder.hideModal(modalTypography); //Trigger Change event
594
-
595
- this.builder.settings.onChange();
603
+ // this.builder.hideModal($modal);
604
+ this.builder.hideModal(modalTypography);
605
+ //Trigger Change event
606
+ this.builder.settings.onChange();
596
607
  });
608
+ */
597
609
  }
598
610
  } //constructor
599
611
 
@@ -728,9 +740,9 @@ class SideBar {
728
740
  html += '<div data-css="' + styles[i].css + '" data-sectioncss="' + styles[i].sectioncss + '" data-classname="' + styles[i].classname + '">' + '<div>[' + (i + 1) + '] ' + styles[i].caption + '</div>' + '<img src="' + contentStylePath + styles[i].img + '" /><span class="is-overlay"></span></div></div>';
729
741
  }
730
742
  }
731
- }
743
+ } // html += '<div data-css="" data-sectioncss="" data-classname=""><img src="' + contentStylePath + '_clear.jpg" /><span class="is-overlay"></span></div></div>';
744
+
732
745
 
733
- html += '<div data-css="" data-sectioncss="" data-classname=""><img src="' + contentStylePath + '_clear.jpg" /><span class="is-overlay"></span></div></div>';
734
746
  let selection = document.querySelector('#divStyles');
735
747
  selection.innerHTML = html;
736
748
  let elms = elementChildren(selection);
@@ -765,21 +777,31 @@ class SideBar {
765
777
  const contentStylePath = this.builder.settings.contentStylePath; //Check apply to what
766
778
 
767
779
  let applyto = builderStuff.querySelector('.is-sidebar > button[data-command="typography"]').getAttribute('data-applyto');
780
+ let mode = document.querySelector('input[name="typoTarget"]:checked').value;
768
781
 
769
- if (applyto === 'box') {
770
- let activeBox = this.builder.activeBox;
771
-
772
- if (activeBox) {
773
- let classList = activeBox.getAttribute('class').split(/\s+/);
782
+ if (applyto !== 'box') {
783
+ if (mode === 'section') {
784
+ let activeSection = this.builder.activeSection;
785
+ let classList = activeSection.getAttribute('class').split(/\s+/);
774
786
  classList.forEach(item => {
775
787
  if (item.indexOf('type-') != -1) {
776
788
  //Remove previous class that has prefix 'type-'
777
- dom$I.removeClass(activeBox, item);
789
+ dom$I.removeClass(activeSection, item);
778
790
  }
791
+ });
792
+ let boxes = activeSection.querySelectorAll('.is-box, .is-box-centered');
793
+ boxes.forEach(box => {
794
+ let classList = box.getAttribute('class').split(/\s+/);
795
+ classList.forEach(item => {
796
+ if (item.indexOf('type-') != -1) {
797
+ //Remove previous class that has prefix 'type-'
798
+ dom$I.removeClass(box, item);
799
+ }
800
+ });
779
801
  }); //Add new class
780
802
 
781
803
  if (className !== '') {
782
- dom$I.addClass(activeBox, className); //Add css
804
+ dom$I.addClass(activeSection, className); //Add css
783
805
 
784
806
  let exist = false;
785
807
  let links = document.getElementsByTagName('link');
@@ -809,20 +831,30 @@ class SideBar {
809
831
  dels.forEach(item => {
810
832
  item.parentNode.removeChild(item);
811
833
  });
812
- }
813
- } else {
814
- let bSectionStyleExists = false;
815
- let links = document.getElementsByTagName('link');
834
+ } else if (mode === 'page') {
835
+ // Replace all sections' style
836
+ let links = document.getElementsByTagName('link');
816
837
 
817
- for (let i = 0; i < links.length; i++) {
818
- if (links[i].getAttribute('data-name') === 'contentstyle') {
819
- bSectionStyleExists = true;
838
+ for (let i = 0; i < links.length; i++) {
839
+ if (links[i].getAttribute('data-name') === 'contentstyle') {
840
+ let classname = links[i].getAttribute('data-class'); //check if classname used in content
841
+
842
+ if (this.builder.wrapperEl.querySelector('.' + classname)) {
843
+ let elms = this.builder.wrapperEl.querySelectorAll('.' + classname);
844
+ elms.forEach(elm => {
845
+ dom$I.removeClass(elm, classname);
846
+ });
847
+ links[i].setAttribute('data-rel', '_del');
848
+ }
849
+ }
820
850
  }
821
- }
822
851
 
823
- if (!bSectionStyleExists) {
824
- //Cleanup (remove previous css that has prefix 'basetype-')
825
- let links = document.getElementsByTagName('link');
852
+ let dels = document.querySelectorAll('[data-rel="_del"]');
853
+ dels.forEach(item => {
854
+ item.parentNode.removeChild(item);
855
+ }); //Cleanup (remove previous css that has prefix 'basetype-')
856
+
857
+ links = document.getElementsByTagName('link');
826
858
 
827
859
  for (let i = 0; i < links.length; i++) {
828
860
  let src = links[i].href.toLowerCase();
@@ -832,21 +864,103 @@ class SideBar {
832
864
  }
833
865
  }
834
866
 
835
- let dels = document.querySelectorAll('[data-rel="_del"]');
867
+ dels = document.querySelectorAll('[data-rel="_del"]');
836
868
  dels.forEach(item => {
837
869
  item.parentNode.removeChild(item);
838
870
  }); //Add new page css
839
871
 
840
- if (pageCss != '') {
872
+ if (this.pageCss != '') {
841
873
  dom$I.appendHtml(document.head, '<link href="' + contentStylePath + pageCss + '" rel="stylesheet">');
842
874
  }
843
- } else {
844
- // this.className = className;
845
- // this.contentCss = contentCss;
846
- this.pageCss = pageCss;
847
- let modal = builderStuff.querySelector('.is-modal.applytypography');
848
- this.builder.showModal(modal);
849
- builderStuff.querySelectorAll('input[name="rdoApplyTypoStyle"]')[1].checked = true;
875
+ } else if (mode === 'container') {
876
+ let builderActive = document.querySelector('.builder-active');
877
+ if (!builderActive) return;
878
+ let box = dom$I.parentsHasClass(builderActive, 'is-box');
879
+ let classList = box.getAttribute('class').split(/\s+/);
880
+ classList.forEach(item => {
881
+ if (item.indexOf('type-') != -1) {
882
+ //Remove previous class that has prefix 'type-'
883
+ dom$I.removeClass(box, item);
884
+ }
885
+ }); //Add new class
886
+
887
+ if (className !== '') {
888
+ dom$I.addClass(box, className); //Add css
889
+
890
+ let exist = false;
891
+ let links = document.getElementsByTagName('link');
892
+
893
+ for (let i = 0; i < links.length; i++) {
894
+ let src = links[i].href.toLowerCase();
895
+ if (src.indexOf(contentCss.toLowerCase()) != -1) exist = true;
896
+ }
897
+
898
+ if (!exist) dom$I.appendHtml(document.head, '<link data-name="contentstyle" data-class="' + className + '" href="' + contentStylePath + contentCss + '" rel="stylesheet">');
899
+ } //Cleanup unused
900
+
901
+
902
+ let links = document.getElementsByTagName('link');
903
+
904
+ for (let i = 0; i < links.length; i++) {
905
+ if (links[i].getAttribute('data-name') === 'contentstyle') {
906
+ let classname = links[i].getAttribute('data-class'); //check if classname used in content
907
+
908
+ if (!this.builder.wrapperEl.querySelector('.' + classname)) {
909
+ links[i].setAttribute('data-rel', '_del');
910
+ }
911
+ }
912
+ }
913
+
914
+ let dels = document.querySelectorAll('[data-rel="_del"]');
915
+ dels.forEach(item => {
916
+ item.parentNode.removeChild(item);
917
+ });
918
+ }
919
+ }
920
+
921
+ if (applyto === 'box') {
922
+ let activeBox = this.builder.activeBox;
923
+
924
+ if (activeBox) {
925
+ let classList = activeBox.getAttribute('class').split(/\s+/);
926
+ classList.forEach(item => {
927
+ if (item.indexOf('type-') != -1) {
928
+ //Remove previous class that has prefix 'type-'
929
+ dom$I.removeClass(activeBox, item);
930
+ }
931
+ }); //Add new class
932
+
933
+ if (className !== '') {
934
+ dom$I.addClass(activeBox, className); //Add css
935
+
936
+ let exist = false;
937
+ let links = document.getElementsByTagName('link');
938
+
939
+ for (let i = 0; i < links.length; i++) {
940
+ let src = links[i].href.toLowerCase();
941
+ if (src.indexOf(contentCss.toLowerCase()) != -1) exist = true;
942
+ }
943
+
944
+ if (!exist) dom$I.appendHtml(document.head, '<link data-name="contentstyle" data-class="' + className + '" href="' + contentStylePath + contentCss + '" rel="stylesheet">');
945
+ } //Cleanup unused
946
+
947
+
948
+ let links = document.getElementsByTagName('link');
949
+
950
+ for (let i = 0; i < links.length; i++) {
951
+ if (links[i].getAttribute('data-name') === 'contentstyle') {
952
+ let classname = links[i].getAttribute('data-class'); //check if classname used in content
953
+
954
+ if (!this.builder.wrapperEl.querySelector('.' + classname)) {
955
+ links[i].setAttribute('data-rel', '_del');
956
+ }
957
+ }
958
+ }
959
+
960
+ let dels = document.querySelectorAll('[data-rel="_del"]');
961
+ dels.forEach(item => {
962
+ item.parentNode.removeChild(item);
963
+ });
850
964
  }
851
965
  } //Trigger Change event
852
966
 
@@ -1771,7 +1885,10 @@ class EditSection {
1771
1885
  this.builder = builder;
1772
1886
  const builderStuff = this.builder.builderStuff;
1773
1887
  this.builderStuff = builderStuff;
1774
- let html = '<div class="is-modal delsectionconfirm">' + '<div style="max-width: 400px;">' + '<p style="margin-bottom: 25px;text-align:center;">' + out('Are you sure you want to delete this section?') + '</p>' + '<button title="' + out('Delete') + '" class="input-ok classic">' + out('Delete') + '</button>' + '</div>' + '</div>' + '' + '<div class="is-modal editsection">' + '<div class="is-modal-content" style="max-width: 270px;padding:0;">' + '<div class="is-modal-bar is-draggable">' + out('Section Settings') + '</div>' + '<div style="padding:30px 20px 20px;">' + '<div style="display:flex;flex-direction:column;">' + '<div style="padding-top:20px;padding-bottom: 3px;">' + out('Move Section') + ':</div>' + '<div style="display:flex">' + '<button title="' + out('Move Up') + '" class="cmd-section-up" style="">&#8593;</button>' + '<button title="' + out('Move Down') + '" class="cmd-section-down" style="border-left:none;">&#8595;</button>' + '<button title="' + out('Move to Top') + '" class="cmd-section-top" style="border-left:none;"><span style="transform:rotate(90deg);position:absolute;top:13px;left:15px;">&#8676;</span></button>' + '<button title="' + out('Move to Bottom') + '" class="cmd-section-bottom" style="border-left:none;"><span style="transform:rotate(90deg);position:absolute;top:13px;left:15px;">&#8677;</span></button>' + '</div>' + '</div>' + '<div style="display:flex;flex-direction:column;">' + '<div style="padding-top:20px;padding-bottom: 3px;">' + out('Height') + ':</div>' + '<div style="display:flex">' + '<button class="cmd-section-height" data-value="0">Auto</button>' + '<button class="cmd-section-height" data-value="20" style="border-left:none;">20%</button>' + '<button class="cmd-section-height" data-value="30" style="border-left:none;">30%</button>' + '<button class="cmd-section-height" data-value="40" style="border-left:none;">40%</button>' + '</div>' + '<div style="display:flex">' + '<button class="cmd-section-height" data-value="50" style="border-top:none;">50%</button>' + '<button class="cmd-section-height" data-value="60" style="border-left:none;border-top:none;">60%</button>' + '<button class="cmd-section-height" data-value="75" style="border-left:none;border-top:none;">75%</button>' + '<button class="cmd-section-height" data-value="100" style="border-left:none;border-top:none;">100%</button>' + '</div>' + '</div>' + '<div style="display:flex;flex-direction:column;">' + '<div style="padding-top:20px;padding-bottom: 3px;">' + '<label for="chkScrollIcon" style="margin:0;"><input id="chkScrollIcon" type="checkbox" /> ' + out('Scroll Icon') + '</label>' + '</div>' + '<div style="display:flex;padding-top:10px;">' + '<button title="' + out('Light') + '" class="cmd-section-scroll" data-value="light" style="min-width:80px;">' + out('Light') + '</button>' + '<button title="' + out('Dark') + '" class="cmd-section-scroll" data-value="dark" style="border-left:none;min-width:80px;">' + out('Dark') + '</button>' + '</div>' + '</div>' + '</div>' + '</div>' + '</div>' + '' + '<div class="is-modal editmodule">' + '<div style="max-width:900px;height:570px;padding:0;box-sizing:border-box;position:relative;">' + '<div class="is-modal-bar is-draggable" style="position: absolute;top: 0;left: 0;width: 100%;z-index:1;">' + out('Module Settings') + '</div>' + '<iframe style="position: absolute;top: 0;left: 0;width:100%;height:100%;border:none;border-bottom:60px solid transparent;border-top:40px solid transparent;margin:0;box-sizing:border-box;" src="about:blank"></iframe>' + '<input id="hidModuleCode" type="hidden" />' + '<input id="hidModuleSettings" type="hidden" />' + '<button class="input-ok classic" style="height:60px;position:absolute;left:0;bottom:0;">' + out('Ok') + '</button>' + '</div>' + '</div>' + '' + '<div class="is-modal editcustomcode">' + '<div style="max-width:900px;height:570px;padding:0;box-sizing:border-box;position:relative;">' + '<div class="is-modal-bar is-draggable" style="position: absolute;top: 0;left: 0;width: 100%;z-index:1;">' + out('Custom Code (Javascript Allowed)') + '</div>' + '<textarea id="txtBoxCustomCode" class="inptxt" style="background: #fff;position: absolute;top: 0;left: 0;width:100%;height:100%;border:none;border-bottom:60px solid transparent;border-top:40px solid transparent;box-sizing:border-box;"></textarea>' + '<input id="hidBoxCustomCode" type="hidden" />' + '<button class="cell-html-larger" style="width:35px;height:35px;position:absolute;right:0;top:0;background:transparent;z-index:2;"><svg class="is-icon-flex" style="width:19px;height:19px;fill:rgb(170, 170, 170);"><use xlink:href="#ion-arrow-expand"></use></svg></button>' + '<button class="input-ok classic" style="height:60px;position:absolute;left:0;bottom:0;">' + out('Ok') + '</button>' + '</div>' + '</div>' + '';
1888
+ let html = '<div class="is-modal delsectionconfirm">' + '<div style="max-width: 400px;">' + '<p style="margin-bottom: 25px;text-align:center;">' + out('Are you sure you want to delete this section?') + '</p>' + '<button title="' + out('Delete') + '" class="input-ok classic">' + out('Delete') + '</button>' + '</div>' + '</div>' + '' + '<div class="is-modal editsection">' + '<div class="is-modal-content" style="max-width:292px;padding:0;">' + '<div class="is-modal-bar is-draggable">' + out('Section Settings') + '</div>' + '<div style="padding:30px 20px 20px;">' + '<div style="display:flex;flex-direction:column;">' + '<div style="padding-top:20px;padding-bottom: 3px;">' + out('Move Section') + ':</div>' + '<div style="display:flex">' + '<button title="' + out('Move Up') + '" class="cmd-section-up" style="">&#8593;</button>' + '<button title="' + out('Move Down') + '" class="cmd-section-down" style="border-left:none;">&#8595;</button>' + '<button title="' + out('Move to Top') + '" class="cmd-section-top" style="border-left:none;"><span style="transform:rotate(90deg);position:absolute;top:13px;left:15px;">&#8676;</span></button>' + '<button title="' + out('Move to Bottom') + '" class="cmd-section-bottom" style="border-left:none;"><span style="transform:rotate(90deg);position:absolute;top:13px;left:15px;">&#8677;</span></button>' + '</div>' + '</div>' + '<div style="display:flex;flex-direction:column;">' + '<div style="padding-top:20px;padding-bottom: 3px;">' + out('Height') + ':</div>' + '<div style="display:flex">' +
1889
+ /*
1890
+ '<button title="Auto" class="cmd-section-height" data-value="0">Auto</button>' + */
1891
+ '<button title="20%" class="cmd-section-height" data-value="20" style="border-left:none;">20%</button>' + '<button title="25%" class="cmd-section-height" data-value="25" style="border-left:none;">25%</button>' + '<button title="30%" class="cmd-section-height" data-value="30" style="border-left:none;">30%</button>' + '<button title="40%" class="cmd-section-height" data-value="40" style="border-left:none;">40%</button>' + '<button title="50%" class="cmd-section-height" data-value="50" style="border-left:none;">50%</button>' + '</div>' + '<div style="display:flex">' + '<button title="60%" class="cmd-section-height" data-value="60" style="border-left:none;border-top:none;">60%</button>' + '<button title="70%" class="cmd-section-height" data-value="70" style="border-left:none;border-top:none;">70%</button>' + '<button title="75%" class="cmd-section-height" data-value="75" style="border-left:none;border-top:none;">75%</button>' + '<button title="80%" class="cmd-section-height" data-value="80" style="border-left:none;border-top:none;">80%</button>' + '<button title="100%" class="cmd-section-height" data-value="100" style="border-left:none;border-top:none;">100%</button>' + '</div>' + '</div>' + '<div style="display:flex;flex-direction:column;">' + '<div style="padding-top:20px;padding-bottom: 3px;">' + out('Spacing') + ':</div>' + '<div style="display:flex">' + '<button title="' + out('xs') + '" class="cmd-box-spacing" data-value="default" style="border-left:none;">' + out('xs') + '</button>' + '<button title="' + out('sm') + '" class="cmd-box-spacing" data-value="sm" style="border-left:none;">' + out('sm') + '</button>' + '<button title="' + out('m') + '" class="cmd-box-spacing" data-value="m" style="border-left:none;">' + out('m') + '</button>' + '<button title="' + out('lg') + '" class="cmd-box-spacing" data-value="lg" style="border-left:none;">' + out('lg') + '</button>' + '<button title="' + out('Clear') + '" class="cmd-box-spacing" data-value="none" style="border-left:none;"><svg class="is-icon-flex" style="width:11px;height:11px;"><use xlink:href="#icon-clean"></use></svg></button>' + '</div>' + '</div>' + '<div style="display:flex;flex-direction:column;">' + '<div style="padding-top:20px;padding-bottom: 3px;">' + '<label for="chkScrollIcon" style="margin:0;"><input id="chkScrollIcon" type="checkbox" /> ' + out('Scroll Icon') + '</label>' + '</div>' + '<div style="display:flex;padding-top:10px;">' + '<button title="' + out('Light') + '" class="cmd-section-scroll" data-value="light" style="min-width:80px;">' + out('Light') + '</button>' + '<button title="' + out('Dark') + '" class="cmd-section-scroll" data-value="dark" style="border-left:none;min-width:80px;">' + out('Dark') + '</button>' + '</div>' + '</div>' + '</div>' + '</div>' + '</div>' + '' + '<div class="is-modal editmodule">' + '<div style="max-width:900px;height:570px;padding:0;box-sizing:border-box;position:relative;">' + '<div class="is-modal-bar is-draggable" style="position: absolute;top: 0;left: 0;width: 100%;z-index:1;">' + out('Module Settings') + '</div>' + '<iframe style="position: absolute;top: 0;left: 0;width:100%;height:100%;border:none;border-bottom:60px solid transparent;border-top:40px solid transparent;margin:0;box-sizing:border-box;" src="about:blank"></iframe>' + '<input id="hidModuleCode" type="hidden" />' + '<input id="hidModuleSettings" type="hidden" />' + '<button class="input-ok classic" style="height:60px;position:absolute;left:0;bottom:0;">' + out('Ok') + '</button>' + '</div>' + '</div>' + '' + '<div class="is-modal editcustomcode">' + '<div style="max-width:900px;height:570px;padding:0;box-sizing:border-box;position:relative;">' + '<div class="is-modal-bar is-draggable" style="position: absolute;top: 0;left: 0;width: 100%;z-index:1;">' + out('Custom Code (Javascript Allowed)') + '</div>' + '<textarea id="txtBoxCustomCode" class="inptxt" style="background: #fff;position: absolute;top: 0;left: 0;width:100%;height:100%;border:none;border-bottom:60px solid transparent;border-top:40px solid transparent;box-sizing:border-box;"></textarea>' + '<input id="hidBoxCustomCode" type="hidden" />' + '<button class="cell-html-larger" style="width:35px;height:35px;position:absolute;right:0;top:0;background:transparent;z-index:2;"><svg class="is-icon-flex" style="width:19px;height:19px;fill:rgb(170, 170, 170);"><use xlink:href="#ion-arrow-expand"></use></svg></button>' + '<button class="input-ok classic" style="height:60px;position:absolute;left:0;bottom:0;">' + out('Ok') + '</button>' + '</div>' + '</div>' + '';
1775
1892
  dom$H.appendHtml(builderStuff, html);
1776
1893
  let modalEditSection = builderStuff.querySelector('.is-modal.editsection');
1777
1894
  this.modalEditSection = modalEditSection;
@@ -1827,6 +1944,16 @@ class EditSection {
1827
1944
  this.builder.settings.onChange();
1828
1945
  });
1829
1946
  });
1947
+ const btnBoxSpacing = modalEditSection.querySelectorAll('.cmd-box-spacing');
1948
+ btnBoxSpacing.forEach(btn => {
1949
+ btn.addEventListener('click', () => {
1950
+ this.builder.editor.saveForUndo();
1951
+ let val = btn.getAttribute('data-value');
1952
+ this.boxSpacing(val); //Trigger Change event
1953
+
1954
+ this.builder.settings.onChange();
1955
+ });
1956
+ });
1830
1957
  const btnScrollIconStyle = modalEditSection.querySelectorAll('.cmd-section-scroll');
1831
1958
  btnScrollIconStyle.forEach(btn => {
1832
1959
  btn.addEventListener('click', () => {
@@ -1928,11 +2055,14 @@ class EditSection {
1928
2055
  activeSection.style.height = '';
1929
2056
  dom$H.removeClass(activeSection, 'is-section-auto');
1930
2057
  dom$H.removeClass(activeSection, 'is-section-20');
2058
+ dom$H.removeClass(activeSection, 'is-section-25');
1931
2059
  dom$H.removeClass(activeSection, 'is-section-30');
1932
2060
  dom$H.removeClass(activeSection, 'is-section-40');
1933
2061
  dom$H.removeClass(activeSection, 'is-section-50');
1934
2062
  dom$H.removeClass(activeSection, 'is-section-60');
2063
+ dom$H.removeClass(activeSection, 'is-section-70');
1935
2064
  dom$H.removeClass(activeSection, 'is-section-75');
2065
+ dom$H.removeClass(activeSection, 'is-section-80');
1936
2066
  dom$H.removeClass(activeSection, 'is-section-100');
1937
2067
 
1938
2068
  if (n === '0') {
@@ -1946,6 +2076,37 @@ class EditSection {
1946
2076
  this.builder.scrollTo(activeSection);
1947
2077
  }
1948
2078
 
2079
+ boxSpacing(s) {
2080
+ const activeSection = this.builder.activeSection;
2081
+
2082
+ if (s == 'none') {
2083
+ dom$H.removeClass(activeSection, 'box-space');
2084
+ dom$H.removeClass(activeSection, 'box-space-sm');
2085
+ dom$H.removeClass(activeSection, 'box-space-m');
2086
+ dom$H.removeClass(activeSection, 'box-space-lg');
2087
+ } else {
2088
+ dom$H.addClass(activeSection, 'box-space');
2089
+ }
2090
+
2091
+ if (s === 'sm') {
2092
+ dom$H.removeClass(activeSection, 'box-space-m');
2093
+ dom$H.removeClass(activeSection, 'box-space-lg');
2094
+ dom$H.addClass(activeSection, 'box-space-sm');
2095
+ } else if (s == 'm') {
2096
+ dom$H.removeClass(activeSection, 'box-space-sm');
2097
+ dom$H.removeClass(activeSection, 'box-space-lg');
2098
+ dom$H.addClass(activeSection, 'box-space-m');
2099
+ } else if (s == 'lg') {
2100
+ dom$H.removeClass(activeSection, 'box-space-sm');
2101
+ dom$H.removeClass(activeSection, 'box-space-m');
2102
+ dom$H.addClass(activeSection, 'box-space-lg');
2103
+ } else if (s == 'default') {
2104
+ dom$H.removeClass(activeSection, 'box-space-sm');
2105
+ dom$H.removeClass(activeSection, 'box-space-m');
2106
+ dom$H.removeClass(activeSection, 'box-space-lg');
2107
+ }
2108
+ }
2109
+
1949
2110
  sectionUseScroll() {
1950
2111
  const activeSection = this.builder.activeSection;
1951
2112
  const modalEditSection = this.modalEditSection;
@@ -7318,8 +7479,11 @@ class EditBox {
7318
7479
  btnBoxTypo.addEventListener('click', () => {
7319
7480
  this.builder.hideModal(modalEditBox); //Open divSidebarTypography
7320
7481
 
7321
- builderStuff.querySelector('.is-sidebar > button[data-command="typography"]').click();
7482
+ builderStuff.querySelector('.is-sidebar > button[data-command="typography"]').click(); //Overide
7483
+
7322
7484
  builderStuff.querySelector('.is-sidebar > button[data-command="typography"]').setAttribute('data-applyto', 'box');
7485
+ builderStuff.querySelector('.typo-target-default').style.display = 'none';
7486
+ builderStuff.querySelector('.typo-target-box').style.display = 'flex';
7323
7487
  });
7324
7488
  });
7325
7489
  const btnBoxSizes = modalEditBox.querySelectorAll('.cmd-box-size');
@@ -7488,6 +7652,9 @@ class EditBox {
7488
7652
  } else if (dom$G.hasClass(container, 'edge-x-5')) {
7489
7653
  dom$G.removeClass(container, 'edge-x-5');
7490
7654
  dom$G.addClass(container, 'edge-x-4');
7655
+ } else if (dom$G.hasClass(container, 'edge-x-6')) {
7656
+ dom$G.removeClass(container, 'edge-x-6');
7657
+ dom$G.addClass(container, 'edge-x-5');
7491
7658
  } else {
7492
7659
  dom$G.addClass(container, 'edge-x-0');
7493
7660
  }
@@ -7510,6 +7677,9 @@ class EditBox {
7510
7677
  dom$G.removeClass(container, 'edge-x-4');
7511
7678
  dom$G.addClass(container, 'edge-x-5');
7512
7679
  } else if (dom$G.hasClass(container, 'edge-x-5')) {
7680
+ dom$G.removeClass(container, 'edge-x-5');
7681
+ dom$G.addClass(container, 'edge-x-6');
7682
+ } else if (dom$G.hasClass(container, 'edge-x-6')) {
7513
7683
  return false;
7514
7684
  } else {
7515
7685
  dom$G.addClass(container, 'edge-x-0');
@@ -7523,6 +7693,7 @@ class EditBox {
7523
7693
  dom$G.removeClass(container, 'edge-x-3');
7524
7694
  dom$G.removeClass(container, 'edge-x-4');
7525
7695
  dom$G.removeClass(container, 'edge-x-5');
7696
+ dom$G.removeClass(container, 'edge-x-6');
7526
7697
  } //Trigger Change event
7527
7698
 
7528
7699
 
@@ -7570,6 +7741,15 @@ class EditBox {
7570
7741
  } else if (dom$G.hasClass(boxCentered, 'edge-y-5')) {
7571
7742
  dom$G.removeClass(boxCentered, 'edge-y-5');
7572
7743
  dom$G.addClass(boxCentered, 'edge-y-4');
7744
+ } else if (dom$G.hasClass(boxCentered, 'edge-y-6')) {
7745
+ dom$G.removeClass(boxCentered, 'edge-y-6');
7746
+ dom$G.addClass(boxCentered, 'edge-y-5');
7747
+ } else if (dom$G.hasClass(boxCentered, 'edge-y-7')) {
7748
+ dom$G.removeClass(boxCentered, 'edge-y-7');
7749
+ dom$G.addClass(boxCentered, 'edge-y-6');
7750
+ } else if (dom$G.hasClass(boxCentered, 'edge-y-8')) {
7751
+ dom$G.removeClass(boxCentered, 'edge-y-8');
7752
+ dom$G.addClass(boxCentered, 'edge-y-7');
7573
7753
  } else {
7574
7754
  dom$G.addClass(boxCentered, 'edge-y-0');
7575
7755
  }
@@ -7607,6 +7787,15 @@ class EditBox {
7607
7787
  dom$G.removeClass(boxCentered, 'edge-y-4');
7608
7788
  dom$G.addClass(boxCentered, 'edge-y-5');
7609
7789
  } else if (dom$G.hasClass(boxCentered, 'edge-y-5')) {
7790
+ dom$G.removeClass(boxCentered, 'edge-y-5');
7791
+ dom$G.addClass(boxCentered, 'edge-y-6');
7792
+ } else if (dom$G.hasClass(boxCentered, 'edge-y-6')) {
7793
+ dom$G.removeClass(boxCentered, 'edge-y-6');
7794
+ dom$G.addClass(boxCentered, 'edge-y-7');
7795
+ } else if (dom$G.hasClass(boxCentered, 'edge-y-7')) {
7796
+ dom$G.removeClass(boxCentered, 'edge-y-7');
7797
+ dom$G.addClass(boxCentered, 'edge-y-8');
7798
+ } else if (dom$G.hasClass(boxCentered, 'edge-y-8')) {
7610
7799
  return false;
7611
7800
  } else {
7612
7801
  dom$G.addClass(boxCentered, 'edge-y-0');
@@ -7625,98 +7814,55 @@ class EditBox {
7625
7814
  dom$G.removeClass(boxCentered, 'edge-y-3');
7626
7815
  dom$G.removeClass(boxCentered, 'edge-y-4');
7627
7816
  dom$G.removeClass(boxCentered, 'edge-y-5');
7628
- } //simplified
7629
-
7630
-
7631
- if (s === '-') {
7632
- if (dom$G.hasClass(activeBox, 'edge-y--5')) {
7633
- return false;
7634
- } else if (dom$G.hasClass(activeBox, 'edge-y--4')) {
7635
- dom$G.removeClass(activeBox, 'edge-y--4');
7636
- dom$G.addClass(activeBox, 'edge-y--5');
7637
- } else if (dom$G.hasClass(activeBox, 'edge-y--3')) {
7638
- dom$G.removeClass(activeBox, 'edge-y--3');
7639
- dom$G.addClass(activeBox, 'edge-y--4');
7640
- } else if (dom$G.hasClass(activeBox, 'edge-y--2')) {
7641
- dom$G.removeClass(activeBox, 'edge-y--2');
7642
- dom$G.addClass(activeBox, 'edge-y--3');
7643
- } else if (dom$G.hasClass(activeBox, 'edge-y--1')) {
7644
- dom$G.removeClass(activeBox, 'edge-y--1');
7645
- dom$G.addClass(activeBox, 'edge-y--2');
7646
- } else if (dom$G.hasClass(activeBox, 'edge-y-0')) {
7647
- dom$G.removeClass(activeBox, 'edge-y-0');
7648
- dom$G.addClass(activeBox, 'edge-y--1');
7649
- } else if (dom$G.hasClass(activeBox, 'edge-y-1')) {
7650
- dom$G.removeClass(activeBox, 'edge-y-1');
7651
- dom$G.addClass(activeBox, 'edge-y-0');
7652
- } else if (dom$G.hasClass(activeBox, 'edge-y-2')) {
7653
- dom$G.removeClass(activeBox, 'edge-y-2');
7654
- dom$G.addClass(activeBox, 'edge-y-1');
7655
- } else if (dom$G.hasClass(activeBox, 'edge-y-3')) {
7656
- dom$G.removeClass(activeBox, 'edge-y-3');
7657
- dom$G.addClass(activeBox, 'edge-y-2');
7658
- } else if (dom$G.hasClass(activeBox, 'edge-y-4')) {
7659
- dom$G.removeClass(activeBox, 'edge-y-4');
7660
- dom$G.addClass(activeBox, 'edge-y-3');
7661
- } else if (dom$G.hasClass(activeBox, 'edge-y-5')) {
7662
- dom$G.removeClass(activeBox, 'edge-y-5');
7663
- dom$G.addClass(activeBox, 'edge-y-4');
7664
- } else {
7665
- dom$G.addClass(activeBox, 'edge-y-0');
7666
- }
7667
- }
7668
-
7669
- if (s == '+') {
7670
- if (dom$G.hasClass(activeBox, 'edge-y--5')) {
7671
- dom$G.removeClass(activeBox, 'edge-y--5');
7672
- dom$G.addClass(activeBox, 'edge-y--4');
7673
- } else if (dom$G.hasClass(activeBox, 'edge-y--4')) {
7674
- dom$G.removeClass(activeBox, 'edge-y--4');
7675
- dom$G.addClass(activeBox, 'edge-y--3');
7676
- } else if (dom$G.hasClass(activeBox, 'edge-y--3')) {
7677
- dom$G.removeClass(activeBox, 'edge-y--3');
7678
- dom$G.addClass(activeBox, 'edge-y--2');
7679
- } else if (dom$G.hasClass(activeBox, 'edge-y--2')) {
7680
- dom$G.removeClass(activeBox, 'edge-y--2');
7681
- dom$G.addClass(activeBox, 'edge-y--1');
7682
- } else if (dom$G.hasClass(activeBox, 'edge-y--1')) {
7683
- dom$G.removeClass(activeBox, 'edge-y--1');
7684
- dom$G.addClass(activeBox, 'edge-y-0');
7685
- } else if (dom$G.hasClass(activeBox, 'edge-y-0')) {
7686
- dom$G.removeClass(activeBox, 'edge-y-0');
7687
- dom$G.addClass(activeBox, 'edge-y-1');
7688
- } else if (dom$G.hasClass(activeBox, 'edge-y-1')) {
7689
- dom$G.removeClass(activeBox, 'edge-y-1');
7690
- dom$G.addClass(activeBox, 'edge-y-2');
7691
- } else if (dom$G.hasClass(activeBox, 'edge-y-2')) {
7692
- dom$G.removeClass(activeBox, 'edge-y-2');
7693
- dom$G.addClass(activeBox, 'edge-y-3');
7694
- } else if (dom$G.hasClass(activeBox, 'edge-y-3')) {
7695
- dom$G.removeClass(activeBox, 'edge-y-3');
7696
- dom$G.addClass(activeBox, 'edge-y-4');
7697
- } else if (dom$G.hasClass(activeBox, 'edge-y-4')) {
7698
- dom$G.removeClass(activeBox, 'edge-y-4');
7699
- dom$G.addClass(activeBox, 'edge-y-5');
7700
- } else if (dom$G.hasClass(activeBox, 'edge-y-5')) {
7701
- return false;
7702
- } else {
7703
- dom$G.addClass(activeBox, 'edge-y-0');
7704
- }
7705
- }
7706
-
7707
- if (s == '') {
7708
- dom$G.removeClass(activeBox, 'edge-y--5');
7709
- dom$G.removeClass(activeBox, 'edge-y--4');
7710
- dom$G.removeClass(activeBox, 'edge-y--3');
7711
- dom$G.removeClass(activeBox, 'edge-y--2');
7712
- dom$G.removeClass(activeBox, 'edge-y--1');
7713
- dom$G.removeClass(activeBox, 'edge-y-0');
7714
- dom$G.removeClass(activeBox, 'edge-y-1');
7715
- dom$G.removeClass(activeBox, 'edge-y-2');
7716
- dom$G.removeClass(activeBox, 'edge-y-3');
7717
- dom$G.removeClass(activeBox, 'edge-y-4');
7718
- dom$G.removeClass(activeBox, 'edge-y-5');
7719
- } //Trigger Change event
7817
+ dom$G.removeClass(boxCentered, 'edge-y-6');
7818
+ dom$G.removeClass(boxCentered, 'edge-y-7');
7819
+ dom$G.removeClass(boxCentered, 'edge-y-8');
7820
+ } // //simplified
7821
+ // if (s === '-') {
7822
+ // if (dom.hasClass(activeBox, 'edge-y--5')) { return false; }
7823
+ // else if (dom.hasClass(activeBox, 'edge-y--4')) { dom.removeClass(activeBox, 'edge-y--4'); dom.addClass(activeBox, 'edge-y--5'); }
7824
+ // else if (dom.hasClass(activeBox, 'edge-y--3')) { dom.removeClass(activeBox, 'edge-y--3'); dom.addClass(activeBox, 'edge-y--4'); }
7825
+ // else if (dom.hasClass(activeBox, 'edge-y--2')) { dom.removeClass(activeBox, 'edge-y--2'); dom.addClass(activeBox, 'edge-y--3'); }
7826
+ // else if (dom.hasClass(activeBox, 'edge-y--1')) { dom.removeClass(activeBox, 'edge-y--1'); dom.addClass(activeBox, 'edge-y--2'); }
7827
+ // else if (dom.hasClass(activeBox, 'edge-y-0')) { dom.removeClass(activeBox, 'edge-y-0'); dom.addClass(activeBox, 'edge-y--1'); }
7828
+ // else if (dom.hasClass(activeBox, 'edge-y-1')) { dom.removeClass(activeBox, 'edge-y-1'); dom.addClass(activeBox, 'edge-y-0'); }
7829
+ // else if (dom.hasClass(activeBox, 'edge-y-2')) { dom.removeClass(activeBox, 'edge-y-2'); dom.addClass(activeBox, 'edge-y-1'); }
7830
+ // else if (dom.hasClass(activeBox, 'edge-y-3')) { dom.removeClass(activeBox, 'edge-y-3'); dom.addClass(activeBox, 'edge-y-2'); }
7831
+ // else if (dom.hasClass(activeBox, 'edge-y-4')) { dom.removeClass(activeBox, 'edge-y-4'); dom.addClass(activeBox, 'edge-y-3'); }
7832
+ // else if (dom.hasClass(activeBox, 'edge-y-5')) { dom.removeClass(activeBox, 'edge-y-5'); dom.addClass(activeBox, 'edge-y-4'); }
7833
+ // else if (dom.hasClass(activeBox, 'edge-y-6')) { dom.removeClass(activeBox, 'edge-y-6'); dom.addClass(activeBox, 'edge-y-5'); }
7834
+ // else { dom.addClass(activeBox, 'edge-y-0'); }
7835
+ // }
7836
+ // if (s == '+') {
7837
+ // if (dom.hasClass(activeBox, 'edge-y--5')) { dom.removeClass(activeBox, 'edge-y--5'); dom.addClass(activeBox, 'edge-y--4'); }
7838
+ // else if (dom.hasClass(activeBox, 'edge-y--4')) { dom.removeClass(activeBox, 'edge-y--4'); dom.addClass(activeBox, 'edge-y--3'); }
7839
+ // else if (dom.hasClass(activeBox, 'edge-y--3')) { dom.removeClass(activeBox, 'edge-y--3'); dom.addClass(activeBox, 'edge-y--2'); }
7840
+ // else if (dom.hasClass(activeBox, 'edge-y--2')) { dom.removeClass(activeBox, 'edge-y--2'); dom.addClass(activeBox, 'edge-y--1'); }
7841
+ // else if (dom.hasClass(activeBox, 'edge-y--1')) { dom.removeClass(activeBox, 'edge-y--1'); dom.addClass(activeBox, 'edge-y-0'); }
7842
+ // else if (dom.hasClass(activeBox, 'edge-y-0')) { dom.removeClass(activeBox, 'edge-y-0'); dom.addClass(activeBox, 'edge-y-1'); }
7843
+ // else if (dom.hasClass(activeBox, 'edge-y-1')) { dom.removeClass(activeBox, 'edge-y-1'); dom.addClass(activeBox, 'edge-y-2'); }
7844
+ // else if (dom.hasClass(activeBox, 'edge-y-2')) { dom.removeClass(activeBox, 'edge-y-2'); dom.addClass(activeBox, 'edge-y-3'); }
7845
+ // else if (dom.hasClass(activeBox, 'edge-y-3')) { dom.removeClass(activeBox, 'edge-y-3'); dom.addClass(activeBox, 'edge-y-4'); }
7846
+ // else if (dom.hasClass(activeBox, 'edge-y-4')) { dom.removeClass(activeBox, 'edge-y-4'); dom.addClass(activeBox, 'edge-y-5'); }
7847
+ // else if (dom.hasClass(activeBox, 'edge-y-5')) { dom.removeClass(activeBox, 'edge-y-5'); dom.addClass(activeBox, 'edge-y-6'); }
7848
+ // else if (dom.hasClass(activeBox, 'edge-y-6')) { return false; }
7849
+ // else { dom.addClass(activeBox, 'edge-y-0'); }
7850
+ // }
7851
+ // if (s == '') {
7852
+ // dom.removeClass(activeBox, 'edge-y--5');
7853
+ // dom.removeClass(activeBox, 'edge-y--4');
7854
+ // dom.removeClass(activeBox, 'edge-y--3');
7855
+ // dom.removeClass(activeBox, 'edge-y--2');
7856
+ // dom.removeClass(activeBox, 'edge-y--1');
7857
+ // dom.removeClass(activeBox, 'edge-y-0');
7858
+ // dom.removeClass(activeBox, 'edge-y-1');
7859
+ // dom.removeClass(activeBox, 'edge-y-2');
7860
+ // dom.removeClass(activeBox, 'edge-y-3');
7861
+ // dom.removeClass(activeBox, 'edge-y-4');
7862
+ // dom.removeClass(activeBox, 'edge-y-5');
7863
+ // dom.removeClass(boxCentered, 'edge-y-6');
7864
+ // }
7865
+ //Trigger Change event
7720
7866
 
7721
7867
 
7722
7868
  this.builder.settings.onChange();
@@ -7923,12 +8069,13 @@ class EditBox {
7923
8069
  this.builder.editor.saveForUndo(true); // checkLater = true
7924
8070
 
7925
8071
  const activeBox = this.builder.activeBox;
7926
- let bgcolor = window.getComputedStyle(activeBox, null).getPropertyValue('background-color');
7927
- if (bgcolor === 'rgba(0, 0, 0, 0)') bgcolor = ''; // let bgcolor = activeBox.style.backgroundColor;
7928
-
8072
+ let bgcolor = btnBoxBgColor.style.backgroundColor;
8073
+ let overlay = activeBox.querySelector('.is-overlay');
7929
8074
  colorpicker.open(s => {
7930
- activeBox.style.backgroundColor = s;
7931
- activeBox.style.backgroundImage = ''; //remove gradient
8075
+ // activeBox.style.backgroundColor = s;
8076
+ // activeBox.style.backgroundImage = '';//remove gradient
8077
+ overlay.style.backgroundColor = s;
8078
+ overlay.style.backgroundImage = ''; //remove gradient
7932
8079
 
7933
8080
  btnBoxBgColor.style.backgroundColor = s; // preview
7934
8081
  }, bgcolor);
@@ -7939,8 +8086,9 @@ class EditBox {
7939
8086
  const activeBox = this.builder.activeBox;
7940
8087
  this.builder.editor.saveForUndo(true); // checkLater = true
7941
8088
 
8089
+ let overlay = activeBox.querySelector('.is-overlay');
7942
8090
  let gradientPicker = this.builder.editor.gradientpicker();
7943
- gradientPicker.open(activeBox);
8091
+ gradientPicker.open(overlay);
7944
8092
  }); // Box Overlay Color
7945
8093
 
7946
8094
  const btnBoxOverlayColor = modalEditBox.querySelector('.input-box-overlaycolor');
@@ -7983,6 +8131,8 @@ class EditBox {
7983
8131
  overlayColor.style.backgroundColor = s;
7984
8132
  }
7985
8133
 
8134
+ btnBoxOverlayColor.style.backgroundColor = s; // preview
8135
+
7986
8136
  return false;
7987
8137
  }, color); //Note: if color empty, colorpicker will stay with its previous color
7988
8138
  }); // Click to Open Media Select Dialog
@@ -8306,12 +8456,7 @@ class EditBox {
8306
8456
  if (dom$G.hasClass(activeBox, 'delay-2700ms')) selAnimateDelay.value = 'delay-2700ms';
8307
8457
  if (dom$G.hasClass(activeBox, 'delay-2800ms')) selAnimateDelay.value = 'delay-2800ms';
8308
8458
  if (dom$G.hasClass(activeBox, 'delay-2900ms')) selAnimateDelay.value = 'delay-2900ms';
8309
- if (dom$G.hasClass(activeBox, 'delay-3000ms')) selAnimateDelay.value = 'delay-3000ms'; //Background color
8310
-
8311
- let bgcolor = window.getComputedStyle(activeBox, null).getPropertyValue('background-color');
8312
- if (bgcolor === 'rgba(0, 0, 0, 0)') bgcolor = '';
8313
- let btnBoxBgColor = modalEditBox.querySelector('.input-box-bgcolor');
8314
- if (bgcolor) btnBoxBgColor.style.backgroundColor = bgcolor;else btnBoxBgColor.style.backgroundColor = 'transparent'; //Background image
8459
+ if (dom$G.hasClass(activeBox, 'delay-3000ms')) selAnimateDelay.value = 'delay-3000ms'; //Background image
8315
8460
  //Hide image tab
8316
8461
 
8317
8462
  modalEditBox.querySelector('#tabBoxImage').style.display = 'none';
@@ -8356,6 +8501,43 @@ class EditBox {
8356
8501
  modalEditBox.querySelector('#divNoBoxSettings').style.display = 'block'; //Show info: This box has no available settings
8357
8502
  } else {
8358
8503
  modalEditBox.querySelector('#divNoBoxSettings').style.display = 'none';
8504
+ } // FIX OLD VERSION
8505
+
8506
+
8507
+ let overlay = activeBox.querySelector('.is-overlay');
8508
+
8509
+ if (overlay) ; else {
8510
+ activeBox.insertAdjacentHTML('afterbegin', '<div class="is-overlay"></div>');
8511
+ overlay = activeBox.querySelector('.is-overlay');
8512
+ } // Gradient Color
8513
+
8514
+
8515
+ const s = activeBox.style.backgroundImage;
8516
+ if (s) if (s.indexOf('linear-gradient') !== -1) {
8517
+ // Fix
8518
+ overlay.style.backgroundImage = s;
8519
+ activeBox.style.backgroundImage = '';
8520
+ } // Background color
8521
+
8522
+ let btnBoxBgColor = modalEditBox.querySelector('.input-box-bgcolor');
8523
+ let bgcolor = activeBox.style.backgroundColor;
8524
+
8525
+ if (bgcolor) {
8526
+ // Fix
8527
+ overlay.style.backgroundColor = bgcolor;
8528
+ activeBox.style.backgroundColor = '';
8529
+ btnBoxBgColor.style.backgroundColor = bgcolor; //preview
8530
+ } else {
8531
+ bgcolor = overlay.style.backgroundColor;
8532
+
8533
+ if (bgcolor) {
8534
+ btnBoxBgColor.style.backgroundColor = bgcolor; //preview
8535
+ } else {
8536
+ //backward
8537
+ bgcolor = window.getComputedStyle(activeBox, null).getPropertyValue('background-color');
8538
+ if (bgcolor === 'rgba(0, 0, 0, 0)') bgcolor = '';
8539
+ btnBoxBgColor.style.backgroundColor = bgcolor; //preview
8540
+ }
8359
8541
  }
8360
8542
  } //edit
8361
8543
 
@@ -8887,7 +9069,7 @@ class EditBox {
8887
9069
  // }
8888
9070
 
8889
9071
 
8890
- overlayBg.style.backgroundImage = 'url(' + url + ')';
9072
+ overlayBg.style.backgroundImage = 'url(\'' + url + '\')';
8891
9073
  overlayBg.style.backgroundPosition = 50 + '%' + ' ' + 60 + '%'; //default
8892
9074
 
8893
9075
  preview.innerHTML = `<img src="${url}">`;
@@ -8897,10 +9079,22 @@ class EditBox {
8897
9079
  modalEditBox.querySelector('#tabBoxImage').style.display = 'inline-block';
8898
9080
  } else {
8899
9081
  let overlayBg = overlay.querySelector('.is-overlay-bg');
8900
- if (overlayBg) overlayBg.parentNode.removeChild(overlayBg); //TODO: Remove overlay color
9082
+ if (overlayBg) overlayBg.parentNode.removeChild(overlayBg);
9083
+ let overlayColor = overlay.querySelector('.is-overlay-color');
9084
+
9085
+ if (overlayColor) {
9086
+ overlayColor.parentNode.removeChild(overlayColor);
9087
+ }
9088
+
9089
+ let overlayContent = overlay.querySelector('.is-overlay-content');
9090
+
9091
+ if (overlayContent) {
9092
+ if (overlayContent.innerHTML === '') overlayContent.parentNode.removeChild(overlayContent);
9093
+ } // if(overlay.childElementCount===0) overlay.parentNode.removeChild(overlay); // new version always need overlay
8901
9094
  // overlayBg.style.backgroundImage = '';
8902
9095
  // overlayBg.style.backgroundPosition = '';
8903
9096
 
9097
+
8904
9098
  preview.innerHTML = ''; //clear overlay color
8905
9099
 
8906
9100
  const btnBoxOverlayColor = modalEditBox.querySelector('.input-box-overlaycolor');
@@ -9482,7 +9676,8 @@ class Util {
9482
9676
  dom.moveAfter(cellElement, cell);
9483
9677
  }
9484
9678
 
9485
- this.builder.applyBehavior();
9679
+ let builderActive = document.querySelector('.builder-active');
9680
+ if (builderActive) this.builder.applyBehaviorOn(builderActive);
9486
9681
  this.fixLayout(row);
9487
9682
  cellElement.click(); //change active block to the newly created
9488
9683
  }
@@ -9531,7 +9726,8 @@ class Util {
9531
9726
 
9532
9727
  row.parentNode.insertBefore(rowElement, row);
9533
9728
  dom.moveAfter(rowElement, row);
9534
- this.builder.applyBehavior();
9729
+ let builderActive = document.querySelector('.builder-active');
9730
+ if (builderActive) this.builder.applyBehaviorOn(builderActive);
9535
9731
  cellElement.click(); //change active block to the newly created
9536
9732
  }
9537
9733
 
@@ -9545,7 +9741,8 @@ class Util {
9545
9741
  // }
9546
9742
 
9547
9743
  element.insertAdjacentHTML('afterend', html);
9548
- this.builder.applyBehavior();
9744
+ let builderActive = document.querySelector('.builder-active');
9745
+ if (builderActive) this.builder.applyBehaviorOn(builderActive);
9549
9746
  let newelement = element.nextElementSibling;
9550
9747
 
9551
9748
  if (newelement.tagName.toLowerCase() === 'img') {
@@ -9553,7 +9750,7 @@ class Util {
9553
9750
  clearTimeout(timeoutId);
9554
9751
  timeoutId = setTimeout(() => {
9555
9752
  if (newelement.complete) {
9556
- newelement.click(); //console.log(2);
9753
+ newelement.click();
9557
9754
  }
9558
9755
  }, 200);
9559
9756
  } else {
@@ -9644,7 +9841,8 @@ class Util {
9644
9841
 
9645
9842
  row.parentNode.insertBefore(rowElement, row);
9646
9843
  dom.moveAfter(rowElement, row);
9647
- this.builder.applyBehavior();
9844
+ let builderActive = document.querySelector('.builder-active');
9845
+ if (builderActive) this.builder.applyBehaviorOn(builderActive);
9648
9846
  cellElement.click(); //change active block to the newly created
9649
9847
  // Change to row selection
9650
9848
 
@@ -9722,10 +9920,16 @@ class Util {
9722
9920
  cell.parentNode.insertBefore(cell, cell.previousElementSibling);
9723
9921
  }
9724
9922
 
9725
- this.builder.applyBehavior();
9726
- this.fixLayout(row);
9727
- cellElement.click(); //change active block to the newly created
9728
- // Call onChange
9923
+ let builderActive = document.querySelector('.builder-active');
9924
+ if (builderActive) this.builder.applyBehaviorOn(builderActive);
9925
+ this.fixLayout(row); // cellElement.click(); //change active block to the newly created
9926
+
9927
+ if (mode === 'cell' || mode === 'cell-right') {
9928
+ cell.nextElementSibling.click();
9929
+ } else {
9930
+ cell.previousElementSibling.click();
9931
+ } // Call onChange
9932
+
9729
9933
 
9730
9934
  this.builder.opts.onChange();
9731
9935
  return;
@@ -9769,10 +9973,11 @@ class Util {
9769
9973
  // row.scrollIntoView({ behavior: 'smooth', block: 'center' });
9770
9974
  // }, 600);
9771
9975
 
9772
- rowElement = row.nextElementSibling; // a must. Must be before applyBehavior() to prevent element delete during fixLayout
9773
-
9774
- this.builder.applyBehavior(); // checkEmpty & onRender called here
9976
+ rowElement = row.nextElementSibling; // a must. Must be before applyBehavior to prevent element delete during fixLayout
9977
+ // checkEmpty & onRender called here
9775
9978
 
9979
+ let builderActive = document.querySelector('.builder-active');
9980
+ if (builderActive) this.builder.applyBehaviorOn(builderActive);
9776
9981
  cellElement = rowElement.childNodes[0];
9777
9982
  cellElement.click(); //change active block to the newly created
9778
9983
  // Change to row selection
@@ -10118,71 +10323,75 @@ class Util {
10118
10323
  }
10119
10324
 
10120
10325
  checkEmpty() {
10121
- const dom = this.dom; // Get all builder areas
10122
-
10326
+ // Get all builder areas
10123
10327
  const builders = document.querySelectorAll(this.builder.opts.container);
10124
10328
  Array.prototype.forEach.call(builders, builder => {
10125
- const rows = dom.elementChildren(builder);
10126
- let empty = true;
10127
- rows.forEach(row => {
10128
- if (dom.hasClass(row, 'row-add-initial')) return;
10129
- if (dom.hasClass(row, 'dummy-space')) return;
10130
- empty = false;
10131
- });
10329
+ this.checkEmptyOn(builder);
10330
+ });
10331
+ }
10132
10332
 
10133
- if (empty) {
10134
- let emptyinfo = builder.querySelector('.row-add-initial');
10333
+ checkEmptyOn(builder) {
10334
+ const dom = this.dom;
10335
+ const rows = dom.elementChildren(builder);
10336
+ let empty = true;
10337
+ rows.forEach(row => {
10338
+ if (dom.hasClass(row, 'row-add-initial')) return;
10339
+ if (dom.hasClass(row, 'dummy-space')) return;
10340
+ empty = false;
10341
+ });
10135
10342
 
10136
- if (!emptyinfo) {
10137
- builder.innerHTML = `<button type="button" class="row-add-initial">${this.out('Empty')}<br><span>${this.out('+ Click to add content')}</span></div>`;
10138
- emptyinfo = builder.querySelector('.row-add-initial');
10139
- }
10343
+ if (empty) {
10344
+ let emptyinfo = builder.querySelector('.row-add-initial');
10140
10345
 
10141
- emptyinfo.addEventListener('click', () => {
10142
- this.clearActiveCell();
10143
- dom.addClass(emptyinfo, 'row-active'); // Needed for addContent(). Directly apply class in Util is fine.
10346
+ if (!emptyinfo) {
10347
+ builder.innerHTML = `<button type="button" class="row-add-initial">${this.out('Empty')}<br><span>${this.out('+ Click to add content')}</span></div>`;
10348
+ emptyinfo = builder.querySelector('.row-add-initial');
10349
+ }
10144
10350
 
10145
- const builderStuff = this.builder.builderStuff;
10146
- let quickadd = builderStuff.querySelector('.quickadd'); // see quickadd.js. Directly select by class in Util is fine.
10351
+ emptyinfo.addEventListener('click', () => {
10352
+ this.clearActiveCell();
10353
+ dom.addClass(emptyinfo, 'row-active'); // Needed for addContent(). Directly apply class in Util is fine.
10147
10354
 
10148
- let tabs = quickadd.querySelector('.is-pop-tabs');
10149
- tabs.style.display = 'none';
10150
- const viewportHeight = window.innerHeight;
10151
- let top = emptyinfo.getBoundingClientRect().top;
10152
- const left = emptyinfo.getBoundingClientRect().left + emptyinfo.offsetWidth * this.builder.opts.zoom / 2 - 11;
10153
- quickadd.style.display = 'flex';
10154
- const w = quickadd.offsetWidth; //to get value, element must not hidden (display:none). So set display:flex before this.
10155
-
10156
- const h = quickadd.offsetHeight;
10157
-
10158
- if (viewportHeight - top > h) {
10159
- top = top + emptyinfo.offsetHeight * this.builder.opts.zoom - 19;
10160
- quickadd.style.top = top + window.pageYOffset + 27 + 'px';
10161
- quickadd.style.left = left - w / 2 + 7 + 'px';
10162
- dom.removeClass(quickadd, 'arrow-bottom');
10163
- dom.removeClass(quickadd, 'arrow-right');
10164
- dom.removeClass(quickadd, 'arrow-left');
10165
- dom.removeClass(quickadd, 'center');
10166
- dom.addClass(quickadd, 'arrow-top');
10167
- dom.addClass(quickadd, 'center');
10168
- } else {
10169
- quickadd.style.top = top + window.pageYOffset - h - 8 + 'px';
10170
- quickadd.style.left = left - w / 2 + 7 + 'px';
10171
- dom.removeClass(quickadd, 'arrow-top');
10172
- dom.removeClass(quickadd, 'arrow-right');
10173
- dom.removeClass(quickadd, 'arrow-left');
10174
- dom.removeClass(quickadd, 'center');
10175
- dom.addClass(quickadd, 'arrow-bottom');
10176
- dom.addClass(quickadd, 'center');
10177
- }
10355
+ const builderStuff = this.builder.builderStuff;
10356
+ let quickadd = builderStuff.querySelector('.quickadd'); // see quickadd.js. Directly select by class in Util is fine.
10178
10357
 
10179
- quickadd.setAttribute('data-mode', 'row');
10180
- });
10181
- } else {
10182
- let emptyinfo = builder.querySelector('.row-add-initial');
10183
- if (emptyinfo) emptyinfo.parentNode.removeChild(emptyinfo);
10184
- }
10185
- });
10358
+ let tabs = quickadd.querySelector('.is-pop-tabs');
10359
+ tabs.style.display = 'none';
10360
+ const viewportHeight = window.innerHeight;
10361
+ let top = emptyinfo.getBoundingClientRect().top;
10362
+ const left = emptyinfo.getBoundingClientRect().left + emptyinfo.offsetWidth * this.builder.opts.zoom / 2 - 11;
10363
+ quickadd.style.display = 'flex';
10364
+ const w = quickadd.offsetWidth; //to get value, element must not hidden (display:none). So set display:flex before this.
10365
+
10366
+ const h = quickadd.offsetHeight;
10367
+
10368
+ if (viewportHeight - top > h) {
10369
+ top = top + emptyinfo.offsetHeight * this.builder.opts.zoom - 19;
10370
+ quickadd.style.top = top + window.pageYOffset + 27 + 'px';
10371
+ quickadd.style.left = left - w / 2 + 7 + 'px';
10372
+ dom.removeClass(quickadd, 'arrow-bottom');
10373
+ dom.removeClass(quickadd, 'arrow-right');
10374
+ dom.removeClass(quickadd, 'arrow-left');
10375
+ dom.removeClass(quickadd, 'center');
10376
+ dom.addClass(quickadd, 'arrow-top');
10377
+ dom.addClass(quickadd, 'center');
10378
+ } else {
10379
+ quickadd.style.top = top + window.pageYOffset - h - 8 + 'px';
10380
+ quickadd.style.left = left - w / 2 + 7 + 'px';
10381
+ dom.removeClass(quickadd, 'arrow-top');
10382
+ dom.removeClass(quickadd, 'arrow-right');
10383
+ dom.removeClass(quickadd, 'arrow-left');
10384
+ dom.removeClass(quickadd, 'center');
10385
+ dom.addClass(quickadd, 'arrow-bottom');
10386
+ dom.addClass(quickadd, 'center');
10387
+ }
10388
+
10389
+ quickadd.setAttribute('data-mode', 'row');
10390
+ });
10391
+ } else {
10392
+ let emptyinfo = builder.querySelector('.row-add-initial');
10393
+ if (emptyinfo) emptyinfo.parentNode.removeChild(emptyinfo);
10394
+ }
10186
10395
  }
10187
10396
 
10188
10397
  clearPreferences() {
@@ -10464,8 +10673,7 @@ class Util {
10464
10673
 
10465
10674
  this.builder.styleButtonClassicBackground = window.getComputedStyle(btnClassic, null).getPropertyValue('background-color');
10466
10675
  this.builder.styleButtonClassicColor = window.getComputedStyle(btnClassic, null).getPropertyValue('color');
10467
- this.builder.styleButtonClassicBackgroundHover = this.getUIStyleValue(btnClassic, 'hover', 'background-color'); // console.log(this.builder.styleButtonClassicBackgroundHover);
10468
-
10676
+ this.builder.styleButtonClassicBackgroundHover = this.getUIStyleValue(btnClassic, 'hover', 'background-color');
10469
10677
  this.builder.styleDark = false;
10470
10678
  this.builder.styleColored = false;
10471
10679
  this.builder.styleColoredDark = false;
@@ -11574,7 +11782,6 @@ class Dom {
11574
11782
  }
11575
11783
  } // https://plainjs.com/javascript/attributes/adding-removing-and-testing-for-classes-9/
11576
11784
  // addClass(element, classname) {
11577
- // console.log(element.classList)
11578
11785
  // if (element.classList) element.classList.add(classname);
11579
11786
  // else if (!this.hasClass(element, classname)) element.className += ' ' + classname;
11580
11787
  // }
@@ -11591,7 +11798,6 @@ class Dom {
11591
11798
  let s = element.getAttribute('class');
11592
11799
  return new RegExp('\\b' + classname + '\\b').test(s);
11593
11800
  } catch (e) {// Do Nothing
11594
- // console.log(element);
11595
11801
  } //return element.classList ? element.classList.contains(classname) : new RegExp('\\b'+ classname+'\\b').test(element.className);
11596
11802
 
11597
11803
  }
@@ -11623,7 +11829,6 @@ class Dom {
11623
11829
  // if(classname==='is-side') console.log(element.nodeName); // NOTE: click on svg can still returns undefined in IE11
11624
11830
  if (!element.tagName) return false;
11625
11831
  if (element.tagName === 'BODY' || element.tagName === 'HTML') return false; // if(!element.classList) {
11626
- // console.log('no classList');
11627
11832
  // return false;
11628
11833
  // }
11629
11834
 
@@ -11673,7 +11878,6 @@ class Dom {
11673
11878
  return true;
11674
11879
  }
11675
11880
  } catch (e) {// Do Nothing
11676
- // console.log(element);
11677
11881
  // return false;
11678
11882
  }
11679
11883
 
@@ -11705,7 +11909,6 @@ class Dom {
11705
11909
  return element;
11706
11910
  }
11707
11911
  } catch (e) {// Do Nothing
11708
- // console.log(element);
11709
11912
  // return false;
11710
11913
  }
11711
11914
 
@@ -11832,7 +12035,7 @@ class Dom {
11832
12035
  textSelection() {
11833
12036
  try {
11834
12037
  var elm;
11835
- var curr = window.getSelection().getRangeAt(0).commonAncestorContainer; //console.log(curr.nodeType)
12038
+ var curr = window.getSelection().getRangeAt(0).commonAncestorContainer;
11836
12039
 
11837
12040
  if (curr.nodeType === 3) {
11838
12041
  // text node
@@ -17320,7 +17523,8 @@ class HtmlUtil {
17320
17523
  if (mode === 'cell') {
17321
17524
  const cell = util.cellSelected();
17322
17525
  cell.innerHTML = html;
17323
- this.builder.applyBehavior(); //Trigger Change event
17526
+ let builderActive = document.querySelector('.builder-active');
17527
+ if (builderActive) this.builder.applyBehaviorOn(builderActive); //Trigger Change event
17324
17528
 
17325
17529
  this.builder.opts.onChange(); //Trigger Render event
17326
17530
 
@@ -17331,7 +17535,8 @@ class HtmlUtil {
17331
17535
  const cell = util.cellSelected();
17332
17536
  const row = cell.parentNode;
17333
17537
  row.innerHTML = html;
17334
- this.builder.applyBehavior(); //Trigger Change event
17538
+ let builderActive = document.querySelector('.builder-active');
17539
+ if (builderActive) this.builder.applyBehaviorOn(builderActive); //Trigger Change event
17335
17540
 
17336
17541
  this.builder.opts.onChange(); //Trigger Render event
17337
17542
 
@@ -17346,7 +17551,8 @@ class HtmlUtil {
17346
17551
  var range = document.createRange();
17347
17552
  range.setStart(area, 0);
17348
17553
  area.appendChild(range.createContextualFragment(html));
17349
- this.builder.applyBehavior(); //Trigger Change event
17554
+ let builderActive = document.querySelector('.builder-active');
17555
+ if (builderActive) this.builder.applyBehaviorOn(builderActive); //Trigger Change event
17350
17556
 
17351
17557
  this.builder.opts.onChange(); //Trigger Render event
17352
17558
 
@@ -19812,9 +20018,10 @@ class Grid {
19812
20018
  row.previousElementSibling.appendChild(cell); //add
19813
20019
 
19814
20020
  row.parentNode.removeChild(row); //remove current (empty) row (including its overlay)
20021
+ //re-add tool
19815
20022
 
19816
- builder.applyBehavior(); //re-add tool
19817
-
20023
+ let builderActive = document.querySelector('.builder-active');
20024
+ builder.applyBehaviorOn(builderActive);
19818
20025
  columnTool.position(cell);
19819
20026
  cell.click(); //refresh active cell/row
19820
20027
 
@@ -19829,9 +20036,10 @@ class Grid {
19829
20036
  var rowElement = row.cloneNode(true);
19830
20037
  rowElement.innerHTML = '';
19831
20038
  rowElement.appendChild(cell);
19832
- row.parentNode.insertBefore(rowElement, row);
19833
- builder.applyBehavior(); //re-add tool
20039
+ row.parentNode.insertBefore(rowElement, row); //re-add tool
19834
20040
 
20041
+ let builderActive = document.querySelector('.builder-active');
20042
+ builder.applyBehaviorOn(builderActive);
19835
20043
  columnTool.position(cell);
19836
20044
  cell.click(); //refresh active cell/row
19837
20045
 
@@ -19887,9 +20095,10 @@ class Grid {
19887
20095
  row.nextElementSibling.appendChild(cell); //add
19888
20096
 
19889
20097
  row.parentNode.removeChild(row); //remove current (empty) row (including its overlay)
20098
+ //re-add tool
19890
20099
 
19891
- builder.applyBehavior(); //re-add tool
19892
-
20100
+ let builderActive = document.querySelector('.builder-active');
20101
+ builder.applyBehaviorOn(builderActive);
19893
20102
  columnTool.position(cell);
19894
20103
  cell.click(); //refresh active cell/row
19895
20104
 
@@ -19904,9 +20113,10 @@ class Grid {
19904
20113
  var rowElement = row.cloneNode(true);
19905
20114
  rowElement.innerHTML = '';
19906
20115
  rowElement.appendChild(cell);
19907
- dom$A.moveAfter(rowElement, row);
19908
- builder.applyBehavior(); //re-add tool
20116
+ dom$A.moveAfter(rowElement, row); //re-add tool
19909
20117
 
20118
+ let builderActive = document.querySelector('.builder-active');
20119
+ builder.applyBehaviorOn(builderActive);
19910
20120
  columnTool.position(cell);
19911
20121
  cell.click(); //refresh active cell/row
19912
20122
 
@@ -19950,8 +20160,10 @@ class Grid {
19950
20160
  }
19951
20161
 
19952
20162
  row.insertBefore(cellElement, cell);
19953
- util.fixLayout(row, builder);
19954
- builder.applyBehavior();
20163
+ util.fixLayout(row, builder); //re-add tool
20164
+
20165
+ let builderActive = document.querySelector('.builder-active');
20166
+ builder.applyBehaviorOn(builderActive);
19955
20167
  columnTool.position(cell);
19956
20168
  cell.click(); //refresh active cell/row
19957
20169
 
@@ -20455,8 +20667,10 @@ class Grid {
20455
20667
  cols = dom$A.elementChildren(row);
20456
20668
  cols.forEach(col => {
20457
20669
  dom$A.removeClass(col, 'cell-active');
20458
- });
20459
- builder.applyBehavior();
20670
+ }); //re-add tool
20671
+
20672
+ let builderActive = document.querySelector('.builder-active');
20673
+ builder.applyBehaviorOn(builderActive);
20460
20674
  this.rowTool.position(rowElement);
20461
20675
  this.builder.opts.onChange();
20462
20676
  } // Utilities
@@ -50433,7 +50647,8 @@ class Module {
50433
50647
 
50434
50648
  i++;
50435
50649
  });
50436
- this.builder.applyBehavior(); //Trigger Change event
50650
+ let builderActive = document.querySelector('.builder-active');
50651
+ if (builderActive) this.builder.applyBehaviorOn(builderActive); //Trigger Change event
50437
50652
 
50438
50653
  this.builder.opts.onChange(); //Trigger Render event
50439
50654
 
@@ -50615,7 +50830,8 @@ class Code {
50615
50830
  var range = document.createRange();
50616
50831
  range.setStart(codeblock, 0);
50617
50832
  codeblock.appendChild(range.createContextualFragment(html));
50618
- this.builder.applyBehavior(); //Trigger Change event
50833
+ let builderActive = document.querySelector('.builder-active');
50834
+ if (builderActive) this.builder.applyBehaviorOn(builderActive); //Trigger Change event
50619
50835
 
50620
50836
  this.builder.opts.onChange(); //Trigger Render event
50621
50837
 
@@ -50780,7 +50996,8 @@ class Iframe {
50780
50996
  }
50781
50997
 
50782
50998
  this.builder.activeIframe = iframeParent.querySelector('iframe');
50783
- this.builder.applyBehavior(); //Trigger Change event
50999
+ let builderActive = document.querySelector('.builder-active');
51000
+ if (builderActive) this.builder.applyBehaviorOn(builderActive); //Trigger Change event
50784
51001
 
50785
51002
  this.builder.opts.onChange();
50786
51003
  }
@@ -60123,7 +60340,8 @@ class ElementTool {
60123
60340
  setTimeout(() => {
60124
60341
  newelm.click();
60125
60342
  this.position(newelm);
60126
- this.builder.applyBehavior(); //Trigger Change event
60343
+ let builderActive = document.querySelector('.builder-active');
60344
+ if (builderActive) this.builder.applyBehaviorOn(builderActive); //Trigger Change event
60127
60345
 
60128
60346
  this.builder.opts.onChange();
60129
60347
  }, 100); //Timeout needed by Safari
@@ -62059,7 +62277,8 @@ class Rte {
62059
62277
  let fileToInsert = modalInsertImage.querySelector('#imgInsertImagePreview').getAttribute('data-filename');
62060
62278
  util.pasteHtmlAtCaret('<img data-filename="' + fileToInsert + '" src="' + val + '" alt="" />', false);
62061
62279
  util.hideModal(modalInsertImage);
62062
- this.builder.applyBehavior(); //save selection
62280
+ let builderActive = document.querySelector('.builder-active');
62281
+ if (builderActive) this.builder.applyBehaviorOn(builderActive); //save selection
62063
62282
 
62064
62283
  util.saveSelection(); //Trigger Change event
62065
62284
 
@@ -62258,8 +62477,9 @@ class Rte {
62258
62477
  let scale = val / 100;
62259
62478
  this.builder.opts.zoom = scale;
62260
62479
  localStorage.setItem('_zoom', scale); // Save
62480
+ // setZoomOnArea
62261
62481
 
62262
- this.builder.setZoom(); // hide tools
62482
+ this.builder.setZoomOnArea(); // hide tools
62263
62483
 
62264
62484
  let tools = this.builderStuff.querySelectorAll('.is-tool');
62265
62485
  Array.prototype.forEach.call(tools, tool => {
@@ -62285,7 +62505,18 @@ class Rte {
62285
62505
 
62286
62506
  this.rteZoomSlider.onchange = () => {
62287
62507
  setTimeout(() => {
62288
- // show & reposition
62508
+ // setZoomOnControl
62509
+ if (this.builder.opts.page !== '') {
62510
+ const wrapper = document.querySelector(this.opts.page);
62511
+ this.builder.setZoomOnControl(wrapper);
62512
+ } else {
62513
+ const builders = document.querySelectorAll(this.builder.opts.container);
62514
+ builders.forEach(builder => {
62515
+ this.builder.setZoomOnControl(builder);
62516
+ });
62517
+ } // show & reposition
62518
+
62519
+
62289
62520
  this.builder.elmTool.repositionElementTool();
62290
62521
  let col = this.builder.activeCol;
62291
62522
  let tool = this.builderStuff.querySelector('.is-column-tool');
@@ -62436,8 +62667,10 @@ class Rte {
62436
62667
  dom$5.selectElementContents(elm);
62437
62668
  document.execCommand('italic', false, null);
62438
62669
  } else {
62439
- if (elm.style.fontStyle === 'italic') {
62440
- elm.style.fontStyle = '';
62670
+ let fontStyle = window.getComputedStyle(elm).getPropertyValue('font-style');
62671
+
62672
+ if (fontStyle === 'italic') {
62673
+ elm.style.fontStyle = 'normal';
62441
62674
  } else {
62442
62675
  elm.style.fontStyle = 'italic';
62443
62676
  }
@@ -62494,10 +62727,18 @@ class Rte {
62494
62727
  }
62495
62728
 
62496
62729
  if (command === 'uppercase') {
62497
- if (elm.style.textTransform === 'uppercase') {
62498
- elm.style.textTransform = '';
62499
- } else {
62730
+ let textTransform = window.getComputedStyle(elm).getPropertyValue('text-transform');
62731
+
62732
+ if (textTransform === 'uppercase') {
62733
+ elm.style.textTransform = 'lowercase';
62734
+ } else if (textTransform === 'lowercase') {
62735
+ elm.style.textTransform = 'capitalize';
62736
+ } else if (textTransform === 'capitalize') {
62737
+ elm.style.textTransform = 'none';
62738
+ } else if (textTransform === 'none') {
62500
62739
  elm.style.textTransform = 'uppercase';
62740
+ } else {
62741
+ elm.style.textTransform = 'none';
62501
62742
  }
62502
62743
  }
62503
62744
 
@@ -66094,6 +66335,7 @@ class ContentBuilder {
66094
66335
  zoom: 1,
66095
66336
  useLightbox: false,
66096
66337
  imageRenameOnEdit: true,
66338
+ disableAutoEmbedVideo: false,
66097
66339
 
66098
66340
  /*
66099
66341
  onZoomStart: () => {
@@ -66265,10 +66507,6 @@ class ContentBuilder {
66265
66507
  const util = new Util(this); // General utilities
66266
66508
 
66267
66509
  this.util = util;
66268
- /** added by Jack */
66269
-
66270
- this.cbDom = new Dom(); // ---
66271
-
66272
66510
  this.isTouchSupport = util.isTouchSupport();
66273
66511
  this.isIE = util.detectIE();
66274
66512
 
@@ -66279,6 +66517,7 @@ class ContentBuilder {
66279
66517
  this.uoTm = null;
66280
66518
  this.uo = new UndoRedo(this);
66281
66519
  this.dom = dom$F;
66520
+ this.cbDom = dom$F;
66282
66521
  this.autoclean = false;
66283
66522
  this.filesAdded = '';
66284
66523
 
@@ -66301,9 +66540,19 @@ class ContentBuilder {
66301
66540
  this.preferences = new Preferences(this); // this will also call setUIColor() and getUIStyles() for theme
66302
66541
 
66303
66542
  renderGridEditor(this); // Render Grid Editor
66543
+ // Check if preview
66544
+ // Get all builder areas
66304
66545
 
66305
- if (this.opts.snippetJSON.snippets.length > 0) {
66306
- renderSnippetPanel(this); // Render Snippet Panel
66546
+ this.preview = false;
66547
+ const builders = document.querySelectorAll(this.opts.container);
66548
+ Array.prototype.forEach.call(builders, builder => {
66549
+ if (dom$F.hasClass(builder, 'preview')) this.preview = true;
66550
+ });
66551
+
66552
+ if (!this.preview) {
66553
+ if (this.opts.snippetJSON.snippets.length > 0) {
66554
+ renderSnippetPanel(this); // Render Snippet Panel
66555
+ }
66307
66556
  }
66308
66557
 
66309
66558
  this.colTool = new ColumnTool(this); // Render Column Tool
@@ -66334,26 +66583,28 @@ class ContentBuilder {
66334
66583
  this.rte = new Rte(this);
66335
66584
  this.tooltip = new Tooltip(this);
66336
66585
  this.lightbox = new Lightbox(this);
66337
- this.applyBehavior(); // Apply editing behavior on content (builder areas)
66586
+ if (!this.preview) this.applyBehavior(); // Apply editing behavior on content (builder areas)
66338
66587
  // Load plugins
66339
66588
 
66340
- if (this.opts.plugins.length > 0) {
66341
- // Option to load plugins without config.js => just use plugins param (and specify the pluginPath).
66342
- this.loadPlugins();
66343
- } else {
66344
- if (typeof this.opts.scriptPath === 'undefined' && this.opts.pluginPath === '') ; else {
66345
- // Backward compatibility
66346
- if (!this.opts.disableConfig) {
66347
- let scriptUrl = this.opts.scriptPath + 'config.js';
66348
- if (this.opts.pluginPath !== '') scriptUrl = this.opts.pluginPath + 'config.js'; // overide plugin location if pluginPath is specified
66349
-
66350
- this.loadScript(scriptUrl).then(() => {
66351
- if (this.opts.plugins.length > 0) {
66352
- this.loadPlugins();
66353
- }
66354
- }, () => {
66355
- console.log('Fail to load config');
66356
- });
66589
+ if (!this.preview) {
66590
+ if (this.opts.plugins.length > 0) {
66591
+ // Option to load plugins without config.js => just use plugins param (and specify the pluginPath).
66592
+ this.loadPlugins();
66593
+ } else {
66594
+ if (typeof this.opts.scriptPath === 'undefined' && this.opts.pluginPath === '') ; else {
66595
+ // Backward compatibility
66596
+ if (!this.opts.disableConfig) {
66597
+ let scriptUrl = this.opts.scriptPath + 'config.js';
66598
+ if (this.opts.pluginPath !== '') scriptUrl = this.opts.pluginPath + 'config.js'; // overide plugin location if pluginPath is specified
66599
+
66600
+ this.loadScript(scriptUrl).then(() => {
66601
+ if (this.opts.plugins.length > 0) {
66602
+ this.loadPlugins();
66603
+ }
66604
+ }, () => {
66605
+ console.log('Fail to load config');
66606
+ });
66607
+ }
66357
66608
  }
66358
66609
  }
66359
66610
  } // Tooltip (move to after plugins loaded)
@@ -66525,9 +66776,11 @@ class ContentBuilder {
66525
66776
  }
66526
66777
 
66527
66778
  setZoom() {
66779
+ // Complete (On Area + On Control)
66528
66780
  if (this.opts.page !== '') {
66529
66781
  const wrapper = document.querySelector(this.opts.page);
66530
66782
  wrapper.style.transform = `scale(${this.opts.zoom})`;
66783
+ this.setZoomOnControl(wrapper);
66531
66784
  } else {
66532
66785
  const builders = document.querySelectorAll(this.opts.container);
66533
66786
  builders.forEach(builder => {
@@ -66546,18 +66799,10 @@ class ContentBuilder {
66546
66799
  builder.style.transition = '';
66547
66800
  }, 300);
66548
66801
  }
66802
+
66803
+ this.setZoomOnControl(builder);
66549
66804
  });
66550
66805
  }
66551
-
66552
- const rowtools = document.querySelectorAll('.is-row-tool');
66553
- rowtools.forEach(rowtool => {
66554
- rowtool.style.transform = `scale(${1 / this.opts.zoom})`;
66555
- rowtool.style.transformOrigin = 'top';
66556
- });
66557
- const rowaddtools = document.querySelectorAll('.is-rowadd-tool button');
66558
- rowaddtools.forEach(rowaddtool => {
66559
- rowaddtool.style.transform = `scale(${1 / this.opts.zoom})`; // rowtool.style.transformOrigin = 'top';
66560
- });
66561
66806
  /*
66562
66807
  if(this.opts.zoom<1) {
66563
66808
  let ss = document.styleSheets;
@@ -66572,296 +66817,342 @@ class ContentBuilder {
66572
66817
  }
66573
66818
  }
66574
66819
  */
66820
+
66821
+ }
66822
+
66823
+ setZoomOnControl(area) {
66824
+ const rowtools = area.querySelectorAll('.is-row-tool');
66825
+ rowtools.forEach(rowtool => {
66826
+ rowtool.style.transform = `scale(${1 / this.opts.zoom})`;
66827
+ rowtool.style.transformOrigin = 'top';
66828
+ });
66829
+ const rowaddtools = area.querySelectorAll('.is-rowadd-tool button');
66830
+ rowaddtools.forEach(rowaddtool => {
66831
+ rowaddtool.style.transform = `scale(${1 / this.opts.zoom})`; // rowtool.style.transformOrigin = 'top';
66832
+ });
66833
+ }
66834
+
66835
+ setZoomOnArea() {
66836
+ if (this.opts.page !== '') {
66837
+ const wrapper = document.querySelector(this.opts.page);
66838
+ wrapper.style.transform = `scale(${this.opts.zoom})`;
66839
+ } else {
66840
+ const builders = document.querySelectorAll(this.opts.container);
66841
+ builders.forEach(builder => {
66842
+ let fade = false; // to prevent initial load animation
66843
+
66844
+ if (!builder.style.transform) fade = true;
66845
+
66846
+ if (fade) {
66847
+ builder.style.transition = 'none';
66848
+ }
66849
+
66850
+ builder.style.transform = `scale(${this.opts.zoom})`;
66851
+
66852
+ if (fade) {
66853
+ setTimeout(() => {
66854
+ builder.style.transition = '';
66855
+ }, 300);
66856
+ }
66857
+ });
66858
+ }
66575
66859
  }
66576
66860
 
66577
66861
  applyBehavior() {
66578
- const util = this.util; // Get all builder areas
66862
+ // Zoom (required by the next process, eg. setZoomOnControl)
66863
+ if (localStorage.getItem('_zoom') !== null) {
66864
+ this.opts.zoom = localStorage.getItem('_zoom'); // Get from saved localStorage
66865
+ }
66866
+
66867
+ this.rte.rteZoomSlider.value = this.opts.zoom * 100; // Set slider value
66868
+ // Get all builder areas
66579
66869
 
66580
66870
  const builders = document.querySelectorAll(this.opts.container);
66581
66871
  Array.prototype.forEach.call(builders, builder => {
66582
- //Make absolute
66583
- if (this.opts.absolutePath) {
66584
- let links = builder.querySelectorAll('a');
66585
- Array.prototype.forEach.call(links, link => {
66586
- let href = link.href;
66587
- link.setAttribute('href', href);
66588
- });
66589
- let imgs = builder.querySelectorAll('img');
66590
- Array.prototype.forEach.call(imgs, img => {
66591
- let src = img.src;
66592
- img.setAttribute('src', src);
66593
- });
66594
- } // Add .is-builder class on each builder area (container)
66872
+ this.applyBehaviorOn(builder); // includes setZoomOnControl
66873
+ }); // Call onRender to indicate content is ready for editing (applyBehavior has been applied)
66874
+
66875
+ this.opts.onRender();
66876
+ this.setZoomOnArea(); // Set zoom
66877
+ } // applyBehavior
66878
+
66879
+
66880
+ applyBehaviorOn(builder) {
66881
+ const util = this.util; //Make absolute
66882
+
66883
+ if (this.opts.absolutePath) {
66884
+ let links = builder.querySelectorAll('a');
66885
+ Array.prototype.forEach.call(links, link => {
66886
+ let href = link.href;
66887
+ link.setAttribute('href', href);
66888
+ });
66889
+ let imgs = builder.querySelectorAll('img');
66890
+ Array.prototype.forEach.call(imgs, img => {
66891
+ let src = img.src;
66892
+ img.setAttribute('src', src);
66893
+ });
66894
+ } // Add .is-builder class on each builder area (container)
66595
66895
 
66596
66896
 
66597
- dom$F.addClass(builder, 'is-builder'); // Additional setting needed for dynamically added .is-builder. Without this, current toolStyle won't be applied to newly created section (eg. in ContentBox))
66598
- // if (localStorage.getItem('_toolstyle') !== null) {
66599
- // let toolStyle = localStorage.getItem('_toolstyle');
66600
- // this.preferences.setToolStyle(toolStyle);
66601
- // }
66602
- // if (localStorage.getItem('_outlinestyle') !== null) {
66603
- // let outlineStyle = localStorage.getItem('_outlinestyle');
66604
- // this.preferences.setOutlineStyle(outlineStyle);
66605
- // }
66897
+ dom$F.addClass(builder, 'is-builder'); // Additional setting needed for dynamically added .is-builder. Without this, current toolStyle won't be applied to newly created section (eg. in ContentBox))
66898
+ // if (localStorage.getItem('_toolstyle') !== null) {
66899
+ // let toolStyle = localStorage.getItem('_toolstyle');
66900
+ // this.preferences.setToolStyle(toolStyle);
66901
+ // }
66902
+ // if (localStorage.getItem('_outlinestyle') !== null) {
66903
+ // let outlineStyle = localStorage.getItem('_outlinestyle');
66904
+ // this.preferences.setOutlineStyle(outlineStyle);
66905
+ // }
66606
66906
 
66607
- this.preferences.initBuilder(builder); // Apply behavior on each row
66907
+ this.preferences.initBuilder(builder); // Apply behavior on each row
66608
66908
 
66609
- const rows = dom$F.elementChildren(builder);
66610
- rows.forEach(row => {
66611
- if (dom$F.hasClass(row, 'row-add-initial')) return; // Hack. If a row has margin left/right specified, don't need to set hidden border (that is used to make smooth sortable)
66909
+ const rows = dom$F.elementChildren(builder);
66910
+ rows.forEach(row => {
66911
+ if (dom$F.hasClass(row, 'row-add-initial')) return; // Hack. If a row has margin left/right specified, don't need to set hidden border (that is used to make smooth sortable)
66612
66912
 
66613
- if (row.style.marginLeft || row.style.marginRight) {
66614
- row.style.border = 'none';
66615
- } // On each row, add 2 tools: Row tool (div.is-row-tool) & Row Add tool (div.is-rowadd-tool)
66616
- // Render Row tool
66913
+ if (row.style.marginLeft || row.style.marginRight) {
66914
+ row.style.border = 'none';
66915
+ } // On each row, add 2 tools: Row tool (div.is-row-tool) & Row Add tool (div.is-rowadd-tool)
66916
+ // Render Row tool
66617
66917
 
66618
66918
 
66619
- this.rowtool = new RowTool(this);
66620
- this.rowtool.render(row); // Render Row Add tool
66919
+ this.rowtool = new RowTool(this);
66920
+ this.rowtool.render(row); // Render Row Add tool
66621
66921
 
66622
- const rowaddtool = new RowAddTool(this);
66623
- rowaddtool.render(row); // Apply behavior on each column
66922
+ const rowaddtool = new RowAddTool(this);
66923
+ rowaddtool.render(row); // Apply behavior on each column
66624
66924
 
66625
- const cols = dom$F.elementChildren(row);
66626
- cols.forEach(col => {
66627
- if (dom$F.hasClass(col, 'is-row-tool') || dom$F.hasClass(col, 'is-rowadd-tool')) return; // Return if not a column
66628
- // For backward compatibility, replace:
66629
- // - data-mode="readonly" with data-noedit
66630
- // - data-mode="readonly-protected" with data-protected
66925
+ const cols = dom$F.elementChildren(row);
66926
+ cols.forEach(col => {
66927
+ if (dom$F.hasClass(col, 'is-row-tool') || dom$F.hasClass(col, 'is-rowadd-tool')) return; // Return if not a column
66928
+ // For backward compatibility, replace:
66929
+ // - data-mode="readonly" with data-noedit
66930
+ // - data-mode="readonly-protected" with data-protected
66631
66931
 
66632
- if (col.getAttribute('data-mode') === 'readonly') {
66633
- col.setAttribute('data-noedit', '');
66634
- col.removeAttribute('data-mode');
66635
- }
66932
+ if (col.getAttribute('data-mode') === 'readonly') {
66933
+ col.setAttribute('data-noedit', '');
66934
+ col.removeAttribute('data-mode');
66935
+ }
66636
66936
 
66637
- if (col.getAttribute('data-mode') === 'readonly-protected') {
66638
- col.setAttribute('data-protected', '');
66639
- col.removeAttribute('data-mode');
66640
- } // Set ContentEditable
66937
+ if (col.getAttribute('data-mode') === 'readonly-protected') {
66938
+ col.setAttribute('data-protected', '');
66939
+ col.removeAttribute('data-mode');
66940
+ } // Set ContentEditable
66641
66941
 
66642
66942
 
66643
- let noedit = false;
66943
+ let noedit = false;
66644
66944
 
66645
- if (col.hasAttribute('data-noedit')) {
66646
- // Column is not (text) editable.
66647
- noedit = true;
66648
- }
66945
+ if (col.hasAttribute('data-noedit')) {
66946
+ // Column is not (text) editable.
66947
+ noedit = true;
66948
+ }
66649
66949
 
66650
- let _protected = false;
66950
+ let _protected = false;
66651
66951
 
66652
- if (col.hasAttribute('data-protected')) {
66653
- // Column is not (text) editable and also: cannot be deleted, moved or duplicated.
66654
- _protected = true;
66655
- }
66952
+ if (col.hasAttribute('data-protected')) {
66953
+ // Column is not (text) editable and also: cannot be deleted, moved or duplicated.
66954
+ _protected = true;
66955
+ }
66656
66956
 
66657
- let customcode = false;
66957
+ let customcode = false;
66658
66958
 
66659
- if (col.hasAttribute('data-html')) {
66660
- // Column contains custom code.
66661
- customcode = true;
66662
- } // let custommodule = false;
66663
- // if (col.hasAttribute('data-module')) { // Column contains custom module.
66664
- // custommodule = true;
66665
- // }
66959
+ if (col.hasAttribute('data-html')) {
66960
+ // Column contains custom code.
66961
+ customcode = true;
66962
+ } // let custommodule = false;
66963
+ // if (col.hasAttribute('data-module')) { // Column contains custom module.
66964
+ // custommodule = true;
66965
+ // }
66666
66966
 
66667
66967
 
66668
- if (!customcode && !noedit && !_protected) {
66669
- // Check if column contains editable text
66670
- let elms = col.querySelectorAll('p,h1,h2,h3,h4,h5,h6,table,ul,ol,pre,blockquote,code,figcaption,label,legend,button,a');
66968
+ if (!customcode && !noedit && !_protected) {
66969
+ // Check if column contains editable text
66970
+ let elms = col.querySelectorAll('p,h1,h2,h3,h4,h5,h6,table,ul,ol,pre,blockquote,code,figcaption,label,legend,button,a');
66671
66971
 
66672
- if (elms.length > 0) {
66673
- col.contentEditable = true; // Column is (text) editable
66674
- }
66675
- } // Apply behavior on several elements for editing purpose
66972
+ if (elms.length > 0) {
66973
+ col.contentEditable = true; // Column is (text) editable
66974
+ }
66975
+ } // Apply behavior on several elements for editing purpose
66676
66976
 
66677
66977
 
66678
- this.element.applyBehavior(col); // Add events on column
66978
+ this.element.applyBehavior(col); // Add events on column
66679
66979
 
66680
- if (!col.getAttribute('data-click')) {
66681
- // ON CLICK
66682
- // Use bind() => https://www.w3schools.com/react/react_events.asp
66683
- col.addEventListener('click', this.handleCellClick.bind(this, col)); // ON KEYPRESS
66980
+ if (!col.getAttribute('data-click')) {
66981
+ // ON CLICK
66982
+ // Use bind() => https://www.w3schools.com/react/react_events.asp
66983
+ col.addEventListener('click', this.handleCellClick.bind(this, col)); // ON KEYPRESS
66684
66984
 
66685
- col.addEventListener('keydown', this.handleCellKeypress.bind(this)); // ON KEYDOWN
66985
+ col.addEventListener('keydown', this.handleCellKeypress.bind(this)); // ON KEYDOWN
66686
66986
 
66687
- col.addEventListener('keydown', this.handleCellKeydown.bind(this, col)); // ON KEYUP
66987
+ col.addEventListener('keydown', this.handleCellKeydown.bind(this, col)); // ON KEYUP
66688
66988
 
66689
- col.addEventListener('keyup', this.handleCellKeyup.bind(this, col)); // ON PASTE
66989
+ col.addEventListener('keyup', this.handleCellKeyup.bind(this, col)); // ON PASTE
66690
66990
 
66691
- col.addEventListener('paste', this.handleCellPaste.bind(this));
66692
- col.setAttribute('data-click', true);
66693
- }
66694
- });
66695
- }); // Sortable on each builder (container)
66991
+ col.addEventListener('paste', this.handleCellPaste.bind(this));
66992
+ col.setAttribute('data-click', true);
66993
+ }
66994
+ });
66995
+ }); // Sortable on each builder (container)
66696
66996
 
66697
- if (!builder.getAttribute('data-sort') && !builder.hasAttribute('nogrid')) {
66698
- // Check first if sortable has been added.
66997
+ if (!builder.getAttribute('data-sort') && !builder.hasAttribute('nogrid')) {
66998
+ // Check first if sortable has been added.
66699
66999
 
66700
- /*
66701
- let userAgentString = navigator.userAgent;
66702
- let safariAgent = userAgentString.indexOf('Safari') > -1;
66703
- let chromeAgent = userAgentString.indexOf('Chrome') > -1;
66704
- if ((chromeAgent) && (safariAgent)) safariAgent = false;
66705
- */
66706
- // let safariAgent = false;
66707
- let sortableObject = new Sortable(builder, {
66708
- // forceFallback: safariAgent,
66709
- // forceFallback: true,
66710
- scroll: true,
66711
- // invertSwap: true, /* https://github.com/SortableJS/Sortable/wiki/Swap-Thresholds-and-Direction#swap-threshold */
66712
- group: 'shared',
66713
- direction: 'dummy',
66714
- animation: 300,
66715
- handle: '.row-handle',
66716
- // swapThreshold: 0.1, // this cause drag drop snippet sometimes difficult
66717
- // invertedSwapThreshold: 0.1,
66718
- sort: true,
66719
- onStart: () => {
66720
- this.uo.saveForUndo(); // Even if cancelled, saveForUndo will make sure not to save if there is no change
66721
-
66722
- this.colTool.hideColumnTool();
66723
- this.elmTool.hide();
66724
- },
66725
- onEnd: () => {
66726
- if (!this.opts.emailMode) {
66727
- if (dom$F.hasClass(this.activeCol.parentNode, 'row-outline')) {
66728
- //if not row selection, but col selection
66729
- //if(this.activeCol.parentNode.classList.contains('row-outline')) { //if not row selection, but col selection
66730
- this.colTool.refreshColumnTool(this.activeCol);
66731
- this.colTool.showColumnTool(this.activeCol);
66732
- }
67000
+ /*
67001
+ let userAgentString = navigator.userAgent;
67002
+ let safariAgent = userAgentString.indexOf('Safari') > -1;
67003
+ let chromeAgent = userAgentString.indexOf('Chrome') > -1;
67004
+ if ((chromeAgent) && (safariAgent)) safariAgent = false;
67005
+ */
67006
+ // let safariAgent = false;
67007
+ let sortableObject = new Sortable(builder, {
67008
+ // forceFallback: safariAgent,
67009
+ // forceFallback: true,
67010
+ scroll: true,
67011
+ // invertSwap: true, /* https://github.com/SortableJS/Sortable/wiki/Swap-Thresholds-and-Direction#swap-threshold */
67012
+ group: 'shared',
67013
+ direction: 'dummy',
67014
+ animation: 300,
67015
+ handle: '.row-handle',
67016
+ // swapThreshold: 0.1, // this cause drag drop snippet sometimes difficult
67017
+ // invertedSwapThreshold: 0.1,
67018
+ sort: true,
67019
+ onStart: () => {
67020
+ this.uo.saveForUndo(); // Even if cancelled, saveForUndo will make sure not to save if there is no change
67021
+
67022
+ this.colTool.hideColumnTool();
67023
+ this.elmTool.hide();
67024
+ },
67025
+ onEnd: () => {
67026
+ if (!this.opts.emailMode) {
67027
+ if (dom$F.hasClass(this.activeCol.parentNode, 'row-outline')) {
67028
+ //if not row selection, but col selection
67029
+ //if(this.activeCol.parentNode.classList.contains('row-outline')) { //if not row selection, but col selection
67030
+ this.colTool.refreshColumnTool(this.activeCol);
67031
+ this.colTool.showColumnTool(this.activeCol);
66733
67032
  }
66734
- },
66735
- onAdd: evt => {
66736
- var itemEl = evt.item;
67033
+ }
67034
+ },
67035
+ onAdd: evt => {
67036
+ var itemEl = evt.item;
66737
67037
 
66738
- if (itemEl.getAttribute('data-id')) {
66739
- // If has data-id attribute, the dropped item is from snippet panel (snippetpanel.js)
66740
- let snippetid = itemEl.getAttribute('data-id'); // snippetJSON is snippet's JSON (from assets/minimalist-blocks/content.js) that store all snippets' html
67038
+ if (itemEl.getAttribute('data-id')) {
67039
+ // If has data-id attribute, the dropped item is from snippet panel (snippetpanel.js)
67040
+ let snippetid = itemEl.getAttribute('data-id'); // snippetJSON is snippet's JSON (from assets/minimalist-blocks/content.js) that store all snippets' html
66741
67041
 
66742
- const result = this.opts.snippetJSON.snippets.filter(item => {
66743
- if (item.id + '' === snippetid) return item;else return false;
66744
- });
66745
- var html = result[0].html;
66746
- var noedit = result[0].noedit;
66747
- var bSnippet;
67042
+ const result = this.opts.snippetJSON.snippets.filter(item => {
67043
+ if (item.id + '' === snippetid) return item;else return false;
67044
+ });
67045
+ var html = result[0].html;
67046
+ var noedit = result[0].noedit;
67047
+ var bSnippet;
66748
67048
 
66749
- if (html.indexOf('row clearfix') === -1) {
66750
- bSnippet = true; // Just snippet (without row/column grid)
66751
- } else {
66752
- bSnippet = false; // Snippet is wrapped in row/colum
66753
- }
67049
+ if (html.indexOf('row clearfix') === -1) {
67050
+ bSnippet = true; // Just snippet (without row/column grid)
67051
+ } else {
67052
+ bSnippet = false; // Snippet is wrapped in row/colum
67053
+ }
66754
67054
 
66755
- if (this.opts.emailMode) bSnippet = false; // Convert snippet into your defined 12 columns grid
67055
+ if (this.opts.emailMode) bSnippet = false; // Convert snippet into your defined 12 columns grid
66756
67056
 
66757
- var rowClass = this.opts.row; //row
67057
+ var rowClass = this.opts.row; //row
66758
67058
 
66759
- var colClass = this.opts.cols; //['col s1', 'col s2', 'col s3', 'col s4', 'col s5', 'col s6', 'col s7', 'col s8', 'col s9', 'col s10', 'col s11', 'col s12']
67059
+ var colClass = this.opts.cols; //['col s1', 'col s2', 'col s3', 'col s4', 'col s5', 'col s6', 'col s7', 'col s8', 'col s9', 'col s10', 'col s11', 'col s12']
66760
67060
 
66761
- if (rowClass !== '' && colClass.length === 12) {
66762
- html = html.replace(new RegExp('row clearfix', 'g'), rowClass);
66763
- html = html.replace(new RegExp('column full', 'g'), colClass[11]);
66764
- html = html.replace(new RegExp('column half', 'g'), colClass[5]);
66765
- html = html.replace(new RegExp('column third', 'g'), colClass[3]);
66766
- html = html.replace(new RegExp('column fourth', 'g'), colClass[2]);
66767
- html = html.replace(new RegExp('column fifth', 'g'), colClass[1]);
66768
- html = html.replace(new RegExp('column sixth', 'g'), colClass[1]);
66769
- html = html.replace(new RegExp('column two-third', 'g'), colClass[7]);
66770
- html = html.replace(new RegExp('column two-fourth', 'g'), colClass[8]);
66771
- html = html.replace(new RegExp('column two-fifth', 'g'), colClass[9]);
66772
- html = html.replace(new RegExp('column two-sixth', 'g'), colClass[9]);
66773
- }
67061
+ if (rowClass !== '' && colClass.length === 12) {
67062
+ html = html.replace(new RegExp('row clearfix', 'g'), rowClass);
67063
+ html = html.replace(new RegExp('column full', 'g'), colClass[11]);
67064
+ html = html.replace(new RegExp('column half', 'g'), colClass[5]);
67065
+ html = html.replace(new RegExp('column third', 'g'), colClass[3]);
67066
+ html = html.replace(new RegExp('column fourth', 'g'), colClass[2]);
67067
+ html = html.replace(new RegExp('column fifth', 'g'), colClass[1]);
67068
+ html = html.replace(new RegExp('column sixth', 'g'), colClass[1]);
67069
+ html = html.replace(new RegExp('column two-third', 'g'), colClass[7]);
67070
+ html = html.replace(new RegExp('column two-fourth', 'g'), colClass[8]);
67071
+ html = html.replace(new RegExp('column two-fifth', 'g'), colClass[9]);
67072
+ html = html.replace(new RegExp('column two-sixth', 'g'), colClass[9]);
67073
+ }
66774
67074
 
66775
- html = html.replace(/{id}/g, util.makeId()); // Replace {id} with auto generated id (for custom code snippet)
67075
+ html = html.replace(/{id}/g, util.makeId()); // Replace {id} with auto generated id (for custom code snippet)
66776
67076
 
66777
- if (this.opts.onAdd) {
66778
- html = this.opts.onAdd(html);
66779
- }
67077
+ if (this.opts.onAdd) {
67078
+ html = this.opts.onAdd(html);
67079
+ }
66780
67080
 
66781
- if (this.opts.snippetPathReplace.length > 0) {
66782
- // try {
66783
- if (this.opts.snippetPathReplace[0] !== '') {
66784
- var regex = new RegExp(this.opts.snippetPathReplace[0], 'g');
66785
- html = html.replace(regex, this.opts.snippetPathReplace[1]);
66786
- var string1 = this.opts.snippetPathReplace[0].replace(/\//g, '%2F');
66787
- var string2 = this.opts.snippetPathReplace[1].replace(/\//g, '%2F');
66788
- var regex2 = new RegExp(string1, 'g');
66789
- html = html.replace(regex2, string2);
66790
- } // } catch (e) { 1; }
67081
+ if (this.opts.snippetPathReplace.length > 0) {
67082
+ // try {
67083
+ if (this.opts.snippetPathReplace[0] !== '') {
67084
+ var regex = new RegExp(this.opts.snippetPathReplace[0], 'g');
67085
+ html = html.replace(regex, this.opts.snippetPathReplace[1]);
67086
+ var string1 = this.opts.snippetPathReplace[0].replace(/\//g, '%2F');
67087
+ var string2 = this.opts.snippetPathReplace[1].replace(/\//g, '%2F');
67088
+ var regex2 = new RegExp(string1, 'g');
67089
+ html = html.replace(regex2, string2);
67090
+ } // } catch (e) { 1; }
66791
67091
 
66792
- }
67092
+ }
66793
67093
 
66794
- if (bSnippet) {
66795
- // Just snippet (without row/column grid), ex. buttons, line, social, video, map.
66796
- // Can be inserted after current row, column (cell), element, or last row.
66797
- html = `<div class="${this.opts.row}"><div class="${this.opts.cols[this.opts.cols.length - 1]}"${noedit ? ' data-noedit' : ''}>${html}</div></div>`; // Clean snippet from sortable related code
67094
+ if (bSnippet) {
67095
+ // Just snippet (without row/column grid), ex. buttons, line, social, video, map.
67096
+ // Can be inserted after current row, column (cell), element, or last row.
67097
+ html = `<div class="${this.opts.row}"><div class="${this.opts.cols[this.opts.cols.length - 1]}"${noedit ? ' data-noedit' : ''}>${html}</div></div>`; // Clean snippet from sortable related code
66798
67098
 
66799
- itemEl.removeAttribute('draggable');
66800
- dom$F.removeClass(itemEl, 'snippet-item');
66801
- itemEl.outerHTML = html;
66802
- } else {
66803
- // Snippet is wrapped in row/colum (may contain custom code or has [data-html] attribute)
66804
- // Can only be inserted after current row or last row (not on column or element).
66805
- let snippet = dom$F.createElement('div');
66806
- snippet.innerHTML = html;
66807
- let blocks = snippet.querySelectorAll('[data-html]');
66808
- Array.prototype.forEach.call(blocks, block => {
66809
- // Render custom code block
66810
- html = decodeURIComponent(block.getAttribute('data-html'));
66811
- html = html.replace(/{id}/g, util.makeId());
66812
-
66813
- for (var i = 1; i <= 20; i++) {
66814
- html = html.replace('[%HTML' + i + '%]', block.getAttribute('data-html-' + i) === undefined ? '' : decodeURIComponent(block.getAttribute('data-html-' + i))); //render editable area
66815
- }
67099
+ itemEl.removeAttribute('draggable');
67100
+ dom$F.removeClass(itemEl, 'snippet-item');
67101
+ itemEl.outerHTML = html;
67102
+ } else {
67103
+ // Snippet is wrapped in row/colum (may contain custom code or has [data-html] attribute)
67104
+ // Can only be inserted after current row or last row (not on column or element).
67105
+ let snippet = dom$F.createElement('div');
67106
+ snippet.innerHTML = html;
67107
+ let blocks = snippet.querySelectorAll('[data-html]');
67108
+ Array.prototype.forEach.call(blocks, block => {
67109
+ // Render custom code block
67110
+ html = decodeURIComponent(block.getAttribute('data-html'));
67111
+ html = html.replace(/{id}/g, util.makeId());
67112
+
67113
+ for (var i = 1; i <= 20; i++) {
67114
+ html = html.replace('[%HTML' + i + '%]', block.getAttribute('data-html-' + i) === undefined ? '' : decodeURIComponent(block.getAttribute('data-html-' + i))); //render editable area
67115
+ }
66816
67116
 
66817
- block.innerHTML = html;
66818
- });
66819
- html = snippet.innerHTML; // Clean snippet from sortable related code
67117
+ block.innerHTML = html;
67118
+ });
67119
+ html = snippet.innerHTML; // Clean snippet from sortable related code
66820
67120
 
66821
- itemEl.removeAttribute('draggable');
66822
- dom$F.removeClass(itemEl, 'snippet-item');
66823
- itemEl.innerHTML = ''; // Use createContextualFragment() to make embedded script executable
66824
- // https://ghinda.net/article/script-tags/
67121
+ itemEl.removeAttribute('draggable');
67122
+ dom$F.removeClass(itemEl, 'snippet-item');
67123
+ itemEl.innerHTML = ''; // Use createContextualFragment() to make embedded script executable
67124
+ // https://ghinda.net/article/script-tags/
66825
67125
 
66826
- var range = document.createRange();
66827
- range.setStart(itemEl, 0);
66828
- itemEl.appendChild(range.createContextualFragment(html));
66829
- itemEl.outerHTML = itemEl.innerHTML;
66830
- } // After snippet has been added, re-apply behavior on builder areas
67126
+ var range = document.createRange();
67127
+ range.setStart(itemEl, 0);
67128
+ itemEl.appendChild(range.createContextualFragment(html));
67129
+ itemEl.outerHTML = itemEl.innerHTML;
67130
+ } // After snippet has been added, re-apply behavior on builder areas
66831
67131
 
66832
67132
 
66833
- this.applyBehavior(); // Call onChange
67133
+ this.applyBehaviorOn(builder); // Call onChange
66834
67134
 
66835
- this.opts.onChange(); // Hide element tool
67135
+ this.opts.onChange(); // Hide element tool
66836
67136
 
66837
- this.elmTool.hide();
66838
- }
67137
+ this.elmTool.hide();
66839
67138
  }
66840
- });
66841
- this.sortableObjects.push(sortableObject);
66842
- builder.setAttribute('data-sort', true);
66843
- } // /Sortable
67139
+ }
67140
+ });
67141
+ this.sortableObjects.push(sortableObject);
67142
+ builder.setAttribute('data-sort', true);
67143
+ } // /Sortable
67144
+ // Additional contentEditable for subblock
66844
67145
 
66845
- }); // Additional contentEditable for subblock
66846
67146
 
66847
- const subblocks = document.querySelectorAll('.is-subblock');
67147
+ const subblocks = builder.querySelectorAll('.is-subblock');
66848
67148
  Array.prototype.forEach.call(subblocks, subblock => {
66849
67149
  subblock.contentEditable = true;
66850
67150
  }); // Check if there is empty builder area (still has no content)
66851
67151
 
66852
- util.checkEmpty(); // Call onRender to indicate content is ready for editing (applyBehavior has been applied)
66853
-
66854
- this.opts.onRender(); // Zoom
66855
-
66856
- if (localStorage.getItem('_zoom') !== null) {
66857
- this.opts.zoom = localStorage.getItem('_zoom'); // Get from saved localStorage
66858
- }
66859
-
66860
- this.rte.rteZoomSlider.value = this.opts.zoom * 100; // Set slider value
66861
-
66862
- this.setZoom(); // Set zoom
66863
- } // applyBehavior
67152
+ this.util.checkEmptyOn(builder); // Zoom
66864
67153
 
67154
+ this.setZoomOnControl(builder);
67155
+ }
66865
67156
 
66866
67157
  html(area) {
66867
67158
  const util = this.util;
@@ -67663,6 +67954,7 @@ class ContentBuilder {
67663
67954
  }
67664
67955
 
67665
67956
  loadSnippets(snippetFile) {
67957
+ if (this.preview) return;
67666
67958
  let snippetPanel = document.querySelector(this.opts.snippetList);
67667
67959
  if (snippetPanel) return; // do not render if already rendered (just protection)
67668
67960
 
@@ -68372,26 +68664,29 @@ class ContentBuilder {
68372
68664
  let contentword = document.querySelector('#idContentWord'); //Check video embed
68373
68665
 
68374
68666
  var bPasteObject = false;
68375
- var src = contentword.innerText; //var youRegex = /^http[s]?:\/\/(((www.youtube.com\/watch\?(feature=player_detailpage&)?)v=)|(youtu.be\/))([^#\&\?]*)/;
68667
+ var src = contentword.innerText;
68376
68668
 
68377
- var youRegex = /^http[s]?:\/\/(((www.youtube.com\/watch\?(feature=player_detailpage&)?)v=)|(youtu.be\/))([^#&?]*)/;
68378
- var vimeoRegex = /^.*(vimeo\.com\/)((channels\/[A-z]+\/)|(groups\/[A-z]+\/videos\/)|(video\/))?([0-9]+)\/?/;
68379
- var youRegexMatches = youRegex.exec(src);
68380
- var vimeoRegexMatches = vimeoRegex.exec(src);
68669
+ if (!this.opts.disableAutoEmbedVideo) {
68670
+ //var youRegex = /^http[s]?:\/\/(((www.youtube.com\/watch\?(feature=player_detailpage&)?)v=)|(youtu.be\/))([^#\&\?]*)/;
68671
+ var youRegex = /^http[s]?:\/\/(((www.youtube.com\/watch\?(feature=player_detailpage&)?)v=)|(youtu.be\/))([^#&?]*)/;
68672
+ var vimeoRegex = /^.*(vimeo\.com\/)((channels\/[A-z]+\/)|(groups\/[A-z]+\/videos\/)|(video\/))?([0-9]+)\/?/;
68673
+ var youRegexMatches = youRegex.exec(src);
68674
+ var vimeoRegexMatches = vimeoRegex.exec(src);
68381
68675
 
68382
- if (youRegexMatches !== null || vimeoRegexMatches !== null) {
68383
- if (youRegexMatches !== null && youRegexMatches.length >= 7) {
68384
- var youMatch = youRegexMatches[6];
68385
- src = 'https://www.youtube.com/embed/' + youMatch + '?rel=0';
68386
- }
68676
+ if (youRegexMatches !== null || vimeoRegexMatches !== null) {
68677
+ if (youRegexMatches !== null && youRegexMatches.length >= 7) {
68678
+ var youMatch = youRegexMatches[6];
68679
+ src = 'https://www.youtube.com/embed/' + youMatch + '?rel=0';
68680
+ }
68387
68681
 
68388
- if (vimeoRegexMatches !== null && vimeoRegexMatches.length >= 7) {
68389
- var vimeoMatch = vimeoRegexMatches[6];
68390
- src = 'https://player.vimeo.com/video/' + vimeoMatch;
68391
- }
68682
+ if (vimeoRegexMatches !== null && vimeoRegexMatches.length >= 7) {
68683
+ var vimeoMatch = vimeoRegexMatches[6];
68684
+ src = 'https://player.vimeo.com/video/' + vimeoMatch;
68685
+ }
68392
68686
 
68393
- sPastedText = '<div class="embed-responsive embed-responsive-16by9"><iframe width="560" height="315" src="' + src + '" frameborder="0" allowfullscreen=""></iframe></div>';
68394
- bPasteObject = true;
68687
+ sPastedText = '<div class="embed-responsive embed-responsive-16by9"><iframe width="560" height="315" src="' + src + '" frameborder="0" allowfullscreen=""></iframe></div>';
68688
+ bPasteObject = true;
68689
+ }
68395
68690
  }
68396
68691
 
68397
68692
  if (!bPasteObject) {
@@ -68513,7 +68808,8 @@ class ContentBuilder {
68513
68808
 
68514
68809
  oSel.removeAllRanges();
68515
68810
  oSel.addRange(range);
68516
- this.applyBehavior(); //Trigger Change event
68811
+ let builderActive = document.querySelector('.builder-active');
68812
+ if (builderActive) this.applyBehaviorOn(builderActive); //Trigger Change event
68517
68813
 
68518
68814
  this.opts.onChange(); //Trigger Render event
68519
68815
 
@@ -70952,6 +71248,12 @@ class ContentBox {
70952
71248
  }
70953
71249
 
70954
71250
  this.wrapperEl = document.querySelector(this.wrapper);
71251
+
71252
+ if (dom.hasClass(this.wrapperEl, 'preview')) {
71253
+ this.preview = true;
71254
+ return;
71255
+ }
71256
+
70955
71257
  dom.addClass(this.wrapperEl, 'is-wrapper');
70956
71258
  dom.addClass(this.wrapperEl, 'is-edit'); //Extend onRender with built-in plugins
70957
71259
 
@@ -71199,11 +71501,14 @@ class ContentBox {
71199
71501
  this.editsection = new EditSection(this);
71200
71502
  this.editbox = new EditBox(this);
71201
71503
  setTimeout(() => {
71202
- this.pageSetup(); // this.wrapperEl.style.opacity = 1;
71504
+ if (!this.pageSetupDone) {
71505
+ this.pageSetup();
71506
+ } // this.wrapperEl.style.opacity = 1;
71203
71507
  // Remove the page-overlay
71204
71508
  // setTimeout(()=>{
71205
71509
  // pageOverlay.parentNode.removeChild(pageOverlay);
71206
71510
  // }, 10);
71511
+
71207
71512
  }, 300); //give delay for the transition (0.3ms) to finish (see box.css on .is-wrapper)
71208
71513
 
71209
71514
  Pace.start();
@@ -71322,13 +71627,11 @@ class ContentBox {
71322
71627
  if (newArea.indexOf('is-static') == -1 && hasStatic) {
71323
71628
  // If page has a footer (a static section), then insert the new section before it.
71324
71629
  dom.appendHtml(lastSection, newArea, 'beforebegin');
71325
- newSection = lastSection.previousSibling;
71326
-
71327
- if (newSection.previousSibling) {
71328
- if (!dom.hasClass(newSection.previousSibling, 'is-bg-grey')) {
71329
- dom.addClass(newSection, 'is-bg-grey');
71330
- }
71331
- }
71630
+ newSection = lastSection.previousSibling; // if(newSection.previousSibling) {
71631
+ // if(!dom.hasClass(newSection.previousSibling, 'is-bg-grey')) {
71632
+ // dom.addClass(newSection, 'is-bg-grey');
71633
+ // }
71634
+ // }
71332
71635
  } else {
71333
71636
  const sectionElms = this.wrapperEl.querySelectorAll('.is-section');
71334
71637
 
@@ -71340,50 +71643,72 @@ class ContentBox {
71340
71643
  dom.appendHtml(this.wrapperEl, newArea, 'afterbegin');
71341
71644
  }
71342
71645
 
71343
- newSection = dom.getLastElement(this.wrapperEl, '.is-section');
71646
+ newSection = dom.getLastElement(this.wrapperEl, '.is-section'); // if(newSection.previousSibling) {
71647
+ // if(!dom.hasClass(newSection.previousSibling, 'is-bg-grey')) {
71648
+ // dom.addClass(newSection, 'is-bg-grey');
71649
+ // }
71650
+ // }
71651
+ }
71344
71652
 
71345
- if (newSection.previousSibling) {
71346
- if (!dom.hasClass(newSection.previousSibling, 'is-bg-grey')) {
71347
- dom.addClass(newSection, 'is-bg-grey');
71348
- }
71349
- }
71350
- } // Code Blocks Handling
71653
+ let arrSections = [];
71654
+ arrSections.push(newSection); // Check up to 3 sections (in case a template has up to 3 sections)
71351
71655
 
71656
+ let prevSection = newSection.previousElementSibling;
71352
71657
 
71353
- let codeBlocks = newSection.querySelectorAll('.is-overlay-content[data-module]');
71354
- codeBlocks.forEach(element => {
71355
- let html = decodeURIComponent(element.getAttribute('data-html')); // Original code is stored in data-html attribute
71658
+ if (prevSection) {
71659
+ let ok = prevSection.querySelector('.is-section-tool');
71356
71660
 
71357
- html = html.replace(/{id}/g, dom.uniqueId()); //Fill the block with original code
71661
+ if (!ok) {
71662
+ arrSections.push(prevSection);
71663
+ }
71358
71664
 
71359
- dom.html(element, html);
71360
- }); // Fix old structure (backward compatible)
71665
+ prevSection = prevSection.previousElementSibling;
71361
71666
 
71362
- let overlays = newSection.querySelectorAll('.is-overlay');
71363
- overlays.forEach(overlay => {
71364
- let overlayContent = overlay.querySelector('.is-overlay-content');
71667
+ if (prevSection) {
71668
+ ok = prevSection.querySelector('.is-section-tool');
71365
71669
 
71366
- if (overlayContent) {
71367
- if (overlayContent.innerHTML === '') {
71368
- if (overlay.childElementCount === 1) {
71369
- overlay.parentNode.removeChild(overlay);
71370
- }
71670
+ if (!ok) {
71671
+ arrSections.push(prevSection);
71371
71672
  }
71372
71673
  }
71373
- });
71374
- this.editor.applyBehavior(); // Section Setup
71674
+ }
71375
71675
 
71376
- this.sectionSetup(newSection); // Box Setup (previously: applyBoxBehavior)
71676
+ arrSections.forEach(section => {
71677
+ // Code Blocks Handling
71678
+ let codeBlocks = section.querySelectorAll('.is-overlay-content[data-module]');
71679
+ codeBlocks.forEach(element => {
71680
+ let html = decodeURIComponent(element.getAttribute('data-html')); // Original code is stored in data-html attribute
71377
71681
 
71378
- if (dom.hasClass(newSection, 'is-box')) {
71379
- this.boxSetup(newSection);
71380
- } else {
71381
- const boxes = newSection.querySelectorAll('.is-box');
71382
- boxes.forEach(box => {
71383
- this.boxSetup(box);
71384
- });
71385
- } //Trigger Change event
71682
+ html = html.replace(/{id}/g, dom.uniqueId()); //Fill the block with original code
71683
+
71684
+ dom.html(element, html);
71685
+ }); // Fix old structure (backward compatible)
71686
+
71687
+ let overlays = section.querySelectorAll('.is-overlay');
71688
+ overlays.forEach(overlay => {
71689
+ let overlayContent = overlay.querySelector('.is-overlay-content');
71690
+
71691
+ if (overlayContent) {
71692
+ if (overlayContent.innerHTML === '') {
71693
+ if (overlay.childElementCount === 1) {
71694
+ overlay.parentNode.removeChild(overlay);
71695
+ }
71696
+ }
71697
+ }
71698
+ }); // Section Setup
71386
71699
 
71700
+ this.sectionSetup(section); // Box Setup (previously: applyBoxBehavior)
71701
+
71702
+ if (dom.hasClass(section, 'is-box')) {
71703
+ this.boxSetup(section);
71704
+ } else {
71705
+ const boxes = section.querySelectorAll('.is-box');
71706
+ boxes.forEach(box => {
71707
+ this.boxSetup(box);
71708
+ });
71709
+ }
71710
+ });
71711
+ this.editor.applyBehavior(); //Trigger Change event
71387
71712
 
71388
71713
  this.onChange();
71389
71714
  dom.removeElement(document.querySelector('.is-sidebar-overlay'));
@@ -71413,6 +71738,7 @@ class ContentBox {
71413
71738
  });
71414
71739
  const typoPanel = document.querySelector('#divStyles');
71415
71740
  typoPanel.style.backgroundColor = this.editor.styleSnippetBackground;
71741
+ typoPanel.style.color = this.editor.styleSnippetColor;
71416
71742
  const sidebar = document.querySelector('.is-sidebar');
71417
71743
  sidebar.style.backgroundColor = this.editor.styleModalBackground;
71418
71744
  sidebar.style.color = this.editor.styleModalColor;
@@ -71512,6 +71838,7 @@ class ContentBox {
71512
71838
  }
71513
71839
 
71514
71840
  addButton(btn) {
71841
+ if (this.preview) return;
71515
71842
  const builderStuff = this.builderStuff;
71516
71843
  const btnId = dom.uniqueId();
71517
71844
  const panelId = dom.uniqueId();
@@ -71647,6 +71974,7 @@ class ContentBox {
71647
71974
  wrapper.appendChild(range.createContextualFragment(html)); // We use createContextualFragment so that embedded javascript code (code block) will be executed
71648
71975
 
71649
71976
  this.pageSetup();
71977
+ this.pageSetupDone = true; //prevent duplicate for traditional pageSetup on init
71650
71978
  }
71651
71979
 
71652
71980
  boxImage(url) {