This commit is contained in:
parent
1900b935aa
commit
7c1f7a8280
2 changed files with 39 additions and 3 deletions
|
@ -1,6 +1,8 @@
|
|||
import {hasClosestBlock} from "../../../protyle/util/hasClosest";
|
||||
import {getTopAloneElement} from "../../../protyle/wysiwyg/getBlock";
|
||||
import {enterBack, zoomOut} from "../../../menus/protyle";
|
||||
import {openFileById} from "../../../editor/util";
|
||||
import {Constants} from "../../../constants";
|
||||
|
||||
export const onlyProtyleCommand = (options: {
|
||||
command: string,
|
||||
|
@ -17,7 +19,16 @@ export const onlyProtyleCommand = (options: {
|
|||
topNodeElement.nextElementSibling?.classList.contains("list") && topNodeElement.previousElementSibling.classList.contains("protyle-action")) {
|
||||
topNodeElement = topNodeElement.parentElement;
|
||||
}
|
||||
zoomOut({protyle: options.protyle, id: topNodeElement.getAttribute("data-node-id")});
|
||||
const id = topNodeElement.getAttribute("data-node-id")
|
||||
if (options.protyle.options.backlinkData) {
|
||||
openFileById({
|
||||
app: options.protyle.app,
|
||||
id,
|
||||
action: [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS]
|
||||
});
|
||||
} else {
|
||||
zoomOut({protyle: options.protyle, id});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (options.command === "enterBack") {
|
||||
|
|
|
@ -60,6 +60,7 @@ import {avContextmenu, duplicateCompletely} from "../render/av/action";
|
|||
import {getPlainText} from "../util/paste";
|
||||
import {addEditorToDatabase} from "../render/av/addToDatabase";
|
||||
import {processClonePHElement} from "../render/util";
|
||||
import {openFileById} from "../../editor/util";
|
||||
|
||||
export class Gutter {
|
||||
public element: HTMLElement;
|
||||
|
@ -67,13 +68,16 @@ export class Gutter {
|
|||
|
||||
constructor(protyle: IProtyle) {
|
||||
if (isMac()) {
|
||||
this.gutterTip = window.siyuan.languages.gutterTip;
|
||||
this.gutterTip = window.siyuan.languages.gutterTip.replace("⌥→", updateHotkeyTip(window.siyuan.config.keymap.general.enter.custom));
|
||||
} else {
|
||||
this.gutterTip = window.siyuan.languages.gutterTip.replace("⌥→", updateHotkeyTip(window.siyuan.config.keymap.general.enter.custom))
|
||||
.replace("⌘↑", updateHotkeyTip(window.siyuan.config.keymap.editor.general.collapse.custom))
|
||||
.replace("⌥⌘A", updateHotkeyTip(window.siyuan.config.keymap.editor.general.attr.custom))
|
||||
.replace(/⌘/g, "Ctrl+").replace(/⌥/g, "Alt+").replace(/⇧/g, "Shift+").replace(/⌃/g, "Ctrl+");
|
||||
}
|
||||
if (protyle.options.backlinkData) {
|
||||
this.gutterTip = this.gutterTip.replace(window.siyuan.languages.enter, window.siyuan.languages.openBy)
|
||||
}
|
||||
this.element = document.createElement("div");
|
||||
this.element.className = "protyle-gutters";
|
||||
this.element.addEventListener("dragstart", (event: DragEvent & { target: HTMLElement }) => {
|
||||
|
@ -305,7 +309,15 @@ export class Gutter {
|
|||
return;
|
||||
}
|
||||
if (isOnlyMeta(event)) {
|
||||
zoomOut({protyle, id});
|
||||
if (protyle.options.backlinkData) {
|
||||
openFileById({
|
||||
app: protyle.app,
|
||||
id,
|
||||
action: [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS]
|
||||
});
|
||||
} else {
|
||||
zoomOut({protyle, id});
|
||||
}
|
||||
} else if (event.altKey) {
|
||||
let foldElement: Element;
|
||||
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${id}"]`)).find(item => {
|
||||
|
@ -1695,6 +1707,19 @@ export class Gutter {
|
|||
enterBack(protyle, id);
|
||||
}
|
||||
}).element);
|
||||
} else {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
id: "enter",
|
||||
accelerator: `${updateHotkeyTip(window.siyuan.config.keymap.general.enter.custom)}/${updateHotkeyTip("⌘" + window.siyuan.languages.click)}`,
|
||||
label: window.siyuan.languages.openBy,
|
||||
click: () => {
|
||||
openFileById({
|
||||
app: protyle.app,
|
||||
id,
|
||||
action: [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS]
|
||||
});
|
||||
}
|
||||
}).element);
|
||||
}
|
||||
if (!protyle.disabled) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
|
|
Loading…
Add table
Reference in a new issue