@innovastudio/contentbuilder 1.4.89 → 1.4.91

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. package/package.json +1 -1
  2. package/public/contentbuilder/contentbuilder.css +17 -6
  3. package/public/contentbuilder/contentbuilder.esm.js +148 -25
  4. package/public/contentbuilder/contentbuilder.min.js +6 -6
  5. package/public/contentbuilder/themes/colored-blue.css +6 -0
  6. package/public/contentbuilder/themes/colored-blue2.css +6 -0
  7. package/public/contentbuilder/themes/colored-blue3.css +6 -0
  8. package/public/contentbuilder/themes/colored-blue4.css +6 -0
  9. package/public/contentbuilder/themes/colored-blue5.css +6 -0
  10. package/public/contentbuilder/themes/colored-blue6.css +6 -0
  11. package/public/contentbuilder/themes/colored-blue7.css +6 -0
  12. package/public/contentbuilder/themes/colored-blue8.css +6 -0
  13. package/public/contentbuilder/themes/colored-dark.css +6 -0
  14. package/public/contentbuilder/themes/colored-darkblue.css +6 -0
  15. package/public/contentbuilder/themes/colored-gray.css +6 -0
  16. package/public/contentbuilder/themes/colored-green.css +6 -0
  17. package/public/contentbuilder/themes/colored-green2.css +6 -0
  18. package/public/contentbuilder/themes/colored-green3.css +6 -0
  19. package/public/contentbuilder/themes/colored-green4.css +6 -0
  20. package/public/contentbuilder/themes/colored-green5.css +6 -0
  21. package/public/contentbuilder/themes/colored-magenta.css +6 -0
  22. package/public/contentbuilder/themes/colored-orange.css +6 -0
  23. package/public/contentbuilder/themes/colored-orange2.css +6 -0
  24. package/public/contentbuilder/themes/colored-orange3.css +6 -0
  25. package/public/contentbuilder/themes/colored-pink.css +6 -0
  26. package/public/contentbuilder/themes/colored-pink2.css +6 -0
  27. package/public/contentbuilder/themes/colored-pink3.css +6 -0
  28. package/public/contentbuilder/themes/colored-pink4.css +6 -0
  29. package/public/contentbuilder/themes/colored-purple.css +6 -0
  30. package/public/contentbuilder/themes/colored-purple2.css +6 -0
  31. package/public/contentbuilder/themes/colored-red.css +6 -0
  32. package/public/contentbuilder/themes/colored-red2.css +6 -0
  33. package/public/contentbuilder/themes/colored-red3.css +6 -0
  34. package/public/contentbuilder/themes/colored-red4.css +6 -0
  35. package/public/contentbuilder/themes/colored-red5.css +6 -0
  36. package/public/contentbuilder/themes/colored-yellow.css +6 -0
  37. package/public/contentbuilder/themes/colored-yellow2.css +6 -0
  38. package/public/contentbuilder/themes/dark-blue.css +6 -0
  39. package/public/contentbuilder/themes/dark-blue2.css +6 -0
  40. package/public/contentbuilder/themes/dark-blue3.css +6 -0
  41. package/public/contentbuilder/themes/dark-gray.css +6 -0
  42. package/public/contentbuilder/themes/dark-pink.css +6 -0
  43. package/public/contentbuilder/themes/dark-purple.css +6 -0
  44. package/public/contentbuilder/themes/dark-red.css +6 -0
  45. package/public/contentbuilder/themes/dark.css +6 -0
  46. package/public/contentbuilder/themes/light-blue.css +6 -0
  47. package/public/contentbuilder/themes/light-blue2.css +6 -0
  48. package/public/contentbuilder/themes/light-blue3.css +6 -0
  49. package/public/contentbuilder/themes/light-cyan.css +6 -0
  50. package/public/contentbuilder/themes/light-gray.css +6 -0
  51. package/public/contentbuilder/themes/light-gray2.css +6 -0
  52. package/public/contentbuilder/themes/light-gray3.css +6 -0
  53. package/public/contentbuilder/themes/light-green.css +6 -0
  54. package/public/contentbuilder/themes/light-pink.css +6 -0
  55. package/public/contentbuilder/themes/light-pink2.css +6 -0
  56. package/public/contentbuilder/themes/light-purple.css +6 -0
  57. package/public/contentbuilder/themes/light-purple2.css +6 -0
  58. package/public/contentbuilder/themes/light-red.css +6 -0
  59. package/public/contentbuilder/themes/light-yellow.css +6 -0
  60. package/public/contentbuilder/themes/light-yellow2.css +6 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbuilder",
3
3
  "type": "module",
4
- "version": "1.4.89",
4
+ "version": "1.4.91",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "files": [
@@ -3024,6 +3024,7 @@ button:focus-visible {
3024
3024
  .is-ui .is-tool.is-iframe-tool {
3025
3025
  background: rgba(0, 0, 0, 0.15);
3026
3026
  border: transparent 1px solid;
3027
+ box-shadow: none;
3027
3028
  }
3028
3029
  #_cbhtml .is-tool#divImageTool > div, #_cbhtml .is-tool#divImageTool > button, #_cbhtml .is-tool.is-video-tool > div, #_cbhtml .is-tool.is-video-tool > button, #_cbhtml .is-tool.is-audio-tool > div, #_cbhtml .is-tool.is-audio-tool > button, #_cbhtml .is-tool.is-iframe-tool > div, #_cbhtml .is-tool.is-iframe-tool > button,
3029
3030
  .is-ui .is-tool#divImageTool > div,
@@ -3065,13 +3066,12 @@ button:focus-visible {
3065
3066
  #_cbhtml .is-tool.is-spacer-tool,
3066
3067
  .is-ui .is-tool.is-spacer-tool {
3067
3068
  border: none;
3068
- background: none;
3069
3069
  }
3070
3070
  #_cbhtml .is-tool.is-spacer-tool > button,
3071
3071
  .is-ui .is-tool.is-spacer-tool > button {
3072
3072
  width: 30px;
3073
3073
  height: 30px;
3074
- background: rgba(240, 240, 240, 0.9);
3074
+ background: none;
3075
3075
  }
3076
3076
  #_cbhtml .is-tool.is-spacer-tool > button svg,
3077
3077
  .is-ui .is-tool.is-spacer-tool > button svg {
@@ -3081,6 +3081,7 @@ button:focus-visible {
3081
3081
  .is-ui .is-tool.is-table-tool {
3082
3082
  border: none;
3083
3083
  background: none;
3084
+ box-shadow: none;
3084
3085
  }
3085
3086
  #_cbhtml .is-tool.is-table-tool:hover,
3086
3087
  .is-ui .is-tool.is-table-tool:hover {
@@ -3114,13 +3115,20 @@ button:focus-visible {
3114
3115
  .is-ui .is-tool.is-module-tool > button svg {
3115
3116
  fill: #121212;
3116
3117
  }
3118
+ #_cbhtml .is-tool#divLinkTool, #_cbhtml .is-tool#divButtonTool, #_cbhtml .is-tool#divSvgTool,
3119
+ .is-ui .is-tool#divLinkTool,
3120
+ .is-ui .is-tool#divButtonTool,
3121
+ .is-ui .is-tool#divSvgTool {
3122
+ background: rgba(243, 243, 243, 0.9);
3123
+ box-shadow: none;
3124
+ }
3117
3125
  #_cbhtml .is-tool#divLinkTool button, #_cbhtml .is-tool#divButtonTool button, #_cbhtml .is-tool#divSvgTool button,
3118
3126
  .is-ui .is-tool#divLinkTool button,
3119
3127
  .is-ui .is-tool#divButtonTool button,
3120
3128
  .is-ui .is-tool#divSvgTool button {
3121
3129
  width: 30px;
3122
3130
  height: 30px;
3123
- background: rgba(243, 243, 243, 0.9);
3131
+ background: transparent;
3124
3132
  }
3125
3133
  #_cbhtml .is-tool#divLinkTool button svg, #_cbhtml .is-tool#divButtonTool button svg, #_cbhtml .is-tool#divSvgTool button svg,
3126
3134
  .is-ui .is-tool#divLinkTool button svg,
@@ -4327,6 +4335,10 @@ button:focus-visible {
4327
4335
  fill: #000;
4328
4336
  }
4329
4337
 
4338
+ #_cbhtml[gray] .is-tool {
4339
+ background: rgba(243, 243, 243, 0.9);
4340
+ box-shadow: none;
4341
+ }
4330
4342
  #_cbhtml[gray] .is-tool.is-column-tool {
4331
4343
  background: rgba(243, 243, 243, 0.9);
4332
4344
  flex-direction: row;
@@ -4570,9 +4582,6 @@ button:focus-visible {
4570
4582
  background: transparent;
4571
4583
  padding: 5px;
4572
4584
  }
4573
- #_cbhtml .is-tool.is-element-tool {
4574
- background: rgba(243, 243, 243, 0.9);
4575
- }
4576
4585
  #_cbhtml .is-tool.is-element-tool button {
4577
4586
  width: 25px;
4578
4587
  height: 25px;
@@ -4612,6 +4621,7 @@ button:focus-visible {
4612
4621
  width: auto;
4613
4622
  left: auto;
4614
4623
  right: -40px;
4624
+ box-shadow: none;
4615
4625
  }
4616
4626
  .is-tool.is-row-tool button {
4617
4627
  width: 25px;
@@ -4664,6 +4674,7 @@ button:focus-visible {
4664
4674
  flex-direction: row;
4665
4675
  margin-top: 0px;
4666
4676
  margin-left: -1px;
4677
+ box-shadow: none;
4667
4678
  }
4668
4679
  .is-tool.is-col-tool button {
4669
4680
  width: 25px;
@@ -5553,13 +5553,13 @@ class Util {
5553
5553
  localStorage.removeItem('_dictation');
5554
5554
  localStorage.removeItem('_mic');
5555
5555
  localStorage.removeItem('_autosendcommand');
5556
- localStorage.removeItem('_sampleshown');
5557
5556
  localStorage.removeItem('_disclaimershown');
5558
5557
  localStorage.removeItem('_temp');
5559
5558
  localStorage.removeItem('_top_p');
5560
5559
  localStorage.removeItem('_autosend_delay');
5561
5560
  localStorage.removeItem('_auto_editblock');
5562
5561
  localStorage.removeItem('_command_lang');
5562
+ localStorage.removeItem('_ai_panel_open');
5563
5563
 
5564
5564
  //NOT USED
5565
5565
  localStorage.removeItem('_scrollableeditor');
@@ -5570,6 +5570,7 @@ class Util {
5570
5570
  localStorage.removeItem('_advancedhtmleditor');
5571
5571
  localStorage.removeItem('_hidecolhtmleditor');
5572
5572
  localStorage.removeItem('_hiderowhtmleditor');
5573
+ localStorage.removeItem('_sampleshown');
5573
5574
  }
5574
5575
 
5575
5576
  // source: http://stackoverflow.com/questions/6690752/insert-html-at-caret-in-a-contenteditable-div */
@@ -77744,6 +77745,7 @@ class Dictation {
77744
77745
  <button class="scope-section on" title="${util.out('General')}" data-value="general" style="margin-right:5px">${util.out('General')}</button>
77745
77746
  <button class="scope-others" title="${util.out('Ask Questions')}" data-value="others">${util.out('Ask Questions')}</button>
77746
77747
  <button class="scope-block" title="${util.out('Edit Selected Block')}" data-value="block" style="">${util.out('Edit Selected Block')}</button>
77748
+ <button class="scope-image" title="${util.out('Image')}" data-value="image" style="display:none;margin-right:5px">${util.out('Image')}</button>
77747
77749
  </div>
77748
77750
  </div>
77749
77751
  <textarea class="inp-command"></textarea>
@@ -77875,15 +77877,12 @@ class Dictation {
77875
77877
  info += '</ul>';
77876
77878
  divInfo.innerHTML = info;
77877
77879
  const inpCommand = this.builderStuff.querySelector('.inp-command');
77878
- if (localStorage.getItem('_sampleshown') === null) {
77879
- inpCommand.setAttribute('placeholder', this.builder.commandPlaceholderText);
77880
- localStorage.setItem('_sampleshown', true);
77881
- }
77882
77880
  this.builder.commandText = '';
77883
77881
  this.builder.autoSendCommand = false;
77884
77882
  if (localStorage.getItem('_dictation') !== null) {
77885
77883
  if (localStorage.getItem('_dictation') === '1') {
77886
77884
  this.modalCommand.classList.add('active');
77885
+ this.doOpen();
77887
77886
  if (localStorage.getItem('_mic') !== null) {
77888
77887
  if (localStorage.getItem('_mic') === '1') {
77889
77888
  this.startDictation();
@@ -77984,28 +77983,34 @@ class Dictation {
77984
77983
  btnCommandList.addEventListener('click', () => {
77985
77984
  let htmlList = '';
77986
77985
  const commandInfo = this.builder.commandInfo;
77986
+ let bImageGeneration = false;
77987
+ if (this.builder.generateImageUrl && this.builder.uploadBase64Url) {
77988
+ bImageGeneration = true;
77989
+ }
77987
77990
  for (const key in commandInfo) {
77988
77991
  if (Object.prototype.hasOwnProperty.call(commandInfo, key)) {
77989
- const {
77990
- title,
77991
- description,
77992
- list,
77993
- width
77994
- } = commandInfo[key];
77995
- if (!this.builder.enableShortCommands) {
77996
- if (description) {
77997
- htmlList += `<h2>${title}</h2>`;
77998
- htmlList += `<p>${description}</p>`;
77992
+ if (key !== 'image' || key === 'image' && bImageGeneration) {
77993
+ const {
77994
+ title,
77995
+ description,
77996
+ list,
77997
+ width
77998
+ } = commandInfo[key];
77999
+ if (!this.builder.enableShortCommands) {
78000
+ if (description) {
78001
+ htmlList += `<h2>${title}</h2>`;
78002
+ htmlList += `<p>${description}</p>`;
78003
+ } else {
78004
+ htmlList += `<h2 style="margin-bottom:30px">${title}</h2>`;
78005
+ }
78006
+ for (const item of list) {
78007
+ if (width) htmlList += `<div role="button" tabindex="0" class="command-item" style="width:${width}">${item}</div>`;else htmlList += `<div role="button" tabindex="0" class="command-item">${item}</div>`;
78008
+ }
77999
78009
  } else {
78000
- htmlList += `<h2 style="margin-bottom:30px">${title}</h2>`;
78001
- }
78002
- for (const item of list) {
78003
- if (width) htmlList += `<div role="button" tabindex="0" class="command-item" style="width:${width}">${item}</div>`;else htmlList += `<div role="button" tabindex="0" class="command-item">${item}</div>`;
78004
- }
78005
- } else {
78006
- htmlList += `<h2>${title}</h2>`;
78007
- for (const item of list) {
78008
- if (width) htmlList += `<div role="button" tabindex="0" class="command-item" style="width:${width}">${item}</div>`;else htmlList += `<div role="button" tabindex="0" class="command-item">${item}</div>`;
78010
+ htmlList += `<h2>${title}</h2>`;
78011
+ for (const item of list) {
78012
+ if (width) htmlList += `<div role="button" tabindex="0" class="command-item" style="width:${width}">${item}</div>`;else htmlList += `<div role="button" tabindex="0" class="command-item">${item}</div>`;
78013
+ }
78009
78014
  }
78010
78015
  }
78011
78016
  }
@@ -78115,7 +78120,10 @@ class Dictation {
78115
78120
  const btnScopeSection = this.modalCommand.querySelector('.scope-section');
78116
78121
  const btnScopeBlock = this.modalCommand.querySelector('.scope-block');
78117
78122
  const btnScopeOthers = this.modalCommand.querySelector('.scope-others');
78123
+ const btnScopeImage = this.modalCommand.querySelector('.scope-image');
78118
78124
  btnScopeBlock.disabled = true;
78125
+ if (this.builder.generateImageUrl) btnScopeImage.style.display = ''; // show generate image button
78126
+
78119
78127
  const assistModeBtns = modalCommand.querySelectorAll('.div-assistant-mode button');
78120
78128
  assistModeBtns.forEach(btn => {
78121
78129
  btn.addEventListener('click', () => {
@@ -78124,7 +78132,21 @@ class Dictation {
78124
78132
  });
78125
78133
  btn.classList.add('on');
78126
78134
  const val = btn.getAttribute('data-value');
78127
- this.builder.assistantMode = val; // general, block, others
78135
+ this.builder.assistantMode = val; // general, block, others, image
78136
+
78137
+ if (this.builder.hidePlaceholder) {
78138
+ inpCommand.setAttribute('placeholder', '');
78139
+ } else {
78140
+ if (val === 'general') {
78141
+ inpCommand.setAttribute('placeholder', this.builder.commandPlaceholders.general);
78142
+ } else if (val === 'block') {
78143
+ inpCommand.setAttribute('placeholder', this.builder.commandPlaceholders.edit_block);
78144
+ } else if (val === 'others') {
78145
+ inpCommand.setAttribute('placeholder', this.builder.commandPlaceholders.ask_questions);
78146
+ } else if (val === 'image') {
78147
+ inpCommand.setAttribute('placeholder', this.builder.commandPlaceholders.generate_image);
78148
+ }
78149
+ }
78128
78150
 
78129
78151
  /*
78130
78152
  // ContentBox
@@ -78155,17 +78177,20 @@ class Dictation {
78155
78177
  btnScopeBlock.classList.add('on');
78156
78178
  btnScopeSection.classList.remove('on');
78157
78179
  btnScopeOthers.classList.remove('on');
78180
+ btnScopeImage.classList.remove('on');
78158
78181
  }
78159
78182
  btnScopeBlock.removeAttribute('disabled');
78160
78183
  } else {
78161
78184
  btnScopeBlock.disabled = true;
78162
78185
  if (btnScopeOthers.classList.contains('on')) return;
78186
+ if (btnScopeImage.classList.contains('on')) return;
78163
78187
 
78164
78188
  // change
78165
78189
  this.builder.assistantMode = 'general';
78166
78190
  btnScopeSection.classList.add('on');
78167
78191
  btnScopeBlock.classList.remove('on');
78168
78192
  btnScopeOthers.classList.remove('on');
78193
+ btnScopeImage.classList.remove('on');
78169
78194
  }
78170
78195
  };
78171
78196
  this.initialStart = false; // for Safari
@@ -78240,7 +78265,28 @@ class Dictation {
78240
78265
  return true;
78241
78266
  }
78242
78267
  }
78268
+ doOpen() {
78269
+ this.builder.hidePlaceholder = false;
78270
+ const numeOfOpenToHidePlaceholderText = 4;
78271
+ if (localStorage.getItem('_ai_panel_open') === null) {
78272
+ localStorage.setItem('_ai_panel_open', 1);
78273
+ } else {
78274
+ let count = parseInt(localStorage.getItem('_ai_panel_open'));
78275
+ if (count < numeOfOpenToHidePlaceholderText) {
78276
+ count++;
78277
+ localStorage.setItem('_ai_panel_open', count);
78278
+ }
78279
+ }
78280
+ const inpCommand = this.builderStuff.querySelector('.inp-command');
78281
+ if (localStorage.getItem('_ai_panel_open') === `${numeOfOpenToHidePlaceholderText}`) {
78282
+ this.builder.hidePlaceholder = true;
78283
+ inpCommand.setAttribute('placeholder', '');
78284
+ } else {
78285
+ inpCommand.setAttribute('placeholder', this.builder.commandPlaceholders.general);
78286
+ }
78287
+ }
78243
78288
  openDictation() {
78289
+ this.doOpen();
78244
78290
  const inpCommand = this.modalCommand.querySelector('.inp-command');
78245
78291
  if (this.modalCommand.classList.contains('active')) {
78246
78292
  setTimeout(() => {
@@ -80021,6 +80067,7 @@ class ContentBuilder {
80021
80067
  window.selectAsset = this.selectAsset.bind(this);
80022
80068
  window.assetType = this.assetType.bind(this);
80023
80069
  window.hideModal = this.hideModal.bind(this);
80070
+ window.generateImage = this.generateImage.bind(this);
80024
80071
  setTimeout(() => {
80025
80072
  // Remember UI
80026
80073
  if (localStorage.getItem('_livepreview') != null) {
@@ -81814,6 +81861,82 @@ class ContentBuilder {
81814
81861
  }
81815
81862
  }
81816
81863
  }
81864
+ async generateImage(prompt, num, callback) {
81865
+ if (!(this.generateImageUrl && this.uploadBase64Url)) return;
81866
+ this.controller = new AbortController(); // Create a new AbortController
81867
+ this.signal = this.controller.signal; // Get a new signal object
81868
+
81869
+ const messages = {
81870
+ prompt,
81871
+ num
81872
+ };
81873
+ try {
81874
+ const response = await fetch(this.generateImageUrl, {
81875
+ signal: this.signal,
81876
+ // Abort
81877
+ method: 'POST',
81878
+ headers: {
81879
+ 'Content-Type': 'application/json'
81880
+ },
81881
+ body: JSON.stringify(messages)
81882
+ });
81883
+ const result = await response.json();
81884
+ if (result.error) {
81885
+ console.log('Error:\n' + result.error);
81886
+ return;
81887
+ }
81888
+ const filename = result.filename;
81889
+ let images = [];
81890
+ const numOfImages = result.data.data.length;
81891
+ const imageList = result.data.data;
81892
+ imageList.forEach(item => {
81893
+ const base64 = item.b64_json;
81894
+ const src = `data:image/jpeg;base64,${base64}`;
81895
+ var newWidth = 1024;
81896
+ var newHeight = 1024;
81897
+ var img = new Image();
81898
+ img.src = src;
81899
+ img.onload = () => {
81900
+ var canvas = document.createElement('canvas');
81901
+ canvas.width = newWidth;
81902
+ canvas.height = newHeight;
81903
+ var ctx = canvas.getContext('2d');
81904
+ ctx.drawImage(img, 0, 0, newWidth, newHeight);
81905
+ var resizedBase64 = canvas.toDataURL('image/jpeg');
81906
+ let image = resizedBase64;
81907
+ image = image.replace(/^data:image\/(png|jpeg);base64,/, '');
81908
+ const reqBody = {
81909
+ image: image,
81910
+ filename: filename
81911
+ };
81912
+ fetch(this.uploadBase64Url, {
81913
+ method: 'POST',
81914
+ body: JSON.stringify(reqBody),
81915
+ headers: {
81916
+ 'Content-Type': 'application/json'
81917
+ }
81918
+ }).then(response => response.json()).then(response => {
81919
+ if (!response.error) {
81920
+ const uploadedImageUrl = response.url;
81921
+ images.push(uploadedImageUrl);
81922
+ if (images.length === numOfImages) {
81923
+ callback(images);
81924
+ }
81925
+ }
81926
+ });
81927
+ };
81928
+ });
81929
+ } catch (error) {
81930
+ if (error.name === 'AbortError') ; else {
81931
+ // CORS or code errors goes here
81932
+ console.error('Error:', error);
81933
+ // console.log('Error:\n'+error);
81934
+
81935
+ this.dictation.finish(); // Must be called after finished
81936
+ }
81937
+ }
81938
+ }
81939
+
81817
81940
  lightboxOpen(col) {
81818
81941
  // Open Lightbox
81819
81942
  if (this.useLightbox) {