Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
71a7a71b3a
3 changed files with 36 additions and 11 deletions
|
@ -885,8 +885,8 @@ func prepareExportTree(bt *treenode.BlockTree) (ret *parse.Tree) {
|
|||
oldRoot := ret.Root
|
||||
ret = parse.Parse("", []byte(""), luteEngine.ParseOptions)
|
||||
first := ret.Root.FirstChild
|
||||
for _, node := range nodes {
|
||||
first.InsertBefore(node)
|
||||
for _, n := range nodes {
|
||||
first.InsertBefore(n)
|
||||
}
|
||||
ret.Root.KramdownIAL = oldRoot.KramdownIAL
|
||||
}
|
||||
|
@ -2107,7 +2107,27 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool,
|
|||
}
|
||||
|
||||
if 4 == blockRefMode { // 块引转脚注
|
||||
unlinks = nil
|
||||
if footnotesDefBlock := resolveFootnotesDefs(&refFootnotes, ret.Root.ID, blockRefTextLeft, blockRefTextRight); nil != footnotesDefBlock {
|
||||
// 如果是聚焦导出,可能存在没有使用的脚注定义块,在这里进行清理
|
||||
// Improve focus export conversion of block refs to footnotes https://github.com/siyuan-note/siyuan/issues/10647
|
||||
footnotesRefs := ret.Root.ChildrenByType(ast.NodeFootnotesRef)
|
||||
for footnotesDef := footnotesDefBlock.FirstChild; nil != footnotesDef; footnotesDef = footnotesDef.Next {
|
||||
exist := false
|
||||
for _, ref := range footnotesRefs {
|
||||
if ref.FootnotesRefId == footnotesDef.FootnotesRefId {
|
||||
exist = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !exist {
|
||||
unlinks = append(unlinks, footnotesDef)
|
||||
}
|
||||
}
|
||||
for _, n := range unlinks {
|
||||
n.Unlink()
|
||||
}
|
||||
|
||||
ret.Root.AppendChild(footnotesDefBlock)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,6 +130,11 @@ func initDBTables() {
|
|||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [blocks] failed: %s", err)
|
||||
}
|
||||
|
||||
_, err = db.Exec("CREATE INDEX idx_blocks_root_id ON blocks(root_id)")
|
||||
if nil != err {
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create index [idx_blocks_root_id] failed: %s", err)
|
||||
}
|
||||
|
||||
_, err = db.Exec("DROP TABLE IF EXISTS blocks_fts")
|
||||
if nil != err {
|
||||
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "drop table [blocks_fts] failed: %s", err)
|
||||
|
@ -1211,18 +1216,18 @@ func batchDeleteByPathPrefix(tx *sql.Tx, boxID, pathPrefix string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func batchUpdateHPath(tx *sql.Tx, boxID, rootID, newHPath string, context map[string]interface{}) (err error) {
|
||||
stmt := "UPDATE blocks SET hpath = ? WHERE box = ? AND root_id = ?"
|
||||
if err = execStmtTx(tx, stmt, newHPath, boxID, rootID); nil != err {
|
||||
func batchUpdateHPath(tx *sql.Tx, rootID, newHPath string, context map[string]interface{}) (err error) {
|
||||
stmt := "UPDATE blocks SET hpath = ? WHERE root_id = ?"
|
||||
if err = execStmtTx(tx, stmt, newHPath, rootID); nil != err {
|
||||
return
|
||||
}
|
||||
stmt = "UPDATE blocks_fts SET hpath = ? WHERE box = ? AND root_id = ?"
|
||||
if err = execStmtTx(tx, stmt, newHPath, boxID, rootID); nil != err {
|
||||
stmt = "UPDATE blocks_fts SET hpath = ? WHERE root_id = ?"
|
||||
if err = execStmtTx(tx, stmt, newHPath, rootID); nil != err {
|
||||
return
|
||||
}
|
||||
if !caseSensitive {
|
||||
stmt = "UPDATE blocks_fts_case_insensitive SET hpath = ? WHERE box = ? AND root_id = ?"
|
||||
if err = execStmtTx(tx, stmt, newHPath, boxID, rootID); nil != err {
|
||||
stmt = "UPDATE blocks_fts_case_insensitive SET hpath = ? WHERE root_id = ?"
|
||||
if err = execStmtTx(tx, stmt, newHPath, rootID); nil != err {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,13 +174,13 @@ func execOp(op *dbQueueOperation, tx *sql.Tx, context map[string]interface{}) (e
|
|||
case "delete_ids":
|
||||
err = batchDeleteByRootIDs(tx, op.removeTreeIDs, context)
|
||||
case "rename":
|
||||
err = batchUpdateHPath(tx, op.renameTree.Box, op.renameTree.ID, op.renameTree.HPath, context)
|
||||
err = batchUpdateHPath(tx, op.renameTree.ID, op.renameTree.HPath, context)
|
||||
if nil != err {
|
||||
break
|
||||
}
|
||||
err = updateRootContent(tx, path.Base(op.renameTree.HPath), op.renameTree.Root.IALAttr("updated"), op.renameTree.ID)
|
||||
case "rename_sub_tree":
|
||||
err = batchUpdateHPath(tx, op.renameTree.Box, op.renameTree.ID, op.renameTree.HPath, context)
|
||||
err = batchUpdateHPath(tx, op.renameTree.ID, op.renameTree.HPath, context)
|
||||
case "delete_box":
|
||||
err = deleteByBoxTx(tx, op.box)
|
||||
case "delete_box_refs":
|
||||
|
|
Loading…
Add table
Reference in a new issue