This commit is contained in:
ThatOneCalculator 2022-08-08 17:24:21 -07:00
parent 109b111871
commit a993acd26c
1 changed files with 7 additions and 4 deletions

View File

@ -6,6 +6,8 @@
<header> <header>
<Mfm v-if="title" class="title" :text="title"/> <Mfm v-if="title" class="title" :text="title"/>
<span class="text-count" :class="{ over: remainingLength < 0 }">{{ remainingLength }}</span> <span class="text-count" :class="{ over: remainingLength < 0 }">{{ remainingLength }}</span>
<br/>
<span id="recognized-text"></span>
</header> </header>
<textarea id="captioninput" v-model="inputValue" autofocus :placeholder="input.placeholder" @keydown="onInputKeydown"></textarea> <textarea id="captioninput" v-model="inputValue" autofocus :placeholder="input.placeholder" @keydown="onInputKeydown"></textarea>
<div v-if="(showOkButton || showCaptionButton || showCancelButton)" class="buttons"> <div v-if="(showOkButton || showCaptionButton || showCancelButton)" class="buttons">
@ -149,10 +151,11 @@ export default defineComponent({
await worker.loadLanguage('eng'); await worker.loadLanguage('eng');
await worker.initialize('eng'); await worker.initialize('eng');
const { data: { text } } = await worker.recognize(imgurl); const { data: { text } } = await worker.recognize(imgurl);
console.log(`\n\n${text}\n\n`); console.log(text);
const allowedLength = 512 - this.inputValue.length; document.getElementById('recognized-text').innerText = text;
this.inputValue += text.slice(0, allowedLength); // const allowedLength = 512 - this.inputValue.length;
await worker.terminate(); // this.inputValue += text.slice(0, allowedLength);
// await worker.terminate();
}, },
}, },
}); });