mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
🎨 数据库块适配外观和宽度调整
This commit is contained in:
parent
ab67389650
commit
25109b906f
3 changed files with 67 additions and 47 deletions
|
|
@ -44,18 +44,41 @@ export const resize = (protyle: IProtyle) => {
|
|||
}
|
||||
if (abs.padding > MIN_ABS || abs.width > MIN_ABS || isNaN(abs.padding)) {
|
||||
protyle.wysiwyg.element.querySelectorAll(".av").forEach((item: HTMLElement) => {
|
||||
item.style.maxWidth = item.parentElement.clientWidth + "px";
|
||||
if (item.getAttribute("data-render") === "true" && !item.style.width.endsWith("%")) {
|
||||
const paddingLeft = item.parentElement.style.paddingLeft;
|
||||
const paddingRight = item.parentElement.style.paddingRight;
|
||||
const avHeaderElement = item.firstElementChild.firstElementChild as HTMLElement;
|
||||
avHeaderElement.style.paddingLeft = paddingLeft;
|
||||
avHeaderElement.style.paddingRight = paddingRight;
|
||||
const avBodyElement = item.querySelector(".av__scroll").firstElementChild as HTMLElement;
|
||||
avBodyElement.style.paddingLeft = paddingLeft;
|
||||
avBodyElement.style.paddingRight = paddingRight;
|
||||
}
|
||||
resizeAV(item);
|
||||
});
|
||||
}
|
||||
}, Constants.TIMEOUT_TRANSITION); // 等待 setPadding 动画结束
|
||||
};
|
||||
|
||||
export const resizeAV = (item: HTMLElement) => {
|
||||
if (!item.classList.contains("av") || item.getAttribute("data-render") !== "true") {
|
||||
return
|
||||
}
|
||||
if (item.style.width.endsWith("%") || item.style.margin) {
|
||||
const avHeaderElement = item.firstElementChild.firstElementChild as HTMLElement;
|
||||
avHeaderElement.style.paddingLeft = "";
|
||||
avHeaderElement.style.paddingRight = "";
|
||||
const avBodyElement = item.querySelector(".av__scroll").firstElementChild as HTMLElement;
|
||||
avBodyElement.style.paddingLeft = "";
|
||||
avBodyElement.style.paddingRight = "";
|
||||
item.style.alignSelf = "";
|
||||
if (!item.style.width.endsWith("%")) {
|
||||
item.style.width = ""
|
||||
item.style.maxWidth = "100%";
|
||||
}
|
||||
} else {
|
||||
const paddingLeft = item.parentElement.style.paddingLeft;
|
||||
const paddingRight = item.parentElement.style.paddingRight;
|
||||
const avHeaderElement = item.firstElementChild.firstElementChild as HTMLElement;
|
||||
avHeaderElement.style.paddingLeft = paddingLeft;
|
||||
avHeaderElement.style.paddingRight = paddingRight;
|
||||
const avBodyElement = item.querySelector(".av__scroll").firstElementChild as HTMLElement;
|
||||
avBodyElement.style.paddingLeft = paddingLeft;
|
||||
avBodyElement.style.paddingRight = paddingRight;
|
||||
item.style.alignSelf = "center";
|
||||
if (item.parentElement.clientWidth > 0) {
|
||||
item.style.width = item.parentElement.clientWidth + "px";
|
||||
item.style.maxWidth = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue