diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts index a8daeba91..4d575e591 100644 --- a/app/src/protyle/render/av/action.ts +++ b/app/src/protyle/render/av/action.ts @@ -82,7 +82,6 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle avID, }]); insertAttrViewBlockAnimation(blockElement, 1, previousID, avID); - popTextCell(protyle, [rowElement[event.altKey ? "previousElementSibling" : "nextElementSibling"].querySelector('[data-detached="true"]')], "block"); } else { const gutterRect = gutterElement.getBoundingClientRect(); avContextmenu(protyle, rowElement, { @@ -238,7 +237,6 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle avID, }]); insertAttrViewBlockAnimation(blockElement, 1, previousID, avID); - popTextCell(protyle, [addRowElement.previousElementSibling.querySelector('[data-detached="true"]')], "block"); event.preventDefault(); event.stopPropagation(); return true; diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts index 4e3732464..48cfad5b9 100644 --- a/app/src/protyle/render/av/render.ts +++ b/app/src/protyle/render/av/render.ts @@ -1,7 +1,7 @@ import {fetchPost} from "../../../util/fetch"; import {getColIconByType} from "./col"; import {Constants} from "../../../constants"; -import {getCalcValue} from "./cell"; +import {getCalcValue, popTextCell} from "./cell"; import * as dayjs from "dayjs"; import {unicode2Emoji} from "../../../emoji"; import {focusBlock} from "../../util/selection"; @@ -177,8 +177,8 @@ ${cell.color ? `color:${cell.color};` : ""}">${text}`;
`; let lastParentID: string; let lastElement: HTMLElement; -export const refreshAV = (protyle: IProtyle, operation: IOperation) => { +export const refreshAV = (protyle: IProtyle, operation: IOperation, isUndo: boolean) => { if (operation.action === "setAttrViewName") { Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.id}"]`)).forEach((item: HTMLElement) => { const titleElement = item.querySelector(".av__title") as HTMLElement; @@ -267,9 +267,15 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => { } else { Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${avId}"]`)).forEach((item: HTMLElement) => { item.removeAttribute("data-render"); - avRender(item, protyle); + avRender(item, protyle, () => { + // https://github.com/siyuan-note/siyuan/issues/9599 + if (!isUndo && operation.action === "insertAttrViewBlock" && operation.isDetached) { + popTextCell(protyle, [item.querySelector(`.av__row[data-id="${operation.srcIDs[0]}"] > .av__cell[data-detached="true"]`)], "block"); + } + }); }); } + setTimeout(() => { lastParentID = null; }, Constants.TIMEOUT_TRANSITION); diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts index 292a0c9dc..dfdb1ffa1 100644 --- a/app/src/protyle/wysiwyg/transaction.ts +++ b/app/src/protyle/wysiwyg/transaction.ts @@ -712,7 +712,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo: "setAttrViewColWrap", "setAttrViewColWidth", "removeAttrViewColOption", "setAttrViewName", "setAttrViewFilters", "setAttrViewSorts", "setAttrViewColCalc", "removeAttrViewCol", "updateAttrViewColNumberFormat", "removeAttrViewBlock", "replaceAttrViewBlock", "updateAttrViewColTemplate", "setAttrViewColIcon"].includes(operation.action)) { - refreshAV(protyle, operation); + refreshAV(protyle, operation, isUndo); } else if (operation.action === "doUpdateUpdated") { updateElements.forEach(item => { item.setAttribute("updated", operation.data);