瀏覽代碼

:art: Support `Jump to the next block in the parent level` on focus status https://github.com/siyuan-note/siyuan/issues/9527

Daniel 1 年之前
父節點
當前提交
e54641f2c1

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

@@ -342,7 +342,7 @@
   "syncConfGuide5": "If the amount of data is large, the first sync will be slow, please wait patiently<br>Do not switch apps and keep the screen bright while the iOS/iPad is syncing",
   "copyPlainText": "Copy plain text",
   "findInDoc": "Match ${y} items in ${x} docs",
-  "jumpToParentNext": "Jump to the next block in the previous level",
+  "jumpToParentNext": "Jump to the next block in the parent 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",
   "crossKeepLazyLoad": "Cross-page multi-selection needs to select [Keep Loaded Content] in the more menu",
   "keepLazyLoad": "Keep loaded content",

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

@@ -342,7 +342,7 @@
   "syncConfGuide5": "Si la cantidad de datos es grande, la primera sincronización será lenta, espere pacientemente<br>No cambie de aplicación y mantenga la pantalla brillante mientras iOS/iPad se sincroniza",
   "copyPlainText": "Copiar texto sin formato",
   "findInDoc": "Hacer coincidir ${y} elementos en ${x} documentos",
-  "jumpToParentNext": "Saltar al siguiente bloque en el nivel anterior",
+  "jumpToParentNext": "Saltar al siguiente bloque en el nivel principal",
   "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",
   "keepLazyLoad": "Mantener el contenido cargado",

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

@@ -342,7 +342,7 @@
   "syncConfGuide5": "Si la quantité de données est importante, la première synchronisation sera lente, veuillez patienter<br> Ne changez pas d'application et gardez l'écran lumineux pendant la synchronisation de l'iOS/iPad",
   "copyPlainText": "Copier du texte brut",
   "findInDoc": "Faire correspondre les éléments ${y} dans les documents ${x}",
-  "jumpToParentNext": "Aller au bloc suivant du niveau précédent",
+  "jumpToParentNext": "Passer au bloc suivant du niveau parent",
   "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",
   "keepLazyLoad": "Conserver le contenu chargé",

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

@@ -342,7 +342,7 @@
   "syncConfGuide5": "如果資料量較大,第一次同步會比較慢,請耐心等待<br>iOS/iPad 端在同步時請勿切換應用並保持螢幕恆亮",
   "copyPlainText": "複製純文字",
   "findInDoc": "${x} 個文檔中匹配 ${y} 項",
-  "jumpToParentNext": "跳轉到上一層級的下一個塊",
+  "jumpToParentNext": "跳轉到級的下一個塊",
   "initRepoKeyTip": "如果其他設備上已經初始化過密鑰,請使用 [導入密鑰] 或者通過相同的密碼生成密鑰,否則無法雲端同步資料,所以請務必在所有設備上使用相同的密鑰",
   "crossKeepLazyLoad": "跨頁多選需在更多菜單中選中【保持已載入內容】",
   "keepLazyLoad": "保持已載入的內容",

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

@@ -342,7 +342,7 @@
   "syncConfGuide5": "如果数据量较大,第一次同步会比较慢,请耐心等待<br>iOS/iPad 端在同步时请勿切换应用并保持亮屏",
   "copyPlainText": "复制纯文本",
   "findInDoc": "${x} 个文档中匹配 ${y} 项",
-  "jumpToParentNext": "跳转到上一层级的下一个块",
+  "jumpToParentNext": "跳转到级的下一个块",
   "initRepoKeyTip": "如果其他设备上已经初始化过密钥,请使用 [导入密钥] 或者通过相同的密码生成密钥,否则无法云端同步数据,所以请务必在所有设备上使用相同的密钥",
   "crossKeepLazyLoad": "跨页多选需在更多菜单中选中 [保持已加载内容]",
   "keepLazyLoad": "保持已加载的内容",

+ 15 - 0
kernel/api/block.go

@@ -29,6 +29,21 @@ import (
 	"github.com/siyuan-note/siyuan/kernel/util"
 )
 
+func getParentNextChildID(c *gin.Context) {
+	ret := gulu.Ret.NewResult()
+	defer c.JSON(http.StatusOK, ret)
+
+	arg, ok := util.JsonArg(c, ret)
+	if !ok {
+		return
+	}
+
+	id := arg["id"].(string)
+	ret.Data = map[string]string{
+		"id": model.GetParentNextChildID(id),
+	}
+}
+
 func transferBlockRef(c *gin.Context) {
 	ret := gulu.Ret.NewResult()
 	defer c.JSON(http.StatusOK, ret)

+ 1 - 0
kernel/api/router.go

@@ -181,6 +181,7 @@ func ServeAPI(ginServer *gin.Engine) {
 	ginServer.Handle("POST", "/api/block/getHeadingChildrenDOM", model.CheckAuth, getHeadingChildrenDOM)
 	ginServer.Handle("POST", "/api/block/swapBlockRef", model.CheckAuth, model.CheckReadonly, swapBlockRef)
 	ginServer.Handle("POST", "/api/block/transferBlockRef", model.CheckAuth, model.CheckReadonly, transferBlockRef)
+	ginServer.Handle("POST", "/api/block/getParentNextChildID", model.CheckAuth, model.CheckReadonly, getParentNextChildID)
 
 	ginServer.Handle("POST", "/api/file/getFile", model.CheckAuth, getFile)
 	ginServer.Handle("POST", "/api/file/putFile", model.CheckAuth, model.CheckReadonly, putFile)

+ 19 - 0
kernel/model/block.go

@@ -89,6 +89,25 @@ type Path struct {
 	Created string `json:"created"` // 创建时间
 }
 
+func GetParentNextChildID(id string) string {
+	tree, err := loadTreeByBlockID(id)
+	if nil != err {
+		return ""
+	}
+
+	node := treenode.GetNodeInTree(tree, id)
+	if nil == node {
+		return ""
+	}
+
+	for p := node.Parent; nil != p; p = p.Parent {
+		if nil != p.Next {
+			return p.Next.ID
+		}
+	}
+	return ""
+}
+
 func IsBlockFolded(id string) bool {
 	for i := 0; i < 32; i++ {
 		b, _ := getBlock(id, nil)