|
@@ -22,7 +22,6 @@ import (
|
|
"path"
|
|
"path"
|
|
"path/filepath"
|
|
"path/filepath"
|
|
"strings"
|
|
"strings"
|
|
- "sync"
|
|
|
|
|
|
|
|
"github.com/88250/gulu"
|
|
"github.com/88250/gulu"
|
|
"github.com/88250/lute/ast"
|
|
"github.com/88250/lute/ast"
|
|
@@ -118,16 +117,12 @@ func (tx *Transaction) doUnfoldHeading(operation *Operation) (ret *TxErr) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-var docConvertLock = sync.Mutex{}
|
|
|
|
-
|
|
|
|
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) {
|
|
if !ast.IsNodeIDPattern(srcID) || !ast.IsNodeIDPattern(targetID) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
FlushTxQueue()
|
|
FlushTxQueue()
|
|
- docConvertLock.Lock()
|
|
|
|
- defer docConvertLock.Unlock()
|
|
|
|
|
|
|
|
srcTree, _ := LoadTreeByBlockID(srcID)
|
|
srcTree, _ := LoadTreeByBlockID(srcID)
|
|
if nil == srcTree {
|
|
if nil == srcTree {
|
|
@@ -253,10 +248,6 @@ func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath st
|
|
pivot.InsertAfter(heading)
|
|
pivot.InsertAfter(heading)
|
|
}
|
|
}
|
|
|
|
|
|
- if contentPivot := treenode.GetNodeInTree(targetTree, targetID); nil != contentPivot && ast.NodeParagraph == contentPivot.Type && nil == contentPivot.FirstChild { // 插入到空的段落块下
|
|
|
|
- contentPivot.Unlink()
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
box := Conf.Box(srcTree.Box)
|
|
box := Conf.Box(srcTree.Box)
|
|
if removeErr := box.Remove(srcTree.Path); nil != removeErr {
|
|
if removeErr := box.Remove(srcTree.Path); nil != removeErr {
|
|
logging.LogWarnf("remove tree [%s] failed: %s", srcTree.Path, removeErr)
|
|
logging.LogWarnf("remove tree [%s] failed: %s", srcTree.Path, removeErr)
|
|
@@ -282,8 +273,6 @@ func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath st
|
|
|
|
|
|
func Heading2Doc(srcHeadingID, targetBoxID, targetPath, previousPath string) (srcRootBlockID, newTargetPath string, err error) {
|
|
func Heading2Doc(srcHeadingID, targetBoxID, targetPath, previousPath string) (srcRootBlockID, newTargetPath string, err error) {
|
|
FlushTxQueue()
|
|
FlushTxQueue()
|
|
- docConvertLock.Lock()
|
|
|
|
- defer docConvertLock.Unlock()
|
|
|
|
|
|
|
|
srcTree, _ := LoadTreeByBlockID(srcHeadingID)
|
|
srcTree, _ := LoadTreeByBlockID(srcHeadingID)
|
|
if nil == srcTree {
|
|
if nil == srcTree {
|