mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-07 01:08:49 +01:00
This commit is contained in:
parent
87dc31673d
commit
5cd2c14009
2 changed files with 16 additions and 15 deletions
|
|
@ -15,7 +15,7 @@ import {promiseTransactions} from "../protyle/wysiwyg/transaction";
|
|||
import {bootSync} from "../dialog/processSystem";
|
||||
import {initMessage} from "../dialog/message";
|
||||
import {goBack} from "./util/MobileBackFoward";
|
||||
import {hideKeyboardToolbar, showKeyboardToolbar} from "./util/keyboardToolbar";
|
||||
import {hideKeyboardToolbar} from "./util/keyboardToolbar";
|
||||
import {getLocalStorage} from "../protyle/util/compatibility";
|
||||
import {openMobileFileById} from "./editor";
|
||||
import {getSearch} from "../util/functions";
|
||||
|
|
@ -84,7 +84,9 @@ class App {
|
|||
new App();
|
||||
|
||||
window.goBack = goBack;
|
||||
window.showKeyboardToolbar = showKeyboardToolbar;
|
||||
window.showKeyboardToolbar = (height) => {
|
||||
document.getElementById("keyboardToolbar").setAttribute("data-keyboardheight", (height ? height : window.innerHeight / 2 - 42).toString());
|
||||
};
|
||||
window.hideKeyboardToolbar = hideKeyboardToolbar;
|
||||
window.openFileByURL = (openURL) => {
|
||||
if (openURL && /^siyuan:\/\/blocks\/\d{14}-\w{7}/.test(openURL)) {
|
||||
|
|
|
|||
|
|
@ -150,7 +150,8 @@ const showKeyboardToolbarUtil = (oldScrollTop: number) => {
|
|||
showUtil = true;
|
||||
|
||||
const toolbarElement = document.getElementById("keyboardToolbar");
|
||||
const keyboardHeight = (parseInt(toolbarElement.getAttribute("data-keyboardheight")) + 42) + "px";
|
||||
let keyboardHeight = toolbarElement.getAttribute("data-keyboardheight")
|
||||
keyboardHeight = (keyboardHeight ? (parseInt(keyboardHeight) + 42) : window.innerHeight / 2) + "px";
|
||||
window.siyuan.mobile.editor.protyle.element.style.marginBottom = keyboardHeight;
|
||||
window.siyuan.mobile.editor.protyle.contentElement.scrollTop = oldScrollTop;
|
||||
setTimeout(() => {
|
||||
|
|
@ -172,17 +173,20 @@ const hideKeyboardToolbarUtil = () => {
|
|||
const renderKeyboardToolbar = () => {
|
||||
clearTimeout(renderKeyboardToolbarTimeout);
|
||||
renderKeyboardToolbarTimeout = window.setTimeout(() => {
|
||||
if (getSelection().rangeCount === 0 || window.siyuan.config.editor.readOnly || window.siyuan.config.readonly) {
|
||||
if (getSelection().rangeCount === 0 || window.siyuan.config.editor.readOnly || window.siyuan.config.readonly ||
|
||||
!document.activeElement || (
|
||||
document.activeElement &&
|
||||
document.activeElement.tagName !== "INPUT" &&
|
||||
document.activeElement.tagName !== "TEXTAREA" &&
|
||||
!document.activeElement.classList.contains("protyle-wysiwyg")
|
||||
)) {
|
||||
hideKeyboardToolbar();
|
||||
return;
|
||||
}
|
||||
if (!showUtil) {
|
||||
hideKeyboardToolbarUtil();
|
||||
}
|
||||
if (window.innerHeight + 200 > ((window.orientation === 90 || window.orientation === -90) ? screen.width : screen.height)) {
|
||||
hideKeyboardToolbar();
|
||||
return;
|
||||
}
|
||||
|
||||
showKeyboardToolbar();
|
||||
const dynamicElements = document.querySelectorAll("#keyboardToolbar .keyboard__dynamic");
|
||||
const range = getSelection().getRangeAt(0);
|
||||
const isProtyle = hasClosestByClassName(range.startContainer, "protyle-wysiwyg", true);
|
||||
|
|
@ -247,13 +251,8 @@ const renderKeyboardToolbar = () => {
|
|||
}, 620); // 需等待 range 更新
|
||||
};
|
||||
|
||||
export const showKeyboardToolbar = (height: number) => {
|
||||
if (getSelection().rangeCount === 0 || window.siyuan.config.editor.readOnly || window.siyuan.config.readonly) {
|
||||
return;
|
||||
}
|
||||
const showKeyboardToolbar = () => {
|
||||
const toolbarElement = document.getElementById("keyboardToolbar");
|
||||
toolbarElement.setAttribute("data-keyboardheight", height.toString());
|
||||
hideKeyboardToolbarUtil();
|
||||
if (!toolbarElement.classList.contains("fn__none")) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue