@innovastudio/contentbuilder 1.4.98 → 1.4.100

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbuilder",
3
3
  "type": "module",
4
- "version": "1.4.98",
4
+ "version": "1.4.100",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "files": [
@@ -4215,14 +4215,16 @@ class Util {
4215
4215
  Note:
4216
4216
  - hideModal will remove the modal element, so calling show modal multiple times won't attach multiple events (safe).
4217
4217
  */
4218
- showModal(modal, overlayStay, cancelCallback, animated) {
4218
+ showModal(modal, overlayStay, cancelCallback, animated, overflowHidden) {
4219
4219
  const dom = this.dom;
4220
4220
  dom.addClass(modal, 'active');
4221
4221
  modal.setAttribute('aria-hidden', false);
4222
+ if (overflowHidden) document.body.style.overflow = 'hidden';
4222
4223
  const handleKeyDown = e => {
4223
4224
  if (e.keyCode === 27) {
4224
4225
  // escape key
4225
4226
 
4227
+ if (overflowHidden) document.body.style.overflow = '';
4226
4228
  if (dom.hasClass(modal, 'active')) this.hideModal(modal); // check first in case programmatically ESC key that already call hideModal is triggered (see _hideModal)
4227
4229
 
4228
4230
  modal.removeEventListener('keydown', handleKeyDown);
@@ -4286,6 +4288,7 @@ class Util {
4286
4288
  if (!overlayStay) {
4287
4289
  let overlay = modal.querySelector('.is-modal-overlay');
4288
4290
  dom.addEventListener(overlay, 'click', () => {
4291
+ if (overflowHidden) document.body.style.overflow = '';
4289
4292
  this.hideModal(modal);
4290
4293
  modal.removeEventListener('keydown', handleKeyDown);
4291
4294
  const btnClose = modal.querySelector('.is-modal-close');
@@ -4295,6 +4298,7 @@ class Util {
4295
4298
  }
4296
4299
  }
4297
4300
  const close = () => {
4301
+ if (overflowHidden) document.body.style.overflow = '';
4298
4302
  if (dom.hasClass(modal, 'active')) this.hideModal(modal); // check first in case programmatically ESC key that already call hideModal is triggered (see _hideModal)
4299
4303
 
4300
4304
  modal.removeEventListener('keydown', handleKeyDown);
@@ -49926,7 +49930,7 @@ class Image$1 {
49926
49930
  util.showModal(modalFileSelect, false, () => {
49927
49931
  inputSelectOther.removeAttribute('data-focus');
49928
49932
  inputSelectOther.focus();
49929
- }, false);
49933
+ }, false, this.builder.assetPanelFullScreen);
49930
49934
  inputSelectOther.setAttribute('data-focus', true);
49931
49935
  }
49932
49936
  this.builder.targetInput = modalImageLink.querySelector('.input-link'); // used by selectAsset() (see contentbuilder.js)
@@ -50146,7 +50150,7 @@ class Image$1 {
50146
50150
  util.showModal(modalImageSelect, false, () => {
50147
50151
  btnImageSelect.removeAttribute('data-focus');
50148
50152
  btnImageSelect.focus();
50149
- });
50153
+ }, false, this.builder.assetPanelFullScreen);
50150
50154
  btnImageSelect.setAttribute('data-focus', true);
50151
50155
  }
50152
50156
  this.builder.targetInput = modalImageLink.querySelector('.input-src'); // used by selectAsset() (see contentbuilder.js)
@@ -50201,7 +50205,7 @@ class Image$1 {
50201
50205
  util.showModal(modalFileSelect, false, () => {
50202
50206
  btnImageSelect2.removeAttribute('data-focus');
50203
50207
  btnImageSelect2.focus();
50204
- }, true);
50208
+ }, false, this.builder.assetPanelFullScreen);
50205
50209
  btnImageSelect2.setAttribute('data-focus', true);
50206
50210
  this.builder.targetInput = modalImageLink.querySelector('.input-link'); // used by selectAsset() (see contentbuilder.js)
50207
50211
  this.builder.targetCallback = null;
@@ -50227,7 +50231,7 @@ class Image$1 {
50227
50231
  util.showModal(modalImageSelect, false, () => {
50228
50232
  btnImageSelect2.removeAttribute('data-focus');
50229
50233
  btnImageSelect2.focus();
50230
- });
50234
+ }, false, this.builder.assetPanelFullScreen);
50231
50235
  btnImageSelect2.setAttribute('data-focus', true);
50232
50236
  this.builder.targetInput = modalImageLink.querySelector('.input-link'); // used by selectAsset() (see contentbuilder.js)
50233
50237
  this.builder.targetCallback = null;
@@ -53012,7 +53016,7 @@ class Hyperlink {
53012
53016
  util.showModal(modalFileSelect, false, () => {
53013
53017
  inputSelectOther.removeAttribute('data-focus');
53014
53018
  inputSelectOther.focus();
53015
- }, false);
53019
+ }, false, this.builder.assetPanelFullScreen);
53016
53020
  inputSelectOther.setAttribute('data-focus', true);
53017
53021
  }
53018
53022
  this.builder.targetInput = modal.querySelector('.input-url'); // used by selectAsset() (see contentbuilder.js)
@@ -53041,7 +53045,7 @@ class Hyperlink {
53041
53045
  if (modalFileSelect.querySelector('iframe').src === 'about:blank') {
53042
53046
  modalFileSelect.querySelector('iframe').src = this.builder.opts.fileselect;
53043
53047
  }
53044
- util.showModal(modalFileSelect, false, null, false);
53048
+ util.showModal(modalFileSelect, false, null, false, this.builder.assetPanelFullScreen);
53045
53049
  }
53046
53050
  this.builder.targetInput = modal.querySelector('.input-url'); // used by selectAsset() (see contentbuilder.js)
53047
53051
  this.builder.targetCallback = null;
@@ -54931,7 +54935,7 @@ class Video {
54931
54935
  util.showModal(modalVideoSelect, false, () => {
54932
54936
  inpSelectVideo.removeAttribute('data-focus');
54933
54937
  inpSelectVideo.focus();
54934
- });
54938
+ }, false, this.builder.assetPanelFullScreen);
54935
54939
  inpSelectVideo.setAttribute('data-focus', true);
54936
54940
  }
