Jelajahi Sumber

:bug: Improve outline dnd https://github.com/siyuan-note/siyuan/issues/10828

Daniel 1 tahun lalu
induk
melakukan
577837894f

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

@@ -1462,6 +1462,7 @@
     "237": "[%d] marketplace packages have all been updated successfully",
     "238": "Marketplace package [%s] update failed, please try again later",
     "239": "Related operations are being processed, please try again later",
-    "240": "The heading under the container block in the doc does not support dragging"
+    "240": "Drag heading under container blocks in the doc is not supported",
+    "241": "Drag to its subheading is not supported"
   }
 }

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

@@ -1462,6 +1462,7 @@
     "237": "[%d] todos los paquetes del mercado se han actualizado correctamente",
     "238": "Error en la actualización del paquete Marketplace [%s], inténtalo de nuevo más tarde",
     "239": "Las operaciones relacionadas se están procesando, inténtalo de nuevo más tarde",
-    "240": "El encabezado debajo del bloque contenedor en el documento no admite el arrastre"
+    "240": "No se admite arrastrar encabezado debajo de los bloques contenedores en el documento",
+    "241": "No se admite arrastrar a su subtítulo"
   }
 }

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

@@ -1462,6 +1462,7 @@
     "237": "[%d] packages Marketplace ont tous été mis à jour avec succès",
     "238": "La mise à jour du package Marketplace [%s] a échoué, veuillez réessayer plus tard",
     "239": "Les opérations associées sont en cours de traitement, veuillez réessayer plus tard",
-    "240": "Le titre sous le bloc conteneur dans la doc ne prend pas en charge le glisser"
+    "240": "Le déplacement du titre sous les blocs conteneurs dans la doc n'est pas pris en charge",
+    "241": "Le glisser vers son sous-titre n'est pas pris en charge"
   }
 }

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

@@ -1462,6 +1462,7 @@
     "237": "[%d] 個市集包已經全部更新成功",
     "238": "市集包 [%s] 更新失敗,請稍後再試",
     "239": "相關操作正在處理中,請稍後再試",
-    "240": "文件中容器區塊下的標題不支援拖曳"
+    "240": "不支援拖曳文件中容器區塊下的標題",
+    "241": "不支持拖曳為自己的子標題"
   }
 }

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

@@ -1462,6 +1462,7 @@
     "237": "[%d] 个集市包已经全部更新成功",
     "238": "集市包 [%s] 更新失败,请稍后再试",
     "239": "相关操作正在处理中,请稍后再试",
-    "240": "文档中容器块下的标题不支持拖拽"
+    "240": "不支持拖拽文档中容器块下的标题",
+    "241": "不支持拖拽为自己的子标题"
   }
 }

+ 16 - 0
kernel/model/outline.go

@@ -85,6 +85,14 @@ func (tx *Transaction) doMoveOutlineHeading(operation *Operation) (ret *TxErr) {
 			return
 		}
 
+		for _, h := range headingChildren {
+			if h.ID == previousID {
+				// 不能移动到自己的子标题下
+				util.PushMsg(Conf.language(241), 5000)
+				return
+			}
+		}
+
 		targetNode := previousHeading
 		previousHeadingChildren := treenode.HeadingChildren(previousHeading)
 		if 0 < len(previousHeadingChildren) {
@@ -122,6 +130,14 @@ func (tx *Transaction) doMoveOutlineHeading(operation *Operation) (ret *TxErr) {
 			return
 		}
 
+		for _, h := range headingChildren {
+			if h.ID == parentID {
+				// 不能移动到自己的子标题下
+				util.PushMsg(Conf.language(241), 5000)
+				return
+			}
+		}
+
 		targetNode := parentHeading
 		parentHeadingChildren := treenode.HeadingChildren(parentHeading)