Skip to content

Commit

Permalink
Merge pull request #16 from TCOTC/dev
Browse files Browse the repository at this point in the history
1
  • Loading branch information
TCOTC authored Jun 23, 2024
2 parents d9b7640 + d37f03f commit 2da4946
Show file tree
Hide file tree
Showing 25 changed files with 101 additions and 45 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
7 changes: 4 additions & 3 deletions app/src/ai/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
focusByRange(protyle.toolbar.range);
});
let customHTML = "";
window.siyuan.storage[Constants.LOCAL_AI].forEach((item: { name: string, memo: string }) => {
customHTML += `<div data-action="${item.memo || item.name}" class="b3-list-item b3-list-item--narrow ariaLabel" aria-label="${escapeAriaLabel(item.memo)}">
window.siyuan.storage[Constants.LOCAL_AI].forEach((item: { name: string, memo: string }, index: number) => {
customHTML += `<div data-action="${item.memo || item.name}" data-index="${index}" class="b3-list-item b3-list-item--narrow ariaLabel" aria-label="${escapeAriaLabel(item.memo)}">
<span class="b3-list-item__text">${escapeHtml(item.name)}</span>
<span data-type="edit" class="b3-list-item__action"><svg><use xlink:href="#iconEdit"></use></svg></span>
</div>`;
Expand Down Expand Up @@ -251,7 +251,8 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
let target = event.target as HTMLElement;
while (target && !target.isSameNode(element)) {
if (target.classList.contains("b3-list-item__action")) {
editDialog(target.previousElementSibling.textContent, target.parentElement.getAttribute("aria-label"));
const subItem = window.siyuan.storage[Constants.LOCAL_AI][target.parentElement.dataset.index]
editDialog(subItem.name, subItem.memo);
menu.close();
event.stopPropagation();
event.preventDefault();
Expand Down
6 changes: 6 additions & 0 deletions app/src/layout/dock/Graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ export class Graph extends Model {
this.searchGraph(false, undefined, true);
} else if (dataType === "fullscreen") {
fullscreen(this.element, target);
const minElement = this.element.querySelector('.block__icons .block__icon[data-type="min"]')
if (this.element.className.includes("fullscreen")) {
minElement.classList.add("fn__none")
} else {
minElement.classList.remove("fn__none")
}
}
break;
} else if (target.classList.contains("graph__svg")) {
Expand Down
9 changes: 6 additions & 3 deletions app/src/layout/dock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,12 @@ export class Dock {
}

public hideDock(reset = false) {
if (!reset && (this.layout.element.style.opacity === "0" || this.pin) ||
this.layout.element.querySelector(".fullscreen") // 关系图全屏不应该退出
) {
if (!reset && (this.layout.element.style.opacity === "0" || this.pin)) {
return;
}
// 关系图全屏不应该退出 & https://github.com/siyuan-note/siyuan/issues/11775
const fullscreenElement = this.layout.element.querySelector(".fullscreen")
if (fullscreenElement && fullscreenElement.clientHeight > 0) {
return;
}
// https://github.com/siyuan-note/siyuan/issues/7504
Expand Down
7 changes: 4 additions & 3 deletions app/src/protyle/util/paste.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ export const pasteEscaped = async (protyle: IProtyle, nodeElement: Element) => {
.replace(/\^/g, "\\^")
.replace(/\|/g, "\\|")
.replace(/\./g, "\\.");
pasteText(protyle, clipText, nodeElement);
// 转义文本不能使用 DOM 结构 https://github.com/siyuan-note/siyuan/issues/11778
pasteText(protyle, clipText, nodeElement, false);
} catch (e) {
console.log(e);
}
Expand Down Expand Up @@ -178,7 +179,7 @@ export const pasteAsPlainText = async (protyle: IProtyle) => {
}
};

export const pasteText = (protyle: IProtyle, textPlain: string, nodeElement: Element) => {
export const pasteText = (protyle: IProtyle, textPlain: string, nodeElement: Element, toBlockDOM = true) => {
const range = getEditorRange(protyle.wysiwyg.element);
if (nodeElement.getAttribute("data-type") === "NodeCodeBlock") {
// 粘贴在代码位置
Expand All @@ -197,7 +198,7 @@ export const pasteText = (protyle: IProtyle, textPlain: string, nodeElement: Ele
}
}
}
insertHTML(protyle.lute.Md2BlockDOM(textPlain), protyle, false, false, true);
insertHTML(toBlockDOM ? protyle.lute.Md2BlockDOM(textPlain) : textPlain, protyle, false, false, true);

blockRender(protyle, protyle.wysiwyg.element);
processRender(protyle.wysiwyg.element);
Expand Down
8 changes: 6 additions & 2 deletions app/src/protyle/wysiwyg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
hasClosestBlock,
hasClosestByAttribute,
hasClosestByClassName,
hasClosestByMatchTag,
hasClosestByMatchTag, hasTopClosestByAttribute,
hasTopClosestByClassName,
} from "../util/hasClosest";
import {
Expand Down Expand Up @@ -1327,7 +1327,11 @@ export class WYSIWYG {
event.preventDefault();
return;
}

// https://github.com/siyuan-note/siyuan/issues/11793
const embedElement = hasTopClosestByAttribute(nodeElement.parentElement, "data-type", "NodeBlockQueryEmbed");
if (embedElement) {
nodeElement = embedElement;
}
event.stopPropagation();
event.preventDefault();
const selectImgElement = nodeElement.querySelector(".img--select");
Expand Down
8 changes: 8 additions & 0 deletions app/src/protyle/wysiwyg/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,14 @@ export const transaction = (protyle: IProtyle, doOperations: IOperation[], undoO
transactionsTimeout = window.setTimeout(() => {
promiseTransaction();
}, Constants.TIMEOUT_INPUT * 2);

// 插入块后会导致高度变化,从而产生再次定位 https://github.com/siyuan-note/siyuan/issues/11798
doOperations.find(item => {
if (item.action === "insert") {
protyle.observerLoad.disconnect()
return true;
}
})
};

export const updateTransaction = (protyle: IProtyle, id: string, newHTML: string, html: string) => {
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
4 changes: 2 additions & 2 deletions kernel/av/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ func NewFormattedValueDate(content, content2 int64, format DateFormat, isNotTime
Content: content,
Content2: content2,
HasEndDate: false,
IsNotTime: true,
IsNotTime: isNotTime,
FormattedContent: formatted,
}
return
Expand Down Expand Up @@ -535,7 +535,7 @@ func NewFormattedValueDate(content, content2 int64, format DateFormat, isNotTime
IsNotEmpty: true,
IsNotEmpty2: !content2Time.IsZero(),
HasEndDate: hasEndDate,
IsNotTime: true,
IsNotTime: isNotTime,
FormattedContent: formatted,
}
return
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.20240620040258-d71a0f3c0c8b
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.20240620040258-d71a0f3c0c8b h1:xNFiG33DopwSzL9WYoCvM6ZA5qkfSHpIRhneDkhGJio=
github.com/88250/lute v1.7.7-0.20240620040258-d71a0f3c0c8b/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
Loading

0 comments on commit 2da4946

Please sign in to comment.