54937
54941
  this.builder.targetInput = videoModal.querySelector('.input-url'); // used by selectAsset() (see contentbuilder.js)
@@ -55124,7 +55128,7 @@ class Audio {
55124
55128
  util.showModal(modalAudioSelect, false, () => {
55125
55129
  inpSelectAudio.removeAttribute('data-focus');
55126
55130
  inpSelectAudio.focus();
55127
- });
55131
+ }, false, this.builder.assetPanelFullScreen);
55128
55132
  inpSelectAudio.setAttribute('data-focus', true);
55129
55133
  }
55130
55134
  this.builder.targetInput = audioModal.querySelector('.input-url'); // used by selectAsset() (see contentbuilder.js)
@@ -59257,7 +59261,7 @@ class ColumnTool {
59257
59261
  util.showModal(modalImageSelect, false, () => {
59258
59262
  elm.removeAttribute('data-focus');
59259
59263
  elm.focus();
59260
- });
59264
+ }, false, this.builder.assetPanelFullScreen);
59261
59265
  elm.setAttribute('data-focus', true);
59262
59266
  }
59263
59267
  this.builder.targetInput = imageSource.querySelector('.input-src'); // used by selectAsset() (see contentbuilder.js)
@@ -60100,7 +60104,7 @@ class ColumnTool {
60100
60104
  util.showModal(modalFileSelect, false, () => {
60101
60105
  inputSelectOther.removeAttribute('data-focus');
60102
60106
  inputSelectOther.focus();
60103
- }, false);
60107
+ }, false, this.builder.assetPanelFullScreen);
60104
60108
  inputSelectOther.setAttribute('data-focus', true);
60105
60109
  }
60106
60110
  this.builder.targetInput = this.cellSettings.querySelector('.input-src'); // used by selectAsset() (see contentbuilder.js)
@@ -60165,7 +60169,7 @@ class ColumnTool {
60165
60169
  util.showModal(modalMediaSelect, false, () => {
60166
60170
  elm.removeAttribute('data-focus');
60167
60171
  elm.focus();
60168
- });
60172
+ }, false, this.builder.assetPanelFullScreen);
60169
60173
  elm.setAttribute('data-focus', true);
60170
60174
  this.builder.targetInput = inpSrc; // used by selectAsset() (see contentbuilder.js)
60171
60175
  this.builder.targetCallback = () => {
@@ -60185,7 +60189,7 @@ class ColumnTool {
60185
60189
  util.showModal(modalImageSelect, false, () => {
60186
60190
  elm.removeAttribute('data-focus');
60187
60191
  elm.focus();
60188
- });
60192
+ }, false, this.builder.assetPanelFullScreen);
60189
60193
  elm.setAttribute('data-focus', true);
60190
60194
  this.builder.targetInput = inpSrc; // used by selectAsset() (see contentbuilder.js)
60191
60195
  this.builder.targetCallback = () => {
@@ -60598,7 +60602,7 @@ class ColumnTool {
60598
60602
  btn.removeAttribute('data-focus');
60599
60603
  btn.focus();
60600
60604
  }
60601
- });
60605
+ }, false, this.builder.assetPanelFullScreen);
60602
60606
  if (btn) btn.setAttribute('data-focus', true);
60603
60607
  }
60604
60608
  readImageAdjust(elm, useTarget) {
@@ -68850,7 +68854,10 @@ class Rte {
68850
68854
  if (iframe.src === 'about:blank') {
68851
68855
  iframe.src = this.builder.opts.imageselect;
68852
68856
  }
68853
- util.showModal(modalImageSelect);
68857
+ util.showModal(modalImageSelect, false, () => {
68858
+ inputImageSelect.removeAttribute('data-focus');
68859
+ inputImageSelect.focus();
68860
+ }, false, this.builder.assetPanelFullScreen);
68854
68861
  }
68855
68862
  this.builder.targetInput = modalInsertImage.querySelector('.input-src'); // used by selectAsset() (see contentbuilder.js)
68856
68863
  this.builder.targetCallback = null;
@@ -75960,7 +75967,7 @@ class MediaPicker {
75960
75967
  this.builder.util.showModal(modal, false, () => {
75961
75968
  elm.removeAttribute('data-focus');
75962
75969
  elm.focus();
75963
- });
75970
+ }, false, this.builder.assetPanelFullScreen);
75964
75971
  elm.setAttribute('data-focus', true);
75965
75972
  this.builder.targetInput = inpSrc; // used by selectAsset() (see contentbuilder.js)
75966
75973
  this.builder.targetCallback = null;
@@ -76123,7 +76130,7 @@ class MediaPicker {
76123
76130
  btn.removeAttribute('data-focus');
76124
76131
  btn.focus();
76125
76132
  }
76126
- });
76133
+ }, false, this.builder.assetPanelFullScreen);
76127
76134
  if (btn) btn.setAttribute('data-focus', true);
76128
76135
  }
76129
76136
  }
