mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
bfc0daf6e5
2 changed files with 19 additions and 9 deletions
|
@ -89,6 +89,9 @@ func setAttrViewGroup(c *gin.Context) {
|
|||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
ret = renderAttrView(blockID, avID, "", "", 1, -1)
|
||||
c.JSON(http.StatusOK, ret)
|
||||
}
|
||||
|
||||
func changeAttrViewLayout(c *gin.Context) {
|
||||
|
|
|
@ -33,7 +33,7 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func InsertLocalAssets(id string, assetPaths []string, isUpload bool) (succMap map[string]interface{}, err error) {
|
||||
func InsertLocalAssets(id string, assetAbsPaths []string, isUpload bool) (succMap map[string]interface{}, err error) {
|
||||
succMap = map[string]interface{}{}
|
||||
|
||||
bt := treenode.GetBlockTree(id)
|
||||
|
@ -50,28 +50,35 @@ func InsertLocalAssets(id string, assetPaths []string, isUpload bool) (succMap m
|
|||
}
|
||||
}
|
||||
|
||||
for _, p := range assetPaths {
|
||||
baseName := filepath.Base(p)
|
||||
for _, assetAbsPath := range assetAbsPaths {
|
||||
baseName := filepath.Base(assetAbsPath)
|
||||
fName := baseName
|
||||
fName = util.FilterUploadFileName(fName)
|
||||
ext := filepath.Ext(fName)
|
||||
fName = strings.TrimSuffix(fName, ext)
|
||||
ext = strings.ToLower(ext)
|
||||
fName += ext
|
||||
if gulu.File.IsDir(p) || !isUpload {
|
||||
if !strings.HasPrefix(p, "\\\\") {
|
||||
p = "file://" + p
|
||||
if gulu.File.IsDir(assetAbsPath) || !isUpload {
|
||||
if !strings.HasPrefix(assetAbsPath, "\\\\") {
|
||||
assetAbsPath = "file://" + assetAbsPath
|
||||
}
|
||||
succMap[baseName] = p
|
||||
succMap[baseName] = assetAbsPath
|
||||
continue
|
||||
}
|
||||
|
||||
fi, statErr := os.Stat(p)
|
||||
if util.IsSubPath(assetsDirPath, assetAbsPath) {
|
||||
// 已经位于 assets 目录下的资源文件不处理
|
||||
// Dragging a file from the assets folder into the editor causes the kernel to exit https://github.com/siyuan-note/siyuan/issues/15355
|
||||
succMap[baseName] = "assets/" + fName
|
||||
continue
|
||||
}
|
||||
|
||||
fi, statErr := os.Stat(assetAbsPath)
|
||||
if nil != statErr {
|
||||
err = statErr
|
||||
return
|
||||
}
|
||||
f, openErr := os.Open(p)
|
||||
f, openErr := os.Open(assetAbsPath)
|
||||
if nil != openErr {
|
||||
err = openErr
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue