An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/10142
Vanessaa5d6d4e848b7
diff --git a/app/src/protyle/render/av/asset.ts b/app/src/protyle/render/av/asset.tsindex 646a576500..66537dcd64 100644--- a/app/src/protyle/render/av/asset.ts+++ b/app/src/protyle/render/av/asset.ts@@ -53,7 +53,7 @@ export const bindAssetEvent = (options: {export const getAssetHTML = (cellElements: HTMLElement[]) => {let html = "";- genCellValueByElement(getTypeByCellElement(cellElements[0]), cellElements[0]).mAsset.forEach(item => {+ genCellValueByElement("mAsset", cellElements[0]).mAsset.forEach(item => {if (!item.content) {return;}diff --git a/app/src/protyle/render/av/blockAttr.ts b/app/src/protyle/render/av/blockAttr.tsindex 14b4d1a83c..3c3313a623 100644--- a/app/src/protyle/render/av/blockAttr.ts+++ b/app/src/protyle/render/av/blockAttr.ts@@ -106,24 +106,25 @@ export const genAVValueHTML = (value: IAVCellValue) => {break;case "relation":value.relation?.blockIDs?.forEach((item, index) => {- html += `<span class="av__celltext--url" style="margin-right: 8px" data-id="${item}">${value.relation?.contents[index]}</span>`;+ html += `<span class="av__celltext--url" style="margin-right: 8px" data-id="${item}">${value.relation?.contents[index] || "Untitled"}</span>`;});break;case "rollup":- value?.rollup?.contents?.forEach((item, index) => {+ value?.rollup?.contents?.forEach((item) => {const rollupText = ["select", "mSelect", "mAsset", "checkbox", "relation"].includes(item.type) ? genAVValueHTML(item) : genAVRollupHTML(item);- if (!rollupText && html) {- html = html.substring(0, html.length - 2);- } else {- html += rollupText + ((index === value.rollup.contents.length - 1 || !rollupText) ? "" : ", ");+ if (rollupText) {+ html += rollupText + ", ";}});+ if (html && html.endsWith(", ")) {+ html = html.substring(0, html.length - 2);+ }break;}return html;};-export const renderAVAttribute = (element: HTMLElement, id: string, protyle?: IProtyle) => {+export const renderAVAttribute = (element: HTMLElement, id: string, protyle: IProtyle) => {fetchPost("/api/av/getAttributeViewKeys", {id}, (response) => {let html = "";response.data.forEach((table: {@@ -167,40 +168,42 @@ class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone"].includes});html += "</div>";});- element.innerHTML = html;- element.addEventListener("click", (event) => {- let target = event.target as HTMLElement;- while (target && !element.isSameNode(target)) {- const type = target.getAttribute("data-type");- if (type === "date") {- popTextCell(protyle, [target], "date");- event.stopPropagation();- event.preventDefault();- break;- } else if (type === "select" || type === "mSelect") {- popTextCell(protyle, [target], target.getAttribute("data-type") as TAVCol);- event.stopPropagation();- event.preventDefault();- break;- } else if (type === "mAsset") {- popTextCell(protyle, [target], "mAsset");- event.stopPropagation();- event.preventDefault();- break;- } else if (type === "checkbox") {- popTextCell(protyle, [target], "checkbox");- event.stopPropagation();- event.preventDefault();- break;- } else if (type === "relation") {- popTextCell(protyle, [target], "relation");- event.stopPropagation();- event.preventDefault();- break;+ if (element.innerHTML === "") {+ element.addEventListener("click", (event) => {+ let target = event.target as HTMLElement;+ while (target && !element.isSameNode(target)) {+ const type = target.getAttribute("data-type");+ if (type === "date") {+ popTextCell(protyle, [target], "date");+ event.stopPropagation();+ event.preventDefault();+ break;+ } else if (type === "select" || type === "mSelect") {+ popTextCell(protyle, [target], target.getAttribute("data-type") as TAVCol);+ event.stopPropagation();+ event.preventDefault();+ break;+ } else if (type === "mAsset") {+ popTextCell(protyle, [target], "mAsset");+ event.stopPropagation();+ event.preventDefault();+ break;+ } else if (type === "checkbox") {+ popTextCell(protyle, [target], "checkbox");+ event.stopPropagation();+ event.preventDefault();+ break;+ } else if (type === "relation") {+ popTextCell(protyle, [target], "relation");+ event.stopPropagation();+ event.preventDefault();+ break;+ }+ target = target.parentElement;}- target = target.parentElement;- }- });+ });+ }+ element.innerHTML = html;element.querySelectorAll(".b3-text-field--text").forEach((item: HTMLInputElement) => {item.addEventListener("change", () => {let value;diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.tsindex ab26f7ce26..87c8f0cdfa 100644--- a/app/src/protyle/render/av/render.ts+++ b/app/src/protyle/render/av/render.ts@@ -8,6 +8,7 @@ import {hasClosestBlock, hasClosestByClassName} from "../../util/hasClosest";import {stickyRow} from "./row";import {getCalcValue} from "./calc";import {openMenuPanel} from "./openMenuPanel";+import {renderAVAttribute} from "./blockAttr";export const avRender = (element: Element, protyle: IProtyle, cb?: () => void, viewID?: string) => {let avElements: Element[] = [];@@ -295,6 +296,13 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {if (operation.action === "addAttrViewCol" && isPulse) {openMenuPanel({protyle, blockElement: item, type: "edit", colId: operation.id});}+ if (operation.action === "updateAttrViewCell") {+ const attrElement = document.querySelector(`.b3-dialog--open[data-key="${Constants.DIALOG_ATTR}"] div[data-av-id="${operation.avID}"]`) as HTMLElement+ if (attrElement) {+ // 更新属性面板+ renderAVAttribute(attrElement.parentElement, attrElement.dataset.nodeId, protyle);+ }+ }}, ["addAttrViewView", "duplicateAttrViewView"].includes(operation.action) ? operation.id :(operation.action === "removeAttrViewView" ? null : undefined));});