Skip to content

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

:art: Display database option descriptions on hover https://github.com/siyuan-note/siyuan/issues/15598

Daniel8872ba987d63
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index 87ce23d688..130e5b72bc 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -1029,7 +1029,8 @@ export const renderCellAttr = (cellElement: Element, value: IAVCellValue) => {
}
};
-export const renderCell = (cellValue: IAVCellValue, rowIndex = 0, showIcon = true, type: TAVView = "table") => {
+export const renderCell = (cellValue: IAVCellValue, rowIndex = 0, showIcon = true, type: TAVView = "table",
+ selectOptions?: IAVColumn["options"]) => {
let text = "";
if ("template" === cellValue.type) {
text = `<span class="av__celltext">${cellValue ? getAVTemplateHTML(cellValue.template.content || "") : ""}</span>`;
@@ -1056,7 +1057,11 @@ export const renderCell = (cellValue: IAVCellValue, rowIndex = 0, showIcon = tru
if (cellValue.type === "select" && index > 0) {
return;
}
- text += `<span class="b3-chip" style="background-color:var(--b3-font-background${item.color});color:var(--b3-font-color${item.color})">${escapeHtml(item.content)}</span>`;
+ const desc = selectOptions?.find(option => option.name === item.content)?.desc;
+ const tooltip = desc ?
+ ` data-position="north" aria-label="${escapeAriaLabel(item.content)}<div class='ft__on-surface'>${escapeAriaLabel(desc)}</div>"` :
+ "";
+ text += `<span class="b3-chip${desc ? " ariaLabel" : ""}"${tooltip} style="background-color:var(--b3-font-background${item.color});color:var(--b3-font-color${item.color})">${escapeHtml(item.content)}</span>`;
});
} else if (cellValue.type === "date") {
const dataValue = cellValue ? cellValue.date : null;
diff --git a/app/src/protyle/render/av/row.ts b/app/src/protyle/render/av/row.ts
index 7ffee338ad..deaa2f26e3 100644
--- a/app/src/protyle/render/av/row.ts
+++ b/app/src/protyle/render/av/row.ts
@@ -73,7 +73,7 @@ data-field-id="${kanbanData.fields[fieldsIndex].id}"
data-dtype="${cell.valueType}"
${cell.value?.isDetached ? ' data-detached="true"' : ""}
style="${cell.bgColor ? `background-color:${cell.bgColor};` : ""}
-${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, options.rowIndex, kanbanData.showIcon, "gallery")}</div>`;
+${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, options.rowIndex, kanbanData.showIcon, "gallery", kanbanData.fields[fieldsIndex].options)}</div>`;
if (kanbanData.displayFieldName) {
html += `<div class="av__gallery-field av__gallery-field--name" data-empty="${isEmpty}">
<div class="av__gallery-name">
@@ -139,7 +139,7 @@ data-field-id="${kanbanData.fields[fieldsIndex].id}"
data-dtype="${cell.valueType}"
${cell.value?.isDetached ? ' data-detached="true"' : ""}
style="${cell.bgColor ? `background-color:${cell.bgColor};` : ""}
-${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, options.rowIndex, kanbanData.showIcon, "kanban")}</div>`;
+${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, options.rowIndex, kanbanData.showIcon, "kanban", kanbanData.fields[fieldsIndex].options)}</div>`;
if (kanbanData.displayFieldName) {
html += `<div class="av__gallery-field av__gallery-field--name" data-empty="${isEmpty}">
<div class="av__gallery-name">
@@ -192,7 +192,7 @@ data-align="${column.align || ""}"
${cell.value?.isDetached ? ' data-detached="true"' : ""}
style="width: ${column.width || "200px"};
${cell.bgColor ? `background-color:${cell.bgColor};` : ""}
-${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, options.rowIndex, tableData.showIcon)}</div>`;
+${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, options.rowIndex, tableData.showIcon, "table", column.options)}</div>`;
if (options.pinIndex === index) {
html += "</div>";