Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2024-05-13 23:33:08 +08:00
commit eb909e5b8e
12 changed files with 56 additions and 46 deletions

View file

@ -44,6 +44,7 @@ Below are the detailed changes in this version.
* [Improve `Display the VIP icon`](https://github.com/siyuan-note/siyuan/issues/11368)
* [Improve HTML inline code clipping](https://github.com/siyuan-note/siyuan/issues/11370)
* [Improve export preview mode](https://github.com/siyuan-note/siyuan/issues/11372)
* [The heading block update time is refreshed after editing the blocks under the heading](https://github.com/siyuan-note/siyuan/issues/11374)
### Bugfix
@ -60,6 +61,7 @@ Below are the detailed changes in this version.
* [Database table view continuously adds new rows above error](https://github.com/siyuan-note/siyuan/issues/11335)
* [Block attributes are not refreshed after data syncing](https://github.com/siyuan-note/siyuan/issues/11343)
* [Undo exception after Delete in the last line of the code block](https://github.com/siyuan-note/siyuan/issues/11362)
* [Opening notebook repeatedly causes reference count to increase](https://github.com/siyuan-note/siyuan/issues/11378)
### Document

View file

@ -44,6 +44,7 @@
* [改進 `顯示VIP圖示`](https://github.com/siyuan-note/siyuan/issues/11368)
* [改進 HTML 行級程式碼元素剪藏](https://github.com/siyuan-note/siyuan/issues/11370)
* [改進匯出預覽模式](https://github.com/siyuan-note/siyuan/issues/11372)
* [標題下方區塊編輯後刷新標題區塊更新時間](https://github.com/siyuan-note/siyuan/issues/11374)
### 修復缺陷
@ -60,6 +61,7 @@
* [資料庫表格檢視連續在上方新增一行錯誤](https://github.com/siyuan-note/siyuan/issues/11335)
* [資料同步後區塊屬性不刷新](https://github.com/siyuan-note/siyuan/issues/11343)
* [在程式碼區塊的最後一行刪除後撤銷異常](https://github.com/siyuan-note/siyuan/issues/11362)
* [重複開啟筆記本導致引用計數增加](https://github.com/siyuan-note/siyuan/issues/11378)
### 改進文檔

View file

@ -44,6 +44,7 @@
* [改进 `显示VIP图标`](https://github.com/siyuan-note/siyuan/issues/11368)
* [改进 HTML 行级代码元素剪藏](https://github.com/siyuan-note/siyuan/issues/11370)
* [改进导出预览模式](https://github.com/siyuan-note/siyuan/issues/11372)
* [标题下方块编辑后刷新标题块更新时间](https://github.com/siyuan-note/siyuan/issues/11374)
### 修复缺陷
@ -60,6 +61,7 @@
* [数据库表格视图连续在上方添加新行错误](https://github.com/siyuan-note/siyuan/issues/11335)
* [数据同步后块属性不刷新](https://github.com/siyuan-note/siyuan/issues/11343)
* [在代码块的最后一行删除后撤销异常](https://github.com/siyuan-note/siyuan/issues/11362)
* [重复打开笔记本导致引用计数增加](https://github.com/siyuan-note/siyuan/issues/11378)
### 改进文档

File diff suppressed because one or more lines are too long

View file

@ -8,7 +8,7 @@ require (
github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48
github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7
github.com/88250/gulu v1.2.3-0.20240505150113-bc43bd50f866
github.com/88250/lute v1.7.7-0.20240513035542-701335ad4def
github.com/88250/lute v1.7.7-0.20240513131036-e24458565f2e
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4

View file

@ -12,8 +12,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950 h1:Pa5hMiBceT
github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/88250/gulu v1.2.3-0.20240505150113-bc43bd50f866 h1:RFfNFS0hv6TbOuwET6xZAfGlV4hNlXiWTnfbLN1eF6k=
github.com/88250/gulu v1.2.3-0.20240505150113-bc43bd50f866/go.mod h1:MUfzyfmbPrRDZLqxc7aPrVYveatTHRfoUa5TynPS0i8=
github.com/88250/lute v1.7.7-0.20240513035542-701335ad4def h1:ydTjPziKUvCdTOZ8TSQyS2YxQSc5WbXZSlxuvNRgmDQ=
github.com/88250/lute v1.7.7-0.20240513035542-701335ad4def/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk=
github.com/88250/lute v1.7.7-0.20240513131036-e24458565f2e h1:dpFfUOmqcfToNSUndfEB3uQE4VEWu9HZvLD/HBlAMKM=
github.com/88250/lute v1.7.7-0.20240513131036-e24458565f2e/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk=
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c h1:Dl/8S9iLyPMTElnWIBxmjaLiWrkI5P4a21ivwAn5pU0=
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=

View file

@ -280,7 +280,7 @@ func IndexRefs() {
}
util.IncBootProgress(bootProgressPart, "Indexing ref "+defTree.ID)
sql.InsertRefsTreeQueue(defTree)
sql.UpdateRefsTreeQueue(defTree)
if 1 < i && 0 == i%64 {
util.PushStatusBar(fmt.Sprintf(Conf.Language(55), i))
}

View file

@ -1241,7 +1241,7 @@ func (tx *Transaction) doSetAttrs(operation *Operation) (ret *TxErr) {
func refreshUpdated(node *ast.Node) {
updated := util.CurrentTimeSecondsStr()
node.SetIALAttr("updated", updated)
parents := treenode.ParentNodes(node)
parents := treenode.ParentNodesWithHeadings(node)
for _, parent := range parents { // 更新所有父节点的更新时间字段
parent.SetIALAttr("updated", updated)
}
@ -1256,7 +1256,7 @@ func createdUpdated(node *ast.Node) {
if updated < created {
updated = created // 复制粘贴块后创建时间小于更新时间 https://github.com/siyuan-note/siyuan/issues/3624
}
parents := treenode.ParentNodes(node)
parents := treenode.ParentNodesWithHeadings(node)
for _, parent := range parents { // 更新所有父节点的更新时间字段
parent.SetIALAttr("updated", updated)
cache.PutBlockIAL(parent.ID, parse.IAL2Map(parent.KramdownIAL))

View file

@ -57,3 +57,14 @@ func deleteRefs(tx *sql.Tx, tree *parse.Tree) (err error) {
}
return
}
func insertRefs(tx *sql.Tx, tree *parse.Tree) (err error) {
refs, fileAnnotationRefs := refsFromTree(tree)
if err = insertBlockRefs(tx, refs); nil != err {
return
}
if err = insertFileAnnotationRefs(tx, fileAnnotationRefs); nil != err {
return
}
return err
}

View file

@ -40,9 +40,9 @@ var (
type dbQueueOperation struct {
inQueueTime time.Time
action string // upsert/delete/delete_id/rename/rename_sub_tree/delete_box/delete_box_refs/insert_refs/index/delete_ids/update_block_content/delete_assets
action string // upsert/delete/delete_id/rename/rename_sub_tree/delete_box/delete_box_refs/index/delete_ids/update_block_content/delete_assets
indexTree *parse.Tree // index
upsertTree *parse.Tree // upsert/insert_refs/update_refs/delete_refs
upsertTree *parse.Tree // upsert/update_refs/delete_refs
removeTreeBox, removeTreePath string // delete
removeTreeID string // delete_id
removeTreeIDs []string // delete_ids
@ -185,8 +185,6 @@ func execOp(op *dbQueueOperation, tx *sql.Tx, context map[string]interface{}) (e
err = deleteByBoxTx(tx, op.box)
case "delete_box_refs":
err = deleteRefsByBoxTx(tx, op.box)
case "insert_refs":
err = insertRefs(tx, op.upsertTree)
case "update_refs":
err = upsertRefs(tx, op.upsertTree)
case "delete_refs":
@ -273,20 +271,6 @@ func UpdateRefsTreeQueue(tree *parse.Tree) {
operationQueue = append(operationQueue, newOp)
}
func InsertRefsTreeQueue(tree *parse.Tree) {
dbQueueLock.Lock()
defer dbQueueLock.Unlock()
newOp := &dbQueueOperation{upsertTree: tree, inQueueTime: time.Now(), action: "insert_refs"}
for i, op := range operationQueue {
if "insert_refs" == op.action && op.upsertTree.ID == tree.ID {
operationQueue[i] = newOp
return
}
}
operationQueue = append(operationQueue, newOp)
}
func DeleteBoxRefsQueue(boxID string) {
dbQueueLock.Lock()
defer dbQueueLock.Unlock()

View file

@ -389,17 +389,6 @@ func insertFileAnnotationRefs0(tx *sql.Tx, bulk []*FileAnnotationRef) (err error
return
}
func insertRefs(tx *sql.Tx, tree *parse.Tree) (err error) {
refs, fileAnnotationRefs := refsFromTree(tree)
if err = insertBlockRefs(tx, refs); nil != err {
return
}
if err = insertFileAnnotationRefs(tx, fileAnnotationRefs); nil != err {
return
}
return err
}
func indexTree(tx *sql.Tx, tree *parse.Tree, context map[string]interface{}) (err error) {
blocks, spans, assets, attributes := fromTree(tree.Root, tree)
refs, fileAnnotationRefs := refsFromTree(tree)

View file

@ -18,8 +18,6 @@ package treenode
import (
"bytes"
"github.com/siyuan-note/siyuan/kernel/av"
"github.com/siyuan-note/siyuan/kernel/cache"
"strings"
"sync"
"text/template"
@ -34,7 +32,10 @@ import (
"github.com/88250/lute/parse"
"github.com/88250/lute/render"
"github.com/88250/vitess-sqlparser/sqlparser"
"github.com/emirpasic/gods/sets/hashset"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/av"
"github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/util"
)
@ -357,19 +358,38 @@ func CountBlockNodes(node *ast.Node) (ret int) {
return
}
func ParentNodes(node *ast.Node) (parents []*ast.Node) {
const maxDepth = 256
// ParentNodesWithHeadings 返回所有父级节点。
// 注意:返回的父级节点包括了标题节点,并且不保证父级层次顺序。
func ParentNodesWithHeadings(node *ast.Node) (parents []*ast.Node) {
const maxDepth = 255
i := 0
for n := node.Parent; nil != n; n = n.Parent {
i++
parents = append(parents, n)
if ast.NodeDocument == n.Type {
return
}
headingIDs := hashset.New()
for n := node; nil != n; n = n.Parent {
parent := n.Parent
if maxDepth < i {
logging.LogWarnf("parent nodes of node [%s] is too deep", node.ID)
return
}
i++
if nil == parent {
return
}
// 标题下方块编辑后刷新标题块更新时间
// The heading block update time is refreshed after editing the blocks under the heading https://github.com/siyuan-note/siyuan/issues/11374
parentHeadingLevel := 7
for prev := n.Previous; nil != prev; prev = prev.Previous {
if ast.NodeHeading == prev.Type && prev.HeadingLevel < parentHeadingLevel && !headingIDs.Contains(prev.ID) {
parents = append(parents, prev)
headingIDs.Add(prev.ID)
}
}
parents = append(parents, parent)
if ast.NodeDocument == parent.Type {
return
}
}
return
}