Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: Simplify redundant image tooltip text https://github.com/siyuan-note/siyuan/issues/19997

Daniel74daab0f8aa9
diff --git a/app/src/protyle/render/imageTooltip.ts b/app/src/protyle/render/imageTooltip.ts
index 68c3cd8319..065f755632 100644
--- a/app/src/protyle/render/imageTooltip.ts
+++ b/app/src/protyle/render/imageTooltip.ts
@@ -12,7 +12,9 @@ export const getImageTooltip = (image: HTMLImageElement, size?: string) => {
} catch (error) {
// 非 URL 编码的文件名保留原文。
}
- const text = Array.from(new Set([name, image.title, image.alt].filter(Boolean)))
+ const nameWithoutExtension = extension ? name.substring(0, name.lastIndexOf(".")) : name;
+ const descriptions = [image.title, image.alt].filter(value => value && value !== nameWithoutExtension);
+ const text = Array.from(new Set([name, ...descriptions].filter(Boolean)))
.map(value => escapeHtml(value)).join("<br>");
const format = /^data:image\/([\w.+-]+)/.exec(source)?.[1].replace(/\+xml$/, "").toUpperCase() ||
extension.substring(1).toUpperCase();