From 2a713b087f05c1e5e3c46801160efd5824cdfa2a Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 18 Aug 2023 10:57:28 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/8992 --- app/src/block/Panel.ts | 22 +++++++++++++++++----- app/src/protyle/util/onGet.ts | 8 -------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/src/block/Panel.ts b/app/src/block/Panel.ts index 4fcc7c41a..15486d2f8 100644 --- a/app/src/block/Panel.ts +++ b/app/src/block/Panel.ts @@ -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(下图标)+8(padding)+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); diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts index ec969d83e..be48441b8 100644 --- a/app/src/protyle/util/onGet.ts +++ b/app/src/protyle/util/onGet.ts @@ -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(下图标)+8(padding)+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" &&