2023-03-27 09:48:11 +08:00
|
|
|
export const openModel = (obj: {
|
|
|
|
|
html: string,
|
2024-12-11 23:24:33 +08:00
|
|
|
icon?: string,
|
2023-03-27 09:48:11 +08:00
|
|
|
title: string,
|
|
|
|
|
bindEvent: (element: HTMLElement) => void
|
|
|
|
|
}) => {
|
2023-03-27 09:48:53 +08:00
|
|
|
const modelElement = document.getElementById("model");
|
2023-04-07 09:06:30 +08:00
|
|
|
modelElement.style.transform = "translateY(0px)";
|
2024-04-18 10:44:46 +08:00
|
|
|
modelElement.style.zIndex = (++window.siyuan.zIndex).toString();
|
2024-12-11 23:24:33 +08:00
|
|
|
const iconElement = modelElement.querySelector(".toolbar__icon")
|
|
|
|
|
if(obj.icon) {
|
|
|
|
|
iconElement.classList.remove("fn__none")
|
|
|
|
|
iconElement.querySelector("use").setAttribute("xlink:href", "#" + obj.icon);
|
|
|
|
|
} else {
|
|
|
|
|
iconElement.classList.add("fn__none")
|
|
|
|
|
}
|
2023-03-27 09:48:53 +08:00
|
|
|
modelElement.querySelector(".toolbar__text").innerHTML = obj.title;
|
2023-03-27 09:48:11 +08:00
|
|
|
const modelMainElement = modelElement.querySelector("#modelMain") as HTMLElement;
|
|
|
|
|
modelMainElement.innerHTML = obj.html;
|
|
|
|
|
obj.bindEvent(modelMainElement);
|
2023-03-27 09:48:53 +08:00
|
|
|
};
|