@@ -78984,24 +78991,25 @@ class ContentBuilder {
78984
78991
  otherSelectCaption: 'Select Document',
78985
78992
  // otherSelectIcon: '<svg class="is-icon-flex"><use xlink:href="#ion-ios-folder-outline"></use></svg>',
78986
78993
  otherSelectIcon: '<svg class="is-icon-flex" style="width:16px;height:16px;"><use xlink:href="#icon-list-search"></use></svg>',
78987
- imageSelectWidth: '80vw',
78988
- imageSelectHeight: '80vh',
78989
- fileSelectWidth: '80vw',
78990
- fileSelectHeight: '80vh',
78991
- videoSelectWidth: '80vw',
78992
- videoSelectHeight: '80vh',
78993
- audioSelectWidth: '80vw',
78994
- audioSelectHeight: '80vh',
78995
- mediaSelectWidth: '80vw',
78996
- mediaSelectHeight: '80vh',
78997
- otherSelectWidth: '80vw',
78998
- otherSelectHeight: '80vh',
78994
+ imageSelectWidth: '88vw',
78995
+ imageSelectHeight: '88vh',
78996
+ fileSelectWidth: '88vw',
78997
+ fileSelectHeight: '88vh',
78998
+ videoSelectWidth: '88vw',
78999
+ videoSelectHeight: '88vh',
79000
+ audioSelectWidth: '88vw',
79001
+ audioSelectHeight: '88vh',
79002
+ mediaSelectWidth: '88vw',
79003
+ mediaSelectHeight: '88vh',
79004
+ otherSelectWidth: '88vw',
79005
+ otherSelectHeight: '88vh',
78999
79006
  imageSelectMaxWidth: '1600px',
79000
79007
  fileSelectMaxWidth: '1600px',
79001
79008
  videoSelectMaxWidth: '1600px',
79002
79009
  audioSelectMaxWidth: '1600px',
79003
79010
  mediaSelectMaxWidth: '1600px',
79004
79011
  otherSelectMaxWidth: '1600px',
79012
+ assetPanelFullScreen: false,
79005
79013
  codeEditorWidth: '80vw',
79006
79014
  codeEditorHeight: '80vh',
79007
79015
  codeEditorMaxWidth: '1600px',
@@ -79690,6 +79698,26 @@ class ContentBuilder {
79690
79698
  } else if (this.opts.videoselect !== '') {
79691
79699
  this.opts.videoSelect = this.opts.videoselect;
79692
79700
  }
79701
+ if (this.assetPanelFullScreen) {
79702
+ this.imageSelectWidth = '100vw';
79703
+ this.imageSelectHeight = '100vh';
79704
+ this.fileSelectWidth = '100vw';
79705
+ this.fileSelectHeight = '100vh';
79706
+ this.videoSelectWidth = '100vw';
79707
+ this.videoSelectHeight = '100vh';
79708
+ this.audioSelectWidth = '100vw';
79709
+ this.audioSelectHeight = '100vh';
79710
+ this.mediaSelectWidth = '100vw';
79711
+ this.mediaSelectHeight = '100vh';
79712
+ this.otherSelectWidth = '100vw';
79713
+ this.otherSelectHeight = '100vh';
79714
+ this.imageSelectMaxWidth = '100vw';
79715
+ this.fileSelectMaxWidth = '100vw';
79716
+ this.videoSelectMaxWidth = '100vw';
79717
+ this.audioSelectMaxWidth = '100vw';
79718
+ this.mediaSelectMaxWidth = '100vw';
79719
+ this.otherSelectMaxWidth = '100vw';
79720
+ }
79693
79721
 
79694
79722
  // if(this.opts.largerImageHandler!=='') {
79695
79723
  // this.opts.mediaHandler = this.opts.largerImageHandler;
@@ -81056,7 +81084,10 @@ class ContentBuilder {
81056
81084
  let modal = this.builderStuff.querySelector('.is-modal.otherselect');
81057
81085
  iframe = modal.querySelector('iframe');
81058
81086
  if (iframe.src === 'about:blank') iframe.src = this.opts.otherSelect;
81059
- this.util.showModal(modal);
81087
+ this.util.showModal(modal, false, () => {
81088
+ theTrigger.removeAttribute('data-focus');
81089
+ theTrigger.focus();
81090
+ }, false, this.assetPanelFullScreen);
81060
81091
  this.targetInput = targetInput; // used by selectAsset() (see contentbuilder.js)
81061
81092
  this.targetCallback = null;
81062
81093
  this.targetAssetType = targetAssetType;
@@ -81121,7 +81152,10 @@ class ContentBuilder {
81121
81152
  iframe = modal.querySelector('iframe');
81122
81153
  if (iframe.src === 'about:blank') iframe.src = this.opts.fileSelect;
81123
81154
  }
81124
- this.util.showModal(modal);
81155
+ this.util.showModal(modal, false, () => {
81156
+ theTrigger.removeAttribute('data-focus');
81157
+ theTrigger.focus();
81158
+ }, false, this.assetPanelFullScreen);
81125
81159
  this.targetInput = targetInput; // used by selectAsset() (see contentbuilder.js)
81126
81160
  this.targetCallback = null;
81127
81161
  this.targetAssetType = targetAssetType;
@@ -81532,8 +81566,8 @@ class ContentBuilder {
81532
81566
  });
81533
81567
  }
