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

This commit is contained in:
Vanessa 2024-03-08 21:39:14 +08:00
commit a08af3a486
5 changed files with 54 additions and 5 deletions

File diff suppressed because one or more lines are too long

View file

@ -29,6 +29,7 @@ import (
"github.com/88250/gulu"
"github.com/88250/lute/ast"
jsoniter "github.com/json-iterator/go"
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/util"
@ -212,6 +213,26 @@ func NewAttributeView(id string) (ret *AttributeView) {
return
}
func GetAttributeViewName(avID string) (ret string, err error) {
avJSONPath := GetAttributeViewDataPath(avID)
if !filelock.IsExist(avJSONPath) {
return
}
data, err := filelock.ReadFile(avJSONPath)
if nil != err {
logging.LogErrorf("read attribute view [%s] failed: %s", avID, err)
return
}
val := jsoniter.Get(data, "name")
if nil == val || val.ValueType() == jsoniter.InvalidValue {
return
}
ret = val.ToString()
return
}
func IsAttributeViewExist(avID string) bool {
avJSONPath := GetAttributeViewDataPath(avID)
return filelock.IsExist(avJSONPath)

View file

@ -9,7 +9,7 @@ require (
github.com/88250/clipboard v0.1.5
github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48
github.com/88250/gulu v1.2.3-0.20231209020950-b7b6994e395c
github.com/88250/lute v1.7.7-0.20240225141140-2acd83bfa5d5
github.com/88250/lute v1.7.7-0.20240308125612-93a1f4e75895
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

@ -10,8 +10,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.20231209020950-b7b6994e395c h1:Fas3hxqP33xA9KKDV50jUmppiiOukk5bdV00Hk5VSSk=
github.com/88250/gulu v1.2.3-0.20231209020950-b7b6994e395c/go.mod h1:pTWnjt+6qUqNnP9xltswsJxgCBVu3C7eW09u48LWX0k=
github.com/88250/lute v1.7.7-0.20240225141140-2acd83bfa5d5 h1:sUT5aPsnYCYjuNSnrx80JJdXOqHslw8KdmaSd/PrAPI=
github.com/88250/lute v1.7.7-0.20240225141140-2acd83bfa5d5/go.mod h1:+wUqx/1kdFDbWtxn9LYJlaCOAeol2pjSO6w+WJTVQsg=
github.com/88250/lute v1.7.7-0.20240308125612-93a1f4e75895 h1:9iQ0Hetjkl1iiqaHahe9uNEbg4z2WoRLLDDwvV45/JY=
github.com/88250/lute v1.7.7-0.20240308125612-93a1f4e75895/go.mod h1:+wUqx/1kdFDbWtxn9LYJlaCOAeol2pjSO6w+WJTVQsg=
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

@ -17,6 +17,7 @@
package model
import (
"bytes"
"errors"
"fmt"
"os"
@ -40,6 +41,7 @@ import (
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/riff"
"github.com/siyuan-note/siyuan/kernel/av"
"github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/search"
@ -731,6 +733,32 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s
}
}
if avs := n.IALAttr(av.NodeAttrNameAvs); "" != avs {
// 填充属性视图角标 Display the database title on the block superscript https://github.com/siyuan-note/siyuan/issues/10545
avNames := bytes.Buffer{}
avIDs := strings.Split(avs, ",")
for _, avID := range avIDs {
avName, getErr := av.GetAttributeViewName(avID)
if nil != getErr {
continue
}
if "" == avName {
avName = "Untitled"
}
tpl := `<span data-av-id="${avID}" data-popover-url="/api/av/getMirrorDatabaseBlocks" class="popover__block">${avName}</span>`
tpl = strings.ReplaceAll(tpl, "${avID}", avID)
tpl = strings.ReplaceAll(tpl, "${avName}", avName)
avNames.WriteString(tpl)
avNames.WriteString("&nbsp;")
}
if 0 < avNames.Len() {
avNames.Truncate(avNames.Len() - 6)
n.SetIALAttr("av-names", avNames.String())
}
}
if "" != n.ID {
// 填充块引计数
if cnt := refCount[n.ID]; 0 < cnt {