This commit is contained in:
parent
c9b0622ee5
commit
02366f3c95
3 changed files with 18 additions and 15 deletions
|
@ -10,17 +10,18 @@ import {disabledForeverProtyle, disabledProtyle, enableProtyle} from "../../prot
|
|||
import {setStorageVal} from "../../protyle/util/compatibility";
|
||||
import {closePanel} from "./closePanel";
|
||||
import {showMessage} from "../../dialog/message";
|
||||
import {getCurrentEditor} from "../editor";
|
||||
|
||||
const forwardStack: IBackStack[] = [];
|
||||
|
||||
const focusStack = (backStack: IBackStack) => {
|
||||
const protyle = window.siyuan.mobile.editor.protyle;
|
||||
const protyle = getCurrentEditor().protyle;
|
||||
window.siyuan.storage[Constants.LOCAL_DOCINFO] = {
|
||||
id: backStack.id,
|
||||
action: backStack.callback,
|
||||
};
|
||||
setStorageVal(Constants.LOCAL_DOCINFO, window.siyuan.storage[Constants.LOCAL_DOCINFO]);
|
||||
hideElements(["toolbar", "hint", "util"], window.siyuan.mobile.editor.protyle);
|
||||
hideElements(["toolbar", "hint", "util"], protyle);
|
||||
if (protyle.contentElement.classList.contains("fn__none")) {
|
||||
setEditMode(protyle, "wysiwyg");
|
||||
}
|
||||
|
@ -28,7 +29,7 @@ const focusStack = (backStack: IBackStack) => {
|
|||
const startEndId = backStack.endId.split(Constants.ZWSP);
|
||||
if (startEndId[0] === protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-id") &&
|
||||
startEndId[1] === protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id")) {
|
||||
window.siyuan.mobile.editor.protyle.contentElement.scrollTo({
|
||||
protyle.contentElement.scrollTo({
|
||||
top: backStack.scrollTop,
|
||||
behavior: "smooth"
|
||||
});
|
||||
|
@ -83,12 +84,12 @@ const focusStack = (backStack: IBackStack) => {
|
|||
}
|
||||
}
|
||||
protyle.contentElement.scrollTop = backStack.scrollTop;
|
||||
window.siyuan.mobile.editor.protyle.breadcrumb?.render(protyle);
|
||||
protyle.breadcrumb?.render(protyle);
|
||||
});
|
||||
};
|
||||
|
||||
export const pushBack = () => {
|
||||
const protyle = window.siyuan.mobile.editor.protyle;
|
||||
const protyle = getCurrentEditor().protyle;
|
||||
window.siyuan.backStack.push({
|
||||
id: protyle.block.showAll ? protyle.block.id : protyle.block.rootID,
|
||||
endId: protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-id") + Constants.ZWSP + protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id"),
|
||||
|
@ -121,6 +122,8 @@ export const goForward = () => {
|
|||
};
|
||||
|
||||
export const goBack = () => {
|
||||
const editor = getCurrentEditor();
|
||||
const protyle = editor.protyle;
|
||||
if (window.siyuan.menus.menu.element.classList.contains("b3-menu--fullscreen") &&
|
||||
!window.siyuan.menus.menu.element.classList.contains("fn__none")) {
|
||||
window.siyuan.menus.menu.element.dispatchEvent(new CustomEvent("click", {detail: "back"}));
|
||||
|
@ -135,8 +138,8 @@ export const goBack = () => {
|
|||
document.getElementById("sidebar").style.transform === "translateX(0px)") {
|
||||
closePanel();
|
||||
return;
|
||||
} else if (window.siyuan.mobile.editor && !window.siyuan.mobile.editor.protyle.toolbar.subElement.classList.contains("fn__none")) {
|
||||
hideElements(["util"], window.siyuan.mobile.editor.protyle);
|
||||
} else if (editor && !editor.protyle.toolbar.subElement.classList.contains("fn__none")) {
|
||||
hideElements(["util"], protyle);
|
||||
closePanel();
|
||||
return;
|
||||
} else if (window.siyuan.dialogs.length !== 0) {
|
||||
|
@ -155,7 +158,6 @@ export const goBack = () => {
|
|||
if (window.siyuan.backStack.length < 1) {
|
||||
return;
|
||||
}
|
||||
const protyle = window.siyuan.mobile.editor.protyle;
|
||||
if (forwardStack.length === 0) {
|
||||
forwardStack.push({
|
||||
id: protyle.block.showAll ? protyle.block.id : protyle.block.rootID,
|
||||
|
|
|
@ -215,7 +215,7 @@ const renderKeyboardToolbar = () => {
|
|||
dynamicElements[1].classList.add("fn__none");
|
||||
}
|
||||
|
||||
const protyle = window.siyuan.mobile.editor.protyle;
|
||||
const protyle = getCurrentEditor().protyle;
|
||||
if (!dynamicElements[0].classList.contains("fn__none")) {
|
||||
if (protyle.undo.undoStack.length === 0) {
|
||||
dynamicElements[0].querySelector('[data-type="undo"]').setAttribute("disabled", "disabled");
|
||||
|
@ -370,7 +370,7 @@ export const initKeyboardToolbar = () => {
|
|||
toolbarElement.addEventListener("click", (event) => {
|
||||
const target = event.target as HTMLElement;
|
||||
const slashBtnElement = hasClosestByClassName(event.target as HTMLElement, "keyboard__slash-item");
|
||||
const protyle = window.siyuan.mobile.editor.protyle;
|
||||
const protyle = getCurrentEditor().protyle;
|
||||
if (slashBtnElement) {
|
||||
const dataValue = decodeURIComponent(slashBtnElement.getAttribute("data-value"));
|
||||
protyle.hint.fill(dataValue, protyle, false); // 点击后 range 会改变
|
||||
|
@ -401,7 +401,7 @@ export const initKeyboardToolbar = () => {
|
|||
}
|
||||
return;
|
||||
}
|
||||
if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly || !window.siyuan.mobile.editor) {
|
||||
if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly || !getCurrentEditor()) {
|
||||
return;
|
||||
}
|
||||
if (type === "undo") {
|
||||
|
@ -458,7 +458,7 @@ export const initKeyboardToolbar = () => {
|
|||
} else {
|
||||
buttonElement.classList.add("protyle-toolbar__item--current");
|
||||
toolbarElement.querySelector('.keyboard__action[data-type="done"] use').setAttribute("xlink:href", "#iconCloseRound");
|
||||
const oldScrollTop = window.siyuan.mobile.editor.protyle.contentElement.scrollTop;
|
||||
const oldScrollTop = protyle.contentElement.scrollTop;
|
||||
renderSlashMenu(protyle, toolbarElement);
|
||||
showKeyboardToolbarUtil(oldScrollTop);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import {hasClosestByAttribute, hasClosestByClassName} from "../../protyle/util/h
|
|||
import {closePanel} from "./closePanel";
|
||||
import {popMenu} from "../menu";
|
||||
import {activeBlur, hideKeyboardToolbar} from "./keyboardToolbar";
|
||||
import {getCurrentEditor} from "../editor";
|
||||
|
||||
let clientX: number;
|
||||
let clientY: number;
|
||||
|
@ -22,7 +23,7 @@ const popSide = (render = true) => {
|
|||
};
|
||||
|
||||
export const handleTouchEnd = (event: TouchEvent) => {
|
||||
if (window.siyuan.mobile.editor) {
|
||||
if (getCurrentEditor()) {
|
||||
document.querySelectorAll(".protyle-breadcrumb__bar--hide").forEach(item => {
|
||||
item.classList.remove("protyle-breadcrumb__bar--hide");
|
||||
});
|
||||
|
@ -32,9 +33,9 @@ export const handleTouchEnd = (event: TouchEvent) => {
|
|||
const target = event.target as HTMLElement;
|
||||
if (!clientX || !clientY || typeof yDiff === "undefined" ||
|
||||
target.tagName === "AUDIO" ||
|
||||
hasClosestByClassName(target, "b3-dialog", true) ||
|
||||
(window.siyuan.mobile.editor && !window.siyuan.mobile.editor.protyle.toolbar.subElement.classList.contains("fn__none")) ||
|
||||
hasClosestByClassName(target, "viewer-container") ||
|
||||
hasClosestByClassName(target, "b3-dialog") ||
|
||||
hasClosestByClassName(target, "keyboard") ||
|
||||
hasClosestByAttribute(target, "id", "commonMenu") ||
|
||||
hasClosestByAttribute(target, "id", "model")
|
||||
|
@ -158,8 +159,8 @@ export const handleTouchMove = (event: TouchEvent) => {
|
|||
const target = event.target as HTMLElement;
|
||||
if (!clientX || !clientY ||
|
||||
target.tagName === "AUDIO" ||
|
||||
hasClosestByClassName(target, "b3-dialog", true) ||
|
||||
(window.siyuan.mobile.editor && !window.siyuan.mobile.editor.protyle.toolbar.subElement.classList.contains("fn__none")) ||
|
||||
hasClosestByClassName(target, "b3-dialog") ||
|
||||
hasClosestByClassName(target, "keyboard") ||
|
||||
hasClosestByClassName(target, "viewer-container") ||
|
||||
hasClosestByAttribute(target, "id", "commonMenu") ||
|
||||
|
|
Loading…
Add table
Reference in a new issue