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

Vanessa6109e8a3c3c6
diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts
index a8daeba91b..4d575e5913 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 4e3732464d..48cfad5b91 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}</div>`;
<div class="layout-tab-bar fn__flex">
${tabHTML}
<div class="fn__flex-1"></div>
- ${response.data.isMirror?` <span class="block__icon block__icon--show b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.mirrorTip}">
- <svg><use xlink:href="#iconSplitLR"></use></svg></span><div class="fn__space"></div>`:""}
+ ${response.data.isMirror ? ` <span class="block__icon block__icon--show b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.mirrorTip}">
+ <svg><use xlink:href="#iconSplitLR"></use></svg></span><div class="fn__space"></div>` : ""}
<span data-type="av-filter" class="block__icon block__icon--show b3-tooltips b3-tooltips__w${data.filters.length > 0 ? " block__icon--active" : ""}" aria-label="${window.siyuan.languages.filter}">
<svg><use xlink:href="#iconFilter"></use></svg>
</span>
@@ -236,7 +236,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${text}</div>`;
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 292a0c9dcd..dfdb1ffa1a 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);