@innovastudio/contentbuilder 1.4.24 → 1.4.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbuilder",
3
3
  "type": "module",
4
- "version": "1.4.24",
4
+ "version": "1.4.26",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "files": [
@@ -58721,6 +58721,7 @@ class ColumnTool {
58721
58721
  const util = this.builder.util;
58722
58722
  const builderStuff = this.builder.builderStuff;
58723
58723
  this.util = util;
58724
+ this.builderStuff = builderStuff;
58724
58725
  const dom = this.builder.dom;
58725
58726
  this.dom = dom;
58726
58727
  let columnMore = builderStuff.querySelector('.is-pop.columnmore');
@@ -58829,9 +58830,6 @@ class ColumnTool {
58829
58830
  <button title="${util.out('Desktop')}" class="input-device on" data-value="" style="width:40px;height:25px;">
58830
58831
  <svg class="is-icon-flex" style="width:16px;height:16px"><use xlink:href="#icon-device-desktop"></use></svg>
58831
58832
  </button>
58832
- <!--<button title="${util.out('Laptop/Tablet (Landscape)')}" class="input-device" data-value="md" style="width:40px;height:25px;">
58833
- <svg class="is-icon-flex" style="width:19px;height:19px;"><use xlink:href="#icon-device-laptop"></use></svg>
58834
- </button>-->
58835
58833
  <button title="${util.out('Laptop/Tablet (Landscape)')}" class="input-device" data-value="md" style="width:40px;height:25px;">
58836
58834
  <svg class="is-icon-flex" style="width:16px;height:16px;transform:rotate(-90deg)"><use xlink:href="#icon-device-tablet"></use></svg>
58837
58835
  </button>
@@ -59022,6 +59020,21 @@ class ColumnTool {
59022
59020
 
59023
59021
  <div style="padding:0;margin-top:25px;">
59024
59022
 
59023
+ <div class="div-target" style="display: flex;justify-content: flex-end;padding: 5px 0 0;">
59024
+ <button title="${util.out('Desktop')}" class="input-device on" data-value="" style="width:40px;height:25px;">
59025
+ <svg class="is-icon-flex" style="width:16px;height:16px"><use xlink:href="#icon-device-desktop"></use></svg>
59026
+ </button>
59027
+ <button title="${util.out('Laptop/Tablet (Landscape)')}" class="input-device" data-value="md" style="width:40px;height:25px;">
59028
+ <svg class="is-icon-flex" style="width:16px;height:16px;transform:rotate(-90deg)"><use xlink:href="#icon-device-tablet"></use></svg>
59029
+ </button>
59030
+ <button title="${util.out('Tablet (Portrait)')}" class="input-device" data-value="sm" style="width:40px;height:25px;">
59031
+ <svg class="is-icon-flex" style="width:16px;height:16px"><use xlink:href="#icon-device-tablet"></use></svg>
59032
+ </button>
59033
+ <button title="${util.out('Mobile')}" class="input-device" data-value="xs" style="width:40px;height:25px;">
59034
+ <svg class="is-icon-flex" style="width:13px;height:13px"><use xlink:href="#icon-device-mobile"></use></svg>
59035
+ </button>
59036
+ </div>
59037
+
59025
59038
  <div style="padding-bottom:3px;">${util.out('Scale')}:</div>
59026
59039
  <div style="padding-top:4px">
59027
59040
  <input type="range" min="100" max="500" value="0" class="image-scale-slider is-rangeslider">
@@ -60640,6 +60653,25 @@ class ColumnTool {
60640
60653
  btnHidden.classList.add('on'); //Trigger Change event
60641
60654
 
60642
60655
  this.builder.opts.onChange();
60656
+ }); // Responsive Image Adjust
60657
+
60658
+ btns = this.imageAdjust.querySelectorAll('.input-device');
60659
+ btns.forEach(btn => {
60660
+ btn.addEventListener('click', () => {
60661
+ let elms = this.imageAdjust.querySelectorAll('.input-device');
60662
+ elms.forEach(elm => {
60663
+ elm.classList.remove('on');
60664
+ });
60665
+ btn.classList.add('on');
60666
+ const modal = builderStuff.querySelector('.is-modal.content-preview');
60667
+
60668
+ if (!modal.classList.contains('active')) {
60669
+ this.builder.openPreview();
60670
+ }
60671
+
60672
+ this.realtimeImageAdjust();
60673
+ this.readImageAdjust(this.builder.elementSelected, this.useTarget);
60674
+ });
60643
60675
  });
60644
60676
  }
60645
60677
 
@@ -60907,9 +60939,8 @@ class ColumnTool {
60907
60939
  if (btn) btn.setAttribute('data-focus', true);
60908
60940
  }
60909
60941
 
60910
- openImageAdjust(elm, btn, useTarget) {
60911
- if (useTarget) this.useTarget = true;else this.useTarget = false; //Current value
60912
-
60942
+ readImageAdjust(elm, useTarget) {
60943
+ //Current value
60913
60944
  const imageAdjust = this.imageAdjust;
60914
60945
  const inpImageScaleSlider = imageAdjust.querySelector('.image-scale-slider');
60915
60946
  const inpImageHorSlider = imageAdjust.querySelector('.image-hor-slider');
@@ -60917,6 +60948,7 @@ class ColumnTool {
60917
60948
  inpImageScaleSlider.value = 100;
60918
60949
  inpImageHorSlider.value = 0;
60919
60950
  inpImageVertSlider.value = 0;
60951
+ inpImageScaleSlider.disabled = false;
60920
60952
 
60921
60953
  if (useTarget) {
60922
60954
  inpImageHorSlider.value = 50;
@@ -60995,16 +61027,79 @@ class ColumnTool {
60995
61027
  } //elementSelected
60996
61028
 
60997
61029
 
60998
- this.builder.elementSelected = elm; //Show modal
61030
+ this.builder.elementSelected = elm;
61031
+ }
61032
+
61033
+ openImageAdjust(elm, btn, useTarget) {
61034
+ if (useTarget) this.useTarget = true;else this.useTarget = false;
61035
+ const divTarget = this.imageAdjust.querySelector('.div-target');
60999
61036
 
61000
- imageAdjust.style.zIndex = '10005';
61001
- this.util.showModal(imageAdjust, false, () => {
61037
+ if (useTarget) {
61038
+ divTarget.style.display = 'flex';
61039
+ } else {
61040
+ divTarget.style.display = 'none';
61041
+ }
61042
+
61043
+ const modal = this.builderStuff.querySelector('.is-modal.content-preview');
61044
+ let elms = this.imageAdjust.querySelectorAll('.input-device');
61045
+ elms.forEach(elm => {
61046
+ elm.classList.remove('on');
61047
+ });
61048
+
61049
+ if (!modal.classList.contains('active')) {
61050
+ this.imageAdjust.querySelector('.input-device[data-value=""]').classList.add('on');
61051
+ }
61052
+
61053
+ this.readImageAdjust(elm, useTarget); //Show modal
61054
+
61055
+ this.imageAdjust.style.zIndex = '10005';
61056
+ this.util.showModal(this.imageAdjust, false, () => {
61002
61057
  if (btn) {
61003
61058
  btn.removeAttribute('data-focus');
61004
61059
  btn.focus();
61005
61060
  }
61006
61061
  });
61007
61062
  if (btn) btn.setAttribute('data-focus', true);
61063
+ this.realtimeImageAdjust(true);
61064
+ }
61065
+
61066
+ realtimeImageAdjust(initialOpen) {
61067
+ if (initialOpen) {
61068
+ const builderStuff = this.builder.builderStuff;
61069
+ const modal = builderStuff.querySelector('.is-modal.content-preview.active');
61070
+
61071
+ if (modal) {
61072
+ let elms = this.imageAdjust.querySelectorAll('.input-device');
61073
+ elms.forEach(elm => {
61074
+ elm.classList.remove('on');
61075
+ });
61076
+
61077
+ if (modal.classList.contains('is-screen-1920')) {
61078
+ this.imageAdjust.querySelector('.input-device[data-value=""]').classList.add('on');
61079
+ } else if (modal.classList.contains('is-screen-1440')) {
61080
+ this.imageAdjust.querySelector('.input-device[data-value=""]').classList.add('on');
61081
+ } else if (modal.classList.contains('is-screen-1024')) {
61082
+ this.imageAdjust.querySelector('.input-device[data-value="md"]').classList.add('on');
61083
+ } else if (modal.classList.contains('is-screen-768')) {
61084
+ this.imageAdjust.querySelector('.input-device[data-value="sm"]').classList.add('on');
61085
+ } else if (modal.classList.contains('is-screen-375')) {
61086
+ this.imageAdjust.querySelector('.input-device[data-value="xs"]').classList.add('on');
61087
+ }
61088
+ }
61089
+ }
61090
+
61091
+ let divTarget = this.imageAdjust.querySelector('.div-target');
61092
+ let target = this.builder.responsive.readTarget(divTarget); // Live Preview Sync
61093
+
61094
+ if (target === 'xs') {
61095
+ if (!initialOpen) this.builder.livePreview.resizePreview(375);
61096
+ } else if (target === 'sm') {
61097
+ if (!initialOpen) this.builder.livePreview.resizePreview(768);
61098
+ } else if (target === 'md') {
61099
+ if (!initialOpen) this.builder.livePreview.resizePreview(1024);
61100
+ } else {
61101
+ if (!initialOpen) this.builder.livePreview.resizePreview(1920);
61102
+ }
61008
61103
  }
61009
61104
 
61010
61105
  resetImage(elm) {
@@ -77187,7 +77282,28 @@ class LivePreview {
77187
77282
  if (!this.builder.doc.querySelector('.is-wrapper')) {
77188
77283
  // ContentBuilder
77189
77284
  if (this.builder.previewURL) {
77190
- iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77285
+ if (this.builder.livePreviewAlwaysReload) {
77286
+ iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77287
+ } else {
77288
+ let iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
77289
+
77290
+ if (iframeDocument) {
77291
+ if (iframeDocument.body.innerHTML === '') {
77292
+ iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77293
+ } else {
77294
+ // sync. html
77295
+ let html = this.builder.html();
77296
+ let container = iframeDocument.querySelector('.container');
77297
+ if (!container) container = iframeDocument.querySelector('.is-container');
77298
+
77299
+ if (container) {
77300
+ container.innerHTML = html;
77301
+ } else {
77302
+ iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77303
+ }
77304
+ }
77305
+ }
77306
+ }
77191
77307
  } else {
77192
77308
  try {
77193
77309
  this.writeHtml(iframe);
@@ -77196,87 +77312,90 @@ class LivePreview {
77196
77312
  }
77197
77313
  } else {
77198
77314
  // ContentBox
77199
- // iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77200
- let iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
77315
+ if (this.builder.livePreviewAlwaysReload) {
77316
+ iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77317
+ } else {
77318
+ let iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
77201
77319
 
77202
- if (iframeDocument) {
77203
- if (iframeDocument.body.innerHTML === '') {
77204
- iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77205
- } else {
77206
- // sync. html
77207
- let html = localStorage.getItem('preview-html');
77208
- let wrapper = iframeDocument.querySelector('.is-wrapper');
77209
- wrapper.innerHTML = html; // sync. styles
77210
- // let mainCss = localStorage.getItem('preview-maincss');
77211
- // let sectionCss = localStorage.getItem('preview-sectioncss');
77212
-
77213
- let elms = iframeDocument.querySelectorAll('link');
77214
- let links = this.builder.doc.getElementsByTagName('link');
77215
- Array.from(links).map(link => {
77216
- let href = link.href.toLowerCase();
77217
-
77218
- if (href.indexOf('/basetype-') !== -1 || href.indexOf('/type-') !== -1) {
77219
- // check
77220
- let exist = false;
77221
- elms.forEach(elm => {
77222
- let elmHref = elm.href.toLowerCase();
77223
-
77224
- if (elmHref) {
77225
- if (elmHref.indexOf('/basetype-') !== -1 || elmHref.indexOf('/type-') !== -1) {
77226
- if (href === elmHref) {
77227
- exist = true;
77320
+ if (iframeDocument) {
77321
+ if (iframeDocument.body.innerHTML === '') {
77322
+ iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77323
+ } else {
77324
+ // sync. html
77325
+ let html = localStorage.getItem('preview-html');
77326
+ let wrapper = iframeDocument.querySelector('.is-wrapper');
77327
+ wrapper.innerHTML = html; // sync. styles
77328
+ // let mainCss = localStorage.getItem('preview-maincss');
77329
+ // let sectionCss = localStorage.getItem('preview-sectioncss');
77330
+
77331
+ let elms = iframeDocument.querySelectorAll('link');
77332
+ let links = this.builder.doc.getElementsByTagName('link');
77333
+ Array.from(links).map(link => {
77334
+ let href = link.href.toLowerCase();
77335
+
77336
+ if (href.indexOf('/basetype-') !== -1 || href.indexOf('/type-') !== -1) {
77337
+ // check
77338
+ let exist = false;
77339
+ elms.forEach(elm => {
77340
+ let elmHref = elm.href.toLowerCase();
77341
+
77342
+ if (elmHref) {
77343
+ if (elmHref.indexOf('/basetype-') !== -1 || elmHref.indexOf('/type-') !== -1) {
77344
+ if (href === elmHref) {
77345
+ exist = true;
77346
+ }
77228
77347
  }
77229
77348
  }
77230
- }
77231
- });
77349
+ });
77232
77350
 
77233
- if (!exist) {
77234
- // clone is needed, otherwise, parent resource may dissapear when loading on iframe
77235
- const clone = link.cloneNode(true);
77236
- iframeDocument.head.appendChild(clone); // ADD
77351
+ if (!exist) {
77352
+ // clone is needed, otherwise, parent resource may dissapear when loading on iframe
77353
+ const clone = link.cloneNode(true);
77354
+ iframeDocument.head.appendChild(clone); // ADD
77355
+ }
77237
77356
  }
77238
- }
77239
- });
77240
- elms.forEach(elm => {
77241
- let href = elm.href.toLowerCase();
77242
-
77243
- if (href.indexOf('/basetype-') !== -1 || href.indexOf('/type-') !== -1) {
77244
- // check
77245
- let exist = false;
77246
- Array.from(links).map(link => {
77247
- let elmHref = link.href.toLowerCase();
77248
-
77249
- if (elmHref) {
77250
- if (elmHref.indexOf('/basetype-') !== -1 || elmHref.indexOf('/type-') !== -1) {
77251
- if (href === elmHref) {
77252
- exist = true;
77357
+ });
77358
+ elms.forEach(elm => {
77359
+ let href = elm.href.toLowerCase();
77360
+
77361
+ if (href.indexOf('/basetype-') !== -1 || href.indexOf('/type-') !== -1) {
77362
+ // check
77363
+ let exist = false;
77364
+ Array.from(links).map(link => {
77365
+ let elmHref = link.href.toLowerCase();
77366
+
77367
+ if (elmHref) {
77368
+ if (elmHref.indexOf('/basetype-') !== -1 || elmHref.indexOf('/type-') !== -1) {
77369
+ if (href === elmHref) {
77370
+ exist = true;
77371
+ }
77253
77372
  }
77254
77373
  }
77255
- }
77256
- });
77374
+ });
77257
77375
 
77258
- if (!exist) {
77259
- iframeDocument.head.removeChild(elm); // REMOVE
77376
+ if (!exist) {
77377
+ iframeDocument.head.removeChild(elm); // REMOVE
77378
+ }
77260
77379
  }
77261
- }
77262
- }); // reload box js
77263
-
77264
- elms = iframeDocument.querySelectorAll('script');
77265
- elms.forEach(elm => {
77266
- let src = elm.getAttribute('src');
77267
-
77268
- if (src) {
77269
- if (src.indexOf('box-flex.js') !== -1 || src.indexOf('box.js') !== -1) {
77270
- elm.parentElement.removeChild(elm);
77271
- let scriptElm = document.createElement('script');
77272
- scriptElm.setAttribute('src', src);
77273
- iframeDocument.body.appendChild(scriptElm);
77380
+ }); // reload box js
77381
+
77382
+ elms = iframeDocument.querySelectorAll('script');
77383
+ elms.forEach(elm => {
77384
+ let src = elm.getAttribute('src');
77385
+
77386
+ if (src) {
77387
+ if (src.indexOf('box-flex.js') !== -1 || src.indexOf('box.js') !== -1) {
77388
+ elm.parentElement.removeChild(elm);
77389
+ let scriptElm = document.createElement('script');
77390
+ scriptElm.setAttribute('src', src);
77391
+ iframeDocument.body.appendChild(scriptElm);
77392
+ }
77274
77393
  }
77275
- }
77276
- });
77394
+ });
77395
+ }
77396
+ } else {
77397
+ iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77277
77398
  }
77278
- } else {
77279
- iframe.src = this.builder.previewURL + '?' + Math.floor(Date.now() / 1000);
77280
77399
  }
77281
77400
  }
77282
77401
 
@@ -77412,6 +77531,7 @@ class ContentBuilder {
77412
77531
  // onPreviewClose: ()=>{},
77413
77532
  previewStyle: 'top:auto;bottom:50px;left:50px;right:auto;',
77414
77533
  livePreviewOpen: false,
77534
+ livePreviewAlwaysReload: false,
77415
77535
  scriptPath: '',
77416
77536
  // Deprecated
77417
77537
  // Old way: