diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index f23e6ddf3..92c587e8b 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 141f9128a..30f5ed8fb 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) => {
`; row.cells.forEach((cell, index) => { - tableHTML += `
${cell.renderValue?.content || ""}
`; + tableHTML += `
${cell.renderValue?.content || ""}
`; }); tableHTML += "
"; }); @@ -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 bd37e33a8..4966f9910 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,