diff --git a/app/changelogs/v3.4.2/v3.4.2.md b/app/changelogs/v3.4.2/v3.4.2.md index b9df53dde..a7f11c18a 100644 --- a/app/changelogs/v3.4.2/v3.4.2.md +++ b/app/changelogs/v3.4.2/v3.4.2.md @@ -16,8 +16,10 @@ Below are the detailed changes in this version. * [Improve the setting of custom attribute names](https://github.com/siyuan-note/siyuan/issues/16447) * [Improve the av-names attribute on block elements](https://github.com/siyuan-note/siyuan/pull/16449) * [Improve database grouping field value filling](https://github.com/siyuan-note/siyuan/issues/16458) +* [Improve database rendering performance after editing](https://github.com/siyuan-note/siyuan/issues/16464) * [Improve container block copy text *](https://github.com/siyuan-note/siyuan/pull/16467) * [Improve file tree scrolling caused by drag file](https://github.com/siyuan-note/siyuan/issues/16471) +* [Import the YAML at the beginning of the Markdown as a code block](https://github.com/siyuan-note/siyuan/issues/16488) ### Bugfix diff --git a/app/changelogs/v3.4.2/v3.4.2_zh_CHT.md b/app/changelogs/v3.4.2/v3.4.2_zh_CHT.md index a30fed1a7..f46ff0d1a 100644 --- a/app/changelogs/v3.4.2/v3.4.2_zh_CHT.md +++ b/app/changelogs/v3.4.2/v3.4.2_zh_CHT.md @@ -16,8 +16,10 @@ * [改進自訂屬性名的設定](https://github.com/siyuan-note/siyuan/issues/16447) * [改進區塊元素上的 av-names 屬性](https://github.com/siyuan-note/siyuan/pull/16449) * [改進資料庫分組欄位值的填充](https://github.com/siyuan-note/siyuan/issues/16458) +* [改進資料庫編輯後渲染效能](https://github.com/siyuan-note/siyuan/issues/16464) * [改進容器區塊複製文字 *](https://github.com/siyuan-note/siyuan/pull/16467) * [改進文件樹拖曳文件捲動](https://github.com/siyuan-note/siyuan/issues/16471) +* [導入 Markdown 時開頭的 YAML 作為程式碼區塊導入](https://github.com/siyuan-note/siyuan/issues/16488) ### 修復缺陷 diff --git a/app/changelogs/v3.4.2/v3.4.2_zh_CN.md b/app/changelogs/v3.4.2/v3.4.2_zh_CN.md index 0953be976..9bfc4bc34 100644 --- a/app/changelogs/v3.4.2/v3.4.2_zh_CN.md +++ b/app/changelogs/v3.4.2/v3.4.2_zh_CN.md @@ -16,8 +16,10 @@ * [改进自定义属性名的设置](https://github.com/siyuan-note/siyuan/issues/16447) * [改进块元素上的 av-names 属性](https://github.com/siyuan-note/siyuan/pull/16449) * [改进数据库分组字段值的填充](https://github.com/siyuan-note/siyuan/issues/16458) +* [改进数据库编辑后渲染性能](https://github.com/siyuan-note/siyuan/issues/16464) * [改进容器块复制文本 *](https://github.com/siyuan-note/siyuan/pull/16467) * [改进文档树拖拽文档滚动](https://github.com/siyuan-note/siyuan/issues/16471) +* [导入 Markdown 时开头的 YAML 作为代码块导入](https://github.com/siyuan-note/siyuan/issues/16488) ### 修复缺陷 diff --git a/kernel/go.mod b/kernel/go.mod index 71e632826..62cea3cfd 100644 --- a/kernel/go.mod +++ b/kernel/go.mod @@ -47,18 +47,18 @@ require ( github.com/mattn/go-sqlite3 v2.0.3+incompatible github.com/mitchellh/go-ps v1.0.0 github.com/mssola/useragent v1.0.0 - github.com/olahol/melody v1.3.0 + github.com/olahol/melody v1.4.0 github.com/open-spaced-repetition/go-fsrs/v3 v3.3.1 github.com/panjf2000/ants/v2 v2.11.3 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pdfcpu/pdfcpu v0.11.0 github.com/radovskyb/watcher v1.0.7 - github.com/rqlite/sql v0.0.0-20250623131620-453fa49cad04 + github.com/rqlite/sql v0.0.0-20251114131613-ef07423e7137 github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 github.com/sashabaranov/go-openai v1.41.2 - github.com/shirou/gopsutil/v4 v4.25.10 + github.com/shirou/gopsutil/v4 v4.25.11 github.com/siyuan-note/dataparser v0.0.0-20250804100744-b41253b236f3 - github.com/siyuan-note/dejavu v0.0.0-20251127131048-ca646f306081 + github.com/siyuan-note/dejavu v0.0.0-20251202041457-7402b7c625c5 github.com/siyuan-note/encryption v0.0.0-20251120032857-3ddc3c2cc49f github.com/siyuan-note/eventbus v0.0.0-20240627125516-396fdb0f0f97 github.com/siyuan-note/filelock v0.0.0-20251107023958-207cad31f0dd @@ -112,7 +112,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/sso v1.30.5 // indirect github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.10 // indirect github.com/aws/aws-sdk-go-v2/service/sts v1.41.2 // indirect - github.com/aws/smithy-go v1.23.2 // indirect + github.com/aws/smithy-go v1.24.0 // indirect github.com/bytedance/gopkg v0.1.3 // indirect github.com/bytedance/sonic v1.14.1 // indirect github.com/bytedance/sonic/loader v0.3.0 // indirect @@ -146,7 +146,7 @@ require ( github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056 // indirect github.com/jolestar/go-commons-pool/v2 v2.1.2 // indirect github.com/juju/errors v1.0.0 // indirect - github.com/klauspost/compress v1.18.1 // indirect + github.com/klauspost/compress v1.18.2 // indirect github.com/klauspost/cpuid/v2 v2.3.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/levigross/exp-html v0.0.0-20120902181939-8df60c69a8f5 // indirect @@ -174,8 +174,8 @@ require ( github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect github.com/teambition/rrule-go v1.8.2 // indirect github.com/tetratelabs/wazero v1.9.0 // indirect - github.com/tklauser/go-sysconf v0.3.15 // indirect - github.com/tklauser/numcpus v0.10.0 // indirect + github.com/tklauser/go-sysconf v0.3.16 // indirect + github.com/tklauser/numcpus v0.11.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.3.0 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect diff --git a/kernel/go.sum b/kernel/go.sum index 109485e36..2e25eaf47 100644 --- a/kernel/go.sum +++ b/kernel/go.sum @@ -92,8 +92,8 @@ github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.10 h1:GtsxyiF3Nd3JahRBJbxLCCd github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.10/go.mod h1:/j67Z5XBVDx8nZVp9EuFM9/BS5dvBznbqILGuu73hug= github.com/aws/aws-sdk-go-v2/service/sts v1.41.2 h1:a5UTtD4mHBU3t0o6aHQZFJTNKVfxFWfPX7J0Lr7G+uY= github.com/aws/aws-sdk-go-v2/service/sts v1.41.2/go.mod h1:6TxbXoDSgBQ225Qd8Q+MbxUxUh6TtNKwbRt/EPS9xso= -github.com/aws/smithy-go v1.23.2 h1:Crv0eatJUQhaManss33hS5r40CG3ZFH+21XSkqMrIUM= -github.com/aws/smithy-go v1.23.2/go.mod h1:LEj2LM3rBRQJxPZTB4KuzZkaZYnZPnvgIhb4pu07mx0= +github.com/aws/smithy-go v1.24.0 h1:LpilSUItNPFr1eY85RYgTIg5eIEPtvFbskaFcmmIUnk= +github.com/aws/smithy-go v1.24.0/go.mod h1:LEj2LM3rBRQJxPZTB4KuzZkaZYnZPnvgIhb4pu07mx0= github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M= github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM= github.com/bytedance/sonic v1.14.1 h1:FBMC0zVz5XUmE4z9wF4Jey0An5FueFvOsTKKKtwIl7w= @@ -260,8 +260,8 @@ github.com/juju/errors v1.0.0/go.mod h1:B5x9thDqx0wIMH3+aLIMP9HjItInYWObRovoCFM5 github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= -github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= +github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk= +github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4= github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= @@ -307,8 +307,8 @@ github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9 github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/mssola/useragent v1.0.0 h1:WRlDpXyxHDNfvZaPEut5Biveq86Ze4o4EMffyMxmH5o= github.com/mssola/useragent v1.0.0/go.mod h1:hz9Cqz4RXusgg1EdI4Al0INR62kP7aPSRNHnpU+b85Y= -github.com/olahol/melody v1.3.0 h1:n7UlKiQnxVrgxKoM0d7usZiN+Z0y2lVENtYLgKtXS6s= -github.com/olahol/melody v1.3.0/go.mod h1:GgkTl6Y7yWj/HtfD48Q5vLKPVoZOH+Qqgfa7CvJgJM4= +github.com/olahol/melody v1.4.0 h1:Pa5SdeZL/zXPi1tJuMAPDbl4n3gQOThSL6G1p4qZ4SI= +github.com/olahol/melody v1.4.0/go.mod h1:GgkTl6Y7yWj/HtfD48Q5vLKPVoZOH+Qqgfa7CvJgJM4= github.com/olekukonko/tablewriter v0.0.0-20180506121414-d4647c9c7a84/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= @@ -360,15 +360,15 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/rqlite/sql v0.0.0-20250623131620-453fa49cad04 h1:bjr7gZERAJhYhqkLHXbkBSpjbB+PlgW6e9CRCJ2+J/w= -github.com/rqlite/sql v0.0.0-20250623131620-453fa49cad04/go.mod h1:ib9zVtNgRKiGuoMyUqqL5aNpk+r+++YlyiVIkclVqPg= +github.com/rqlite/sql v0.0.0-20251114131613-ef07423e7137 h1:OG5MfYAA0yaWgllfPdOq9Xa2bo1vpurCNx1LWz7+Zh0= +github.com/rqlite/sql v0.0.0-20251114131613-ef07423e7137/go.mod h1:ib9zVtNgRKiGuoMyUqqL5aNpk+r+++YlyiVIkclVqPg= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs= github.com/sashabaranov/go-openai v1.41.2 h1:vfPRBZNMpnqu8ELsclWcAvF19lDNgh1t6TVfFFOPiSM= github.com/sashabaranov/go-openai v1.41.2/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg= github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg= -github.com/shirou/gopsutil/v4 v4.25.10 h1:at8lk/5T1OgtuCp+AwrDofFRjnvosn0nkN2OLQ6g8tA= -github.com/shirou/gopsutil/v4 v4.25.10/go.mod h1:+kSwyC8DRUD9XXEHCAFjK+0nuArFJM0lva+StQAcskM= +github.com/shirou/gopsutil/v4 v4.25.11 h1:X53gB7muL9Gnwwo2evPSE+SfOrltMoR6V3xJAXZILTY= +github.com/shirou/gopsutil/v4 v4.25.11/go.mod h1:EivAfP5x2EhLp2ovdpKSozecVXn1TmuG7SMzs/Wh4PU= github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d h1:lvCTyBbr36+tqMccdGMwuEU+hjux/zL6xSmf5S9ITaA= @@ -376,8 +376,8 @@ github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d/go.mod h1:05Ut github.com/simplereach/timeutils v1.2.0/go.mod h1:VVbQDfN/FHRZa1LSqcwo4kNZ62OOyqLLGQKYB3pB0Q8= github.com/siyuan-note/dataparser v0.0.0-20250804100744-b41253b236f3 h1:EH063L0HD1f82DvddurUmEXS0obXypv8pQrcaC/zNgI= github.com/siyuan-note/dataparser v0.0.0-20250804100744-b41253b236f3/go.mod h1:8lb+SsWAPQblGbjmwEBsBdJszMCcLeECtB95fv6mReg= -github.com/siyuan-note/dejavu v0.0.0-20251127131048-ca646f306081 h1:blX3PCxIUXSR4X47dEl6aiV/UMBCMPdSEQlQOjB+Kho= -github.com/siyuan-note/dejavu v0.0.0-20251127131048-ca646f306081/go.mod h1:jdqY5deo0EBA51GYWNvUQzZm0IRTx9FbhSF+c6wDZHA= +github.com/siyuan-note/dejavu v0.0.0-20251202041457-7402b7c625c5 h1:KZ+l6WeLmdGobI193Ty/cqA15QOCOPBxvgKP9thFQf8= +github.com/siyuan-note/dejavu v0.0.0-20251202041457-7402b7c625c5/go.mod h1:NiyGdfe/v4QzmlCA9NLNfzkwHijB+Fr208f7WVOtMUE= github.com/siyuan-note/encryption v0.0.0-20251120032857-3ddc3c2cc49f h1:HSgJKIAMgokJDAvBBfRj47SzRSm6mNGssY0Wv7rcEtg= github.com/siyuan-note/encryption v0.0.0-20251120032857-3ddc3c2cc49f/go.mod h1:JE3S9VuJqTggyfhjesNDuqvqrRvwG3IctFjXXchLx1M= github.com/siyuan-note/eventbus v0.0.0-20240627125516-396fdb0f0f97 h1:lM5v8BfNtbOL5jYwhCdMYBcYtr06IYBKjjSLAPMKTM8= @@ -414,10 +414,10 @@ github.com/teambition/rrule-go v1.8.2 h1:lIjpjvWTj9fFUZCmuoVDrKVOtdiyzbzc93qTmRV github.com/teambition/rrule-go v1.8.2/go.mod h1:Ieq5AbrKGciP1V//Wq8ktsTXwSwJHDD5mD/wLBGl3p4= github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I= github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM= -github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4= -github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= -github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= -github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= +github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA= +github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI= +github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw= +github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA= diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index 5fd975582..d8df81f0e 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -3548,7 +3548,7 @@ func removeAttributeViewBlock(srcIDs []string, avID string, tx *Transaction) (er return } - refreshRelatedSrcAvs(avID) + refreshRelatedSrcAvs(avID, tx) historyDir, err := GetHistoryDir(HistoryOpUpdate) if err != nil { @@ -4688,7 +4688,7 @@ func replaceAttributeViewBlock0(attrView *av.AttributeView, oldBlockID, newNodeI content = util.UnescapeHTML(content) blockVal.Block.Icon, blockVal.Block.Content = icon, content - refreshRelatedSrcAvs(avID) + refreshRelatedSrcAvs(avID, tx) } else { blockVal.Block.ID = "" } @@ -4950,21 +4950,37 @@ func updateAttributeViewValue(tx *Transaction, attrView *av.AttributeView, keyID return } - refreshRelatedSrcAvs(avID) + refreshRelatedSrcAvs(avID, tx) return } -func refreshRelatedSrcAvs(destAvID string) { +func refreshRelatedSrcAvs(destAvID string, tx *Transaction) { relatedAvIDs := av.GetSrcAvIDs(destAvID) + + var tmp []string for _, relatedAvID := range relatedAvIDs { - destAv, _ := av.ParseAttributeView(relatedAvID) - if nil == destAv { + if relatedAvID == destAvID { + // 目标和源相同则跳过 continue } - regenAttrViewGroups(destAv) - av.SaveAttributeView(destAv) - ReloadAttrView(relatedAvID) + tmp = append(tmp, relatedAvID) + } + relatedAvIDs = tmp + + if nil != tx { + tx.relatedAvIDs = append(tx.relatedAvIDs, relatedAvIDs...) + } else { + for _, relatedAvID := range relatedAvIDs { + destAv, _ := av.ParseAttributeView(relatedAvID) + if nil == destAv { + continue + } + + regenAttrViewGroups(destAv) + av.SaveAttributeView(destAv) + ReloadAttrView(relatedAvID) + } } } diff --git a/kernel/model/box.go b/kernel/model/box.go index 0f4edfb8b..d6ca8147c 100644 --- a/kernel/model/box.go +++ b/kernel/model/box.go @@ -650,6 +650,21 @@ func normalizeTree(tree *parse.Tree) (yfmRootID, yfmTitle, yfmUpdated string) { tree.Root.SetIALAttr("custom-"+attrK, fmt.Sprint(attrV)) } + + // Import the YAML at the beginning of the Markdown as a code block https://github.com/siyuan-note/siyuan/issues/16488 + codeBlock := &ast.Node{Type: ast.NodeCodeBlock} + openMarker := &ast.Node{Type: ast.NodeCodeBlockFenceOpenMarker, Tokens: []byte("```"), CodeBlockFenceLen: 3} + codeBlock.AppendChild(openMarker) + info := &ast.Node{Type: ast.NodeCodeBlockFenceInfoMarker, CodeBlockInfo: []byte("yaml")} + codeBlock.AppendChild(info) + content := []byte("---\n") + content = append(content, n.Tokens...) + content = append(content, []byte("\n---")...) + code := &ast.Node{Type: ast.NodeCodeBlockCode, Tokens: content} + codeBlock.AppendChild(code) + closeMarker := &ast.Node{Type: ast.NodeCodeBlockFenceCloseMarker, Tokens: []byte("```"), CodeBlockFenceLen: 3} + codeBlock.AppendChild(closeMarker) + tree.Root.PrependChild(codeBlock) } if ast.NodeYamlFrontMatter == n.Type { diff --git a/kernel/model/push_reload.go b/kernel/model/push_reload.go index ea5972432..2a85eb100 100644 --- a/kernel/model/push_reload.go +++ b/kernel/model/push_reload.go @@ -392,7 +392,7 @@ func updateAttributeViewBlockText(updatedDefNodes map[string]*ast.Node) { av.SaveAttributeView(attrView) ReloadAttrView(avID) - refreshRelatedSrcAvs(avID) + refreshRelatedSrcAvs(avID, nil) } } } diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index ba8d44f83..f1473f87b 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -1924,8 +1924,9 @@ type Transaction struct { DoOperations []*Operation `json:"doOperations"` UndoOperations []*Operation `json:"undoOperations"` - trees map[string]*parse.Tree // 事务中变更的树 - nodes map[string]*ast.Node // 事务中变更的节点 + trees map[string]*parse.Tree // 事务中变更的树 + nodes map[string]*ast.Node // 事务中变更的节点 + relatedAvIDs []string // 事务中变更的属性视图 ID isGlobalAssetsInit bool // 是否初始化过全局资源判断 isGlobalAssets bool // 是否属于全局资源 @@ -1968,6 +1969,19 @@ func (tx *Transaction) commit() (err error) { checkUpsertInUserGuide(tree) } refreshDynamicRefTexts(tx.nodes, tx.trees) + + tx.relatedAvIDs = gulu.Str.RemoveDuplicatedElem(tx.relatedAvIDs) + for _, avID := range tx.relatedAvIDs { + destAv, _ := av.ParseAttributeView(avID) + if nil == destAv { + continue + } + + regenAttrViewGroups(destAv) + av.SaveAttributeView(destAv) + ReloadAttrView(avID) + } + IncSync() tx.state.Store(2) tx.m.Unlock() diff --git a/kernel/sql/block_query.go b/kernel/sql/block_query.go index 2ba4f645b..6387febf7 100644 --- a/kernel/sql/block_query.go +++ b/kernel/sql/block_query.go @@ -379,6 +379,7 @@ func QueryNoLimit(stmt string) (ret []map[string]interface{}, err error) { } func Query(stmt string, limit int) (ret []map[string]interface{}, err error) { + originalStmt := stmt // Kernel API `/api/query/sql` support `||` operator https://github.com/siyuan-note/siyuan/issues/9662 // 这里为了支持 || 操作符,使用了另一个 sql 解析器,但是这个解析器无法处理 UNION https://github.com/siyuan-note/siyuan/issues/8226 // 考虑到 UNION 的使用场景不多,这里还是以支持 || 操作符为主 @@ -426,8 +427,11 @@ func Query(stmt string, limit int) (ret []map[string]interface{}, err error) { ret = []map[string]interface{}{} rows, err := query(stmt) if err != nil { - logging.LogWarnf("sql query [%s] failed: %s", stmt, err) - return + rows, err = query(originalStmt + " LIMIT " + strconv.Itoa(limit)) + if err != nil { + logging.LogWarnf("sql query [%s] failed: %s", stmt, err) + return + } } defer rows.Close()