Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Documents created via the database are no longer automatically hidden Fix https://github.com/siyuan-note/siyuan/issues/9298

Daniel3842a17d0760
diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts
index 28718d05a9..c076116929 100644
--- a/app/src/protyle/hint/index.ts
+++ b/app/src/protyle/hint/index.ts
@@ -422,7 +422,6 @@ ${genHintItemHTML(item)}
const realFileName = fileNames.length === 1 ? fileNames[0] : fileNames[1];
getSavePath(protyle.path, protyle.notebookId, (pathString) => {
fetchPost("/api/filetree/createDocWithMd", {
- hidden: false,
notebook: protyle.notebookId,
path: pathPosix().join(pathString, realFileName),
parentID: protyle.block.rootID,
diff --git a/kernel/api/filetree.go b/kernel/api/filetree.go
index f451d026fc..c965a05dc1 100644
--- a/kernel/api/filetree.go
+++ b/kernel/api/filetree.go
@@ -481,12 +481,6 @@ func createDocWithMd(c *gin.Context) {
parentID = parentIDArg.(string)
}
- hidden := true
- hiddenArg := arg["hidden"]
- if nil != hiddenArg {
- hidden = hiddenArg.(bool)
- }
-
hPath := arg["path"].(string)
markdown := arg["markdown"].(string)
@@ -502,7 +496,7 @@ func createDocWithMd(c *gin.Context) {
hPath = "/" + hPath
}
- id, err := model.CreateWithMarkdown(notebook, hPath, markdown, parentID, hidden)
+ id, err := model.CreateWithMarkdown(notebook, hPath, markdown, parentID)
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
@@ -510,10 +504,6 @@ func createDocWithMd(c *gin.Context) {
}
ret.Data = id
- if !hidden {
- return
- }
-
box := model.Conf.Box(notebook)
b, _ := model.GetBlock(id, nil)
p := b.Path
diff --git a/kernel/model/file.go b/kernel/model/file.go
index 2f12a7f950..cfd8f404c5 100644
--- a/kernel/model/file.go
+++ b/kernel/model/file.go
@@ -1019,7 +1019,7 @@ func CreateDocByMd(boxID, p, title, md string, sorts []string) (tree *parse.Tree
luteEngine := util.NewLute()
dom := luteEngine.Md2BlockDOM(md, false)
- tree, err = createDoc(box.ID, p, title, dom, true)
+ tree, err = createDoc(box.ID, p, title, dom)
if nil != err {
return
}
@@ -1028,7 +1028,7 @@ func CreateDocByMd(boxID, p, title, md string, sorts []string) (tree *parse.Tree
return
}
-func CreateWithMarkdown(boxID, hPath, md, parentID string, hidden bool) (id string, err error) {
+func CreateWithMarkdown(boxID, hPath, md, parentID string) (id string, err error) {
box := Conf.Box(boxID)
if nil == box {
err = errors.New(Conf.Language(0))
@@ -1038,7 +1038,7 @@ func CreateWithMarkdown(boxID, hPath, md, parentID string, hidden bool) (id stri
WaitForWritingFiles()
luteEngine := util.NewLute()
dom := luteEngine.Md2BlockDOM(md, false)
- id, _, err = createDocsByHPath(box.ID, hPath, dom, parentID, hidden)
+ id, _, err = createDocsByHPath(box.ID, hPath, dom, parentID)
return
}
@@ -1442,7 +1442,7 @@ func CreateDailyNote(boxID string) (p string, existed bool, err error) {
return
}
- id, existed, err := createDocsByHPath(box.ID, hPath, "", "", true)
+ id, existed, err := createDocsByHPath(box.ID, hPath, "", "")
if nil != err {
return
}
@@ -1487,7 +1487,7 @@ func CreateDailyNote(boxID string) (p string, existed bool, err error) {
return
}
-func createDoc(boxID, p, title, dom string, hidden bool) (tree *parse.Tree, err error) {
+func createDoc(boxID, p, title, dom string) (tree *parse.Tree, err error) {
title = gulu.Str.RemoveInvisible(title)
if 512 < utf8.RuneCountInString(title) {
// 限制笔记本名和文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299
@@ -1559,10 +1559,6 @@ func createDoc(boxID, p, title, dom string, hidden bool) (tree *parse.Tree, err
tree.Root.AppendChild(treenode.NewParagraph())
}
- if !hidden {
- tree.Root.SetIALAttr("custom-hidden", "true")
- }
-
transaction := &Transaction{DoOperations: []*Operation{{Action: "create", Data: tree}}}
PerformTransactions(&[]*Transaction{transaction})
WaitForWritingFiles()
diff --git a/kernel/model/path.go b/kernel/model/path.go
index 3cfc184208..ee9fe774bb 100644
--- a/kernel/model/path.go
+++ b/kernel/model/path.go
@@ -33,7 +33,7 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
-func createDocsByHPath(boxID, hPath, content, parentID string, hidden bool) (id string, existed bool, err error) {
+func createDocsByHPath(boxID, hPath, content, parentID string) (id string, existed bool, err error) {
hPath = strings.TrimSuffix(hPath, ".sy")
pathBuilder := bytes.Buffer{}
pathBuilder.WriteString("/")
@@ -51,7 +51,7 @@ func createDocsByHPath(boxID, hPath, content, parentID string, hidden bool) (id
// 如果父文档存在且 ID 一致,则直接在父文档下创建
id = ast.NewNodeID()
p := strings.TrimSuffix(preferredParent.Path, ".sy") + "/" + id + ".sy"
- if _, err = createDoc(boxID, p, name, content, hidden); nil != err {
+ if _, err = createDoc(boxID, p, name, content); nil != err {
return
}
}
@@ -68,11 +68,11 @@ func createDocsByHPath(boxID, hPath, content, parentID string, hidden bool) (id
pathBuilder.WriteString(id)
docP := pathBuilder.String() + ".sy"
if isNotLast {
- if _, err = createDoc(boxID, docP, part, "", hidden); nil != err {
+ if _, err = createDoc(boxID, docP, part, ""); nil != err {
return
}
} else {
- if _, err = createDoc(boxID, docP, part, content, hidden); nil != err {
+ if _, err = createDoc(boxID, docP, part, content); nil != err {
return
}
}