Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/15956

Vanessac8831f8119bd
diff --git a/app/src/protyle/render/av/blockAttr.ts b/app/src/protyle/render/av/blockAttr.ts
index f6dbf08b4f..58920931e4 100644
--- a/app/src/protyle/render/av/blockAttr.ts
+++ b/app/src/protyle/render/av/blockAttr.ts
@@ -573,3 +573,7 @@ const openEdit = (protyle: IProtyle, element: HTMLElement, event: MouseEvent) =>
target = target.parentElement;
}
};
+
+export const isCustomAttr = (cellElement: Element) => {
+ return !!cellElement.getAttribute("data-av-id");
+};
diff --git a/app/src/protyle/render/av/row.ts b/app/src/protyle/render/av/row.ts
index f12f3a66ca..4904918789 100644
--- a/app/src/protyle/render/av/row.ts
+++ b/app/src/protyle/render/av/row.ts
@@ -14,9 +14,10 @@ import * as dayjs from "dayjs";
import {Constants} from "../../../constants";
import {insertGalleryItemAnimation} from "./gallery/item";
import {clearSelect} from "../../util/clearSelect";
+import {isCustomAttr} from "./blockAttr";
export const getFieldIdByCellElement = (cellElement: Element, viewType: TAVView): string => {
- if (hasClosestByClassName(cellElement, "custom-attr")) {
+ if (isCustomAttr(cellElement)) {
return cellElement.getAttribute("data-row-id");
}
return (hasClosestByClassName(cellElement, viewType === "table" ? "av__row" : "av__gallery-item") as HTMLElement).dataset.id;
diff --git a/app/src/protyle/render/av/select.ts b/app/src/protyle/render/av/select.ts
index c0a9a50dcc..eb0ae0eebd 100644
--- a/app/src/protyle/render/av/select.ts
+++ b/app/src/protyle/render/av/select.ts
@@ -5,7 +5,7 @@ import {confirmDialog} from "../../../dialog/confirmDialog";
import {upDownHint} from "../../../util/upDownHint";
import {bindEditEvent, getColId, getEditHTML} from "./col";
import {updateAttrViewCellAnimation} from "./action";
-import {genAVValueHTML} from "./blockAttr";
+import {genAVValueHTML, isCustomAttr} from "./blockAttr";
import {escapeAriaLabel, escapeAttr, escapeHtml} from "../../../util/escape";
import {genCellValueByElement, getTypeByCellElement} from "./cell";
import * as dayjs from "dayjs";
@@ -213,7 +213,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement,
} else {
cellElements.forEach((cellElement: HTMLElement, index) => {
const rowID = getFieldIdByCellElement(cellElement, viewType);
- if (viewType === "table") {
+ if (viewType === "table" || isCustomAttr) {
cellElement = cellElements[index] = (blockElement.querySelector(`.av__row[data-id="${rowID}"] .av__cell[data-col-id="${cellElement.dataset.colId}"]`) ||
blockElement.querySelector(`.fn__flex-1[data-col-id="${cellElement.dataset.colId}"]`)) as HTMLElement;
} else {
@@ -331,7 +331,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement,
} else {
cellElements.forEach((cellElement: HTMLElement, index) => {
const rowID = getFieldIdByCellElement(cellElement, viewType);
- if (viewType === "table") {
+ if (viewType === "table" || isCustomAttr) {
cellElement = cellElements[index] = (blockElement.querySelector(`.av__row[data-id="${rowID}"] .av__cell[data-col-id="${cellElement.dataset.colId}"]`) ||
blockElement.querySelector(`.fn__flex-1[data-col-id="${cellElement.dataset.colId}"]`)) as HTMLElement;
} else {
@@ -523,7 +523,7 @@ export const addColOptionOrCell = (protyle: IProtyle, data: IAV, cellElements: H
if (!nodeElement) {
cellElements.forEach((item, index) => {
const rowID = getFieldIdByCellElement(item, data.viewType);
- if (data.viewType === "table") {
+ if (data.viewType === "table" || isCustomAttr(item)) {
cellElements[index] = (blockElement.querySelector(`.av__row[data-id="${rowID}"] .av__cell[data-col-id="${item.dataset.colId}"]`) ||
blockElement.querySelector(`.fn__flex-1[data-col-id="${item.dataset.colId}"]`)) as HTMLElement;
} else {