Skip to content

Commit 3eb749f

Browse files
committed
feat: auto copy
1 parent c7ed0a4 commit 3eb749f

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

app/pages/ocr.vue

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ async function onFileChange(newFile: File | null | undefined) {
110110
imageFile.value = newFile
111111
await runOCR(imageFile.value)
112112
format()
113+
if (auto_copy_value.value) {
114+
switch (auto_copy_value.value) {
115+
case 'typst':
116+
copyAsTypst()
117+
break
118+
case 'latex':
119+
copy()
120+
break
121+
default:
122+
copy(auto_copy_value.value)
123+
}
124+
}
113125
}
114126
}
115127
@@ -163,6 +175,10 @@ const handlePaste = async (event: ClipboardEvent) => {
163175
}
164176
}
165177
178+
// auto copy
179+
const auto_copy_items = ref(['latex', 'typst', ...wrap_format_options])
180+
const auto_copy_value = ref(null)
181+
166182
let load: (model_config: ModelConfig) => Promise<void>
167183
let runOCR: (imageFile: File) => Promise<void>
168184
@@ -410,6 +426,16 @@ onBeforeUnmount(() => {
410426
{{ t('copyAs') + ' ' + t('typstCode') }}
411427
</UButton>
412428
</div>
429+
<div class="flex">
430+
<USelect
431+
v-model="auto_copy_value"
432+
:items="auto_copy_items"
433+
:placeholder="t('autoCopy')"
434+
:ui="{
435+
content: 'w-auto'
436+
}"
437+
/>
438+
</div>
413439
</div>
414440
</template>
415441
</UCard>

i18n/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"typstCode": "Typst",
2727
"convert_to": "Convert to ",
2828
"failed": "failed",
29+
"autoCopy": "Auto copy",
2930
"comment_welcome": "Wanna say something to the developer or the users?",
3031
"report_issue": "Encounter an issue? Report here!",
3132
"load_model_from": "Load model from",

i18n/locales/zh-CN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"typstCode": "Typst",
2727
"convert_to": "转换为",
2828
"failed": "失败",
29+
"autoCopy": "自动复制",
2930
"comment_welcome": "想对开发者或用户说点什么?",
3031
"report_issue": "遇到问题?点我反馈!",
3132
"load_model_from": "加载模型自",

0 commit comments

Comments
 (0)