mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
This commit is contained in:
parent
4318aa4463
commit
ea00753f38
4 changed files with 13 additions and 2 deletions
|
|
@ -264,6 +264,7 @@ export abstract class Constants {
|
|||
expandUp: {default: "⌥⇧↑", custom: "⌥⇧↑"},
|
||||
copyPlainText: {default: "", custom: ""},
|
||||
copyID: {default: "", custom: ""},
|
||||
copyProtocolInMd: {default: "", custom: ""},
|
||||
netImg2LocalAsset: {default: "", custom: ""},
|
||||
optimizeTypography: {default: "", custom: ""},
|
||||
hLayout: {default: "", custom: ""},
|
||||
|
|
|
|||
|
|
@ -394,6 +394,7 @@ export const copySubMenu = (id: string, accelerator = true, focusElement?: Eleme
|
|||
}
|
||||
}, {
|
||||
label: window.siyuan.languages.copyProtocolInMd,
|
||||
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyProtocolInMd.custom : undefined,
|
||||
click: () => {
|
||||
fetchPost("/api/block/getRefText", {id}, (response) => {
|
||||
writeText(`[${response.data}](siyuan://blocks/${id})`);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import {onGet} from "../util/onGet";
|
|||
import {Constants} from "../../constants";
|
||||
import * as dayjs from "dayjs";
|
||||
|
||||
export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent) => {
|
||||
export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent, nodeElement?: HTMLElement) => {
|
||||
const target = event.target as HTMLElement;
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.copyHPath.custom, event)) {
|
||||
fetchPost("/api/filetree/getHPathByID", {
|
||||
|
|
@ -56,6 +56,15 @@ export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent) => {
|
|||
event.preventDefault();
|
||||
return true;
|
||||
}
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.copyProtocolInMd.custom, event)) {
|
||||
const id = nodeElement ? nodeElement.getAttribute("data-node-id") : protyle.block.rootID;
|
||||
fetchPost("/api/block/getRefText", {id}, (response) => {
|
||||
writeText(`[${response.data}](siyuan://blocks/${id})`);
|
||||
});
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
}
|
||||
/// #if !MOBILE
|
||||
if (protyle.model) {
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.backlinks.custom, event)) {
|
||||
|
|
|
|||
|
|
@ -983,7 +983,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
return true;
|
||||
}
|
||||
/// #if !MOBILE
|
||||
if (commonHotkey(protyle, event)) {
|
||||
if (commonHotkey(protyle, event, nodeElement)) {
|
||||
return true;
|
||||
}
|
||||
/// #endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue