Browse Source

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

Vanessa 1 year ago
parent
commit
a08af3a486
5 changed files with 52 additions and 3 deletions
  1. 0 0
      app/stage/protyle/js/lute/lute.min.js
  2. 21 0
      kernel/av/av.go
  3. 1 1
      kernel/go.mod
  4. 2 2
      kernel/go.sum
  5. 28 0
      kernel/model/file.go

File diff suppressed because it is too large
+ 0 - 0
app/stage/protyle/js/lute/lute.min.js


+ 21 - 0
kernel/av/av.go

@@ -29,6 +29,7 @@ import (
 
 
 	"github.com/88250/gulu"
 	"github.com/88250/gulu"
 	"github.com/88250/lute/ast"
 	"github.com/88250/lute/ast"
+	jsoniter "github.com/json-iterator/go"
 	"github.com/siyuan-note/filelock"
 	"github.com/siyuan-note/filelock"
 	"github.com/siyuan-note/logging"
 	"github.com/siyuan-note/logging"
 	"github.com/siyuan-note/siyuan/kernel/util"
 	"github.com/siyuan-note/siyuan/kernel/util"
@@ -212,6 +213,26 @@ func NewAttributeView(id string) (ret *AttributeView) {
 	return
 	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 {
 func IsAttributeViewExist(avID string) bool {
 	avJSONPath := GetAttributeViewDataPath(avID)
 	avJSONPath := GetAttributeViewDataPath(avID)
 	return filelock.IsExist(avJSONPath)
 	return filelock.IsExist(avJSONPath)

+ 1 - 1
kernel/go.mod

@@ -9,7 +9,7 @@ require (
 	github.com/88250/clipboard v0.1.5
 	github.com/88250/clipboard v0.1.5
 	github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48
 	github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48
 	github.com/88250/gulu v1.2.3-0.20231209020950-b7b6994e395c
 	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/pdfcpu v0.3.14-0.20230401044135-c7369a99720c
 	github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
 	github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
 	github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4
 	github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4

+ 2 - 2
kernel/go.sum

@@ -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/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 h1:Fas3hxqP33xA9KKDV50jUmppiiOukk5bdV00Hk5VSSk=
 github.com/88250/gulu v1.2.3-0.20231209020950-b7b6994e395c/go.mod h1:pTWnjt+6qUqNnP9xltswsJxgCBVu3C7eW09u48LWX0k=
 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 h1:Dl/8S9iLyPMTElnWIBxmjaLiWrkI5P4a21ivwAn5pU0=
 github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
 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=
 github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=

+ 28 - 0
kernel/model/file.go

@@ -17,6 +17,7 @@
 package model
 package model
 
 
 import (
 import (
+	"bytes"
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
 	"os"
 	"os"
@@ -40,6 +41,7 @@ import (
 	"github.com/siyuan-note/filelock"
 	"github.com/siyuan-note/filelock"
 	"github.com/siyuan-note/logging"
 	"github.com/siyuan-note/logging"
 	"github.com/siyuan-note/riff"
 	"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/cache"
 	"github.com/siyuan-note/siyuan/kernel/filesys"
 	"github.com/siyuan-note/siyuan/kernel/filesys"
 	"github.com/siyuan-note/siyuan/kernel/search"
 	"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 "" != n.ID {
 				// 填充块引计数
 				// 填充块引计数
 				if cnt := refCount[n.ID]; 0 < cnt {
 				if cnt := refCount[n.ID]; 0 < cnt {

Some files were not shown because too many files changed in this diff