From 5d015b516ce1f9f5e08192540fc4bdb3307ff329 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 16 Oct 2025 23:28:08 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/16132 Signed-off-by: Daniel <845765@qq.com> --- app/src/menus/protyle.ts | 20 ++++++++++---------- kernel/api/asset.go | 10 +++++++++- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index 2f1c10a18..2f88f74d1 100644 --- a/app/src/menus/protyle.ts +++ b/app/src/menus/protyle.ts @@ -1,8 +1,10 @@ import { hasClosestBlock, hasClosestByAttribute, - hasClosestByClassName, hasClosestByTag, - hasTopClosestByClassName, isInEmbedBlock + hasClosestByClassName, + hasClosestByTag, + hasTopClosestByClassName, + isInEmbedBlock } from "../protyle/util/hasClosest"; import {MenuItem} from "./Menu"; import {focusBlock, focusByRange, focusByWbr, getEditorRange, selectAll,} from "../protyle/util/selection"; @@ -24,13 +26,7 @@ import {transaction, updateTransaction} from "../protyle/wysiwyg/transaction"; import {openMenu} from "./commonMenuItem"; import {fetchPost, fetchSyncPost} from "../util/fetch"; import {Constants} from "../constants"; -import { - copyPlainText, - readClipboard, - setStorageVal, - updateHotkeyTip, - writeText -} from "../protyle/util/compatibility"; +import {copyPlainText, readClipboard, setStorageVal, updateHotkeyTip, writeText} from "../protyle/util/compatibility"; import {preventScroll} from "../protyle/scroll/preventScroll"; import {onGet} from "../protyle/util/onGet"; import {getAllModels} from "../layout/getAll"; @@ -1087,6 +1083,10 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme const imgElement = assetElement.querySelector("img"); const titleElement = assetElement.querySelector(".protyle-action__title span") as HTMLElement; const html = nodeElement.outerHTML; + let src = imgElement.getAttribute("src"); + if (!src) { + src = "" + } if (!protyle.disabled) { window.siyuan.menus.menu.append(new MenuItem({ id: "imageUrlAndTitleAndTooltipText", @@ -1098,7 +1098,7 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme -
+
${window.siyuan.languages.title} diff --git a/kernel/api/asset.go b/kernel/api/asset.go index 2d660cb72..6225c1cd8 100644 --- a/kernel/api/asset.go +++ b/kernel/api/asset.go @@ -113,7 +113,15 @@ func getImageOCRText(c *gin.Context) { return } - path := arg["path"].(string) + var path string + if nil == arg["path"] { + ret.Data = map[string]interface{}{ + "text": "", + } + return + } else { + path = arg["path"].(string) + } ret.Data = map[string]interface{}{ "text": util.GetAssetText(path),