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/11966
Vanessa5fbc57a55afb
diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.tsindex a4aaff881a..8179d2979f 100644--- a/app/src/protyle/render/av/render.ts+++ b/app/src/protyle/render/av/render.ts@@ -670,7 +670,6 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {const avID = operation.action === "setAttrViewName" ? operation.id : operation.avID;Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${avID}"]`)).forEach((item: HTMLElement) => {item.removeAttribute("data-render");- const updateRow = item.querySelector('[data-need-update="true"]');if (operation.action === "sortAttrViewCol" || operation.action === "sortAttrViewRow") {item.querySelectorAll(".av__cell--active").forEach((item: HTMLElement) => {item.classList.remove("av__cell--active");@@ -707,10 +706,6 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {renderAVAttribute(attrElement.parentElement, attrElement.dataset.nodeId, protyle);} else {if (operation.action === "insertAttrViewBlock") {- if (updateRow && !item.querySelector(`[data-id="${updateRow.getAttribute("data-id")}"]`)) {- showMessage(window.siyuan.languages.insertRowTip);- document.querySelector(".av__mask")?.remove();- }if (item.getAttribute("data-av-type") === "gallery") {operation.srcs.forEach(srcItem => {const filesElement = item.querySelector(`.av__gallery-item[data-id="${srcItem.id}"]`)?.querySelector(".av__gallery-fields");diff --git a/app/src/protyle/render/av/row.ts b/app/src/protyle/render/av/row.tsindex d58e59f3fa..1c22bf8cf7 100644--- a/app/src/protyle/render/av/row.ts+++ b/app/src/protyle/render/av/row.ts@@ -3,7 +3,7 @@ import {focusBlock} from "../../util/selection";import {Menu} from "../../../plugin/Menu";import {transaction} from "../../wysiwyg/transaction";import {- addDragFill,+ addDragFill, genCellValue,genCellValueByElement,getTypeByCellElement,popTextCell,@@ -122,39 +122,48 @@ export const insertAttrViewBlockAnimation = (options: {groupID?: string}) => {(options.blockElement.querySelector('[data-type="av-search"]') as HTMLInputElement).value = "";- const avId = options.blockElement.getAttribute("data-av-id");+ const hasSort = options.blockElement.querySelector('.av__views [data-type="av-sort"]').classList.contains("block__icon--active");+ const hasMore = !options.blockElement.querySelector('[data-type="av-load-more"]').classList.contains("fn__none");+ if (hasMore && hasSort) {+ showMessage(window.siyuan.languages.insertRowTip);+ }const groupQuery = options.groupID ? `.av__body[data-group-id="${options.groupID}"] ` : "";let previousElement = options.blockElement.querySelector(`.av__row[data-id="${options.previousId}"]`) || options.blockElement.querySelector(groupQuery + ".av__row--header");// 有排序需要加入最后一行- if (options.blockElement.querySelector('.av__views [data-type="av-sort"]').classList.contains("block__icon--active")) {+ if (hasSort) {previousElement = options.blockElement.querySelector(groupQuery + ".av__row--util").previousElementSibling;}- let colHTML = '<div class="av__colsticky"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg></div></div>';++ let cellsHTML = '<div class="av__colsticky"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg></div></div>';const pinIndex = previousElement.querySelectorAll(".av__colsticky .av__cell").length - 1;if (pinIndex > -1) {- colHTML = '<div class="av__colsticky"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg></div>';+ cellsHTML = '<div class="av__colsticky"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg></div>';}+ const avId = options.blockElement.getAttribute("data-av-id");previousElement.querySelectorAll(".av__cell").forEach((item: HTMLElement, index) => {- let lineNumber = "";- if (getTypeByCellElement(item) === "lineNumber") {+ let lineNumber = 1;+ const colType = getTypeByCellElement(item);+ if (colType === "lineNumber") {const lineNumberValue = item.querySelector(".av__celltext")?.getAttribute("data-value");if (lineNumberValue) {- lineNumber = (parseInt(lineNumberValue) + 1).toString();+ lineNumber = parseInt(lineNumberValue) + 1;}}- colHTML += `<div class="av__cell" data-col-id="${item.dataset.colId}"+ cellsHTML += `<div class="av__cell${colType === "checkbox" ? " av__cell-uncheck" : ""}" data-col-id="${item.dataset.colId}"+data-wrap="${item.dataset.wrap}"+data-dtype="${item.dataset.dtype}"style="width: ${item.style.width};${item.dataset.dtype === "number" ? "text-align: right;" : ""}"-${getTypeByCellElement(item) === "block" ? ' data-detached="true"' : ""}><span class="${avId ? "av__celltext" : "av__pulse"}">${lineNumber}</span></div>`;+${colType === "block" ? ' data-detached="true"' : ""}>${renderCell(genCellValue(colType, null), lineNumber)}</div>`;if (pinIndex === index) {- colHTML += "</div>";+ cellsHTML += "</div>";}});let html = "";options.srcIDs.forEach((id) => {const blockCellElement = options.blockElement.querySelector(`[data-block-id="${id}"]`);if (!blockCellElement) {- html += `<div class="av__row" data-type="ghost" data-id="${id}" data-avid="${avId}" data-previous-id="${options.previousId}">- ${colHTML}+ html += `<div class="av__row" data-type="ghost">+ ${cellsHTML}</div>`;} else {clearSelect(["cell"], options.blockElement);@@ -163,112 +172,31 @@ ${getTypeByCellElement(item) === "block" ? ' data-detached="true"' : ""}><span c}});previousElement.insertAdjacentHTML("afterend", html);- if (avId) {- const currentRow = previousElement.nextElementSibling;- if (options.blockElement.querySelector('.av__views [data-type="av-sort"]').classList.contains("block__icon--active") &&- !options.blockElement.querySelector('[data-type="av-load-more"]').classList.contains("fn__none")) {- currentRow.setAttribute("data-need-update", "true");- }- const sideRow = previousElement.classList.contains("av__row--header") ? currentRow.nextElementSibling : previousElement;- fetchPost("/api/av/getAttributeViewAddingBlockDefaultValues", {- avID: avId,- viewID: options.blockElement.getAttribute(Constants.CUSTOM_SY_AV_VIEW),- groupID: options.groupID,- previousID: options.previousId,- }, (response) => {- // https://github.com/siyuan-note/siyuan/issues/10517- let hideTextCell = false;- response.data.filters.find((item: IAVFilter) => {- const headerElement = options.blockElement.querySelector(`.av__cell--header[data-col-id="${item.column}"]`);- if (!headerElement) {- return;- }- const filterType = headerElement.getAttribute("data-dtype");- if (item.value && filterType !== item.value.type) {- return;+ fetchPost("/api/av/getAttributeViewAddingBlockDefaultValues", {+ avID: avId,+ viewID: options.blockElement.getAttribute(Constants.CUSTOM_SY_AV_VIEW),+ groupID: options.groupID,+ previousID: options.previousId,+ }, (response) => {+ let popCellElement: HTMLElement;+ options.blockElement.querySelectorAll('[data-type="ghost"]').forEach(rowItem => {+ const updateIds = Object.keys(response.data.values);+ rowItem.querySelectorAll(".av__cell").forEach((cellItem: HTMLElement) => {+ if (!popCellElement && cellItem.getAttribute("data-detached") === "true") {+ popCellElement = cellItem;}- if (["relation", "rollup", "template"].includes(filterType)) {- hideTextCell = true;- return true;- }-- // 根据后台计算出显示与否的结果进行标识,以便于在 refreshAV 中更新 UI- if (["created", "updated"].includes(filterType)) {- currentRow.setAttribute("data-need-update", "true");- } else {- response.data.sorts.find((sortItem: IAVSort) => {- if (sortItem.column === item.column) {- currentRow.setAttribute("data-need-update", "true");- return true;- }- });- }- // 当空或非空外,需要根据值进行判断- let isRenderValue = true;- if (item.operator !== "Is empty" && item.operator !== "Is not empty") {- switch (item.value.type) {- case "select":- case "mSelect":- if (!item.value.mSelect || item.value.mSelect.length === 0) {- isRenderValue = false;- }- break;- case "block":- if (!item.value.block || !item.value.block.content) {- isRenderValue = false;- }- break;- case "number":- if (!item.value.number || !item.value.number.isNotEmpty) {- isRenderValue = false;- }- break;- case "date":- case "created":- case "updated":- if (!item.value[item.value.type] || !item.value[item.value.type].isNotEmpty) {- isRenderValue = false;- }- break;- case "mAsset":- if (!item.value.mAsset || item.value.mAsset.length === 0) {- isRenderValue = false;- }- break;- case "checkbox":- if (!item.value.checkbox) {- isRenderValue = false;- }- break;- case "text":- case "url":- case "phone":- case "email":- if (!item.value[item.value.type] || !item.value[item.value.type].content) {- isRenderValue = false;- }- break;- }- }- if (sideRow.classList.contains("av__row") && isRenderValue) {- const sideRowCellElement = sideRow.querySelector(`.av__cell[data-col-id="${item.column}"]`) as HTMLElement;- const cellElement = currentRow.querySelector(`.av__cell[data-col-id="${item.column}"]`);- const cellValue = genCellValueByElement(getTypeByCellElement(sideRowCellElement), sideRowCellElement);- const iconElement = cellElement.querySelector(".b3-menu__avemoji");- cellElement.innerHTML = renderCell(cellValue, 0, iconElement ? !iconElement.classList.contains("fn__none") : false);- renderCellAttr(cellElement, cellValue);+ if (updateIds.includes(cellItem.dataset.colId)) {+ const cellValue = response.data.values[cellItem.dataset.colId];+ cellItem.innerHTML = renderCell(cellValue);+ renderCellAttr(cellItem, cellValue);}});- if (hideTextCell) {- currentRow.remove();- showMessage(window.siyuan.languages.insertRowTip);- } else if (options.srcIDs.length === 1) {- popTextCell(options.protyle, [currentRow.querySelector('.av__cell[data-detached="true"]')], "block");- }- setPage(options.blockElement);});- }- setPage(options.blockElement);+ if (options.srcIDs.length === 1 && !(hasMore && hasSort)) {+ popTextCell(options.protyle, [popCellElement], "block");+ }+ setPage(options.blockElement);+ });};export const stickyRow = (blockElement: HTMLElement, elementRect: DOMRect, status: "top" | "bottom" | "all") => {