mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
This commit is contained in:
parent
7c2ab3eea1
commit
4af11a3583
1 changed files with 24 additions and 3 deletions
|
|
@ -2,7 +2,7 @@ import {addScript, addScriptSync} from "../protyle/util/addScript";
|
|||
import {Constants} from "../constants";
|
||||
import {onMessage} from "./util/onMessage";
|
||||
import {genUUID} from "../util/genID";
|
||||
import {hasClosestByAttribute, hasTopClosestByClassName} from "../protyle/util/hasClosest";
|
||||
import {hasClosestBlock, hasClosestByAttribute, hasTopClosestByClassName} from "../protyle/util/hasClosest";
|
||||
import {Model} from "../layout/Model";
|
||||
import "../assets/scss/mobile.scss";
|
||||
import {Menus} from "../menus";
|
||||
|
|
@ -16,13 +16,15 @@ import {initMessage, showMessage} from "../dialog/message";
|
|||
import {goBack} from "./util/MobileBackFoward";
|
||||
import {hideKeyboardToolbar, showKeyboardToolbar} from "./util/keyboardToolbar";
|
||||
import {getLocalStorage, writeText} from "../protyle/util/compatibility";
|
||||
import {openMobileFileById} from "./editor";
|
||||
import {getCurrentEditor, openMobileFileById} from "./editor";
|
||||
import {getSearch} from "../util/functions";
|
||||
import {initRightMenu} from "./menu";
|
||||
import {openChangelog} from "../boot/openChangelog";
|
||||
import {registerServiceWorker} from "../util/serviceWorker";
|
||||
import {afterLoadPlugin, loadPlugins} from "../plugin/loader";
|
||||
import {saveScroll} from "../protyle/scroll/saveScroll";
|
||||
import {removeBlock} from "../protyle/wysiwyg/remove";
|
||||
import {isNotEditBlock} from "../protyle/wysiwyg/getBlock";
|
||||
|
||||
class App {
|
||||
public plugins: import("../plugin").Plugin[] = [];
|
||||
|
|
@ -68,7 +70,7 @@ class App {
|
|||
}
|
||||
});
|
||||
window.addEventListener("beforeunload", () => {
|
||||
saveScroll(window.siyuan.mobile.editor.protyle);
|
||||
saveScroll(window.siyuan.mobile.editor.protyle);
|
||||
}, false);
|
||||
window.addEventListener("pagehide", () => {
|
||||
saveScroll(window.siyuan.mobile.editor.protyle);
|
||||
|
|
@ -108,6 +110,25 @@ class App {
|
|||
document.addEventListener("touchend", (event) => {
|
||||
handleTouchEnd(event, siyuanApp);
|
||||
}, false);
|
||||
// https://github.com/siyuan-note/siyuan/issues/9259
|
||||
window.addEventListener("keydown", (event) => {
|
||||
if (getSelection().rangeCount > 0) {
|
||||
const range = getSelection().getRangeAt(0);
|
||||
const editor = getCurrentEditor();
|
||||
if (range.toString() === "" &&
|
||||
editor && editor.protyle.wysiwyg.element.contains(range.startContainer) &&
|
||||
!event.altKey && (event.key === "Backspace" || event.key === "Delete")) {
|
||||
const nodeElement = hasClosestBlock(range.startContainer);
|
||||
if (nodeElement && isNotEditBlock(nodeElement)) {
|
||||
nodeElement.classList.add("protyle-wysiwyg--select");
|
||||
removeBlock(editor.protyle, nodeElement, range);
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue