From bbb818eb517293fe76d06982633e8c016408f1c5 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 24 Oct 2022 11:44:46 +0800 Subject: [PATCH 1/6] =?UTF-8?q?:memo:=20=E6=94=AF=E6=8C=81=E9=9D=9E?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=A4=A7=E7=BA=B2=E5=BC=8F=E7=BC=A9=E5=87=BA?= =?UTF-8?q?=20https://github.com/siyuan-note/siyuan/issues/4346?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/appearance/langs/en_US.json | 1 + app/appearance/langs/es_ES.json | 1 + app/appearance/langs/fr_FR.json | 1 + app/appearance/langs/zh_CHT.json | 1 + app/appearance/langs/zh_CN.json | 1 + 5 files changed, 5 insertions(+) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index b21cd93d7..b55fabd20 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -750,6 +750,7 @@ "nameEmpty": "Name is empty", "ordered-list": "Order List", "outdent": "Outdent", + "outdentTip": "After enabling will use the logical outdent of the list outline, move the list item below the parent", "over": "over", "preview": "Export Preview", "quote": "Blockquote", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index 3bdc5275b..d51db1648 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -750,6 +750,7 @@ "nameEmpty": "El nombre está vacío", "ordered-list": "Lista ordenada", "outdent": "anular la sangría", + "outdentTip": "Después de habilitar usará la sangría lógica del esquema de la lista, mueva el elemento de la lista debajo del padre", "over": "sobre", "preview": "Vista previa de la exportación", "quote": "Párrafo cita", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index a589088b0..e4641b322 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -750,6 +750,7 @@ "nameEmpty": "Nom est vide", "ordered-list": "Liste d'ordres", "outdent": "Outdent", + "outdentTip": "Après l'activation, le retrait logique du contour de la liste sera utilisé, déplacez l'élément de la liste sous le parent", "over": "over", "preview": "Aperçu de l'exportation", "quote": "Citation de bloc", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index eb418e1b3..61dc8b829 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -750,6 +750,7 @@ "nameEmpty": "檔案名不能為空", "ordered-list": "有序列表", "outdent": "列表反向縮進", + "outdentTip": "啟用後將使用列表大綱的邏輯式反向縮進,即將列表項移動到父級下方", "over": "超過", "preview": "匯出預覽", "quote": "引述", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index f119641b2..d1a108a0a 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -750,6 +750,7 @@ "nameEmpty": "文件名不能为空", "ordered-list": "有序列表", "outdent": "列表反向缩进", + "outdentTip": "启用后将使用列表大纲的逻辑式反向缩进,即将列表项移动到父级下方", "over": "超过", "preview": "导出预览", "quote": "引述", From d8553c6e2a6a3ae1cc11dd7118856550c47ba97d Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 24 Oct 2022 12:17:21 +0800 Subject: [PATCH 2/6] =?UTF-8?q?:art:=20iframe=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=9F=AD=E7=BD=91=E5=9D=80=E4=BC=9A=E6=89=93=E5=BC=80=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E6=88=96=E8=B7=B3=E8=BD=AC=20APP=20Fix=20htt?= =?UTF-8?q?ps://github.com/siyuan-note/siyuan/issues/6327?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/electron/main.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index 171e58160..c405f6df4 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -86,10 +86,8 @@ try { } } catch (e) { console.error(e) - require('electron'). - dialog. - showErrorBox('创建配置目录失败 Failed to create config directory', - '思源需要在用户家目录下创建配置文件夹(~/.config/siyuan),请确保该路径具有写入权限。\n\nSiYuan needs to create a configuration folder (~/.config/siyuan) in the user\'s home directory. Please make sure that the path has write permissions.') + require('electron').dialog.showErrorBox('创建配置目录失败 Failed to create config directory', + '思源需要在用户家目录下创建配置文件夹(~/.config/siyuan),请确保该路径具有写入权限。\n\nSiYuan needs to create a configuration folder (~/.config/siyuan) in the user\'s home directory. Please make sure that the path has write permissions.') app.exit() } @@ -332,10 +330,19 @@ const boot = () => { if (url.startsWith('http://127.0.0.1:6806')) { return } + console.log("will-navigate", url) event.preventDefault() shell.openExternal(url) }) + // iframe 使用短网址会打开浏览器或跳转 APP https://github.com/siyuan-note/siyuan/issues/6327 + mainWindow.webContents.on('will-redirect', (event, url) => { + if (url.startsWith('http://127.0.0.1:6806')) { + return + } + event.preventDefault() + }) + mainWindow.on('close', (event) => { if (mainWindow && !mainWindow.isDestroyed()) { mainWindow.webContents.send('siyuan-save-close', false) From c9882b29d4741534cf0ef8d29864078f8c6a71c5 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 24 Oct 2022 12:17:54 +0800 Subject: [PATCH 3/6] =?UTF-8?q?:art:=20iframe=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=9F=AD=E7=BD=91=E5=9D=80=E4=BC=9A=E6=89=93=E5=BC=80=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E6=88=96=E8=B7=B3=E8=BD=AC=20APP=20Fix=20htt?= =?UTF-8?q?ps://github.com/siyuan-note/siyuan/issues/6327?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/electron/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/electron/main.js b/app/electron/main.js index c405f6df4..726b46ac6 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -330,7 +330,7 @@ const boot = () => { if (url.startsWith('http://127.0.0.1:6806')) { return } - console.log("will-navigate", url) + event.preventDefault() shell.openExternal(url) }) @@ -340,6 +340,7 @@ const boot = () => { if (url.startsWith('http://127.0.0.1:6806')) { return } + event.preventDefault() }) From 7a99f9078e418b09fbd5396fbdb92594f68c1b66 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 24 Oct 2022 12:56:10 +0800 Subject: [PATCH 4/6] =?UTF-8?q?:art:=20iframe=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=9F=AD=E7=BD=91=E5=9D=80=E4=BC=9A=E6=89=93=E5=BC=80=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E6=88=96=E8=B7=B3=E8=BD=AC=20APP=20Fix=20htt?= =?UTF-8?q?ps://github.com/siyuan-note/siyuan/issues/6327?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/electron/main.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index 726b46ac6..6c4580fa1 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -336,12 +336,15 @@ const boot = () => { }) // iframe 使用短网址会打开浏览器或跳转 APP https://github.com/siyuan-note/siyuan/issues/6327 - mainWindow.webContents.on('will-redirect', (event, url) => { + mainWindow.webContents.on('will-redirect', (event, url, isInPlace, isMainFrame) => { if (url.startsWith('http://127.0.0.1:6806')) { return } - event.preventDefault() + if (!isMainFrame) { + event.preventDefault() + return + } }) mainWindow.on('close', (event) => { From 29a14f722da46b46b1457623d836df1309a025b2 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 24 Oct 2022 12:58:20 +0800 Subject: [PATCH 5/6] =?UTF-8?q?:art:=20iframe=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=9F=AD=E7=BD=91=E5=9D=80=E4=BC=9A=E6=89=93=E5=BC=80=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E6=88=96=E8=B7=B3=E8=BD=AC=20APP=20Fix=20htt?= =?UTF-8?q?ps://github.com/siyuan-note/siyuan/issues/6327?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/electron/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/electron/main.js b/app/electron/main.js index 6c4580fa1..a9860ca6f 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -335,7 +335,7 @@ const boot = () => { shell.openExternal(url) }) - // iframe 使用短网址会打开浏览器或跳转 APP https://github.com/siyuan-note/siyuan/issues/6327 + // IFrame 块不跟随重定向 https://github.com/siyuan-note/siyuan/issues/6327 mainWindow.webContents.on('will-redirect', (event, url, isInPlace, isMainFrame) => { if (url.startsWith('http://127.0.0.1:6806')) { return From 055a8b598155e3914f44faf81cbd763793bb531d Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 24 Oct 2022 17:43:21 +0800 Subject: [PATCH 6/6] =?UTF-8?q?:bug:=20=E7=9F=AD=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=86=85=E5=A4=9A=E6=AC=A1=E4=BF=AE=E6=94=B9=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=9D=97=E6=A0=87=E9=A2=98=E5=90=8E=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E9=94=9A=E6=96=87=E6=9C=AC=E6=B2=A1=E6=9C=89=E8=B7=9F?= =?UTF-8?q?=E9=9A=8F=20Fix=20https://github.com/siyuan-note/siyuan/issues/?= =?UTF-8?q?6330?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/file.go | 29 ++++++++++------------------- kernel/model/transaction.go | 32 +++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/kernel/model/file.go b/kernel/model/file.go index c50d7bc99..f30bd15a2 100644 --- a/kernel/model/file.go +++ b/kernel/model/file.go @@ -1282,6 +1282,15 @@ func RenameDoc(boxID, p, title string) (err error) { title = "Untitled" } + oldHPath := tree.HPath + tree.HPath = path.Join(path.Dir(tree.HPath), title) + tree.Root.SetIALAttr("title", title) + tree.Root.SetIALAttr("updated", util.CurrentTimeSecondsStr()) + + if err = renameWriteJSONQueue(tree, oldHPath); nil != err { + return + } + refText := getNodeRefText(tree.Root) evt := util.NewCmdResult("rename", 0, util.PushModeBroadcast, util.PushModeNone) evt.Data = map[string]interface{}{ @@ -1293,26 +1302,8 @@ func RenameDoc(boxID, p, title string) (err error) { } util.PushEvent(evt) - oldHPath := tree.HPath - tree.HPath = path.Join(path.Dir(tree.HPath), title) - tree.Root.SetIALAttr("title", title) - tree.Root.SetIALAttr("updated", util.CurrentTimeSecondsStr()) - - if err = renameWriteJSONQueue(tree, oldHPath); nil != err { - return - } - box.renameSubTrees(tree) - changedDefs := map[string]*ast.Node{tree.ID: tree.Root} - changedTrees := map[string]*parse.Tree{tree.ID: tree} - - // 引用文档时锚文本没有跟随文档重命名 https://github.com/siyuan-note/siyuan/issues/4193 - // 详见 refreshDynamicRefText 函数实现 - go func() { - sql.WaitForWritingDatabase() - refreshDynamicRefText(changedDefs, changedTrees) - }() - + go updateRefTextRenameDoc(tree) IncSync() return } diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 10bd0b730..3803004d4 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -100,6 +100,7 @@ func isWritingFiles() bool { } func AutoFlushTx() { + go autoFlushUpdateRefTextRenameDoc() for { flushTx() time.Sleep(time.Duration(txDelay) * time.Millisecond) @@ -1060,9 +1061,6 @@ func (tx *Transaction) writeTree(tree *parse.Tree) (err error) { func refreshDynamicRefText(updatedDefNodes map[string]*ast.Node, updatedTrees map[string]*parse.Tree) { // 这个实现依赖了数据库缓存,导致外部调用时可能需要阻塞等待数据库写入后才能获取到 refs - // 比如通过块引创建文档后立即重命名文档,这时引用关系还没有入库,所以重命名查询不到引用关系,最终导致动态锚文本设置失败 - // 引用文档时锚文本没有跟随文档重命名 https://github.com/siyuan-note/siyuan/issues/4193 - // 解决方案是将重命名通过协程异步调用,详见 RenameDoc 函数 treeRefNodeIDs := map[string]*hashset.Set{} for _, updateNode := range updatedDefNodes { @@ -1126,6 +1124,34 @@ func refreshDynamicRefText(updatedDefNodes map[string]*ast.Node, updatedTrees ma } } +var updateRefTextRenameDocs = map[string]*parse.Tree{} +var updateRefTextRenameDocLock = sync.Mutex{} + +func updateRefTextRenameDoc(renamedTree *parse.Tree) { + updateRefTextRenameDocLock.Lock() + updateRefTextRenameDocs[renamedTree.ID] = renamedTree + updateRefTextRenameDocLock.Unlock() +} + +func autoFlushUpdateRefTextRenameDoc() { + for { + sql.WaitForWritingDatabase() + flushUpdateRefTextRenameDoc() + } +} + +func flushUpdateRefTextRenameDoc() { + updateRefTextRenameDocLock.Lock() + defer updateRefTextRenameDocLock.Unlock() + + for _, tree := range updateRefTextRenameDocs { + changedDefs := map[string]*ast.Node{tree.ID: tree.Root} + changedTrees := map[string]*parse.Tree{tree.ID: tree} + refreshDynamicRefText(changedDefs, changedTrees) + } + updateRefTextRenameDocs = map[string]*parse.Tree{} +} + func updateRefText(refNode *ast.Node, changedDefNodes map[string]*ast.Node) (changed bool) { ast.Walk(refNode, func(n *ast.Node, entering bool) ast.WalkStatus { if !entering {