Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Supports searching database blocks by the view title https://github.com/siyuan-note/siyuan/issues/9348

Daniel3c6770168190
diff --git a/app/src/config/query.ts b/app/src/config/query.ts
index c82d2af62d..eb3e98c00e 100644
--- a/app/src/config/query.ts
+++ b/app/src/config/query.ts
@@ -114,6 +114,15 @@ export const query = {
<span class="fn__space"></span>
<input class="b3-switch" id="embedBlock" type="checkbox"${window.siyuan.config.search.embedBlock ? " checked" : ""}/>
</label>
+ <label class="fn__flex">
+ <svg class="svg"><use xlink:href="#iconDatabase"></use></svg>
+ <span class="fn__space"></span>
+ <div class="fn__flex-1">
+ ${window.siyuan.languages.database}
+ </div>
+ <span class="fn__space"></span>
+ <input class="b3-switch" id="databaseBlock" type="checkbox"${window.siyuan.config.search.databaseBlock ? " checked" : ""}/>
+ </label>
</div>
</div>
<div class="b3-label">
@@ -269,6 +278,7 @@ export const query = {
codeBlock: (query.element.querySelector("#codeBlock") as HTMLInputElement).checked,
htmlBlock: (query.element.querySelector("#htmlBlock") as HTMLInputElement).checked,
embedBlock: (query.element.querySelector("#embedBlock") as HTMLInputElement).checked,
+ databaseBlock: (query.element.querySelector("#databaseBlock") as HTMLInputElement).checked,
mathBlock: (query.element.querySelector("#mathBlock") as HTMLInputElement).checked,
table: (query.element.querySelector("#table") as HTMLInputElement).checked,
blockquote: (query.element.querySelector("#blockquote") as HTMLInputElement).checked,
diff --git a/app/src/mobile/menu/search.ts b/app/src/mobile/menu/search.ts
index 0c7976e66e..637b669226 100644
--- a/app/src/mobile/menu/search.ts
+++ b/app/src/mobile/menu/search.ts
@@ -18,7 +18,8 @@ import {App} from "../../index";
import {
assetFilterMenu,
assetInputEvent,
- assetMethodMenu, assetMoreMenu,
+ assetMethodMenu,
+ assetMoreMenu,
renderNextAssetMark,
renderPreview,
} from "../../search/assets";
@@ -482,6 +483,7 @@ const initSearchEvent = (app: App, element: Element, config: ISearchOption) => {
superBlock: window.siyuan.config.search.superBlock,
paragraph: window.siyuan.config.search.paragraph,
embedBlock: window.siyuan.config.search.embedBlock,
+ databaseBlock: window.siyuan.config.search.databaseBlock,
}
}, config);
});
diff --git a/app/src/search/menu.ts b/app/src/search/menu.ts
index 53415716f0..95dd5fd1a9 100644
--- a/app/src/search/menu.ts
+++ b/app/src/search/menu.ts
@@ -20,7 +20,7 @@ export const filterMenu = (config: ISearchOption, cb: () => void) => {
${window.siyuan.languages.math}
</div>
<span class="fn__space"></span>
- <input id="removeAssets" class="b3-switch fn__flex-center" data-type="mathBlock" type="checkbox"${config.types.mathBlock ? " checked" : ""}>
+ <input class="b3-switch fn__flex-center" data-type="mathBlock" type="checkbox"${config.types.mathBlock ? " checked" : ""}>
</label>
<label class="fn__flex b3-label">
<svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconTable"></use></svg>
@@ -29,7 +29,7 @@ export const filterMenu = (config: ISearchOption, cb: () => void) => {
${window.siyuan.languages.table}
</div>
<span class="fn__space"></span>
- <input id="removeAssets" class="b3-switch fn__flex-center" data-type="table" type="checkbox"${config.types.table ? " checked" : ""}>
+ <input class="b3-switch fn__flex-center" data-type="table" type="checkbox"${config.types.table ? " checked" : ""}>
</label>
<label class="fn__flex b3-label">
<svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconQuote"></use></svg>
@@ -38,7 +38,7 @@ export const filterMenu = (config: ISearchOption, cb: () => void) => {
${window.siyuan.languages.quote}
</div>
<span class="fn__space"></span>
- <input id="removeAssets" class="b3-switch fn__flex-center" data-type="blockquote" type="checkbox"${config.types.blockquote ? " checked" : ""}>
+ <input class="b3-switch fn__flex-center" data-type="blockquote" type="checkbox"${config.types.blockquote ? " checked" : ""}>
</label>
<label class="fn__flex b3-label">
<svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconSuper"></use></svg>
@@ -47,7 +47,7 @@ export const filterMenu = (config: ISearchOption, cb: () => void) => {
${window.siyuan.languages.superBlock}
</div>
<span class="fn__space"></span>
- <input id="removeAssets" class="b3-switch fn__flex-center" data-type="superBlock" type="checkbox"${config.types.superBlock ? " checked" : ""}>
+ <input class="b3-switch fn__flex-center" data-type="superBlock" type="checkbox"${config.types.superBlock ? " checked" : ""}>
</label>
<label class="fn__flex b3-label">
<svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconParagraph"></use></svg>
@@ -56,7 +56,7 @@ export const filterMenu = (config: ISearchOption, cb: () => void) => {
${window.siyuan.languages.paragraph}
</div>
<span class="fn__space"></span>
- <input id="removeAssets" class="b3-switch fn__flex-center" data-type="paragraph" type="checkbox"${config.types.paragraph ? " checked" : ""}>
+ <input class="b3-switch fn__flex-center" data-type="paragraph" type="checkbox"${config.types.paragraph ? " checked" : ""}>
</label>
<label class="fn__flex b3-label">
<svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconFile"></use></svg>
@@ -65,7 +65,7 @@ export const filterMenu = (config: ISearchOption, cb: () => void) => {
${window.siyuan.languages.doc}
</div>
<span class="fn__space"></span>
- <input id="removeAssets" class="b3-switch fn__flex-center" data-type="document" type="checkbox"${config.types.document ? " checked" : ""}>
+ <input class="b3-switch fn__flex-center" data-type="document" type="checkbox"${config.types.document ? " checked" : ""}>
</label>
<label class="fn__flex b3-label">
<svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconHeadings"></use></svg>
@@ -74,7 +74,7 @@ export const filterMenu = (config: ISearchOption, cb: () => void) => {
${window.siyuan.languages.headings}
</div>
<span class="fn__space"></span>
- <input id="removeAssets" class="b3-switch fn__flex-center" data-type="heading" type="checkbox"${config.types.heading ? " checked" : ""}>
+ <input class="b3-switch fn__flex-center" data-type="heading" type="checkbox"${config.types.heading ? " checked" : ""}>
</label>
<label class="fn__flex b3-label">
<svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconList"></use></svg>
@@ -83,7 +83,7 @@ export const filterMenu = (config: ISearchOption, cb: () => void) => {
${window.siyuan.languages.list1}
</div>
<span class="fn__space"></span>
- <input id="removeAssets" class="b3-switch fn__flex-center" data-type="list" type="checkbox"${config.types.list ? " checked" : ""}>
+ <input class="b3-switch fn__flex-center" data-type="list" type="checkbox"${config.types.list ? " checked" : ""}>
</label>
<label class="fn__flex b3-label">
<svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconListItem"></use></svg>
@@ -92,7 +92,7 @@ export const filterMenu = (config: ISearchOption, cb: () => void) => {
${window.siyuan.languages.listItem}
</div>
<span class="fn__space"></span>
- <input id="removeAssets" class="b3-switch fn__flex-center" data-type="listItem" type="checkbox"${config.types.listItem ? " checked" : ""}>
+ <input class="b3-switch fn__flex-center" data-type="listItem" type="checkbox"${config.types.listItem ? " checked" : ""}>
</label>
<label class="fn__flex b3-label">
<svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconCode"></use></svg>
@@ -101,7 +101,7 @@ export const filterMenu = (config: ISearchOption, cb: () => void) => {
${window.siyuan.languages.code}
</div>
<span class="fn__space"></span>
- <input id="removeAssets" class="b3-switch fn__flex-center" data-type="codeBlock" type="checkbox"${config.types.codeBlock ? " checked" : ""}>
+ <input class="b3-switch fn__flex-center" data-type="codeBlock" type="checkbox"${config.types.codeBlock ? " checked" : ""}>
</label>
<label class="fn__flex b3-label">
<svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconHTML5"></use></svg>
@@ -110,7 +110,7 @@ export const filterMenu = (config: ISearchOption, cb: () => void) => {
HTML
</div>
<span class="fn__space"></span>
- <input id="removeAssets" class="b3-switch fn__flex-center" data-type="htmlBlock" type="checkbox"${config.types.htmlBlock ? " checked" : ""}>
+ <input class="b3-switch fn__flex-center" data-type="htmlBlock" type="checkbox"${config.types.htmlBlock ? " checked" : ""}>
</label>
<label class="fn__flex b3-label">
<svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconSQL"></use></svg>
@@ -119,7 +119,16 @@ export const filterMenu = (config: ISearchOption, cb: () => void) => {
${window.siyuan.languages.embedBlock}
</div>
<span class="fn__space"></span>
- <input id="removeAssets" class="b3-switch fn__flex-center" data-type="embedBlock" type="checkbox"${config.types.embedBlock ? " checked" : ""}>
+ <input class="b3-switch fn__flex-center" data-type="embedBlock" type="checkbox"${config.types.embedBlock ? " checked" : ""}>
+ </label>
+ <label class="fn__flex b3-label">
+ <svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconDatabase"></use></svg>
+ <span class="fn__space"></span>
+ <div class="fn__flex-1 fn__flex-center">
+ ${window.siyuan.languages.database}
+ </div>
+ <span class="fn__space"></span>
+ <input class="b3-switch fn__flex-center" data-type="databaseBlock" type="checkbox"${config.types.databaseBlock ? " checked" : ""}>
</label>
</div>
<div class="b3-dialog__action">
diff --git a/app/src/search/util.ts b/app/src/search/util.ts
index ea03248a9c..30cfe90ba8 100644
--- a/app/src/search/util.ts
+++ b/app/src/search/util.ts
@@ -32,8 +32,10 @@ import {upDownHint} from "../util/upDownHint";
import {
assetFilterMenu,
assetInputEvent,
- assetMethodMenu, assetMoreMenu,
- openSearchAsset, renderNextAssetMark,
+ assetMethodMenu,
+ assetMoreMenu,
+ openSearchAsset,
+ renderNextAssetMark,
renderPreview,
toggleAssetHistory
} from "./assets";
@@ -365,6 +367,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
superBlock: window.siyuan.config.search.superBlock,
paragraph: window.siyuan.config.search.paragraph,
embedBlock: window.siyuan.config.search.embedBlock,
+ databaseBlock: window.siyuan.config.search.databaseBlock,
}
}, config, edit);
element.querySelector(".b3-chip--current")?.classList.remove("b3-chip--current");
@@ -578,6 +581,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
superBlock: window.siyuan.config.search.superBlock,
paragraph: window.siyuan.config.search.paragraph,
embedBlock: window.siyuan.config.search.embedBlock,
+ databaseBlock: window.siyuan.config.search.databaseBlock,
}
}, config, edit);
element.querySelector("#criteria .b3-chip--current")?.classList.remove("b3-chip--current");
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index d803058a82..7a3df4d74a 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -237,6 +237,7 @@ interface ISearchOption {
codeBlock: boolean
htmlBlock: boolean
embedBlock: boolean
+ databaseBlock: boolean
}
}
@@ -751,6 +752,7 @@ interface IConfig {
sort: number
}
search: {
+ databaseBlock: boolean
embedBlock: boolean
htmlBlock: boolean
document: boolean
diff --git a/kernel/conf/search.go b/kernel/conf/search.go
index 563ade6ab5..d1e2771815 100644
--- a/kernel/conf/search.go
+++ b/kernel/conf/search.go
@@ -25,18 +25,19 @@ import (
)
type Search struct {
- Document bool `json:"document"`
- Heading bool `json:"heading"`
- List bool `json:"list"`
- ListItem bool `json:"listItem"`
- CodeBlock bool `json:"codeBlock"`
- MathBlock bool `json:"mathBlock"`
- Table bool `json:"table"`
- Blockquote bool `json:"blockquote"`
- SuperBlock bool `json:"superBlock"`
- Paragraph bool `json:"paragraph"`
- HTMLBlock bool `json:"htmlBlock"`
- EmbedBlock bool `json:"embedBlock"`
+ Document bool `json:"document"`
+ Heading bool `json:"heading"`
+ List bool `json:"list"`
+ ListItem bool `json:"listItem"`
+ CodeBlock bool `json:"codeBlock"`
+ MathBlock bool `json:"mathBlock"`
+ Table bool `json:"table"`
+ Blockquote bool `json:"blockquote"`
+ SuperBlock bool `json:"superBlock"`
+ Paragraph bool `json:"paragraph"`
+ HTMLBlock bool `json:"htmlBlock"`
+ EmbedBlock bool `json:"embedBlock"`
+ DatabaseBlock bool `json:"databaseBlock"`
Limit int `json:"limit"`
CaseSensitive bool `json:"caseSensitive"`
@@ -62,18 +63,19 @@ type Search struct {
func NewSearch() *Search {
return &Search{
- Document: true,
- Heading: true,
- List: true,
- ListItem: true,
- CodeBlock: true,
- MathBlock: true,
- Table: true,
- Blockquote: true,
- SuperBlock: true,
- Paragraph: true,
- HTMLBlock: true,
- EmbedBlock: false,
+ Document: true,
+ Heading: true,
+ List: true,
+ ListItem: true,
+ CodeBlock: true,
+ MathBlock: true,
+ Table: true,
+ Blockquote: true,
+ SuperBlock: true,
+ Paragraph: true,
+ HTMLBlock: true,
+ EmbedBlock: false,
+ DatabaseBlock: true,
Limit: 64,
CaseSensitive: false,
diff --git a/kernel/model/search.go b/kernel/model/search.go
index c8c29131e5..cd82697bf2 100644
--- a/kernel/model/search.go
+++ b/kernel/model/search.go
@@ -604,6 +604,7 @@ func buildTypeFilter(types map[string]bool) string {
s.Paragraph = types["paragraph"]
s.HTMLBlock = types["htmlBlock"]
s.EmbedBlock = types["embedBlock"]
+ s.DatabaseBlock = types["databaseBlock"]
} else {
s.Document = Conf.Search.Document
s.Heading = Conf.Search.Heading
@@ -617,6 +618,7 @@ func buildTypeFilter(types map[string]bool) string {
s.Paragraph = Conf.Search.Paragraph
s.HTMLBlock = Conf.Search.HTMLBlock
s.EmbedBlock = Conf.Search.EmbedBlock
+ s.DatabaseBlock = Conf.Search.DatabaseBlock
}
return s.TypeFilter()
}
diff --git a/kernel/sql/block_ref_query.go b/kernel/sql/block_ref_query.go
index 752cff4d34..eb9fece8d2 100644
--- a/kernel/sql/block_ref_query.go
+++ b/kernel/sql/block_ref_query.go
@@ -203,6 +203,8 @@ func getRefText(defBlockID string) string {
return block.Content
case "query_embed":
return "Query Embed Block " + block.Markdown
+ case "av":
+ return "Database " + block.Markdown
case "iframe":
return "IFrame " + block.Markdown
case "tb":
diff --git a/kernel/treenode/node.go b/kernel/treenode/node.go
index 65a760b30d..90211fe0f3 100644
--- a/kernel/treenode/node.go
+++ b/kernel/treenode/node.go
@@ -145,8 +145,6 @@ func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATi
attrView, err := av.ParseAttributeView(node.AttributeViewID)
if nil == err {
buf := bytes.Buffer{}
- buf.WriteString(attrView.Name)
- buf.WriteString(" ")
for _, v := range attrView.Views {
buf.WriteString(v.Name)
buf.WriteString(" ")
@@ -393,6 +391,7 @@ var typeAbbrMap = map[string]string{
"NodeParagraph": "p",
"NodeHTMLBlock": "html",
"NodeBlockQueryEmbed": "query_embed",
+ "NodeAttributeView": "av",
"NodeKramdownBlockIAL": "ial",
"NodeIFrame": "iframe",
"NodeWidget": "widget",