mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-25 09:46:10 +01:00
This commit is contained in:
parent
743f4eecbf
commit
2232320919
2 changed files with 16 additions and 16 deletions
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue