@innovastudio/contentbuilder 1.4.91 → 1.4.93
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
@@ -78138,13 +78138,13 @@ class Dictation {
|
|
78138
78138
|
inpCommand.setAttribute('placeholder', '');
|
78139
78139
|
} else {
|
78140
78140
|
if (val === 'general') {
|
78141
|
-
inpCommand.setAttribute('placeholder', this.builder.commandPlaceholders.general);
|
78141
|
+
inpCommand.setAttribute('placeholder', this.builder.commandPlaceholders.general || '');
|
78142
78142
|
} else if (val === 'block') {
|
78143
|
-
inpCommand.setAttribute('placeholder', this.builder.commandPlaceholders.edit_block);
|
78143
|
+
inpCommand.setAttribute('placeholder', this.builder.commandPlaceholders.edit_block || '');
|
78144
78144
|
} else if (val === 'others') {
|
78145
|
-
inpCommand.setAttribute('placeholder', this.builder.commandPlaceholders.ask_questions);
|
78145
|
+
inpCommand.setAttribute('placeholder', this.builder.commandPlaceholders.ask_questions || '');
|
78146
78146
|
} else if (val === 'image') {
|
78147
|
-
inpCommand.setAttribute('placeholder', this.builder.commandPlaceholders.generate_image);
|
78147
|
+
inpCommand.setAttribute('placeholder', this.builder.commandPlaceholders.generate_image || '');
|
78148
78148
|
}
|
78149
78149
|
}
|
78150
78150
|
|
@@ -78282,7 +78282,11 @@ class Dictation {
|
|
78282
78282
|
this.builder.hidePlaceholder = true;
|
78283
78283
|
inpCommand.setAttribute('placeholder', '');
|
78284
78284
|
} else {
|
78285
|
-
|
78285
|
+
if (!this.builder.commandPlaceholders) {
|
78286
|
+
this.builder.commandPlaceholders = {};
|
78287
|
+
this.builder.commandPlaceholders.general = '';
|
78288
|
+
}
|
78289
|
+
inpCommand.setAttribute('placeholder', this.builder.commandPlaceholders.general || '');
|
78286
78290
|
}
|
78287
78291
|
}
|
78288
78292
|
openDictation() {
|
@@ -79370,7 +79374,6 @@ class ContentBuilder {
|
|
79370
79374
|
onlineDemo: false,
|
79371
79375
|
autoSendDelay: 4000,
|
79372
79376
|
autoEditBlock: false,
|
79373
|
-
commandPlaceholderText: '',
|
79374
79377
|
enableShortCommands: true,
|
79375
79378
|
speechRecognitionLang: 'en-US',
|
79376
79379
|
assistantMode: 'general',
|
@@ -81887,45 +81890,39 @@ class ContentBuilder {
|
|
81887
81890
|
}
|
81888
81891
|
const filename = result.filename;
|
81889
81892
|
let images = [];
|
81890
|
-
const
|
81891
|
-
const
|
81892
|
-
|
81893
|
-
|
81894
|
-
|
81895
|
-
|
81896
|
-
|
81897
|
-
var
|
81898
|
-
|
81899
|
-
|
81900
|
-
|
81901
|
-
|
81902
|
-
|
81903
|
-
|
81904
|
-
|
81905
|
-
|
81906
|
-
|
81907
|
-
|
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
|
-
});
|
81893
|
+
const base64 = result.data;
|
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
|
81927
81911
|
};
|
81928
|
-
|
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
|
+
callback(images);
|
81923
|
+
}
|
81924
|
+
});
|
81925
|
+
};
|
81929
81926
|
} catch (error) {
|
81930
81927
|
if (error.name === 'AbortError') ; else {
|
81931
81928
|
// CORS or code errors goes here
|
@@ -81937,6 +81934,92 @@ class ContentBuilder {
|
|
81937
81934
|
}
|
81938
81935
|
}
|
81939
81936
|
|
81937
|
+
/*
|
81938
|
+
async generateImage(prompt, num, callback) {
|
81939
|
+
if(!(this.generateImageUrl && this.uploadBase64Url)) return;
|
81940
|
+
this.controller = new AbortController(); // Create a new AbortController
|
81941
|
+
this.signal = this.controller.signal; // Get a new signal object
|
81942
|
+
const messages = { prompt, num };
|
81943
|
+
try {
|
81944
|
+
const response = await fetch(this.generateImageUrl, {
|
81945
|
+
signal: this.signal, // Abort
|
81946
|
+
method: 'POST',
|
81947
|
+
headers: {
|
81948
|
+
'Content-Type': 'application/json',
|
81949
|
+
},
|
81950
|
+
body: JSON.stringify(messages),
|
81951
|
+
});
|
81952
|
+
|
81953
|
+
const result = await response.json();
|
81954
|
+
|
81955
|
+
if(result.error) {
|
81956
|
+
console.log('Error:\n'+result.error);
|
81957
|
+
return;
|
81958
|
+
}
|
81959
|
+
|
81960
|
+
const filename = result.filename;
|
81961
|
+
|
81962
|
+
let images = [];
|
81963
|
+
|
81964
|
+
const numOfImages = result.data.data.length;
|
81965
|
+
|
81966
|
+
const imageList = result.data.data;
|
81967
|
+
imageList.forEach(item=>{
|
81968
|
+
const base64 = item.b64_json;
|
81969
|
+
const src = `data:image/jpeg;base64,${base64}`;
|
81970
|
+
|
81971
|
+
var newWidth = 1024;
|
81972
|
+
var newHeight = 1024;
|
81973
|
+
var img = new Image();
|
81974
|
+
img.src = src;
|
81975
|
+
img.onload = () => {
|
81976
|
+
|
81977
|
+
var canvas = document.createElement('canvas');
|
81978
|
+
canvas.width = newWidth;
|
81979
|
+
canvas.height = newHeight;
|
81980
|
+
|
81981
|
+
var ctx = canvas.getContext('2d');
|
81982
|
+
ctx.drawImage(img, 0, 0, newWidth, newHeight);
|
81983
|
+
var resizedBase64 = canvas.toDataURL('image/jpeg');
|
81984
|
+
|
81985
|
+
let image = resizedBase64;
|
81986
|
+
image = image.replace(/^data:image\/(png|jpeg);base64,/, '');
|
81987
|
+
|
81988
|
+
const reqBody = { image: image, filename: filename };
|
81989
|
+
fetch(this.uploadBase64Url, {
|
81990
|
+
method:'POST',
|
81991
|
+
body: JSON.stringify(reqBody),
|
81992
|
+
headers: {
|
81993
|
+
'Content-Type': 'application/json',
|
81994
|
+
}
|
81995
|
+
})
|
81996
|
+
.then(response=>response.json())
|
81997
|
+
.then(response=>{
|
81998
|
+
if(!response.error) {
|
81999
|
+
const uploadedImageUrl = response.url;
|
82000
|
+
images.push(uploadedImageUrl);
|
82001
|
+
if(images.length===numOfImages) {
|
82002
|
+
callback(images);
|
82003
|
+
}
|
82004
|
+
}
|
82005
|
+
});
|
82006
|
+
};
|
82007
|
+
|
82008
|
+
});
|
82009
|
+
} catch (error) {
|
82010
|
+
if (error.name === 'AbortError') {
|
82011
|
+
// Do Nothing
|
82012
|
+
// console.log('Request aborted by user.');
|
82013
|
+
} else {
|
82014
|
+
// CORS or code errors goes here
|
82015
|
+
console.error('Error:', error);
|
82016
|
+
// console.log('Error:\n'+error);
|
82017
|
+
this.dictation.finish(); // Must be called after finished
|
82018
|
+
}
|
82019
|
+
}
|
82020
|
+
}
|
82021
|
+
*/
|
82022
|
+
|
81940
82023
|
lightboxOpen(col) {
|
81941
82024
|
// Open Lightbox
|
81942
82025
|
if (this.useLightbox) {
|