Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Jun 23, 2024
2 parents ff8d2ac + 18ea513 commit d37f03f
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 32 deletions.
2 changes: 1 addition & 1 deletion app/appearance/langs/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@
"239": "Related operations are being processed, please try again later",
"240": "The current drag-and-drop heading is located in the container block and the drag-and-drop operation cannot be performed",
"241": "Drag to its subheading is not supported",
"242": "The binding block already exists in the current database",
"242": "TODO",
"243": "Only list the first [%d] tags (including subtags), if you need to adjust, please modify [Settings - Doc Tree - Maximum number to list]",
"244": "It did not exit normally after the last use. It is recommended to execute [Doc Tree - Rebuild Index]. In the future, please exit the program completely before shutting down the computer",
"245": "It did not exit normally after the last use. It is recommended to execute [Doc Tree - Rebuild Index]. In the future, please use [Exit Application] in the right panel to exit normally",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@
"239": "Las operaciones relacionadas se están procesando, inténtalo de nuevo más tarde",
"240": "El encabezado actual de arrastrar y soltar está ubicado en el bloque contenedor y la operación de arrastrar y soltar no se puede realizar",
"241": "No se admite arrastrar a su subtítulo",
"242": "El bloque de enlace ya existe en la base de datos actual",
"242": "TODO",
"243": "Enumere solo las primeras [%d] etiquetas (incluidas las subetiquetas), modifique [Configuración - Árbol de documentos - Número máximo a listar]",
"244": "No salió normalmente después del último uso. Se recomienda ejecutar [Árbol de documentos - Reconstruir índice]. En el futuro, salga del programa por completo antes de apagar la computadora",
"245": "No salió normalmente después del último uso. Se recomienda ejecutar [Árbol de documentos - Reconstruir índice]. En el futuro, utilice [Salir de la aplicación] en el panel derecho para salir normalmente",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@
"239": "Les opérations associées sont en cours de traitement, veuillez réessayer plus tard",
"240": "L'en-tête du glisser-déposer actuel se trouve dans le bloc conteneur et l'opération de glisser-déposer ne peut pas être effectuée",
"241": "Le glisser vers son sous-titre n'est pas pris en charge",
"242": "Le bloc de liaison existe déjà dans la base de données actuelle",
"242": "TODO",
"243": "Répertorier uniquement les [%d] premières balises (y compris les sous-balises). veuillez modifier [Paramètres - Arbre des documents - Nombre maximum de documents à lister].",
"244": "Il ne s'est pas terminé normalement après la dernière utilisation. Il est recommandé d'exécuter [Doc Tree - Reconstruire l'index]. À l'avenir, veuillez quitter complètement le programme avant d'éteindre l'ordinateur",
"245": "Il ne s'est pas terminé normalement après la dernière utilisation. Il est recommandé d'exécuter [Doc Tree - Reconstruire l'index]. À l'avenir, veuillez utiliser [Quitter l'application] dans le panneau de droite pour quitter normalement",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@
"239": "関連する操作が処理中です。後でまた試してください",
"240": "コンテナブロック内の見出しは移動できません",
"241": "小見出しへのドラッグはサポートされていません",
"242": "現在のデータベースにはすでにバインディングブロックが存在します",
"242": "TODO",
"243": "最初の [%d] 個のタグ (サブタグを含む) のみを表示します。調整が必要な場合は [設定] - [ドキュメントツリー] - [リストする最大数] を変更してください",
"244": "前回の使用後に正常に終了しませんでした。[ドキュメントツリー] - [インデックスの再構築] を実行することをお勧めします。今後はコンピュータをシャットダウンする前にプログラムを完全に終了してください",
"245": "前回の使用後に正常に終了しませんでした。[ドキュメントツリー] - [インデックスの再構築] を実行することをお勧めします。今後は右パネルの [アプリケーションの終了] を使用して終了してください",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/zh_CHT.json
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@
"239": "相關操作正在處理中,請稍後再試",
"240": "目前拖曳標題位於容器區塊中,無法進行拖曳操作",
"241": "不支持拖曳為自己的子標題",
"242": "目前資料庫中已經存在該綁定區塊",
"242": "TODO",
"243": "僅列出前 [%d] 個標籤(含子標籤),如需調整請修改 [設置 - 文檔樹 - 最大列出數量]",
"244": "上次使用後未正常退出,建議執行一次 [文檔樹 - 重建索引]。以後請完整退出程式後再關閉電腦",
"245": "上次使用後未正常退出,建議執行一次 [文檔樹 - 重建索引]。以後請使用右側欄面板中的 [退出應用] 進行正常退出",
Expand Down
2 changes: 1 addition & 1 deletion app/appearance/langs/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@
"239": "相关操作正在处理中,请稍后再试",
"240": "当前拖拽标题位于容器块中,无法进行拖拽操作",
"241": "不支持拖拽为自己的子标题",
"242": "当前数据库中已经存在该绑定块",
"242": "TODO",
"243": "仅列出前 [%d] 个标签(含子标签),如需调整请修改 [设置 - 文档树 - 最大列出数量]",
"244": "上次使用后未正常退出,建议执行一次 [文档树 - 重建索引]。以后请完整退出程序后再关闭电脑",
"245": "上次使用后未正常退出,建议执行一次 [文档树 - 重建索引]。以后请使用右侧栏面板中的 [退出应用] 进行正常退出",
Expand Down
2 changes: 1 addition & 1 deletion app/stage/protyle/js/lute/lute.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion kernel/api/notebook.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func openNotebook(c *gin.Context) {
"20240530133126-axarxgx": "20240530101000-4qitucx",
}
startID = guideStartID[notebook]
if nil != treenode.GetBlockTree(startID) {
if treenode.ExistBlockTree(startID) {
util.BroadcastByTypeAndApp("main", app, "openFileById", 0, "", map[string]interface{}{
"id": startID,
})
Expand Down
2 changes: 1 addition & 1 deletion kernel/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48
github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7
github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02
github.com/88250/lute v1.7.7-0.20240622011733-13f09e554802
github.com/88250/lute v1.7.7-0.20240623095026-370d2de2cd5e
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4
Expand Down
4 changes: 2 additions & 2 deletions kernel/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950 h1:Pa5hMiBceT
github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02 h1:3e5+yobj655pTeKOYMbJrnc1mE51ZkbXIxquTYZuYCY=
github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02/go.mod h1:MUfzyfmbPrRDZLqxc7aPrVYveatTHRfoUa5TynPS0i8=
github.com/88250/lute v1.7.7-0.20240622011733-13f09e554802 h1:rNntwekmFfGagGzHpGiLWkB0ebXGbUYXC1ulAXSoTA4=
github.com/88250/lute v1.7.7-0.20240622011733-13f09e554802/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk=
github.com/88250/lute v1.7.7-0.20240623095026-370d2de2cd5e h1:Vy7xpd4b9OQ5xtCqa6keGu8bL8sTAs+hGfG/Z4riZBo=
github.com/88250/lute v1.7.7-0.20240623095026-370d2de2cd5e/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk=
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c h1:Dl/8S9iLyPMTElnWIBxmjaLiWrkI5P4a21ivwAn5pU0=
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=
Expand Down
17 changes: 12 additions & 5 deletions kernel/model/attribute_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func GetAttributeViewPrimaryKeyValues(avID, keyword string, page, pageSize int)
switch view.LayoutType {
case av.LayoutTypeTable:
if !kv.IsDetached {
if nil == treenode.GetBlockTree(kv.BlockID) {
if !treenode.ExistBlockTree(kv.BlockID) {
break
}
}
Expand Down Expand Up @@ -2826,16 +2826,23 @@ func replaceAttributeViewBlock(operation *Operation, tx *Transaction) (err error
}

var node *ast.Node
var tree *parse.Tree
if !operation.IsDetached {
node, _, _ = getNodeByBlockID(tx, operation.NextID)
node, tree, _ = getNodeByBlockID(tx, operation.NextID)
}

// 检查是否已经存在绑定块
// Improve database primary key binding block https://github.com/siyuan-note/siyuan/issues/10945
now := util.CurrentTimeMillis()
// 检查是否已经存在绑定块,如果存在的话则重新绑定
for _, keyValues := range attrView.KeyValues {
for _, value := range keyValues.Values {
if value.BlockID == operation.NextID {
util.PushMsg(Conf.language(242), 3000)
if !operation.IsDetached {
bindBlockAv0(tx, operation.AvID, node, tree)
value.IsDetached = false
value.Block.Content = getNodeRefText(node)
value.UpdatedAt = now
err = av.SaveAttributeView(attrView)
}
return
}
}
Expand Down
6 changes: 3 additions & 3 deletions kernel/model/blockinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ func GetDocInfo(blockID string) (ret *BlockInfo) {
delete(ret.IAL, "scroll")
} else {
if zoomInId := scroll["zoomInId"]; nil != zoomInId {
if nil == treenode.GetBlockTree(zoomInId.(string)) {
if !treenode.ExistBlockTree(zoomInId.(string)) {
delete(ret.IAL, "scroll")
}
} else {
if startId := scroll["startId"]; nil != startId {
if nil == treenode.GetBlockTree(startId.(string)) {
if !treenode.ExistBlockTree(startId.(string)) {
delete(ret.IAL, "scroll")
}
}
if endId := scroll["endId"]; nil != endId {
if nil == treenode.GetBlockTree(endId.(string)) {
if !treenode.ExistBlockTree(endId.(string)) {
delete(ret.IAL, "scroll")
}
}
Expand Down
2 changes: 1 addition & 1 deletion kernel/model/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s
luteEngine.RenderOptions.NodeIndexStart = index
dom = luteEngine.Tree2BlockDOM(subTree, luteEngine.RenderOptions)

SetRecentDocByTree(tree)
go setRecentDocByTree(tree)
return
}

Expand Down
2 changes: 1 addition & 1 deletion kernel/model/flashcard.go
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ func getDeckDueCards(deck *riff.Deck, reviewedCardIDs, blockIDs []string, newCar
continue
}

if nil == treenode.GetBlockTree(c.BlockID()) {
if !treenode.ExistBlockTree(c.BlockID()) {
continue
}

Expand Down
14 changes: 5 additions & 9 deletions kernel/model/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,13 @@ func RemoveRecentDoc(ids []string) {
return
}

func SetRecentDocByTree(tree *parse.Tree) {
func setRecentDocByTree(tree *parse.Tree) {
recentDoc := &RecentDoc{
RootID: tree.Root.ID,
Icon: tree.Root.IALAttr("icon"),
Title: tree.Root.IALAttr("title"),
}

SetRecentDoc(recentDoc)
}

func SetRecentDoc(doc *RecentDoc) (err error) {
recentDocLock.Lock()
defer recentDocLock.Unlock()

Expand All @@ -83,13 +79,13 @@ func SetRecentDoc(doc *RecentDoc) (err error) {
}

for i, c := range recentDocs {
if c.RootID == doc.RootID {
if c.RootID == recentDoc.RootID {
recentDocs = append(recentDocs[:i], recentDocs[i+1:]...)
break
}
}

recentDocs = append([]*RecentDoc{doc}, recentDocs...)
recentDocs = append([]*RecentDoc{recentDoc}, recentDocs...)
if 32 < len(recentDocs) {
recentDocs = recentDocs[:32]
}
Expand Down Expand Up @@ -161,10 +157,10 @@ func getRecentDocs() (ret []*RecentDoc, err error) {

type Criterion struct {
Name string `json:"name"`
Sort int `json:"sort"` // 0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时)
Sort int `json:"sort"` // 0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时)
Group int `json:"group"` // 0:不分组,1:按文档分组
HasReplace bool `json:"hasReplace"` // 是否有替换
Method int `json:"method"` // 0:文本,1:查询语法,2:SQL,3:正则表达式
Method int `json:"method"` // 0:文本,1:查询语法,2:SQL,3:正则表达式
HPath string `json:"hPath"`
IDPath []string `json:"idPath"`
K string `json:"k"` // 搜索关键字
Expand Down
7 changes: 6 additions & 1 deletion kernel/sql/av.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func RenderAttributeViewTable(attrView *av.AttributeView, view *av.View, query s

// 过滤掉不存在的行
var notFound []string
var toCheckBlockIDs []string
for blockID, keyValues := range rows {
blockValue := getRowBlockValue(keyValues)
if nil == blockValue {
Expand All @@ -127,7 +128,11 @@ func RenderAttributeViewTable(attrView *av.AttributeView, view *av.View, query s
continue
}

if nil == treenode.GetBlockTree(blockID) {
toCheckBlockIDs = append(toCheckBlockIDs, blockID)
}
checkRet := treenode.ExistBlockTrees(toCheckBlockIDs)
for blockID, exist := range checkRet {
if !exist {
notFound = append(notFound, blockID)
}
}
Expand Down
24 changes: 24 additions & 0 deletions kernel/treenode/blocktree.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,30 @@ func ExistBlockTree(id string) bool {
return 0 < count
}

func ExistBlockTrees(ids []string) (ret map[string]bool) {
ret = map[string]bool{}
for _, id := range ids {
ret[id] = false
}

sqlStmt := "SELECT id FROM blocktrees WHERE id IN ('" + strings.Join(ids, "','") + "')"
rows, err := db.Query(sqlStmt)
if nil != err {
logging.LogErrorf("sql query [%s] failed: %s", sqlStmt, err)
return
}
defer rows.Close()
for rows.Next() {
var id string
if err = rows.Scan(&id); nil != err {
logging.LogErrorf("query scan field failed: %s", err)
return
}
ret[id] = true
}
return
}

func GetBlockTrees(ids []string) (ret map[string]*BlockTree) {
ret = map[string]*BlockTree{}
sqlStmt := "SELECT * FROM blocktrees WHERE id IN ('" + strings.Join(ids, "','") + "')"
Expand Down
3 changes: 2 additions & 1 deletion kernel/util/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ func isKnownCloudDrivePath(workspaceAbsPath string) bool {
workspaceAbsPathLower := strings.ToLower(workspaceAbsPath)
return strings.Contains(workspaceAbsPathLower, "onedrive") || strings.Contains(workspaceAbsPathLower, "dropbox") ||
strings.Contains(workspaceAbsPathLower, "google drive") || strings.Contains(workspaceAbsPathLower, "pcloud") ||
strings.Contains(workspaceAbsPathLower, "坚果云")
strings.Contains(workspaceAbsPathLower, "坚果云") ||
strings.Contains(workspaceAbsPathLower, "天翼云")
}

func isICloudPath(workspaceAbsPath string) (ret bool) {
Expand Down

0 comments on commit d37f03f

Please sign in to comment.