mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-03 22:21:48 +01:00
🎨 嵌入块纳入引用计数和反链 https://github.com/siyuan-note/siyuan/issues/7096
This commit is contained in:
parent
6afa767f01
commit
492aabcf22
8 changed files with 117 additions and 50 deletions
|
|
@ -105,7 +105,7 @@ func ListNotebooks() (ret []*Box, err error) {
|
|||
continue
|
||||
}
|
||||
|
||||
if !util.IsIDPattern(dir.Name()) {
|
||||
if !ast.IsNodeIDPattern(dir.Name()) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
@ -329,7 +329,7 @@ func (box *Box) Move(oldPath, newPath string) error {
|
|||
return errors.New(msg)
|
||||
}
|
||||
|
||||
if oldDir := path.Dir(oldPath); util.IsIDPattern(path.Base(oldDir)) {
|
||||
if oldDir := path.Dir(oldPath); ast.IsNodeIDPattern(path.Base(oldDir)) {
|
||||
fromDir := filepath.Join(boxLocalPath, oldDir)
|
||||
if util.IsEmptyDir(fromDir) {
|
||||
filelock.Remove(fromDir)
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ func ListDocTree(boxID, path string, sortMode int) (ret []*File, totals int, err
|
|||
var docs []*File
|
||||
for _, file := range files {
|
||||
if file.isdir {
|
||||
if !util.IsIDPattern(file.name) {
|
||||
if !ast.IsNodeIDPattern(file.name) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ package model
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
"math"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
|
@ -27,6 +25,7 @@ import (
|
|||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/html"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
|
|
@ -690,7 +689,7 @@ func nodeTitleLabel(node *GraphNode, blockContent string) {
|
|||
|
||||
func query2Stmt(queryStr string) (ret string) {
|
||||
buf := bytes.Buffer{}
|
||||
if util.IsIDPattern(queryStr) {
|
||||
if ast.IsNodeIDPattern(queryStr) {
|
||||
buf.WriteString("id = '" + queryStr + "'")
|
||||
} else {
|
||||
var tags []string
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
if info.IsDir() && util.IsIDPattern(info.Name()) {
|
||||
if info.IsDir() && ast.IsNodeIDPattern(info.Name()) {
|
||||
renamePaths[path] = path
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -534,7 +534,7 @@ func searchBySQL(stmt string, beforeLen int) (ret []*Block, matchedBlockCount, m
|
|||
func fullTextSearchRefBlock(keyword string, beforeLen int) (ret []*Block) {
|
||||
keyword = gulu.Str.RemoveInvisible(keyword)
|
||||
|
||||
if util.IsIDPattern(keyword) {
|
||||
if ast.IsNodeIDPattern(keyword) {
|
||||
ret, _, _ = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+keyword+"'", 36)
|
||||
return
|
||||
}
|
||||
|
|
@ -581,7 +581,7 @@ func fullTextSearchRefBlock(keyword string, beforeLen int) (ret []*Block) {
|
|||
|
||||
func fullTextSearchByQuerySyntax(query, boxFilter, pathFilter, typeFilter, orderBy string, beforeLen int) (ret []*Block, matchedBlockCount, matchedRootCount int) {
|
||||
query = gulu.Str.RemoveInvisible(query)
|
||||
if util.IsIDPattern(query) {
|
||||
if ast.IsNodeIDPattern(query) {
|
||||
ret, matchedBlockCount, matchedRootCount = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+query+"'", beforeLen)
|
||||
return
|
||||
}
|
||||
|
|
@ -590,7 +590,7 @@ func fullTextSearchByQuerySyntax(query, boxFilter, pathFilter, typeFilter, order
|
|||
|
||||
func fullTextSearchByKeyword(query, boxFilter, pathFilter, typeFilter string, orderBy string, beforeLen int) (ret []*Block, matchedBlockCount, matchedRootCount int) {
|
||||
query = gulu.Str.RemoveInvisible(query)
|
||||
if util.IsIDPattern(query) {
|
||||
if ast.IsNodeIDPattern(query) {
|
||||
ret, matchedBlockCount, matchedRootCount = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+query+"'", beforeLen)
|
||||
return
|
||||
}
|
||||
|
|
@ -660,7 +660,7 @@ func fullTextSearchByFTS(query, boxFilter, pathFilter, typeFilter, orderBy strin
|
|||
|
||||
func fullTextSearchCount(query, boxFilter, pathFilter, typeFilter string) (matchedBlockCount, matchedRootCount int) {
|
||||
query = gulu.Str.RemoveInvisible(query)
|
||||
if util.IsIDPattern(query) {
|
||||
if ast.IsNodeIDPattern(query) {
|
||||
ret, _ := sql.Query("SELECT COUNT(id) AS `matches`, COUNT(DISTINCT(root_id)) AS `docs` FROM `blocks` WHERE `id` = '" + query + "'")
|
||||
if 1 > len(ret) {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue