🎨 Search type filtering supports Audio, Video, IFrame and Widget block https://github.com/siyuan-note/siyuan/issues/10645

This commit is contained in:
Daniel 2024-03-22 11:47:18 +08:00
parent c5cc3ff779
commit 4f1013a35e
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 40 additions and 5 deletions

View file

@ -38,6 +38,10 @@ type Search struct {
HTMLBlock bool `json:"htmlBlock"`
EmbedBlock bool `json:"embedBlock"`
DatabaseBlock bool `json:"databaseBlock"`
AudioBlock bool `json:"audioBlock"`
VideoBlock bool `json:"videoBlock"`
IFrameBlock bool `json:"iframeBlock"`
WidgetBlock bool `json:"widgetBlock"`
Limit int `json:"limit"`
CaseSensitive bool `json:"caseSensitive"`
@ -76,6 +80,10 @@ func NewSearch() *Search {
HTMLBlock: true,
EmbedBlock: false,
DatabaseBlock: true,
AudioBlock: true,
VideoBlock: true,
IFrameBlock: true,
WidgetBlock: true,
Limit: 64,
CaseSensitive: false,
@ -195,11 +203,30 @@ func (s *Search) TypeFilter() string {
buf.WriteByte('\'')
buf.WriteString(",")
}
// 无法搜索到 iframe 块、视频块和音频块 https://github.com/siyuan-note/siyuan/issues/3604
buf.WriteString("'iframe','video','audio',")
// 挂件块支持内置属性搜索 https://github.com/siyuan-note/siyuan/issues/4497
buf.WriteString("'widget',")
if s.AudioBlock {
buf.WriteByte('\'')
buf.WriteString(treenode.TypeAbbr(ast.NodeAudio.String()))
buf.WriteByte('\'')
buf.WriteString(",")
}
if s.VideoBlock {
buf.WriteByte('\'')
buf.WriteString(treenode.TypeAbbr(ast.NodeVideo.String()))
buf.WriteByte('\'')
buf.WriteString(",")
}
if s.IFrameBlock {
buf.WriteByte('\'')
buf.WriteString(treenode.TypeAbbr(ast.NodeIFrame.String()))
buf.WriteByte('\'')
buf.WriteString(",")
}
if s.WidgetBlock {
buf.WriteByte('\'')
buf.WriteString(treenode.TypeAbbr(ast.NodeWidget.String()))
buf.WriteByte('\'')
buf.WriteString(",")
}
ret := buf.String()
if "" == ret {

View file

@ -971,6 +971,10 @@ func buildTypeFilter(types map[string]bool) string {
s.HTMLBlock = types["htmlBlock"]
s.EmbedBlock = types["embedBlock"]
s.DatabaseBlock = types["databaseBlock"]
s.AudioBlock = types["audioBlock"]
s.VideoBlock = types["videoBlock"]
s.IFrameBlock = types["iFrameBlock"]
s.WidgetBlock = types["widgetBlock"]
} else {
s.Document = Conf.Search.Document
s.Heading = Conf.Search.Heading
@ -985,6 +989,10 @@ func buildTypeFilter(types map[string]bool) string {
s.HTMLBlock = Conf.Search.HTMLBlock
s.EmbedBlock = Conf.Search.EmbedBlock
s.DatabaseBlock = Conf.Search.DatabaseBlock
s.AudioBlock = Conf.Search.AudioBlock
s.VideoBlock = Conf.Search.VideoBlock
s.IFrameBlock = Conf.Search.IFrameBlock
s.WidgetBlock = Conf.Search.WidgetBlock
}
return s.TypeFilter()
}