🎨 Supports searching database blocks by the view title https://github.com/siyuan-note/siyuan/issues/9348
This commit is contained in:
parent
5e38fe4335
commit
3c67701681
9 changed files with 73 additions and 41 deletions
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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");
|
||||
|
|
2
app/src/types/index.d.ts
vendored
2
app/src/types/index.d.ts
vendored
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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":
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Add table
Reference in a new issue