mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-27 01:14:07 +01:00
This commit is contained in:
parent
0328020aec
commit
d25a2ce718
5 changed files with 44 additions and 5 deletions
|
|
@ -79,6 +79,23 @@ export const onGetConfig = (isStart: boolean, app: App) => {
|
|||
let resizeTimeout = 0;
|
||||
let firstResize = true;
|
||||
window.addEventListener("resize", () => {
|
||||
/// #if MOBILE
|
||||
// 获取键盘高度
|
||||
window.siyuan.mobile.size.isLandscape = window.matchMedia && window.matchMedia("(orientation: landscape)").matches;
|
||||
if (window.siyuan.mobile.size.isLandscape) {
|
||||
if (window.innerHeight < window.siyuan.mobile.size.landscape.height1) {
|
||||
window.siyuan.mobile.size.landscape.height2 = window.innerHeight;
|
||||
} else {
|
||||
window.siyuan.mobile.size.landscape.height1 = window.innerHeight;
|
||||
}
|
||||
} else {
|
||||
if (window.innerHeight < window.siyuan.mobile.size.portrait.height1) {
|
||||
window.siyuan.mobile.size.portrait.height2 = window.innerHeight;
|
||||
} else {
|
||||
window.siyuan.mobile.size.portrait.height1 = window.innerHeight;
|
||||
}
|
||||
}
|
||||
/// #endif
|
||||
if (firstResize) {
|
||||
recordBeforeResizeTop();
|
||||
firstResize = false;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,17 @@ class App {
|
|||
dialogs: [],
|
||||
blockPanels: [],
|
||||
mobile: {
|
||||
size: {
|
||||
isLandscape: window.matchMedia && window.matchMedia("(orientation: landscape)").matches,
|
||||
landscape: {
|
||||
height1: window.innerHeight,
|
||||
height2: window.innerHeight,
|
||||
}, // 横屏
|
||||
portrait: {
|
||||
height1: window.innerHeight,
|
||||
height2: window.innerHeight,
|
||||
}
|
||||
},
|
||||
docks: {
|
||||
outline: null,
|
||||
file: null,
|
||||
|
|
|
|||
|
|
@ -288,8 +288,8 @@ export const showKeyboardToolbarUtil = (oldScrollTop: number) => {
|
|||
showUtil = true;
|
||||
|
||||
const toolbarElement = document.getElementById("keyboardToolbar");
|
||||
const keyboardHeight = ((document.documentElement.clientHeight - window.visualViewport.height) ||
|
||||
(window.outerHeight / 2 - 42)) + "px";
|
||||
const keyboardHeight = ((window.siyuan.mobile.size.isLandscape ? window.siyuan.mobile.size.landscape.height1 - window.siyuan.mobile.size.landscape.height2 : window.siyuan.mobile.size.portrait.height1 - window.siyuan.mobile.size.portrait.height2) ||
|
||||
(window.innerHeight / 2 - 42)) + "px";
|
||||
const editor = getCurrentEditor();
|
||||
if (editor) {
|
||||
editor.protyle.element.parentElement.style.paddingBottom = keyboardHeight;
|
||||
|
|
|
|||
|
|
@ -417,9 +417,9 @@ export const cellScrollIntoView = (blockElement: HTMLElement, cellElement: Eleme
|
|||
/// #if MOBILE
|
||||
const contentElement = hasClosestByClassName(blockElement, "protyle-content", true);
|
||||
if (contentElement && cellElement.getAttribute("data-dtype") !== "checkbox") {
|
||||
const keyboardH = document.documentElement.clientHeight - window.visualViewport.height;
|
||||
if (cellRect.bottom > window.innerHeight - keyboardH - 42) {
|
||||
contentElement.scrollTop += cellRect.bottom - window.innerHeight + 42 + keyboardH;
|
||||
const keyboardToolbarHeight = document.querySelector("#keyboardToolbar").clientHeight;
|
||||
if (cellRect.bottom > keyboardToolbarHeight) {
|
||||
contentElement.scrollTop = contentElement.scrollTop + (cellRect.bottom - keyboardToolbarHeight);
|
||||
} else if (cellRect.top < 110) {
|
||||
contentElement.scrollTop -= 110 - cellRect.top;
|
||||
}
|
||||
|
|
|
|||
11
app/src/types/index.d.ts
vendored
11
app/src/types/index.d.ts
vendored
|
|
@ -488,6 +488,17 @@ interface ISiyuan {
|
|||
emojis?: IEmoji[],
|
||||
backStack?: IBackStack[],
|
||||
mobile?: {
|
||||
size: {
|
||||
isLandscape:boolean,
|
||||
landscape: {
|
||||
height1: number,
|
||||
height2: number, // 键盘弹起时的高度
|
||||
}, // 横屏
|
||||
portrait: {
|
||||
height1: number,
|
||||
height2: number,
|
||||
}
|
||||
}
|
||||
editor?: import("../protyle").Protyle
|
||||
popEditor?: import("../protyle").Protyle
|
||||
docks?: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue