Update.
This commit is contained in:
parent
006882cd6f
commit
1e6f8b9cd8
@ -3,6 +3,10 @@ class STTButton extends HTMLElement {
|
||||
static get observedAttributes() { return ['target']; }
|
||||
|
||||
simulateTypingWithEvents(element, text, delay = 100) {
|
||||
let resolver = null
|
||||
let promise = new Promise((resolve, reject)=>{
|
||||
resolver = resolve
|
||||
})
|
||||
let index = 0;
|
||||
|
||||
function triggerEvent(type, key) {
|
||||
@ -39,8 +43,10 @@ class STTButton extends HTMLElement {
|
||||
index++;
|
||||
} else {
|
||||
clearInterval(interval);
|
||||
resolver()
|
||||
}
|
||||
}, delay);
|
||||
return promise
|
||||
}
|
||||
|
||||
constructor() {
|
||||
@ -102,13 +108,17 @@ this.recog.onresult = (e) => {
|
||||
committed += punctuated + ' '; // add to permanent text
|
||||
if (this.targetEl) {
|
||||
this.targetEl.focus()
|
||||
|
||||
punctuated = punctuated.replace(/\./g, ".\n")
|
||||
punctuated = punctuated.replace(/\?/g, "?\n")
|
||||
punctuated = punctuated.replace(/\!/g, "!\n")
|
||||
this.simulateTypingWithEvents(this.targetEl, punctuated,1)
|
||||
this.simulateTypingWithEvents(this.targetEl, punctuated,1).then(()=>{
|
||||
const chatInput = document.querySelector('chat-input')
|
||||
chatInput.finalizeMessage()
|
||||
})
|
||||
//triggerEvent('keydown', "Enter");
|
||||
|
||||
|
||||
triggerEvent('keyup', "Enter");
|
||||
//this.targetEl.value = committed + interim
|
||||
|
||||
/*this.targetElement.dispatchEvent(new ChangeEvent('change', {
|
||||
|
Loading…
Reference in New Issue
Block a user