Skip to content

Commit

Permalink
🎨 fix #9392
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Oct 10, 2023
1 parent 4318aa4 commit ea00753
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""},
Expand Down
1 change: 1 addition & 0 deletions app/src/menus/commonMenuItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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})`);
Expand Down
11 changes: 10 additions & 1 deletion app/src/protyle/wysiwyg/commonHotkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/protyle/wysiwyg/keydown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ea00753

Please sign in to comment.