mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-01 18:30:16 +01:00
♻️
This commit is contained in:
parent
fd0893d8d8
commit
6806392b41
57 changed files with 271 additions and 360 deletions
|
|
@ -11,11 +11,10 @@ import {setStorageVal} from "../../protyle/util/compatibility";
|
|||
import {closePanel} from "./closePanel";
|
||||
import {showMessage} from "../../dialog/message";
|
||||
import {getCurrentEditor} from "../editor";
|
||||
import {App} from "../../index";
|
||||
|
||||
const forwardStack: IBackStack[] = [];
|
||||
|
||||
const focusStack = (backStack: IBackStack, app: App) => {
|
||||
const focusStack = (backStack: IBackStack) => {
|
||||
const protyle = getCurrentEditor().protyle;
|
||||
window.siyuan.storage[Constants.LOCAL_DOCINFO] = {
|
||||
id: backStack.id,
|
||||
|
|
@ -52,7 +51,6 @@ const focusStack = (backStack: IBackStack, app: App) => {
|
|||
fetchPost("/api/block/checkBlockExist", {id: backStack.id}, existResponse => {
|
||||
if (existResponse.data) {
|
||||
zoomOut({
|
||||
app,
|
||||
protyle,
|
||||
id: backStack.id,
|
||||
isPushBack: false,
|
||||
|
|
@ -111,29 +109,7 @@ export const pushBack = () => {
|
|||
});
|
||||
};
|
||||
|
||||
export const goForward = (app: App) => {
|
||||
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"}));
|
||||
return;
|
||||
} else if (document.getElementById("model").style.transform === "translateY(0px)" ||
|
||||
document.getElementById("menu").style.transform === "translateX(0px)" ||
|
||||
document.getElementById("sidebar").style.transform === "translateX(0px)") {
|
||||
closePanel();
|
||||
return;
|
||||
}
|
||||
if (window.JSAndroid && forwardStack.length < 2) {
|
||||
window.JSAndroid.returnDesktop();
|
||||
return;
|
||||
}
|
||||
if (forwardStack.length < 2) {
|
||||
return;
|
||||
}
|
||||
window.siyuan.backStack.push(forwardStack.pop());
|
||||
focusStack(forwardStack[forwardStack.length - 1], app);
|
||||
};
|
||||
|
||||
export const goBack = (app: App) => {
|
||||
export const goBack = () => {
|
||||
const editor = getCurrentEditor();
|
||||
if (window.siyuan.menus.menu.element.classList.contains("b3-menu--fullscreen") &&
|
||||
!window.siyuan.menus.menu.element.classList.contains("fn__none")) {
|
||||
|
|
@ -181,5 +157,5 @@ export const goBack = (app: App) => {
|
|||
}
|
||||
const item = window.siyuan.backStack.pop();
|
||||
forwardStack.push(item);
|
||||
focusStack(item, app);
|
||||
focusStack(item);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import {App} from "../../index";
|
|||
export const initFramework = (app: App) => {
|
||||
setInlineStyle();
|
||||
renderSnippet();
|
||||
initKeyboardToolbar(app);
|
||||
initKeyboardToolbar();
|
||||
const sidebarElement = document.getElementById("sidebar");
|
||||
let outline: MobileOutline;
|
||||
let backlink: MobileBacklinks;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import {moveToDown, moveToUp} from "../../protyle/wysiwyg/move";
|
|||
import {Constants} from "../../constants";
|
||||
import {focusByRange, getSelectionPosition} from "../../protyle/util/selection";
|
||||
import {getCurrentEditor} from "../editor";
|
||||
import {App} from "../../index";
|
||||
|
||||
let renderKeyboardToolbarTimeout: number;
|
||||
let showUtil = false;
|
||||
|
|
@ -328,7 +327,7 @@ export const activeBlur = () => {
|
|||
(document.activeElement as HTMLElement).blur();
|
||||
};
|
||||
|
||||
export const initKeyboardToolbar = (app: App) => {
|
||||
export const initKeyboardToolbar = () => {
|
||||
let preventRender = false;
|
||||
document.addEventListener("selectionchange", () => {
|
||||
if (!preventRender) {
|
||||
|
|
@ -417,10 +416,10 @@ export const initKeyboardToolbar = (app: App) => {
|
|||
return;
|
||||
}
|
||||
if (type === "undo") {
|
||||
protyle.undo.undo(app, protyle);
|
||||
protyle.undo.undo(protyle);
|
||||
return;
|
||||
} else if (type === "redo") {
|
||||
protyle.undo.redo(app, protyle);
|
||||
protyle.undo.redo(protyle);
|
||||
return;
|
||||
}
|
||||
if (getSelection().rangeCount === 0) {
|
||||
|
|
@ -476,7 +475,7 @@ export const initKeyboardToolbar = (app: App) => {
|
|||
}
|
||||
return;
|
||||
} else if (type === "more") {
|
||||
protyle.breadcrumb.showMenu(app, protyle, {
|
||||
protyle.breadcrumb.showMenu(protyle, {
|
||||
x: 0,
|
||||
y: 0
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import {popMenu} from "../menu";
|
|||
import {activeBlur, hideKeyboardToolbar} from "./keyboardToolbar";
|
||||
import {getCurrentEditor} from "../editor";
|
||||
import {linkMenu, refMenu, tagMenu} from "../../menus/protyle";
|
||||
import {App} from "../../index";
|
||||
|
||||
let clientX: number;
|
||||
let clientY: number;
|
||||
|
|
@ -24,7 +23,7 @@ const popSide = (render = true) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const handleTouchEnd = (app: App, event: TouchEvent) => {
|
||||
export const handleTouchEnd = (event: TouchEvent) => {
|
||||
const editor = getCurrentEditor();
|
||||
if (editor) {
|
||||
document.querySelectorAll(".protyle-breadcrumb__bar--hide").forEach(item => {
|
||||
|
|
@ -45,13 +44,13 @@ export const handleTouchEnd = (app: App, event: TouchEvent) => {
|
|||
return;
|
||||
}
|
||||
if (types.includes("block-ref")) {
|
||||
refMenu(app, editor.protyle, target);
|
||||
refMenu(editor.protyle, target);
|
||||
} else if (types.includes("file-annotation-ref")) {
|
||||
editor.protyle.toolbar.showFileAnnotationRef(editor.protyle, target);
|
||||
} else if (types.includes("tag")) {
|
||||
tagMenu(app, editor.protyle, target);
|
||||
tagMenu(editor.protyle, target);
|
||||
} else if (types.includes("a")) {
|
||||
linkMenu(app, editor.protyle, target);
|
||||
linkMenu(editor.protyle, target);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue