mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 00:38:49 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
e7c544e7ad
8 changed files with 75 additions and 17 deletions
|
|
@ -24,7 +24,6 @@ export const setLute = (options: ILuteOptions) => {
|
|||
lute.SetKramdownIAL(true);
|
||||
lute.SetTag(true);
|
||||
lute.SetSuperBlock(true);
|
||||
lute.SetMark(true);
|
||||
lute.SetInlineAsterisk(window.siyuan.config.editor.markdown.inlineAsterisk);
|
||||
lute.SetInlineUnderscore(window.siyuan.config.editor.markdown.inlineUnderscore);
|
||||
lute.SetSup(window.siyuan.config.editor.markdown.inlineSup);
|
||||
|
|
|
|||
2
app/stage/protyle/js/lute/lute.min.js
vendored
2
app/stage/protyle/js/lute/lute.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -41,6 +41,10 @@ import (
|
|||
|
||||
func LoadTrees(ids []string) (ret map[string]*parse.Tree) {
|
||||
ret = map[string]*parse.Tree{}
|
||||
if 1 > len(ids) {
|
||||
return ret
|
||||
}
|
||||
|
||||
bts := treenode.GetBlockTrees(ids)
|
||||
luteEngine := util.NewLute()
|
||||
var boxIDs []string
|
||||
|
|
|
|||
|
|
@ -10,7 +10,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.20250227144607-7f4570b0d689
|
||||
github.com/88250/lute v1.7.7-0.20250621022853-b1f1ae270cbc
|
||||
github.com/88250/lute v1.7.7-0.20250622030929-fb99373b041d
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
|
||||
github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4
|
||||
github.com/ConradIrwin/font v0.2.1
|
||||
|
|
|
|||
|
|
@ -14,8 +14,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.20250227144607-7f4570b0d689 h1:39y5g7vnFAIcXhTN3IXPk7h2xBhC4a9hBTykDhHJqRY=
|
||||
github.com/88250/gulu v1.2.3-0.20250227144607-7f4570b0d689/go.mod h1:c8uVw25vW2W4dhJ/j4iYsX5H1hc19spim266jO5x2hU=
|
||||
github.com/88250/lute v1.7.7-0.20250621022853-b1f1ae270cbc h1:edI8+HT7ZHYlzUWE+lW8jQEjIPWygQhth/I2HpcwyMc=
|
||||
github.com/88250/lute v1.7.7-0.20250621022853-b1f1ae270cbc/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o=
|
||||
github.com/88250/lute v1.7.7-0.20250622030929-fb99373b041d h1:qhAsohKw5Jyo7wW64uKCgj+EAhaEGjb7DzBnURndU8I=
|
||||
github.com/88250/lute v1.7.7-0.20250622030929-fb99373b041d/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o=
|
||||
github.com/88250/pdfcpu v0.3.14-0.20250424122812-f10e8d9d8d46 h1:Bq1JsDfVbHKUxNL/B2JXd8cC/1h6aFjrlXpGycnh0Hk=
|
||||
github.com/88250/pdfcpu v0.3.14-0.20250424122812-f10e8d9d8d46/go.mod h1:fVfOloBzs2+W2VJCCbq60XIxc3yJHAZ0Gahv1oO0gyI=
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/88250/lute/parse"
|
||||
"github.com/88250/lute/render"
|
||||
"github.com/siyuan-note/siyuan/kernel/av"
|
||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
|
@ -66,6 +67,16 @@ func RenderAttributeViewGallery(attrView *av.AttributeView, view *av.View, query
|
|||
cardsValues := generateAttrViewItems(attrView) // 生成卡片
|
||||
filterNotFoundAttrViewItems(&cardsValues) // 过滤掉不存在的卡片
|
||||
|
||||
// 批量加载绑定块对应的树
|
||||
var ialIDs []string
|
||||
for _, card := range ret.Cards {
|
||||
block := card.GetBlockValue()
|
||||
if nil != block && !block.IsDetached {
|
||||
ialIDs = append(ialIDs, card.ID)
|
||||
}
|
||||
}
|
||||
boundTrees := filesys.LoadTrees(ialIDs)
|
||||
|
||||
// 生成卡片字段值
|
||||
for cardID, cardValues := range cardsValues {
|
||||
var galleryCard av.GalleryCard
|
||||
|
|
@ -97,19 +108,12 @@ func RenderAttributeViewGallery(attrView *av.AttributeView, view *av.View, query
|
|||
galleryCard.Values = append(galleryCard.Values, fieldValue)
|
||||
}
|
||||
|
||||
fillAttributeViewGalleryCardCover(attrView, view, cardValues, &galleryCard, cardID, luteEngine)
|
||||
fillAttributeViewGalleryCardCover(attrView, view, cardValues, &galleryCard, cardID, luteEngine, boundTrees)
|
||||
ret.Cards = append(ret.Cards, &galleryCard)
|
||||
}
|
||||
|
||||
// 批量获取块属性以提升性能
|
||||
var ialIDs []string
|
||||
for _, card := range ret.Cards {
|
||||
block := card.GetBlockValue()
|
||||
if nil != block && !block.IsDetached {
|
||||
ialIDs = append(ialIDs, card.ID)
|
||||
}
|
||||
}
|
||||
ials := BatchGetBlockAttrs(ialIDs)
|
||||
ials := BatchGetBlockAttrsWitTrees(ialIDs, boundTrees)
|
||||
|
||||
// 渲染自动生成的字段值,比如关联字段、汇总字段、创建时间字段和更新时间字段
|
||||
avCache := map[string]*av.AttributeView{}
|
||||
|
|
@ -139,7 +143,7 @@ func RenderAttributeViewGallery(attrView *av.AttributeView, view *av.View, query
|
|||
return
|
||||
}
|
||||
|
||||
func fillAttributeViewGalleryCardCover(attrView *av.AttributeView, view *av.View, cardValues []*av.KeyValues, galleryCard *av.GalleryCard, cardID string, luteEngine *lute.Lute) {
|
||||
func fillAttributeViewGalleryCardCover(attrView *av.AttributeView, view *av.View, cardValues []*av.KeyValues, galleryCard *av.GalleryCard, cardID string, luteEngine *lute.Lute, trees map[string]*parse.Tree) {
|
||||
switch view.Gallery.CoverFrom {
|
||||
case av.CoverFromNone:
|
||||
case av.CoverFromContentImage:
|
||||
|
|
@ -148,7 +152,7 @@ func fillAttributeViewGalleryCardCover(attrView *av.AttributeView, view *av.View
|
|||
break
|
||||
}
|
||||
|
||||
tree := loadTreeByBlockID(blockValue.BlockID)
|
||||
tree := trees[blockValue.BlockID]
|
||||
if nil == tree {
|
||||
break
|
||||
}
|
||||
|
|
|
|||
|
|
@ -276,8 +276,51 @@ func nodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATi
|
|||
return buf.String()
|
||||
}
|
||||
|
||||
func BatchGetBlockAttrsWitTrees(ids []string, trees map[string]*parse.Tree) (ret map[string]map[string]string) {
|
||||
ret = map[string]map[string]string{}
|
||||
|
||||
hitCache := true
|
||||
for _, id := range ids {
|
||||
ial := cache.GetBlockIAL(id)
|
||||
if nil != ial {
|
||||
ret[id] = ial
|
||||
continue
|
||||
}
|
||||
hitCache = false
|
||||
break
|
||||
}
|
||||
if hitCache {
|
||||
return
|
||||
}
|
||||
|
||||
for _, id := range ids {
|
||||
tree := trees[id]
|
||||
if nil == tree {
|
||||
continue
|
||||
}
|
||||
|
||||
ret[id] = getBlockAttrsFromTree(id, tree)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func BatchGetBlockAttrs(ids []string) (ret map[string]map[string]string) {
|
||||
ret = map[string]map[string]string{}
|
||||
|
||||
hitCache := true
|
||||
for _, id := range ids {
|
||||
ial := cache.GetBlockIAL(id)
|
||||
if nil != ial {
|
||||
ret[id] = ial
|
||||
continue
|
||||
}
|
||||
hitCache = false
|
||||
break
|
||||
}
|
||||
if hitCache {
|
||||
return
|
||||
}
|
||||
|
||||
trees := filesys.LoadTrees(ids)
|
||||
for _, id := range ids {
|
||||
tree := trees[id]
|
||||
|
|
@ -308,6 +351,15 @@ func GetBlockAttrs(id string) (ret map[string]string) {
|
|||
|
||||
func getBlockAttrsFromTree(id string, tree *parse.Tree) (ret map[string]string) {
|
||||
ret = map[string]string{}
|
||||
|
||||
ial := cache.GetBlockIAL(id)
|
||||
if nil != ial {
|
||||
for k, v := range ial {
|
||||
ret[k] = v
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
node := treenode.GetNodeInTree(tree, id)
|
||||
if nil == node {
|
||||
logging.LogWarnf("block [%s] not found", id)
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ func NewLute() (ret *lute.Lute) {
|
|||
ret.SetSuperBlock(true)
|
||||
ret.SetImgPathAllowSpace(true)
|
||||
ret.SetGitConflict(true)
|
||||
ret.SetMark(true)
|
||||
ret.SetInlineAsterisk(MarkdownSettings.InlineAsterisk)
|
||||
ret.SetInlineUnderscore(MarkdownSettings.InlineUnderscore)
|
||||
ret.SetSup(MarkdownSettings.InlineSup)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue