@innovastudio/contentbuilder 1.5.52 → 1.5.54

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.5.52",
4
+ "version": "1.5.54",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "types": "index.d.ts",
@@ -76908,10 +76908,16 @@ class Dictation {
76908
76908
  };
76909
76909
  this.opts = Object.assign(this, defaults, opts);
76910
76910
  this.builder = builder;
76911
- const util = this.builder.util;
76912
- this.util = util;
76911
+ } // constructor
76912
+
76913
+ renderPanel() {
76913
76914
  const builderStuff = this.builder.builderStuff;
76914
76915
  this.builderStuff = builderStuff;
76916
+ const util = this.builder.util;
76917
+ this.util = util;
76918
+
76919
+ // const dom = this.builder.dom;
76920
+
76915
76921
  if (localStorage.getItem('_mic') === null) {
76916
76922
  localStorage.setItem('_mic', '0'); // make mic disable by default
76917
76923
  }
@@ -77711,6 +77717,7 @@ class Dictation {
77711
77717
  }
77712
77718
  }
77713
77719
  openDictation() {
77720
+ this.renderPanel();
77714
77721
  if (this.builder.showDisclaimer) {
77715
77722
  if (localStorage.getItem('_disclaimershown') === null) {
77716
77723
  this.builder.util.showModal(this.modalDisclaimer, true, () => {
@@ -80722,12 +80729,14 @@ ${answer}
80722
80729
  };
80723
80730
  try {
80724
80731
  /*
80732
+ let headers = {
80733
+ ...this.builder.headers,
80734
+ ...this.builder.defaultHeaders
80735
+ };
80725
80736
  const response = await fetch(this.builder.sendCommandUrl, {
80726
80737
  signal: this.signal, // Abort
80727
80738
  method: 'POST',
80728
- headers: {
80729
- 'Content-Type': 'application/json',
80730
- },
80739
+ headers,
80731
80740
  body: JSON.stringify(messages),
80732
80741
  });
80733
80742
  const data = await response.json();
@@ -80737,13 +80746,15 @@ ${answer}
80737
80746
  if (this.builder.sendCommand) {
80738
80747
  data = await this.builder.sendCommand(messages);
80739
80748
  } else {
80749
+ let headers = {
80750
+ ...this.builder.headers,
80751
+ ...this.builder.defaultHeaders
80752
+ };
80740
80753
  const response = await fetch(this.builder.sendCommandUrl, {
80741
80754
  signal: this.signal,
80742
80755
  // Abort
80743
80756
  method: 'POST',
80744
- headers: {
80745
- 'Content-Type': 'application/json'
80746
- },
80757
+ headers,
80747
80758
  body: JSON.stringify(messages)
80748
80759
  });
80749
80760
  data = await response.json();
@@ -80807,11 +80818,13 @@ ${answer}
80807
80818
  if (this.builder.consoleLog) {
80808
80819
  if (!(error + '').includes('Failed to fetch')) {
80809
80820
  // Only if not CORS error
80821
+ let headers = {
80822
+ ...this.builder.headers,
80823
+ ...this.builder.defaultHeaders
80824
+ };
80810
80825
  const response = await fetch(this.builder.sendCommandUrl, {
80811
80826
  method: 'POST',
80812
- headers: {
80813
- 'Content-Type': 'application/json'
80814
- },
80827
+ headers,
80815
80828
  body: JSON.stringify(messages)
80816
80829
  });
80817
80830
  const data = await response.text();
@@ -86190,7 +86203,7 @@ class ContentBuilder {
86190
86203
  // { name: 'buttoneditor', showInMainToolbar: false, showInElementToolbar: false },
86191
86204
  // ],
86192
86205
  // pluginPath: 'contentbuilder/', // Location of the plugin scripts
86193
- disableConfig: false,
86206
+ disableConfig: true,
86194
86207
  // If you don't specify the plugins param and set the disableConfig to true, then no plugins will be loaded.
86195
86208
 
86196
86209
  modulePath: 'assets/modules/',
@@ -86854,6 +86867,11 @@ class ContentBuilder {
86854
86867
  enableDragResize: true,
86855
86868
  simpleTextSettings: false,
86856
86869
  enableColumnsPerLine: true,
86870
+ // For fetch
86871
+ defaultHeaders: {
86872
+ 'Content-Type': 'application/json'
86873
+ },
86874
+ headers: {},
86857
86875
  /* Prompt/Command Stuff for AI Assistant */
86858
86876
  startAIAssistant: false,
86859
86877
  isContentBox: false,
@@ -89464,16 +89482,21 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
89464
89482
  }
89465
89483
  closeAIAssistant() {
89466
89484
  let modal = document.querySelector('.is-modal.page-command');
89485
+ if (!modal) return;
89467
89486
  modal.classList.remove('active');
89468
89487
  this.dictation.stopDictation();
89469
89488
  localStorage.setItem('_dictation', '0');
89470
89489
  }
89471
89490
  toggleAIAssistant() {
89472
89491
  let modal = document.querySelector('.is-modal.page-command');
89473
- if (modal.classList.contains('active')) {
89474
- this.closeAIAssistant();
89475
- } else {
89492
+ if (!modal) {
89476
89493
  this.openAIAssistant();
89494
+ } else {
89495
+ if (modal.classList.contains('active')) {
89496
+ this.closeAIAssistant();
89497
+ } else {
89498
+ this.openAIAssistant();
89499
+ }
89477
89500
  }
89478
89501
  }
89479
89502
 
@@ -91183,13 +91206,15 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
91183
91206
  image: image,
91184
91207
  folder_path: ''
91185
91208
  };
91209
+ let headers = {
91210
+ ...this.headers,
91211
+ ...this.defaultHeaders
91212
+ };
91186
91213
  const response = await fetch(this.upscaleImageUrl, {
91187
91214
  signal: this.signal,
91188
91215
  // Abort
91189
91216
  method: 'POST',
91190
- headers: {
91191
- 'Content-Type': 'application/json'
91192
- },
91217
+ headers,
91193
91218
  body: JSON.stringify(messages)
91194
91219
  });
91195
91220
  const result = await response.json();
@@ -91219,13 +91244,15 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
91219
91244
  };
91220
91245
  try {
91221
91246
  let url = this.textToImageUrl;
91247
+ let headers = {
91248
+ ...this.headers,
91249
+ ...this.defaultHeaders
91250
+ };
91222
91251
  const response = await fetch(url, {
91223
91252
  signal: this.signal,
91224
91253
  // Abort
91225
91254
  method: 'POST',
91226
- headers: {
91227
- 'Content-Type': 'application/json'
91228
- },
91255
+ headers,
91229
91256
  body: JSON.stringify(messages)
91230
91257
  });
91231
91258
  const result = await response.json();
@@ -91260,12 +91287,14 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
91260
91287
  this.signal = this.controller.signal; // Get a new signal object
91261
91288
  const messages = { prompt, num };
91262
91289
  try {
91263
- const response = await fetch(this.generateImageUrl, {
91290
+ let headers = {
91291
+ ...this.headers,
91292
+ ...this.defaultHeaders
91293
+ };
91294
+ const response = await fetch(this.generateImageUrl, {
91264
91295
  signal: this.signal, // Abort
91265
91296
  method: 'POST',
91266
- headers: {
91267
- 'Content-Type': 'application/json',
91268
- },
91297
+ headers,
91269
91298
  body: JSON.stringify(messages),
91270
91299
  });
91271
91300
 
@@ -91304,13 +91333,15 @@ Add an image for each feature.`, 'Create a new content showcasing a photo galler
91304
91333
  let image = resizedBase64;
91305
91334
  image = image.replace(/^data:image\/(png|jpeg);base64,/, '');
91306
91335
 
91307
- const reqBody = { image: image, filename: filename };
91336
+ let headers = {
91337
+ ...this.headers,
91338
+ ...this.defaultHeaders
91339
+ };
91340
+ const reqBody = { image: image, filename: filename };
91308
91341
  fetch(this.uploadBase64Url, {
91309
91342
  method:'POST',
91310
91343
  body: JSON.stringify(reqBody),
91311
- headers: {
91312
- 'Content-Type': 'application/json',
91313
- }
91344
+ headers
91314
91345
  })
91315
91346
  .then(response=>response.json())
91316
91347
  .then(response=>{