This commit is contained in:
Vanessa 2023-08-18 10:57:28 +08:00
parent b567e245af
commit 2a713b087f
2 changed files with 17 additions and 13 deletions

View file

@ -15,6 +15,7 @@ import {disabledProtyle} from "../protyle/util/onGet";
import {fetchPost} from "../util/fetch";
import {showMessage} from "../dialog/message";
import {App} from "../index";
import {isMobile} from "../util/functions";
export class BlockPanel {
public element: HTMLElement;
@ -185,6 +186,13 @@ export class BlockPanel {
if (afterCB) {
afterCB();
}
// https://ld246.com/article/1653639418266
if (editor.protyle.element.nextElementSibling || editor.protyle.element.previousElementSibling) {
editor.protyle.element.style.minHeight = Math.min(30 + editor.protyle.wysiwyg.element.clientHeight, window.innerHeight / 3) + "px";
}
// 由于 afterCB 中高度的设定,需在之后再进行设定
// 49 = 16上图标+16下图标+8padding+9底部距离
editor.protyle.scroll.element.parentElement.setAttribute("style", `--b3-dynamicscroll-width:${Math.min(editor.protyle.contentElement.clientHeight - 49, 200)}px;${isMobile() ? "" : "right:10px"}`);
}
});
this.editors.push(editor);
@ -268,7 +276,9 @@ export class BlockPanel {
}
}
// 单击嵌入块悬浮窗的位置最好是覆盖嵌入块
setPosition(this.element, targetRect.left, Math.max(top - 84, Constants.SIZE_TOOLBAR_HEIGHT), 0, 8);
// 防止图片撑高后悬浮窗显示不下,只能设置高度
this.element.style.height = Math.min(window.innerHeight - Constants.SIZE_TOOLBAR_HEIGHT, targetRect.height + 42) + "px";
setPosition(this.element, targetRect.left, Math.max(top - 42, Constants.SIZE_TOOLBAR_HEIGHT), -42, 0);
} else if (this.targetElement) {
if (this.targetElement.classList.contains("pdf__rect")) {
targetRect = this.targetElement.firstElementChild.getBoundingClientRect();
@ -285,10 +295,12 @@ export class BlockPanel {
setPosition(this.element, this.x, this.y);
}
const elementRect = this.element.getBoundingClientRect();
if (this.targetElement && elementRect.top < targetRect.top) {
this.element.style.maxHeight = Math.floor(targetRect.top - elementRect.top - 8) + "px";
} else {
this.element.style.maxHeight = Math.floor(window.innerHeight - elementRect.top - 8) + "px";
if (this.targetElement && !this.targetElement.classList.contains("protyle-wysiwyg__embed")) {
if (elementRect.top < targetRect.top) {
this.element.style.maxHeight = Math.floor(targetRect.top - elementRect.top - 8) + "px";
} else {
this.element.style.maxHeight = Math.floor(window.innerHeight - elementRect.top - 8) + "px";
}
}
this.element.classList.add("block__popover--open");
} : undefined);

View file

@ -249,14 +249,6 @@ const setHTML = (options: {
});
protyle.options.defId = undefined;
}
// https://ld246.com/article/1653639418266
if (protyle.element.classList.contains("block__edit")) {
if (protyle.element.nextElementSibling || protyle.element.previousElementSibling) {
protyle.element.style.minHeight = Math.min(30 + protyle.wysiwyg.element.clientHeight, window.innerHeight / 3) + "px";
}
// 49 = 16上图标+16下图标+8padding+9底部距离
protyle.scroll.element.parentElement.setAttribute("style", `--b3-dynamicscroll-width:${Math.min(protyle.contentElement.clientHeight - 49, 200)}px;${isMobile() ? "" : "right:10px"}`);
}
// 屏幕太高的页签 https://github.com/siyuan-note/siyuan/issues/5018
if (!protyle.scroll.element.classList.contains("fn__none") &&
protyle.wysiwyg.element.lastElementChild.getAttribute("data-eof") !== "2" &&