mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
eaae164e18
3 changed files with 38 additions and 27 deletions
|
|
@ -912,7 +912,10 @@ func (tx *Transaction) doDelete(operation *Operation) (ret *TxErr) {
|
|||
node.Next.Unlink()
|
||||
}
|
||||
|
||||
next := node.Next
|
||||
node.Unlink()
|
||||
unfoldParentFoldedHeading(next)
|
||||
|
||||
if nil != parent && ast.NodeListItem == parent.Type && nil == parent.FirstChild {
|
||||
needAppendEmptyListItem := true
|
||||
for _, op := range tx.DoOperations {
|
||||
|
|
@ -1276,17 +1279,7 @@ func (tx *Transaction) doInsert(operation *Operation) (ret *TxErr) {
|
|||
}
|
||||
node.InsertAfter(insertedNode)
|
||||
|
||||
if parentFoldedHeading := treenode.GetParentFoldedHeading(insertedNode); nil != parentFoldedHeading {
|
||||
ast.Walk(insertedNode, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering || !n.IsBlock() {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
n.SetIALAttr("fold", "1")
|
||||
n.SetIALAttr("heading-fold", "1")
|
||||
return ast.WalkContinue
|
||||
})
|
||||
}
|
||||
unfoldParentFoldedHeading(insertedNode)
|
||||
} else {
|
||||
node = treenode.GetNodeInTree(tree, operation.ParentID)
|
||||
if nil == node {
|
||||
|
|
@ -1537,22 +1530,7 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
|
|||
oldNode.InsertAfter(updatedNode)
|
||||
oldNode.Unlink()
|
||||
|
||||
parentFoldedHeading := treenode.GetParentFoldedHeading(updatedNode)
|
||||
if nil != parentFoldedHeading {
|
||||
children := treenode.HeadingChildren(parentFoldedHeading)
|
||||
for _, child := range children {
|
||||
ast.Walk(child, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering || !n.IsBlock() {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
n.SetIALAttr("fold", "1")
|
||||
n.SetIALAttr("heading-fold", "1")
|
||||
return ast.WalkContinue
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
unfoldParentFoldedHeading(updatedNode)
|
||||
createdUpdated(updatedNode)
|
||||
tx.nodes[updatedNode.ID] = updatedNode
|
||||
if err = tx.writeTree(tree); err != nil {
|
||||
|
|
@ -1583,6 +1561,25 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
|
|||
return
|
||||
}
|
||||
|
||||
func unfoldParentFoldedHeading(node *ast.Node) {
|
||||
if parentFoldedHeading := treenode.GetParentFoldedHeading(node); nil != parentFoldedHeading {
|
||||
children := treenode.HeadingChildren(parentFoldedHeading)
|
||||
for _, child := range children {
|
||||
ast.Walk(child, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering || !n.IsBlock() {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
n.RemoveIALAttr("fold")
|
||||
n.RemoveIALAttr("heading-fold")
|
||||
return ast.WalkContinue
|
||||
})
|
||||
}
|
||||
parentFoldedHeading.RemoveIALAttr("fold")
|
||||
parentFoldedHeading.RemoveIALAttr("heading-fold")
|
||||
}
|
||||
}
|
||||
|
||||
func getRefDefIDs(node *ast.Node) (refDefIDs []string) {
|
||||
ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering {
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ func GetHeadingFold(nodes []*ast.Node) (ret []*ast.Node) {
|
|||
}
|
||||
|
||||
func GetParentFoldedHeading(node *ast.Node) (parentFoldedHeading *ast.Node) {
|
||||
if nil == node {
|
||||
return
|
||||
}
|
||||
|
||||
currentLevel := 7
|
||||
if ast.NodeHeading == node.Type {
|
||||
currentLevel = node.HeadingLevel
|
||||
|
|
|
|||
|
|
@ -471,6 +471,16 @@ func initMime() {
|
|||
|
||||
mime.AddExtensionType(".md", "text/markdown")
|
||||
mime.AddExtensionType(".markdown", "text/markdown")
|
||||
|
||||
// 添加常用的图片格式
|
||||
mime.AddExtensionType(".png", "image/png")
|
||||
mime.AddExtensionType(".jpg", "image/jpeg")
|
||||
mime.AddExtensionType(".jpeg", "image/jpeg")
|
||||
mime.AddExtensionType(".gif", "image/gif")
|
||||
mime.AddExtensionType(".bmp", "image/bmp")
|
||||
mime.AddExtensionType(".tiff", "image/tiff")
|
||||
mime.AddExtensionType(".webp", "image/webp")
|
||||
mime.AddExtensionType(".ico", "image/x-icon")
|
||||
}
|
||||
|
||||
func GetDataAssetsAbsPath() (ret string) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue