mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-01 22:38:49 +01:00
🎨 Remove the check for !TesseractEnabled when saving OCR recognition results (#11708)
* 去除保存ocr识别结果时对 !TesseractEnabled 的检测 * 🐛 https://github.com/siyuan-note/siyuan/issues/11709 * https://github.com/siyuan-note/siyuan/pull/11708 修改ocr相关接口 * https://github.com/siyuan-note/siyuan/pull/11708 修改前端相关代码 * Update router.go * Update router.go --------- Co-authored-by: Vanessa <lly219@gmail.com>
This commit is contained in:
parent
6efa948859
commit
b590091c9e
5 changed files with 38 additions and 18 deletions
|
|
@ -1017,8 +1017,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
|
|||
bind(element) {
|
||||
element.style.maxWidth = "none";
|
||||
fetchPost("/api/asset/getImageOCRText", {
|
||||
path: imgElement.getAttribute("src"),
|
||||
force: false
|
||||
path: imgElement.getAttribute("src")
|
||||
}, (response) => {
|
||||
element.querySelector("textarea").value = response.data.text;
|
||||
});
|
||||
|
|
@ -1029,9 +1028,14 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
|
|||
iconHTML: "",
|
||||
label: window.siyuan.languages.reOCR,
|
||||
click() {
|
||||
fetchPost("/api/asset/getImageOCRText", {
|
||||
fetchPost("/api/asset/ocr", {
|
||||
path: imgElement.getAttribute("src"),
|
||||
force: true
|
||||
}, (response) => {
|
||||
fetchPost("/api/asset/setImageOCRText", {
|
||||
path: imgElement.getAttribute("src"),
|
||||
text: response.data.text
|
||||
});
|
||||
});
|
||||
}
|
||||
}],
|
||||
|
|
@ -1115,13 +1119,6 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
|
|||
const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea");
|
||||
textElements[0].focus();
|
||||
window.siyuan.menus.menu.removeCB = () => {
|
||||
const ocrElemennt = window.siyuan.menus.menu.element.querySelector('[data-type="ocr"]') as HTMLTextAreaElement;
|
||||
if (ocrElemennt) {
|
||||
fetchPost("/api/asset/setImageOCRText", {
|
||||
path: imgElement.getAttribute("src"),
|
||||
text: ocrElemennt.value
|
||||
});
|
||||
}
|
||||
imgElement.setAttribute("alt", textElements[2].value.replace(/\n|\r\n|\r|\u2028|\u2029/g, ""));
|
||||
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
||||
updateTransaction(protyle, id, nodeElement.outerHTML, html);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue