Skip to content

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

:sparkles: Improve document icon display in database relation selection dialogs https://github.com/siyuan-note/siyuan/issues/19699

Danielb3bcbc777053
diff --git a/app/src/assets/scss/business/_av.scss b/app/src/assets/scss/business/_av.scss
index f4235c71fc..9a77aa76a7 100644
--- a/app/src/assets/scss/business/_av.scss
+++ b/app/src/assets/scss/business/_av.scss
@@ -2629,6 +2629,24 @@ img.av__cellassetimg {
}
}
+ .av__relation-row-icon {
+ align-items: center;
+ display: flex;
+ flex: 0 0 auto;
+ justify-content: center;
+ height: 20px;
+ width: 20px;
+ margin-right: 6px;
+ font-size: 16px;
+
+ svg,
+ img {
+ height: 16px;
+ width: 16px;
+ object-fit: contain;
+ }
+ }
+
.av__relation-row-open {
align-items: center;
background-color: transparent;
diff --git a/app/src/protyle/render/av/relation.ts b/app/src/protyle/render/av/relation.ts
index 5c559101d5..1ec35e7a00 100644
--- a/app/src/protyle/render/av/relation.ts
+++ b/app/src/protyle/render/av/relation.ts
@@ -23,6 +23,7 @@ import {getSearchAVFocus} from "./searchAVFocus";
import {getAVTemplateHTML} from "./attributeValue";
import {hasAVRenderTemplateResult} from "./cellValue";
import {renderAVRichTextElements} from "./richText";
+import {getFileTreeIconHTML} from "../../../emoji/fileTreeIcon";
interface IAVItem {
avID: string;
@@ -446,8 +447,10 @@ style="grid-template-columns:${gridTemplate}">
data-value-id="${escapeAttr(primaryCell.id || "")}"
style="${primaryCell.bgColor ? `background-color:${primaryCell.bgColor};` : ""}${primaryCell.color ? `color:${primaryCell.color};` : ""}">
${selected ? '<svg class="b3-menu__icon fn__grab"><use xlink:href="#iconDrag"></use></svg>' : ""}
+ ${isDetached ? "" : `<span class="av__relation-row-icon">${getFileTreeIconHTML(primaryValue.block?.icon, "file")}</span>`}
<span class="b3-menu__label fn__ellipsis${isDetached ? "" : " popover__block"}${useRenderedContent ? " av__celltext--template" : ""}"
${isDetached ? "" : 'style="color:var(--b3-protyle-inline-blockref-color)"'}
+ data-icon="${escapeAttr(primaryValue.block?.icon || "")}"
data-id="${escapeAttr(primaryValue.block?.id || "")}" data-content="${escapeAttr(primaryValue.block?.content || "")}">${content}</span>
${primaryCell.id ? `<button type="button" class="av__relation-row-open ariaLabel" data-type="openRelationRow" draggable="false"
data-position="north" aria-label="${window.siyuan.languages.openBy}"><svg><use xlink:href="#iconOpen"></use></svg></button>` : ""}
@@ -614,6 +617,7 @@ export const bindRelationEvent = (options: {
return {
id: item.dataset.rowId,
blockID: blockElement.dataset.id,
+ icon: blockElement.dataset.icon || "",
content: blockElement.dataset.content ?? blockElement.textContent,
isDetached: !blockElement.classList.contains("popover__block"),
};
@@ -625,6 +629,7 @@ export const bindRelationEvent = (options: {
return {
id,
blockID: value?.block?.id,
+ icon: value?.block?.icon || "",
content: value?.block?.content || "",
isDetached: value?.isDetached === true || !value?.block?.id,
};
@@ -734,6 +739,7 @@ ${genRelationLoaderHTML(state.loading, state.loaderVisible)}`;
isDetached: item.isDetached,
block: {
id: item.blockID,
+ icon: item.icon,
content: item.content,
}
}
@@ -907,6 +913,7 @@ const getRelationValue = (menuElement: HTMLElement) => {
type: "block",
block: {
id: blockElement.dataset.id,
+ icon: blockElement.dataset.icon || "",
content: blockElement.dataset.content ?? blockElement.textContent
},
isDetached: !blockElement.classList.contains("popover__block")