Bladeren bron

:sparkles: fix https://github.com/siyuan-note/siyuan/issues/5407

Vanessa 2 jaren geleden
bovenliggende
commit
9e55cc6c37

+ 1 - 0
app/appearance/langs/en_US.json

@@ -1,4 +1,5 @@
 {
 {
+  "jumpToParentNext": "Jump to the next block in the previous level",
   "initRepoKeyTip": "If the key has been initialized on other devices, please use [Import Key] or generate the key with the same passphrase, otherwise the data cannot be synced to the cloud, so be sure to use the same key on all devices",
   "initRepoKeyTip": "If the key has been initialized on other devices, please use [Import Key] or generate the key with the same passphrase, otherwise the data cannot be synced to the cloud, so be sure to use the same key on all devices",
   "crossKeepLazyLoad": "Cross-page multi-selection needs to select [Keep Loaded Content] in the more menu",
   "crossKeepLazyLoad": "Cross-page multi-selection needs to select [Keep Loaded Content] in the more menu",
   "keepLazyLoad": "Keep loaded content",
   "keepLazyLoad": "Keep loaded content",

+ 1 - 0
app/appearance/langs/es_ES.json

@@ -1,4 +1,5 @@
 {
 {
+  "jumpToParentNext": "Saltar al siguiente bloque en el nivel anterior",
   "initRepoKeyTip": "Si la clave se ha inicializado en otros dispositivos, use [Importar la clave] o genere la clave con la misma contraseña; de lo contrario, los datos no se pueden sincronizar con la nube, así que asegúrese de usar la misma clave en todos los dispositivos.",
   "initRepoKeyTip": "Si la clave se ha inicializado en otros dispositivos, use [Importar la clave] o genere la clave con la misma contraseña; de lo contrario, los datos no se pueden sincronizar con la nube, así que asegúrese de usar la misma clave en todos los dispositivos.",
   "crossKeepLazyLoad": "La selección múltiple entre páginas debe seleccionar [Mantener contenido cargado] en el menú más",
   "crossKeepLazyLoad": "La selección múltiple entre páginas debe seleccionar [Mantener contenido cargado] en el menú más",
   "keepLazyLoad": "Mantener el contenido cargado",
   "keepLazyLoad": "Mantener el contenido cargado",

+ 1 - 0
app/appearance/langs/fr_FR.json

@@ -1,4 +1,5 @@
 {
 {
+  "jumpToParentNext": "Aller au bloc suivant du niveau précédent",
   "initRepoKeyTip": "Si la clé a été initialisée sur d'autres appareils, veuillez utiliser [Importer la clé] ou générer la clé avec le même mot de passe, sinon les données ne peuvent pas être synchronisées avec le cloud, alors assurez-vous d'utiliser la même clé sur tous les appareils",
   "initRepoKeyTip": "Si la clé a été initialisée sur d'autres appareils, veuillez utiliser [Importer la clé] ou générer la clé avec le même mot de passe, sinon les données ne peuvent pas être synchronisées avec le cloud, alors assurez-vous d'utiliser la même clé sur tous les appareils",
   "crossKeepLazyLoad": "La multi-sélection sur plusieurs pages doit sélectionner [Conserver le contenu chargé] dans le menu plus",
   "crossKeepLazyLoad": "La multi-sélection sur plusieurs pages doit sélectionner [Conserver le contenu chargé] dans le menu plus",
   "keepLazyLoad": "Conserver le contenu chargé",
   "keepLazyLoad": "Conserver le contenu chargé",

+ 1 - 0
app/appearance/langs/zh_CHT.json

@@ -1,4 +1,5 @@
 {
 {
+  "jumpToParentNext": "跳轉到上一層級的下一個塊",
   "initRepoKeyTip": "如果其他設備上已經初始化過密鑰,請使用 [導入密鑰] 或者通過相同的密碼生成密鑰,否則無法雲端同步數據,所以請務必在所有設備上使用相同的密鑰",
   "initRepoKeyTip": "如果其他設備上已經初始化過密鑰,請使用 [導入密鑰] 或者通過相同的密碼生成密鑰,否則無法雲端同步數據,所以請務必在所有設備上使用相同的密鑰",
   "crossKeepLazyLoad": "跨頁多選需在更多菜單中選中【保持已加載內容】",
   "crossKeepLazyLoad": "跨頁多選需在更多菜單中選中【保持已加載內容】",
   "keepLazyLoad": "保持已加載的內容",
   "keepLazyLoad": "保持已加載的內容",

+ 1 - 0
app/appearance/langs/zh_CN.json

@@ -1,4 +1,5 @@
 {
 {
+  "jumpToParentNext": "跳转到上一层级的下一个块",
   "initRepoKeyTip": "如果其他设备上已经初始化过密钥,请使用 [导入密钥] 或者通过相同的密码生成密钥,否则无法云端同步数据,所以请务必在所有设备上使用相同的密钥",
   "initRepoKeyTip": "如果其他设备上已经初始化过密钥,请使用 [导入密钥] 或者通过相同的密码生成密钥,否则无法云端同步数据,所以请务必在所有设备上使用相同的密钥",
   "crossKeepLazyLoad": "跨页多选需在更多菜单中选中 [保持已加载内容]",
   "crossKeepLazyLoad": "跨页多选需在更多菜单中选中 [保持已加载内容]",
   "keepLazyLoad": "保持已加载的内容",
   "keepLazyLoad": "保持已加载的内容",

+ 15 - 3
app/src/block/util.ts

@@ -1,6 +1,6 @@
-import {focusByWbr, getEditorRange} from "../protyle/util/selection";
-import {hasClosestBlock} from "../protyle/util/hasClosest";
-import {getTopAloneElement} from "../protyle/wysiwyg/getBlock";
+import {focusBlock, focusByWbr, getEditorRange} from "../protyle/util/selection";
+import {hasClosestBlock, hasClosestByClassName} from "../protyle/util/hasClosest";
+import {getNextBlock, getTopAloneElement} from "../protyle/wysiwyg/getBlock";
 import {genListItemElement, updateListOrder} from "../protyle/wysiwyg/list";
 import {genListItemElement, updateListOrder} from "../protyle/wysiwyg/list";
 import {transaction, updateTransaction} from "../protyle/wysiwyg/transaction";
 import {transaction, updateTransaction} from "../protyle/wysiwyg/transaction";
 import {scrollCenter} from "../util/highlightById";
 import {scrollCenter} from "../util/highlightById";
@@ -60,6 +60,18 @@ export const genSBElement = (layout: string, id?: string, attrHTML?: string) =>
     return sbElement;
     return sbElement;
 };
 };
 
 
+export const jumpToParentNext = (protyle:IProtyle,nodeElement: Element) => {
+    const topElement = getTopAloneElement(nodeElement);
+    if (topElement) {
+        const topParentElement = hasClosestByClassName(topElement, "list") || hasClosestByClassName(topElement, "bq") || hasClosestByClassName(topElement, "sb") || topElement
+        const nextElement = getNextBlock(topParentElement)
+        if (nextElement) {
+            focusBlock(nextElement)
+            scrollCenter(protyle, nextElement);
+        }
+    }
+}
+
 export const insertEmptyBlock = (protyle: IProtyle, position: InsertPosition, id?: string) => {
 export const insertEmptyBlock = (protyle: IProtyle, position: InsertPosition, id?: string) => {
     const range = getEditorRange(protyle.wysiwyg.element);
     const range = getEditorRange(protyle.wysiwyg.element);
     let blockElement: Element;
     let blockElement: Element;

+ 1 - 0
app/src/constants.ts

@@ -146,6 +146,7 @@ export abstract class Constants {
                 preview: {default: "⌥⌘9", custom: "⌥⌘9"},
                 preview: {default: "⌥⌘9", custom: "⌥⌘9"},
                 insertBefore: {default: "⇧⌘B", custom: "⇧⌘B"},
                 insertBefore: {default: "⇧⌘B", custom: "⇧⌘B"},
                 insertAfter: {default: "⇧⌘A", custom: "⇧⌘A"},
                 insertAfter: {default: "⇧⌘A", custom: "⇧⌘A"},
+                jumpToParentNext: {default: "⇧⌘N", custom: "⇧⌘N"},
                 moveToUp: {default: "⇧⌘↑", custom: "⇧⌘↑"},
                 moveToUp: {default: "⇧⌘↑", custom: "⇧⌘↑"},
                 moveToDown: {default: "⇧⌘↓", custom: "⇧⌘↓"},
                 moveToDown: {default: "⇧⌘↓", custom: "⇧⌘↓"},
             },
             },

+ 9 - 1
app/src/protyle/gutter/index.ts

@@ -16,7 +16,7 @@ import {removeEmbed} from "../wysiwyg/removeEmbed";
 import {getContenteditableElement, getTopAloneElement, isNotEditBlock} from "../wysiwyg/getBlock";
 import {getContenteditableElement, getTopAloneElement, isNotEditBlock} from "../wysiwyg/getBlock";
 import * as dayjs from "dayjs";
 import * as dayjs from "dayjs";
 import {fetchPost} from "../../util/fetch";
 import {fetchPost} from "../../util/fetch";
-import {cancelSB, insertEmptyBlock} from "../../block/util";
+import {cancelSB, insertEmptyBlock, jumpToParentNext} from "../../block/util";
 import {scrollCenter} from "../../util/highlightById";
 import {scrollCenter} from "../../util/highlightById";
 import {isMobile} from "../../util/functions";
 import {isMobile} from "../../util/functions";
 import {confirmDialog} from "../../dialog/confirmDialog";
 import {confirmDialog} from "../../dialog/confirmDialog";
@@ -1094,6 +1094,14 @@ export class Gutter {
                     insertEmptyBlock(protyle, "afterend", id);
                     insertEmptyBlock(protyle, "afterend", id);
                 }
                 }
             }).element);
             }).element);
+            window.siyuan.menus.menu.append(new MenuItem({
+                label: window.siyuan.languages.jumpToParentNext,
+                accelerator: window.siyuan.config.keymap.editor.general.jumpToParentNext.custom,
+                click() {
+                    nodeElement.classList.remove("protyle-wysiwyg--select");
+                    jumpToParentNext(protyle, nodeElement)
+                }
+            }).element);
             window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
             window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
 
 
             window.siyuan.menus.menu.append(new MenuItem({
             window.siyuan.menus.menu.append(new MenuItem({

+ 7 - 1
app/src/protyle/wysiwyg/keydown.ts

@@ -32,7 +32,7 @@ import {phTransaction, transaction, turnsIntoTransaction, updateTransaction} fro
 import {fontEvent} from "../toolbar/Font";
 import {fontEvent} from "../toolbar/Font";
 import {listIndent, listOutdent, updateListOrder} from "./list";
 import {listIndent, listOutdent, updateListOrder} from "./list";
 import {newFileBySelect, newFileContentBySelect, rename, replaceFileName} from "../../editor/rename";
 import {newFileBySelect, newFileContentBySelect, rename, replaceFileName} from "../../editor/rename";
-import {insertEmptyBlock} from "../../block/util";
+import {insertEmptyBlock, jumpToParentNext} from "../../block/util";
 import {isLocalPath} from "../../util/pathName";
 import {isLocalPath} from "../../util/pathName";
 /// #if !BROWSER
 /// #if !BROWSER
 import {clipboard} from "electron";
 import {clipboard} from "electron";
@@ -1189,6 +1189,12 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
             event.stopPropagation();
             event.stopPropagation();
             return true;
             return true;
         }
         }
+        if (matchHotKey(window.siyuan.config.keymap.editor.general.jumpToParentNext.custom, event)) {
+            jumpToParentNext(protyle, nodeElement)
+            event.preventDefault();
+            event.stopPropagation();
+            return true;
+        }
 
 
         if (matchHotKey(window.siyuan.config.keymap.editor.general.moveToUp.custom, event)) {
         if (matchHotKey(window.siyuan.config.keymap.editor.general.moveToUp.custom, event)) {
             event.preventDefault();
             event.preventDefault();