mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-29 12:58:48 +01:00
This commit is contained in:
parent
e42d6abde7
commit
1c0732eae1
4 changed files with 33 additions and 34 deletions
|
|
@ -43,6 +43,7 @@ import {alignImgCenter, alignImgLeft} from "../protyle/wysiwyg/commonHotkey";
|
|||
import {renameTag} from "../util/noRelyPCFunction";
|
||||
import {hideElements} from "../protyle/ui/hideElements";
|
||||
import {emitOpenMenu} from "../plugin/EventBus";
|
||||
import {openMobileFileById} from "../mobile/editor";
|
||||
|
||||
export const fileAnnotationRefMenu = (protyle: IProtyle, refElement: HTMLElement) => {
|
||||
const nodeElement = hasClosestBlock(refElement);
|
||||
|
|
@ -531,6 +532,25 @@ export const contentMenu = (protyle: IProtyle, nodeElement: Element) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const enterBack = (protyle: IProtyle, id: string) => {
|
||||
if (!protyle.block.showAll) {
|
||||
const ids = protyle.path.split("/");
|
||||
if (ids.length > 2) {
|
||||
/// #if MOBILE
|
||||
openMobileFileById(protyle.app, ids[ids.length - 2], [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]);
|
||||
/// #else
|
||||
openFileById({
|
||||
app: protyle.app,
|
||||
id: ids[ids.length - 2],
|
||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
|
||||
});
|
||||
/// #endif
|
||||
}
|
||||
} else {
|
||||
zoomOut({protyle, id: protyle.block.parent2ID, focusId: id});
|
||||
}
|
||||
}
|
||||
|
||||
export const zoomOut = (options: {
|
||||
protyle: IProtyle,
|
||||
id: string,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import {hasClosestBlock, hasClosestByAttribute, hasClosestByMatchTag, hasClosestByTag} from "../util/hasClosest";
|
||||
import {getIconByType} from "../../editor/getIcon";
|
||||
import {iframeMenu, setFold, tableMenu, videoMenu, zoomOut} from "../../menus/protyle";
|
||||
import {enterBack, iframeMenu, setFold, tableMenu, videoMenu, zoomOut} from "../../menus/protyle";
|
||||
import {MenuItem} from "../../menus/Menu";
|
||||
import {copySubMenu, openAttr, openWechatNotify} from "../../menus/commonMenuItem";
|
||||
import {copyPlainText, updateHotkeyTip, writeText} from "../util/compatibility";
|
||||
|
|
@ -1427,22 +1427,7 @@ export class Gutter {
|
|||
accelerator: window.siyuan.config.keymap.general.enterBack.custom,
|
||||
label: window.siyuan.languages.enterBack,
|
||||
click: () => {
|
||||
if (!protyle.block.showAll) {
|
||||
const ids = protyle.path.split("/");
|
||||
if (ids.length > 2) {
|
||||
/// #if MOBILE
|
||||
openMobileFileById(protyle.app, ids[ids.length - 2], [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]);
|
||||
/// #else
|
||||
openFileById({
|
||||
app: protyle.app,
|
||||
id: ids[ids.length - 2],
|
||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
|
||||
});
|
||||
/// #endif
|
||||
}
|
||||
} else {
|
||||
zoomOut({protyle, id: protyle.block.parent2ID, focusId: id});
|
||||
}
|
||||
enterBack(protyle, id);
|
||||
}
|
||||
}).element);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import {isLocalPath, pathPosix} from "../../util/pathName";
|
|||
import {genEmptyElement} from "../../block/util";
|
||||
import {previewImage} from "../preview/image";
|
||||
import {
|
||||
contentMenu,
|
||||
contentMenu, enterBack,
|
||||
fileAnnotationRefMenu,
|
||||
imgMenu,
|
||||
linkMenu,
|
||||
|
|
@ -1933,6 +1933,7 @@ export class WYSIWYG {
|
|||
clientY: event.clientY
|
||||
});
|
||||
} else if (actionElement.parentElement.classList.contains("li")) {
|
||||
const actionId = actionElement.parentElement.getAttribute("data-node-id")
|
||||
if (event.altKey && !protyle.disabled) {
|
||||
// 展开/折叠当前层级的所有列表项
|
||||
if (actionElement.parentElement.parentElement.classList.contains("protyle-wysiwyg")) {
|
||||
|
|
@ -1964,7 +1965,7 @@ export class WYSIWYG {
|
|||
} else if (event.shiftKey && !protyle.disabled) {
|
||||
openAttr(actionElement.parentElement);
|
||||
} else if (ctrlIsPressed) {
|
||||
zoomOut({protyle, id: actionElement.parentElement.getAttribute("data-node-id")});
|
||||
zoomOut({protyle, id: actionId});
|
||||
} else {
|
||||
if (actionElement.classList.contains("protyle-action--task")) {
|
||||
if (!protyle.disabled) {
|
||||
|
|
@ -1977,10 +1978,14 @@ export class WYSIWYG {
|
|||
actionElement.parentElement.classList.add("protyle-task--done");
|
||||
}
|
||||
actionElement.parentElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
||||
updateTransaction(protyle, actionElement.parentElement.getAttribute("data-node-id"), actionElement.parentElement.outerHTML, html);
|
||||
updateTransaction(protyle, actionId, actionElement.parentElement.outerHTML, html);
|
||||
}
|
||||
} else {
|
||||
zoomOut({protyle, id: actionElement.parentElement.getAttribute("data-node-id")});
|
||||
if (protyle.block.id === actionId) {
|
||||
enterBack(protyle, actionId);
|
||||
} else {
|
||||
zoomOut({protyle, id: actionId});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ import {
|
|||
goHome,
|
||||
upSelect
|
||||
} from "./commonHotkey";
|
||||
import {fileAnnotationRefMenu, linkMenu, refMenu, setFold, tagMenu, zoomOut} from "../../menus/protyle";
|
||||
import {enterBack, fileAnnotationRefMenu, linkMenu, refMenu, setFold, tagMenu, zoomOut} from "../../menus/protyle";
|
||||
import {removeEmbed} from "./removeEmbed";
|
||||
import {openAttr} from "../../menus/commonMenuItem";
|
||||
import {Constants} from "../../constants";
|
||||
|
|
@ -445,18 +445,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
}
|
||||
|
||||
if (matchHotKey(window.siyuan.config.keymap.general.enterBack.custom, event)) {
|
||||
if (!protyle.block.showAll) {
|
||||
const ids = protyle.path.split("/");
|
||||
if (ids.length > 2) {
|
||||
openFileById({
|
||||
app: protyle.app,
|
||||
id: ids[ids.length - 2],
|
||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
|
||||
});
|
||||
}
|
||||
} else {
|
||||
zoomOut({protyle, id: protyle.block.parent2ID, focusId: nodeElement.getAttribute("data-node-id")});
|
||||
}
|
||||
enterBack(protyle, nodeElement.getAttribute("data-node-id"));
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue