This commit is contained in:
Vanessa 2023-10-10 21:18:17 +08:00
parent 4318aa4463
commit ea00753f38
4 changed files with 13 additions and 2 deletions

View file

@ -264,6 +264,7 @@ export abstract class Constants {
expandUp: {default: "⌥⇧↑", custom: "⌥⇧↑"}, expandUp: {default: "⌥⇧↑", custom: "⌥⇧↑"},
copyPlainText: {default: "", custom: ""}, copyPlainText: {default: "", custom: ""},
copyID: {default: "", custom: ""}, copyID: {default: "", custom: ""},
copyProtocolInMd: {default: "", custom: ""},
netImg2LocalAsset: {default: "", custom: ""}, netImg2LocalAsset: {default: "", custom: ""},
optimizeTypography: {default: "", custom: ""}, optimizeTypography: {default: "", custom: ""},
hLayout: {default: "", custom: ""}, hLayout: {default: "", custom: ""},

View file

@ -394,6 +394,7 @@ export const copySubMenu = (id: string, accelerator = true, focusElement?: Eleme
} }
}, { }, {
label: window.siyuan.languages.copyProtocolInMd, label: window.siyuan.languages.copyProtocolInMd,
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyProtocolInMd.custom : undefined,
click: () => { click: () => {
fetchPost("/api/block/getRefText", {id}, (response) => { fetchPost("/api/block/getRefText", {id}, (response) => {
writeText(`[${response.data}](siyuan://blocks/${id})`); writeText(`[${response.data}](siyuan://blocks/${id})`);

View file

@ -21,7 +21,7 @@ import {onGet} from "../util/onGet";
import {Constants} from "../../constants"; import {Constants} from "../../constants";
import * as dayjs from "dayjs"; 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; const target = event.target as HTMLElement;
if (matchHotKey(window.siyuan.config.keymap.editor.general.copyHPath.custom, event)) { if (matchHotKey(window.siyuan.config.keymap.editor.general.copyHPath.custom, event)) {
fetchPost("/api/filetree/getHPathByID", { fetchPost("/api/filetree/getHPathByID", {
@ -56,6 +56,15 @@ export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent) => {
event.preventDefault(); event.preventDefault();
return true; 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 !MOBILE
if (protyle.model) { if (protyle.model) {
if (matchHotKey(window.siyuan.config.keymap.editor.general.backlinks.custom, event)) { if (matchHotKey(window.siyuan.config.keymap.editor.general.backlinks.custom, event)) {

View file

@ -983,7 +983,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return true; return true;
} }
/// #if !MOBILE /// #if !MOBILE
if (commonHotkey(protyle, event)) { if (commonHotkey(protyle, event, nodeElement)) {
return true; return true;
} }
/// #endif /// #endif