81534
81568
  }
81535
- showModal(modal, overlayStay, cancelCallback, animated) {
81536
- this.util.showModal(modal, overlayStay, cancelCallback, animated);
81569
+ showModal(modal, overlayStay, cancelCallback, animated, overflowHidden) {
81570
+ this.util.showModal(modal, overlayStay, cancelCallback, animated, overflowHidden);
81537
81571
  }
81538
81572
  hideModal(modal) {
81539
81573
  this.util._hideModal(modal); // this _hideModal will also trigger cancelCallback defined by showModal. This is done by programmatically click the overlay.
@@ -81544,13 +81578,13 @@ class ContentBuilder {
81544
81578
  selector: selector
81545
81579
  });
81546
81580
  }
81547
- createModal(modal, selector, overlayStay, cancelCallback, animated) {
81581
+ createModal(modal, selector, overlayStay, cancelCallback, animated, overflowHidden) {
81548
81582
  let embeddedModal = this.builderStuff.querySelector(selector);
81549
81583
  if (!embeddedModal) {
81550
81584
  this.builderStuff.appendChild(modal);
81551
81585
  embeddedModal = this.builderStuff.querySelector(selector);
81552
81586
  }
81553
- this.showModal(embeddedModal, overlayStay, cancelCallback, animated);
81587
+ this.showModal(embeddedModal, overlayStay, cancelCallback, animated, overflowHidden);
81554
81588
  new Draggable$1({
81555
81589
  selector: '.is-draggable'
81556
81590
  });
@@ -81979,31 +82013,56 @@ class ContentBuilder {
81979
82013
  }
81980
82014
  }
81981
82015
  }
82016
+ async upscaleImage(src, callback) {
82017
+ const width = 512;
82018
+ const height = 512;
82019
+ const img = new Image();
82020
+ img.src = src;
82021
+ img.onload = async () => {
82022
+ const canvas = document.createElement('canvas');
82023
+ canvas.width = width;
82024
+ canvas.height = height;
82025
+ const ctx = canvas.getContext('2d');
82026
+ ctx.drawImage(img, 0, 0, width, height);
82027
+ const resizedBase64 = canvas.toDataURL('image/jpeg');
82028
+ let image = resizedBase64;
82029
+ image = image.replace(/^data:image\/(png|jpeg);base64,/, '');
82030
+ const messages = {
82031
+ image: image,
82032
+ folder_path: ''
82033
+ };
82034
+ const response = await fetch(this.upscaleImageUrl, {
82035
+ signal: this.signal,
82036
+ // Abort
82037
+ method: 'POST',
82038
+ headers: {
82039
+ 'Content-Type': 'application/json'
82040
+ },
82041
+ body: JSON.stringify(messages)
82042
+ });
82043
+ const result = await response.json();
82044
+ callback([result.url]);
82045
+ };
82046
+ }
81982
82047
  async generateImage(prompt, callback) {
81983
82048
  this.controller = new AbortController(); // Create a new AbortController
81984
82049
  this.signal = this.controller.signal; // Get a new signal object
81985
82050
 
81986
- let model = 'realistic-vision-v3';
81987
- let negative_prompt = '';
81988
- if (model.includes('realistic-vision')) {
81989
- if (negative_prompt === '') negative_prompt = 'duplicate, (deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime:1.4), text, close up, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, bad_prompt_version2, bad-hands-5, badhandv4, bad anatomy, deformed, mutated, amputated, missing finger, extra finger, fused fingers, missing leg, extra leg, fused legs, missing digit, extra digit, fused digits, missing hand, extra hand, fused hands, missing arm, extra arm, fused arms, missing limb, extra limb, fused limbs, fused bodies, merged bodies, extra bodies, dual bodies, extra navel, elongated body, missing joint, extra joint, fused joints, deformed hip, twisted limbs, twisted legs, twisted arms, missing head, extra head, double head, twins, missing ear, extra ear, deformed ear, black and white, monochrome, multiple views, blurry, text, signature, head out of frame, paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, grayscale, glans, bad hands, error, extra digit, fewer digits, cropped, jpeg artifacts, watermark, username, bad feet, poorly drawn hands, poorly drawn face, mutation, too many fingers, long neck, long body, long arms, cross-eyed, mutated hands, polar lowres, bad body, bad proportions, gross proportions, cropped head , bad eyes, extra breast, missing breast, fused breasts, unnatural proportions, necklace';
81990
- }
81991
- let width = 1024;
81992
- let height = 1024;
81993
- let steps = 25;
81994
- let guidance = 7.5;
81995
- let scheduler = 'dpmsolver++';
81996
- let output_format = 'jpeg';
82051
+ let model = this.imageModel || 'realistic-vision-v3';
82052
+ let negative_prompt = this.imageNegativePrompt || 'duplicate, (deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime:1.4), text, close up, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, bad_prompt_version2, bad-hands-5, badhandv4, bad anatomy, deformed, mutated, amputated, missing finger, extra finger, fused fingers, missing leg, extra leg, fused legs, missing digit, extra digit, fused digits, missing hand, extra hand, fused hands, missing arm, extra arm, fused arms, missing limb, extra limb, fused limbs, fused bodies, merged bodies, extra bodies, dual bodies, extra navel, elongated body, missing joint, extra joint, fused joints, deformed hip, twisted limbs, twisted legs, twisted arms, missing head, extra head, double head, twins, missing ear, extra ear, deformed ear, black and white, monochrome, multiple views, blurry, text, signature, head out of frame, paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, grayscale, glans, bad hands, error, extra digit, fewer digits, cropped, jpeg artifacts, watermark, username, bad feet, poorly drawn hands, poorly drawn face, mutation, too many fingers, long neck, long body, long arms, cross-eyed, mutated hands, polar lowres, bad body, bad proportions, gross proportions, cropped head , bad eyes, extra breast, missing breast, fused breasts, unnatural proportions, necklace';
82053
+ let steps = this.imageSteps || 25;
82054
+ let guidance = this.imageGuidance || 7.5;
82055
+ let scheduler = this.imageScheduler || 'dpmsolver++';
81997
82056
  const messages = {
81998
- model: 'realistic-vision-v3',
82057
+ model,
81999
82058
  prompt: prompt,
82000
- negative_prompt: negative_prompt,
82001
- width: width,
82002
- height: height,
82003
- steps: steps,
82004
- guidance: guidance,
82005
- scheduler: scheduler,
82006
- output_format: output_format,
82059
+ negative_prompt,
82060
+ width: 512,
82061
+ height: 512,
82062
+ steps,
82063
+ guidance,
82064
+ scheduler,
82065
+ output_format: 'jpeg',
82007
82066
  folder_path: ''
82008
82067
  };
82009
82068
  try {
@@ -82023,7 +82082,9 @@ class ContentBuilder {
82023
82082
  return;
82024
82083
  }
82025
82084
  const imageUrl = result.url;
82026
- callback([imageUrl]);
82085
+
82086
+ //callback([imageUrl]);
82087
+ this.upscaleImage(imageUrl, callback);
82027
82088
  } catch (error) {
82028
82089
  if (error.name === 'AbortError') ; else {
82029
82090
  // CORS or code errors goes here