This commit is contained in:
Daniel 2024-12-11 23:00:04 +08:00
parent 225adea9b6
commit 2f30253366
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 9 additions and 0 deletions

View file

@ -22,6 +22,7 @@ import (
"path"
"path/filepath"
"strings"
"sync"
"github.com/88250/gulu"
"github.com/88250/lute/ast"
@ -117,12 +118,16 @@ func (tx *Transaction) doUnfoldHeading(operation *Operation) (ret *TxErr) {
return
}
var docConvertLock = sync.Mutex{}
func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath string, err error) {
if !ast.IsNodeIDPattern(srcID) || !ast.IsNodeIDPattern(targetID) {
return
}
FlushTxQueue()
docConvertLock.Lock()
defer docConvertLock.Unlock()
srcTree, _ := LoadTreeByBlockID(srcID)
if nil == srcTree {
@ -277,6 +282,8 @@ func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath st
func Heading2Doc(srcHeadingID, targetBoxID, targetPath, previousPath string) (srcRootBlockID, newTargetPath string, err error) {
FlushTxQueue()
docConvertLock.Lock()
defer docConvertLock.Unlock()
srcTree, _ := LoadTreeByBlockID(srcHeadingID)
if nil == srcTree {

View file

@ -29,6 +29,8 @@ import (
func ListItem2Doc(srcListItemID, targetBoxID, targetPath, previousPath string) (srcRootBlockID, newTargetPath string, err error) {
FlushTxQueue()
docConvertLock.Lock()
defer docConvertLock.Unlock()
srcTree, _ := LoadTreeByBlockID(srcListItemID)
if nil == srcTree {