mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
🎨 文档树支持 Ctrl+Click 和 Shift+↑/↓ 进行多选 https://github.com/siyuan-note/siyuan/issues/1359
This commit is contained in:
parent
f3bcdb1d39
commit
0378cf52d5
2 changed files with 32 additions and 30 deletions
|
|
@ -1031,7 +1031,8 @@ func MoveDoc(fromBoxID, fromPath, toBoxID, toPath string) (newPath string, err e
|
||||||
func MoveDocs(fromPaths []string, toPath string) (err error) {
|
func MoveDocs(fromPaths []string, toPath string) (err error) {
|
||||||
util.PushEndlessProgress(Conf.Language(116))
|
util.PushEndlessProgress(Conf.Language(116))
|
||||||
|
|
||||||
fromPaths = filterFromPaths(fromPaths, toPath)
|
WaitForWritingFiles()
|
||||||
|
fromPaths = util.FilterFromPaths(fromPaths, toPath)
|
||||||
pathsBoxes := getBoxesByPaths(fromPaths)
|
pathsBoxes := getBoxesByPaths(fromPaths)
|
||||||
|
|
||||||
toID := strings.TrimSuffix(path.Base(toPath), ".sy")
|
toID := strings.TrimSuffix(path.Base(toPath), ".sy")
|
||||||
|
|
@ -1062,34 +1063,6 @@ func MoveDocs(fromPaths []string, toPath string) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func filterFromPaths(fromPaths []string, toPath string) (retFromPaths []string) {
|
|
||||||
fromPaths = append(fromPaths, toPath)
|
|
||||||
retFromPaths = filterSelfChildDocs(fromPaths)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func filterSelfChildDocs(paths []string) (ret []string) {
|
|
||||||
sort.Slice(paths, func(i, j int) bool { return len(paths[i]) < len(paths[j]) })
|
|
||||||
|
|
||||||
dirs := map[string]string{}
|
|
||||||
for _, fromPath := range paths {
|
|
||||||
dir := strings.TrimSuffix(fromPath, ".sy")
|
|
||||||
existParent := false
|
|
||||||
for d, _ := range dirs {
|
|
||||||
if strings.HasPrefix(fromPath, d) {
|
|
||||||
existParent = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if existParent {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
dirs[dir] = fromPath
|
|
||||||
ret = append(ret, fromPath)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func moveDoc(fromBox *Box, fromPath string, toBox *Box, toPath string) (newPath string, err error) {
|
func moveDoc(fromBox *Box, fromPath string, toBox *Box, toPath string) (newPath string, err error) {
|
||||||
isSameBox := fromBox.ID == toBox.ID
|
isSameBox := fromBox.ID == toBox.ID
|
||||||
|
|
||||||
|
|
@ -1217,7 +1190,7 @@ func RemoveDoc(boxID, p string) (err error) {
|
||||||
func RemoveDocs(paths []string) (err error) {
|
func RemoveDocs(paths []string) (err error) {
|
||||||
util.PushEndlessProgress(Conf.Language(116))
|
util.PushEndlessProgress(Conf.Language(116))
|
||||||
|
|
||||||
paths = filterSelfChildDocs(paths)
|
paths = util.FilterSelfChildDocs(paths)
|
||||||
pathsBoxes := getBoxesByPaths(paths)
|
pathsBoxes := getBoxesByPaths(paths)
|
||||||
WaitForWritingFiles()
|
WaitForWritingFiles()
|
||||||
for p, box := range pathsBoxes {
|
for p, box := range pathsBoxes {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -173,3 +174,31 @@ func NormalizeEndpoint(endpoint string) string {
|
||||||
}
|
}
|
||||||
return endpoint
|
return endpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FilterFromPaths(fromPaths []string, toPath string) (retFromPaths []string) {
|
||||||
|
fromPaths = append(fromPaths, toPath)
|
||||||
|
retFromPaths = FilterSelfChildDocs(fromPaths)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func FilterSelfChildDocs(paths []string) (ret []string) {
|
||||||
|
sort.Slice(paths, func(i, j int) bool { return len(paths[i]) < len(paths[j]) })
|
||||||
|
|
||||||
|
dirs := map[string]string{}
|
||||||
|
for _, fromPath := range paths {
|
||||||
|
dir := strings.TrimSuffix(fromPath, ".sy")
|
||||||
|
existParent := false
|
||||||
|
for d, _ := range dirs {
|
||||||
|
if strings.HasPrefix(fromPath, d) {
|
||||||
|
existParent = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if existParent {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
dirs[dir] = fromPath
|
||||||
|
ret = append(ret, fromPath)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue