Skip to content

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

:lipstick: Show custom field and document icons in relation selection https://github.com/siyuan-note/siyuan/issues/19904

Daniel0766498fe74a
diff --git a/app/src/assets/scss/business/_av.scss b/app/src/assets/scss/business/_av.scss
index 5f375a7cce..8153116ba5 100644
--- a/app/src/assets/scss/business/_av.scss
+++ b/app/src/assets/scss/business/_av.scss
@@ -2599,6 +2599,7 @@ img.av__cellassetimg {
right: 0;
}
+ > .av__relation-header-icon,
> svg {
flex-shrink: 0;
height: 14px;
@@ -2606,6 +2607,16 @@ img.av__cellassetimg {
width: 14px;
}
+ .av__relation-header-icon {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ object-fit: contain;
+ line-height: 1;
+ font-family: var(--b3-font-family-emoji);
+ font-variant-emoji: emoji;
+ }
+
.av__relation-sort {
flex-shrink: 0;
margin-left: auto;
diff --git a/app/src/protyle/render/av/relation.ts b/app/src/protyle/render/av/relation.ts
index 863e189901..7e97f975f2 100644
--- a/app/src/protyle/render/av/relation.ts
+++ b/app/src/protyle/render/av/relation.ts
@@ -24,6 +24,7 @@ import {getAVTemplateHTML} from "./attributeValue";
import {hasAVRenderTemplateResult} from "./cellValue";
import {renderAVRichTextElements} from "./richText";
import {getFileTreeIconHTML} from "../../../emoji/fileTreeIcon";
+import {unicode2Emoji} from "../../../emoji";
import {bindRelationLayout} from "./relationLayout";
import {getTopBarHeight} from "../../../layout/getTopBarHeight";
@@ -421,7 +422,8 @@ const genRelationHeaderHTML = (columns: IAVColumn[], gridTemplate: string, sort?
columns.forEach((column, index) => {
const sorted = sort?.column === column.id;
html += `<span data-relation-column="${escapeAttr(column.id)}" role="columnheader" tabindex="0" aria-sort="${sorted ? sort.order === "ASC" ? "ascending" : "descending" : "none"}" class="av__relation-table-cell fn__pointer${index === 0 ? " av__relation-table-primary" : ""}">
- <svg><use xlink:href="#${getColIconByType(column.type)}"></use></svg>
+ ${column.icon ? unicode2Emoji(column.icon, "av__relation-header-icon", true) :
+ `<svg><use xlink:href="#${getColIconByType(column.type)}"></use></svg>`}
<span class="fn__ellipsis">${escapeHtml(column.name)}</span>
<svg class="av__relation-sort${sorted ? "" : " fn__hidden"}" aria-hidden="true"><use xlink:href="#${sort?.order === "DESC" ? "iconDown" : "iconUp"}"></use></svg>
<span class="av__widthdrag"></span>
@@ -463,7 +465,7 @@ style="${primaryCell.bgColor ? `background-color:${primaryCell.bgColor};` : ""}$
} else {
html += `<div data-relation-column="${escapeAttr(column.id)}" class="av__relation-table-cell"
style="${cell?.bgColor ? `background-color:${cell.bgColor};` : ""}${cell?.color ? `color:${cell.color};` : ""}">${cell?.value ?
- renderCell(cell.value, 0, false, "table", column.options, column.dateFormat, column.renderTemplate) : ""}</div>`;
+ renderCell(cell.value, 0, true, "table", column.options, column.dateFormat, column.renderTemplate) : ""}</div>`;
}
});
return html + "</div>";