An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:lipstick: Reserve relation header space for sort arrows https://github.com/siyuan-note/siyuan/issues/19904
Daniel0c149ce34b9e
diff --git a/app/src/assets/scss/business/_av.scss b/app/src/assets/scss/business/_av.scssindex d5d58ed240..5f375a7cce 100644--- a/app/src/assets/scss/business/_av.scss+++ b/app/src/assets/scss/business/_av.scss@@ -2585,6 +2585,7 @@ img.av__cellassetimg {position: sticky;top: 0;z-index: 4;+ white-space: nowrap;.av__relation-table-cell {font-weight: 600;@@ -2599,6 +2600,7 @@ img.av__cellassetimg {}> svg {+ flex-shrink: 0;height: 14px;margin-right: 6px;width: 14px;diff --git a/app/src/protyle/render/av/columnWidth.test.ts b/app/src/protyle/render/av/columnWidth.test.tsindex 1b69c198f9..34182ea0e4 100644--- a/app/src/protyle/render/av/columnWidth.test.ts+++ b/app/src/protyle/render/av/columnWidth.test.ts@@ -33,6 +33,12 @@ describe("getAVRelationColumnWidth", () => {assert.equal(getAVRelationColumnWidth("480px", "relation", false), "200px");assert.equal(getAVRelationColumnWidth("120px", "date", false), "120px");});++ it("reserves header space for the sort arrow before sorting", () => {+ assert.equal(getAVRelationColumnWidth("84px", "checkbox", false, 42), "104px");+ assert.equal(getAVRelationColumnWidth("150px", "text", false, 30), "150px");+ assert.equal(getAVRelationColumnWidth("480px", "text", false, 480), "160px");+ });});describe("getAVTableFitWidths", () => {diff --git a/app/src/protyle/render/av/columnWidth.ts b/app/src/protyle/render/av/columnWidth.tsindex 691b7c4c4b..fe64eac48a 100644--- a/app/src/protyle/render/av/columnWidth.ts+++ b/app/src/protyle/render/av/columnWidth.ts@@ -33,8 +33,9 @@ export const getAVColumnFitWidth = (name: string, type: TAVCol, values: string[]return `${Math.ceil(Math.min(480, Math.max(64, headerWidth, contentWidth)))}px`;};-export const getAVRelationColumnWidth = (fitWidth: string, type: TAVCol, primary: boolean) => {- const width = parseFloat(fitWidth) || 64;+export const getAVRelationColumnWidth = (fitWidth: string, type: TAVCol, primary: boolean, nameWidth = 0) => {+ // 表头为字段图标、排序箭头和内边距预留空间。+ const width = Math.max(parseFloat(fitWidth) || 64, nameWidth + 62);const minWidth = primary ? 240 : 64;const maxWidth = primary ? 400 : ["relation", "rollup", "mAsset"].includes(type) ? 200 : 160;return `${Math.min(maxWidth, Math.max(minWidth, width))}px`;diff --git a/app/src/protyle/render/av/relation.ts b/app/src/protyle/render/av/relation.tsindex c327589c22..0c16ea90f4 100644--- a/app/src/protyle/render/av/relation.ts+++ b/app/src/protyle/render/av/relation.ts@@ -407,7 +407,7 @@ const getRelationGridTemplate = (columns: IAVColumn[], rows: IAVRow[],} as IAVTable, getCellValueText, measureText);return `32px ${columns.map((column, index) => {const width = widths[column.id] || "64px";- return getAVRelationColumnWidth(width, column.type, index === 0);+ return getAVRelationColumnWidth(width, column.type, index === 0, measureText(column.name));}).join(" ")}`;};@@ -423,7 +423,7 @@ const genRelationHeaderHTML = (columns: IAVColumn[], gridTemplate: string, sort?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><span class="fn__ellipsis">${escapeHtml(column.name)}</span>- ${sorted ? `<svg class="av__relation-sort"><use xlink:href="#${sort.order === "ASC" ? "iconUp" : "iconDown"}"></use></svg>` : ""}+ <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></span>`;});