mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 15:40:12 +01:00
🎨 Improve doc convert to heading https://github.com/siyuan-note/siyuan/issues/12607
This commit is contained in:
parent
459b700e26
commit
800dec29df
2 changed files with 12 additions and 3 deletions
|
|
@ -118,6 +118,10 @@ func (tx *Transaction) doUnfoldHeading(operation *Operation) (ret *TxErr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath string, err error) {
|
func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath string, err error) {
|
||||||
|
if !ast.IsNodeIDPattern(srcID) || !ast.IsNodeIDPattern(targetID) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
srcTree, _ := LoadTreeByBlockID(srcID)
|
srcTree, _ := LoadTreeByBlockID(srcID)
|
||||||
if nil == srcTree {
|
if nil == srcTree {
|
||||||
err = ErrBlockNotFound
|
err = ErrBlockNotFound
|
||||||
|
|
@ -136,9 +140,14 @@ func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath st
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if nil == treenode.GetBlockTree(targetID) {
|
||||||
|
// 目标块不存在时忽略处理
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
targetTree, _ := LoadTreeByBlockID(targetID)
|
targetTree, _ := LoadTreeByBlockID(targetID)
|
||||||
if nil == targetTree {
|
if nil == targetTree {
|
||||||
err = ErrBlockNotFound
|
// 目标块不存在时忽略处理
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -203,8 +203,8 @@ func LoadTreeByBlockIDWithReindex(id string) (ret *parse.Tree, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadTreeByBlockID(id string) (ret *parse.Tree, err error) {
|
func LoadTreeByBlockID(id string) (ret *parse.Tree, err error) {
|
||||||
if "" == id {
|
if !ast.IsNodeIDPattern(id) {
|
||||||
logging.LogErrorf("block id is empty")
|
logging.LogErrorf("block id is invalid [id=%s]", id)
|
||||||
return nil, ErrTreeNotFound
|
return nil, ErrTreeNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue