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),