Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/15055

Vanessa223232091966
diff --git a/app/src/protyle/render/av/layout.ts b/app/src/protyle/render/av/layout.ts
index f53bab280d..10371b0ad8 100644
--- a/app/src/protyle/render/av/layout.ts
+++ b/app/src/protyle/render/av/layout.ts
@@ -1,6 +1,6 @@
import {transaction} from "../../wysiwyg/transaction";
import {Constants} from "../../../constants";
-import {fetchPost} from "../../../util/fetch";
+import {fetchSyncPost} from "../../../util/fetch";
import {getCardAspectRatio} from "./gallery/util";
export const getLayoutHTML = (data: IAV) => {
@@ -207,7 +207,7 @@ export const bindLayoutEvent = (options: {
});
};
-export const updateLayout = (options: {
+export const updateLayout = async (options: {
data: IAV
nodeElement: Element,
protyle: IProtyle,
@@ -219,19 +219,19 @@ export const updateLayout = (options: {
options.target.dataset.load = "true";
options.target.parentElement.querySelector(".av__layout-item--select").classList.remove("av__layout-item--select");
options.target.classList.add("av__layout-item--select");
- fetchPost("/api/av/changeAttrViewLayout", {
+ const response = await fetchSyncPost("/api/av/changeAttrViewLayout", {
blockID: options.nodeElement.getAttribute("data-node-id"),
avID: options.nodeElement.getAttribute("data-av-id"),
layoutType: options.target.getAttribute("data-view-type")
- }, (response) => {
- const menuElement = document.querySelector(".av__panel").lastElementChild as HTMLElement;
- menuElement.innerHTML = getLayoutHTML(response.data);
- bindLayoutEvent({
- protyle: options.protyle,
- data: response.data,
- menuElement,
- blockElement: options.nodeElement
- });
- options.target.removeAttribute("data-load");
});
+ const menuElement = document.querySelector(".av__panel").lastElementChild as HTMLElement;
+ menuElement.innerHTML = getLayoutHTML(response.data);
+ bindLayoutEvent({
+ protyle: options.protyle,
+ data: response.data,
+ menuElement,
+ blockElement: options.nodeElement
+ });
+ options.target.removeAttribute("data-load");
+ return response.data;
};
diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts
index 2bcac7c4aa..710df65f1e 100644
--- a/app/src/protyle/render/av/openMenuPanel.ts
+++ b/app/src/protyle/render/av/openMenuPanel.ts
@@ -82,7 +82,7 @@ export const openMenuPanel = (options: {
const blockID = options.blockElement.getAttribute("data-node-id");
const isCustomAttr = !options.blockElement.classList.contains("av");
- const data = response.data as IAV;
+ let data = response.data as IAV;
let html;
const fields = getFieldsByData(data);
if (options.type === "config") {
@@ -511,7 +511,7 @@ export const openMenuPanel = (options: {
document.querySelector(".av__panel").dispatchEvent(new CustomEvent("click", {detail: "close"}));
}
});
- avPanelElement.addEventListener("click", (event: MouseEvent) => {
+ avPanelElement.addEventListener("click", async (event: MouseEvent) => {
let type: string;
let target = event.target as HTMLElement;
if (typeof event.detail === "string") {
@@ -1405,7 +1405,7 @@ export const openMenuPanel = (options: {
event.stopPropagation();
break;
} else if (type === "set-layout") {
- updateLayout({
+ data = await updateLayout({
target,
protyle: options.protyle,
nodeElement: options.blockElement,