mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-06 12:50:16 +01:00
🎨 Add configuration item Editor - [[ Only search doc block Fix https://github.com/siyuan-note/siyuan/issues/8077
This commit is contained in:
parent
d4806332a3
commit
99407dcc1c
8 changed files with 22 additions and 11 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"onlySearchForDoc": "<code class='fn__code'>[[</code> only search documents",
|
||||
"onlySearchForDocTip": "After enabling, [[ to search for block references only in doc blocks",
|
||||
"onlySearchForDocTip": "After enabling, [[ or 【【 to search for block references only in doc blocks",
|
||||
"ocrResult": "OCR result text",
|
||||
"reOCR": "Re OCR",
|
||||
"continueReview1": "Continue Review",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"onlySearchForDoc": "<code class='fn__code'>[[</code> solo buscar documentos",
|
||||
"onlySearchForDocTip": "Después de habilitar, [[ para buscar referencias de bloque solo en bloques de documentos",
|
||||
"onlySearchForDocTip": "Después de habilitar, [[ o 【【 para buscar referencias de bloque solo en bloques de documentos",
|
||||
"ocrResult": "Texto de resultado de OCR",
|
||||
"reOCR": "Re-OCR",
|
||||
"continueReview1": "Continuar revisión",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"onlySearchForDoc": "<code class='fn__code'>[[</code> rechercher uniquement les documents",
|
||||
"onlySearchForDocTip": "Après l'activation, [[ pour rechercher des références de bloc uniquement dans les blocs doc",
|
||||
"onlySearchForDocTip": "Après l'activation, [[ ou 【【 pour rechercher des références de bloc uniquement dans les blocs doc",
|
||||
"reOCR": "ReOCR",
|
||||
"continueReview1": "Continuer la révision",
|
||||
"continueReview2": "Il reste encore des fiches <code class='fn__code'>${count}</code> à examiner, continuer ?",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"onlySearchForDoc": "<code class='fn__code'>[[</code> 僅搜索文檔",
|
||||
"onlySearchForDocTip": "啟用後使用 [[ 搜索塊引用時將只在文檔塊中進行搜索",
|
||||
"onlySearchForDocTip": "啟用後使用 [[ 或 【【 搜索塊引用時將只在文檔塊中進行搜索",
|
||||
"ocrResult": "OCR 結果文本",
|
||||
"reOCR": "重新 OCR",
|
||||
"continueReview1": "繼續複習",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"onlySearchForDoc": "<code class='fn__code'>[[</code> 仅搜索文档",
|
||||
"onlySearchForDocTip": "启用后使用 [[ 搜索块引用时将只在文档块中进行搜索",
|
||||
"onlySearchForDocTip": "启用后使用 [[ 或 【【 搜索块引用时将只在文档块中进行搜索",
|
||||
"ocrResult": "OCR 结果文本",
|
||||
"reOCR": "重新 OCR",
|
||||
"continueReview1": "继续复习",
|
||||
|
|
|
|||
|
|
@ -307,6 +307,7 @@ export const hintRef = (key: string, protyle: IProtyle, isQuick = false): IHintD
|
|||
id: nodeElement ? nodeElement.getAttribute("data-node-id") : protyle.block.parentID,
|
||||
beforeLen: Math.floor((Math.max(protyle.element.clientWidth / 2, 320) - 58) / 28.8),
|
||||
rootID: protyle.block.rootID,
|
||||
isSquareBrackets: ["[[", "【【"].includes(protyle.hint.splitChar)
|
||||
}, (response) => {
|
||||
const dataList: IHintData[] = [];
|
||||
if (response.data.newDoc) {
|
||||
|
|
|
|||
|
|
@ -191,11 +191,16 @@ func searchRefBlock(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
isSquareBrackets := false
|
||||
if isSquareBracketsArg := arg["isSquareBrackets"]; nil != isSquareBracketsArg {
|
||||
isSquareBrackets = isSquareBracketsArg.(bool)
|
||||
}
|
||||
|
||||
rootID := arg["rootID"].(string)
|
||||
id := arg["id"].(string)
|
||||
keyword := arg["k"].(string)
|
||||
beforeLen := int(arg["beforeLen"].(float64))
|
||||
blocks, newDoc := model.SearchRefBlock(id, rootID, keyword, beforeLen)
|
||||
blocks, newDoc := model.SearchRefBlock(id, rootID, keyword, beforeLen, isSquareBrackets)
|
||||
ret.Data = map[string]interface{}{
|
||||
"blocks": blocks,
|
||||
"newDoc": newDoc,
|
||||
|
|
|
|||
|
|
@ -121,12 +121,17 @@ func searchEmbedBlock(embedBlockID, stmt string, excludeIDs []string, headingMod
|
|||
return
|
||||
}
|
||||
|
||||
func SearchRefBlock(id, rootID, keyword string, beforeLen int) (ret []*Block, newDoc bool) {
|
||||
func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets bool) (ret []*Block, newDoc bool) {
|
||||
cachedTrees := map[string]*parse.Tree{}
|
||||
|
||||
onlyDoc := false
|
||||
if isSquareBrackets {
|
||||
onlyDoc = Conf.Editor.OnlySearchForDoc
|
||||
}
|
||||
|
||||
if "" == keyword {
|
||||
// 查询为空时默认的块引排序规则按最近使用优先 https://github.com/siyuan-note/siyuan/issues/3218
|
||||
refs := sql.QueryRefsRecent(Conf.Editor.OnlySearchForDoc)
|
||||
refs := sql.QueryRefsRecent(onlyDoc)
|
||||
for _, ref := range refs {
|
||||
tree := cachedTrees[ref.DefBlockRootID]
|
||||
if nil == tree {
|
||||
|
|
@ -158,7 +163,7 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int) (ret []*Block, ne
|
|||
return
|
||||
}
|
||||
|
||||
ret = fullTextSearchRefBlock(keyword, beforeLen)
|
||||
ret = fullTextSearchRefBlock(keyword, beforeLen, onlyDoc)
|
||||
tmp := ret[:0]
|
||||
for _, b := range ret {
|
||||
tree := cachedTrees[b.RootID]
|
||||
|
|
@ -646,7 +651,7 @@ func removeLimitClause(stmt string) string {
|
|||
return stmt
|
||||
}
|
||||
|
||||
func fullTextSearchRefBlock(keyword string, beforeLen int) (ret []*Block) {
|
||||
func fullTextSearchRefBlock(keyword string, beforeLen int, onlyDoc bool) (ret []*Block) {
|
||||
keyword = gulu.Str.RemoveInvisible(keyword)
|
||||
|
||||
if ast.IsNodeIDPattern(keyword) {
|
||||
|
|
@ -669,7 +674,7 @@ func fullTextSearchRefBlock(keyword string, beforeLen int) (ret []*Block) {
|
|||
"snippet(" + table + ", 11, '" + search.SearchMarkLeft + "', '" + search.SearchMarkRight + "', '...', 64) AS content, " +
|
||||
"fcontent, markdown, length, type, subtype, ial, sort, created, updated"
|
||||
stmt := "SELECT " + projections + " FROM " + table + " WHERE " + table + " MATCH '" + columnFilter() + ":(" + quotedKeyword + ")' AND type"
|
||||
if Conf.Editor.OnlySearchForDoc {
|
||||
if onlyDoc {
|
||||
stmt += " = 'd'"
|
||||
} else {
|
||||
stmt += " IN " + Conf.Search.TypeFilter()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue