mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 01:20:12 +01:00
This commit is contained in:
parent
bb0995eb6b
commit
e1e8eb464b
9 changed files with 77 additions and 49 deletions
|
|
@ -118,10 +118,8 @@
|
|||
"safeQuit": "Quit the application",
|
||||
"anchor": "Anchor",
|
||||
"showMore": "Show More",
|
||||
"refPopover": "Open the ref block by popover",
|
||||
"refRight": "Open the ref block on the right",
|
||||
"refBottom": "Open the ref block on the bottom",
|
||||
"refTab": "Open the ref block in a new tab",
|
||||
"refPopover": "Open in Popover",
|
||||
"refTab": "Open in background tab",
|
||||
"showHideBg": "Show/Hide Background",
|
||||
"directConnection": "Direct connection",
|
||||
"networkProxy": "Network Proxy",
|
||||
|
|
|
|||
|
|
@ -118,10 +118,8 @@
|
|||
"safeQuit": "Salir de la aplicación",
|
||||
"anchor": "Anclaje",
|
||||
"showMore": "Mostrar más",
|
||||
"refPopover": "Abrir el bloque de ref mediante popover",
|
||||
"refRight": "Abrir el bloque de ref a la derecha",
|
||||
"refBottom": "Abrir el bloque de ref en la parte inferior",
|
||||
"refTab": "Abrir el bloque de ref en una nueva pestaña",
|
||||
"refPopover": "Abrir en Popover",
|
||||
"refTab": "Abrir en la pestaña de fondo",
|
||||
"showHideBg": "Mostrar/Ocultar fondo",
|
||||
"directConnection": "Conexión directa",
|
||||
"networkProxy": "Proxy de red",
|
||||
|
|
|
|||
|
|
@ -118,10 +118,8 @@
|
|||
"safeQuit": "Quitter l'application",
|
||||
"anchor": "ancre",
|
||||
"showMore": "Afficher plus",
|
||||
"refPopover": "Utiliser la fenêtre flottante pour ouvrir la référence",
|
||||
"refRight": "Ouvrir le bloc de référence à droite",
|
||||
"refBottom": "Ouvrir le bloc de référence dans la goutte inférieure",
|
||||
"refTab": "Ouvrir le bloc de référence dans un nouvel onglet",
|
||||
"refPopover": "Ouvrir dans Popover",
|
||||
"refTab": "Ouvrir en arrière-plan",
|
||||
"showHideBg": "Afficher/Masquer l'arrière-plan",
|
||||
"directConnection": "Connexion directe",
|
||||
"networkProxy": "Proxy réseau",
|
||||
|
|
|
|||
|
|
@ -118,10 +118,8 @@
|
|||
"safeQuit": "退出應用",
|
||||
"anchor": "錨點",
|
||||
"showMore": "顯示更多",
|
||||
"refPopover": "使用浮窗打開引用塊",
|
||||
"refRight": "在右側打開引用塊",
|
||||
"refBottom": "在下側打開引用塊",
|
||||
"refTab": "在新分頁中打開引用塊",
|
||||
"refPopover": "在浮窗中打開",
|
||||
"refTab": "在後台頁簽中打開",
|
||||
"showHideBg": "顯示/隱藏背景",
|
||||
"directConnection": "直接連接",
|
||||
"networkProxy": "網路代理",
|
||||
|
|
|
|||
|
|
@ -118,10 +118,8 @@
|
|||
"safeQuit": "退出应用",
|
||||
"anchor": "锚文本",
|
||||
"showMore": "显示更多",
|
||||
"refPopover": "使用浮窗打开引用块",
|
||||
"refRight": "在右侧打开引用块",
|
||||
"refBottom": "在下侧打开引用块",
|
||||
"refTab": "在新页签中打开引用块",
|
||||
"refPopover": "在浮窗中打开",
|
||||
"refTab": "在后台页签中打开",
|
||||
"showHideBg": "显示/隐藏背景",
|
||||
"directConnection": "直接连接",
|
||||
"networkProxy": "网络代理",
|
||||
|
|
|
|||
|
|
@ -125,10 +125,11 @@ export abstract class Constants {
|
|||
netImg2LocalAsset: {default: "", custom: ""},
|
||||
hLayout: {default: "", custom: ""},
|
||||
vLayout: {default: "", custom: ""},
|
||||
refBottom: {default: "⇧>", custom: "⇧>"},
|
||||
refRight: {default: "⌥.", custom: "⌥."},
|
||||
refPopover: {default: "⌥⌘.", custom: "⌥⌘."},
|
||||
refPopover: {default: "", custom: ""},
|
||||
insertBottom: {default: "⌥⌘.", custom: "⌥⌘."},
|
||||
refTab: {default: "⇧⌘.", custom: "⇧⌘."},
|
||||
openBy: {default: "⌘.", custom: "⌘."},
|
||||
insertRight: {default: "⌥.", custom: "⌥."},
|
||||
attr: {default: "⌥⌘A", custom: "⌥⌘A"},
|
||||
refresh: {default: "F5", custom: "F5"},
|
||||
copyBlockRef: {default: "⇧⌘C", custom: "⇧⌘C"},
|
||||
|
|
|
|||
|
|
@ -91,7 +91,20 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
|||
/// #if !MOBILE
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.openBy,
|
||||
accelerator: "⌘Click",
|
||||
accelerator: window.siyuan.config.keymap.editor.general.openBy.custom + "/Click",
|
||||
click() {
|
||||
fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {
|
||||
openFileById({
|
||||
id: refBlockId,
|
||||
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
|
||||
zoomIn: foldResponse.data
|
||||
});
|
||||
});
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.refTab,
|
||||
accelerator: window.siyuan.config.keymap.editor.general.refTab.custom + "/⌘Click",
|
||||
click() {
|
||||
fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {
|
||||
openFileById({
|
||||
|
|
@ -106,7 +119,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
|||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.insertRight,
|
||||
icon: "iconRight",
|
||||
accelerator: window.siyuan.config.keymap.editor.general.refBottom.custom + "/⌥Click",
|
||||
accelerator: window.siyuan.config.keymap.editor.general.insertRight.custom + "/⌥Click",
|
||||
click() {
|
||||
fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {
|
||||
openFileById({
|
||||
|
|
@ -121,7 +134,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
|
|||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.insertBottom,
|
||||
icon: "iconDown",
|
||||
accelerator: "⇧Click",
|
||||
accelerator: window.siyuan.config.keymap.editor.general.insertBottom.custom + (window.siyuan.config.keymap.editor.general.insertBottom.custom ? "/" : "") + "⇧Click",
|
||||
click() {
|
||||
fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {
|
||||
openFileById({
|
||||
|
|
|
|||
|
|
@ -69,17 +69,21 @@ export const matchHotKey = (hotKey: string, event: KeyboardEvent) => {
|
|||
// 是否匹配 ⇧⌘[] / ⌘[]
|
||||
const hasShift = hotKeys.length > 2 && (hotKeys[0] === "⇧");
|
||||
let key = (hasShift ? hotKeys[2] : hotKeys[1]);
|
||||
if (hasShift // 更新 electron 后不需要判断 mac && !/Mac/.test(navigator.platform)
|
||||
) {
|
||||
let keyCode
|
||||
// 更新 electron 后不需要判断 Mac,但 Mac 下中英文有区别,需使用 keyCode 辅助
|
||||
if (hasShift) {
|
||||
if (key === "-") {
|
||||
key = "_";
|
||||
keyCode = 189;
|
||||
} else if (key === "=") {
|
||||
key = "+";
|
||||
keyCode = 187;
|
||||
} else if (key === ".") {
|
||||
key = ">";
|
||||
keyCode = 190;
|
||||
}
|
||||
}
|
||||
if (isCtrl(event) && event.key.toLowerCase() === key.toLowerCase() && !event.altKey
|
||||
if (isCtrl(event) && (event.key.toLowerCase() === key.toLowerCase() || event.keyCode === keyCode) && !event.altKey
|
||||
&& ((!hasShift && !event.shiftKey) || (hasShift && event.shiftKey))) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1591,40 +1591,60 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
const refElement = hasClosestByAttribute(range.startContainer, "data-type", "block-ref");
|
||||
if (refElement) {
|
||||
const id = refElement.getAttribute("data-id");
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.refPopover.custom, event)) {
|
||||
// open popover
|
||||
window.siyuan.blockPanels.push(new BlockPanel({
|
||||
targetElement: refElement,
|
||||
nodeIds: [id],
|
||||
}));
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.openBy.custom, event)) {
|
||||
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
|
||||
openFileById({
|
||||
id,
|
||||
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
|
||||
zoomIn: foldResponse.data
|
||||
});
|
||||
});
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
} else if (matchHotKey(window.siyuan.config.keymap.editor.general.refTab.custom, event)) {
|
||||
// 打开块引和编辑器中引用、反链、书签中点击事件需保持一致,都加载上下文
|
||||
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
|
||||
openFileById({
|
||||
id,
|
||||
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT],
|
||||
keepCursor: true,
|
||||
action: [Constants.CB_GET_CONTEXT]
|
||||
zoomIn: foldResponse.data
|
||||
});
|
||||
});
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
} else if (matchHotKey(window.siyuan.config.keymap.editor.general.refRight.custom, event)) {
|
||||
} else if (matchHotKey(window.siyuan.config.keymap.editor.general.insertRight.custom, event)) {
|
||||
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
|
||||
openFileById({
|
||||
id,
|
||||
position: "right",
|
||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
|
||||
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
|
||||
zoomIn: foldResponse.data
|
||||
});
|
||||
});
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
} else if (matchHotKey(window.siyuan.config.keymap.editor.general.refBottom.custom, event)) {
|
||||
} else if (matchHotKey(window.siyuan.config.keymap.editor.general.insertBottom.custom, event)) {
|
||||
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
|
||||
openFileById({
|
||||
id,
|
||||
position: "bottom",
|
||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
|
||||
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
|
||||
zoomIn: foldResponse.data
|
||||
});
|
||||
});
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
}else if (matchHotKey(window.siyuan.config.keymap.editor.general.refPopover.custom, event)) {
|
||||
// open popover
|
||||
window.siyuan.blockPanels.push(new BlockPanel({
|
||||
targetElement: refElement,
|
||||
nodeIds: [id],
|
||||
}));
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue