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/7536

Vanessad96f09d2d44f
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index f23e6ddf38..92c587e8b2 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -1,5 +1,5 @@
import {transaction} from "../../wysiwyg/transaction";
-import {hasClosestBlock} from "../../util/hasClosest";
+import {hasClosestBlock, hasClosestByClassName} from "../../util/hasClosest";
import {Menu} from "../../../plugin/Menu";
import {getColIconByType} from "./col";
@@ -40,16 +40,22 @@ export const popTextCell = (protyle: IProtyle, cellElement: HTMLElement) => {
const updateCellValue = (protyle: IProtyle, cellElement: HTMLElement, type: TAVCol) => {
- const avMaskElement = document.querySelector(".av__mask");
- const inputElement = avMaskElement.querySelector(".b3-text-field") as HTMLInputElement;
- const blockElement = hasClosestBlock(cellElement);
+ const rowElement = hasClosestByClassName(cellElement, "av__row");
+ if (!rowElement) {
+ return;
+ }
+ const blockElement = hasClosestBlock(rowElement);
if (!blockElement) {
return;
}
+ const avMaskElement = document.querySelector(".av__mask");
+ const inputElement = avMaskElement.querySelector(".b3-text-field") as HTMLInputElement;
+
transaction(protyle, [{
action: "updateAttrViewCell",
- id: blockElement.getAttribute("data-node-id"),
- rowID: blockElement.getAttribute("data-av-id"),
+ id: cellElement.getAttribute("data-id"),
+ rowID: rowElement.getAttribute("data-id"),
+ parentID: blockElement.getAttribute("data-av-id"),
type,
data: inputElement.value,
}], [{
diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts
index 141f9128a5..30f5ed8fb6 100644
--- a/app/src/protyle/render/av/render.ts
+++ b/app/src/protyle/render/av/render.ts
@@ -48,7 +48,7 @@ export const avRender = (element: Element, cb?: () => void) => {
</div>
<div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg></div>`;
row.cells.forEach((cell, index) => {
- tableHTML += `<div class="av__cell" data-block-id="${cell.renderValue?.id || ""}" data-index="${index}" style="width: ${data.columns[index].width || 200}px;${cell.bgColor ? `background-color:${cell.bgColor};` : ""}${cell.color ? `color:${cell.color};` : ""}">${cell.renderValue?.content || ""}</div>`;
+ tableHTML += `<div class="av__cell" ${index === 0 ? 'data-block-id="' + (cell.renderValue?.id || "") + '"' : ""} data-id="${cell.id}" data-index="${index}" style="width: ${data.columns[index].width || 200}px;${cell.bgColor ? `background-color:${cell.bgColor};` : ""}${cell.color ? `color:${cell.color};` : ""}">${cell.renderValue?.content || ""}</div>`;
});
tableHTML += "<div></div></div>";
});
@@ -95,7 +95,7 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
});
});
} else if (operation.action === "insertAttrViewBlock") {
- Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`)).forEach((item: HTMLElement) => {
+ Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.parentID}"]`)).forEach((item: HTMLElement) => {
item.removeAttribute("data-render");
avRender(item);
});
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index bd37e33a8c..4966f99104 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -833,6 +833,7 @@ interface IAVRow {
}
interface IAVCell {
+ id: string,
color: string,
bgColor: string,
value: string,