mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-04 20:00:17 +01:00
This commit is contained in:
parent
4dce33436e
commit
d3e876368c
4 changed files with 21 additions and 2 deletions
|
|
@ -21,6 +21,7 @@ import {openFileById} from "../../editor/util";
|
|||
import {checkFold} from "../../util/noRelyPCFunction";
|
||||
import {hideAllElements} from "../../protyle/ui/hideElements";
|
||||
import {dragOverScroll, stopScrollAnimation} from "./dragover";
|
||||
import {setWebViewFocusable} from "../../mobile/util/mobileAppUtil";
|
||||
|
||||
export const initWindowEvent = (app: App) => {
|
||||
document.body.addEventListener("mouseleave", () => {
|
||||
|
|
@ -125,6 +126,9 @@ export const initWindowEvent = (app: App) => {
|
|||
window.siyuan.ctrlIsPressed = false;
|
||||
window.siyuan.shiftIsPressed = false;
|
||||
window.siyuan.altIsPressed = false;
|
||||
/// #if BROWSER
|
||||
setWebViewFocusable();
|
||||
/// #endif
|
||||
});
|
||||
|
||||
window.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import {correctHotkey} from "../boot/globalEvent/commonHotkey";
|
|||
import {processIOSPurchaseResponse} from "../util/iOSPurchase";
|
||||
import {updateControlAlt} from "../protyle/util/hotKey";
|
||||
import {nbsp2space} from "../protyle/util/normalizeText";
|
||||
import {callMobileAppShowKeyboard, canInput} from "./util/mobileAppUtil";
|
||||
import {callMobileAppShowKeyboard, canInput, setWebViewFocusable} from "./util/mobileAppUtil";
|
||||
|
||||
class App {
|
||||
public plugins: import("../plugin").Plugin[] = [];
|
||||
|
|
@ -180,6 +180,9 @@ class App {
|
|||
window.siyuan.shiftIsPressed = false;
|
||||
window.siyuan.altIsPressed = false;
|
||||
});
|
||||
window.addEventListener("blur", (event) => {
|
||||
setWebViewFocusable();
|
||||
});
|
||||
// 移动端删除键 https://github.com/siyuan-note/siyuan/issues/9259
|
||||
window.addEventListener("keydown", (event) => {
|
||||
mobileKeydown(siyuanApp, event);
|
||||
|
|
|
|||
|
|
@ -30,4 +30,14 @@ export const canInput = (element: Element) => {
|
|||
return hasClosestByAttribute(element, "contenteditable", "true");
|
||||
}
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
export const setWebViewFocusable = () => {
|
||||
if (document.activeElement.tagName === "IFRAME") {
|
||||
if (window.JSAndroid && window.JSAndroid.setWebViewFocusable) {
|
||||
window.JSAndroid.setWebViewFocusable(true);
|
||||
} else if (window.JSHarmony && window.JSHarmony.setWebViewFocusable) {
|
||||
window.JSHarmony.setWebViewFocusable(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
2
app/src/types/index.d.ts
vendored
2
app/src/types/index.d.ts
vendored
|
|
@ -254,6 +254,7 @@ interface Window {
|
|||
print(title: string, html: string): void
|
||||
getScreenWidthPx(): number
|
||||
exit(): void
|
||||
setWebViewFocusable(enable: boolean): void
|
||||
};
|
||||
JSHarmony: {
|
||||
showKeyboard(): void
|
||||
|
|
@ -271,6 +272,7 @@ interface Window {
|
|||
print(title: string, html: string): void
|
||||
getScreenWidthPx(): number
|
||||
exit(): void
|
||||
setWebViewFocusable(enable: boolean): void
|
||||
};
|
||||
|
||||
Protyle: import("../protyle/method").default;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue