An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Support copying database rollup cell contents https://github.com/siyuan-note/siyuan/issues/19566
Vanessab78f366a9ef0
diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.tsindex e24c7c35a9..a66f72a9fe 100644--- a/app/src/protyle/render/av/action.ts+++ b/app/src/protyle/render/av/action.ts@@ -8,6 +8,7 @@ import {cellValueIsEmpty,genCellValueByElement,getCellText,+ getCellValueText,getTypeByCellElement,popTextCell,renderCell,@@ -764,6 +765,25 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEleevent.stopPropagation();return true;} else if (type === "copy") {+ if (target.hasAttribute("data-rollup-value")) {+ const values: IAVCellValue[] = JSON.parse(decodeURIComponent(target.dataset.rollupValue));+ writeText(values.map(value => {+ if (value.type === "block") {+ return value.block?.content || window.siyuan.languages.untitled;+ }+ if (value.type === "checkbox") {+ return value.checkbox?.checked ? "true" : "false";+ }+ if (value.type === "mAsset") {+ return (value.mAsset || []).map(asset => asset.content).join(", ");+ }+ return getCellValueText(value);+ }).join(", "));+ showMessage(window.siyuan.languages.copied);+ event.preventDefault();+ event.stopPropagation();+ return true;+ }const cellElement = hasClosestByClassName(target, "av__cell") as HTMLElement;const source = getAVTextSource(genCellValueByElement("text", cellElement));if (source.kind === "rich") {diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.tsindex a224e41601..69e39c513a 100644--- a/app/src/protyle/render/av/cell.ts+++ b/app/src/protyle/render/av/cell.ts@@ -1211,7 +1211,7 @@ export const renderCellAttr = (cellElement: Element, value: IAVCellValue) => {export const renderCell = (cellValue: IAVCellValue, rowIndex = 0, showIcon = true, type: TAVView = "table",selectOptions?: IAVColumn["options"], dateFormat: TAVDateFormat = "",- renderTemplate?: string) => {+ renderTemplate?: string, showCopy = true) => {let text = "";if (hasAVRenderTemplateResult(cellValue, renderTemplate)) {const storedValue = cloneAVCellValueSnapshot(cellValue);@@ -1299,7 +1299,7 @@ export const renderCell = (cellValue: IAVCellValue, rowIndex = 0, showIcon = tru} else if (cellValue.type === "rollup") {let rollupType;cellValue?.rollup?.contents?.forEach((item) => {- const rollupText = ["template", "select", "mSelect", "mAsset", "relation"].includes(item.type) ? renderCell(item, rowIndex, showIcon, type) : renderRollup(item, showIcon);+ const rollupText = ["template", "select", "mSelect", "mAsset", "relation"].includes(item.type) ? renderCell(item, rowIndex, showIcon, type, undefined, "", undefined, false) : renderRollup(item, showIcon);if (rollupText) {text += rollupText + (item.type === "checkbox" ? "" : ", ");}@@ -1329,10 +1329,12 @@ export const renderCell = (cellValue: IAVCellValue, rowIndex = 0, showIcon = tru}}- if ((["text", "template", "url", "email", "phone", "date", "created", "updated"].includes(cellValue.type) && cellValue[cellValue.type as "url"]?.content) ||+ if (showCopy && cellValue.type === "rollup" && text) {+ text += `<button class="av__cell-action ariaLabel" type="button" data-position="4north" aria-label="${window.siyuan.languages.copy}" data-type="copy" data-rollup-value="${escapeAttr(encodeURIComponent(JSON.stringify(cellValue.rollup?.contents || [])))}"><svg><use xlink:href="#iconCopy"></use></svg></button>`;+ } else if (showCopy && ((["text", "template", "url", "email", "phone", "date", "created", "updated"].includes(cellValue.type) && cellValue[cellValue.type as "url"]?.content) ||cellValue.type === "lineNumber" ||(cellValue.type === "number" && cellValue.number?.isNotEmpty) ||- (cellValue.type === "block" && cellValue.block?.content)) {+ (cellValue.type === "block" && cellValue.block?.content))) {text += `<button class="av__cell-action ariaLabel" type="button" data-position="4north" aria-label="${window.siyuan.languages.copy}" data-type="copy"><svg><use xlink:href="#iconCopy"></use></svg></button>`;}return text;