diff --git a/app/src/mobile/util/mobileAppUtil.ts b/app/src/mobile/util/mobileAppUtil.ts index 12b88891c..4128b6e8c 100644 --- a/app/src/mobile/util/mobileAppUtil.ts +++ b/app/src/mobile/util/mobileAppUtil.ts @@ -4,8 +4,8 @@ export let keyboardLockUntil = 0; export const callMobileAppShowKeyboard = () => { // 某些机型(比如鸿蒙 Pura X)在弹起键盘后会立即触发 activeBlur 导致键盘被关闭,所以在主动唤起键盘时锁定一段时间,禁止 activeBlur 关闭键盘 - // 每次主动唤起键盘时,锁定接下来的 200ms 不允许通过 activeBlur 关闭 - keyboardLockUntil = Date.now() + 200; + // 每次主动唤起键盘时,锁定接下来的 500ms 不允许通过 activeBlur 关闭 + keyboardLockUntil = Date.now() + 500; if (window.JSAndroid && window.JSAndroid.showKeyboard) { window.JSAndroid.showKeyboard(); diff --git a/kernel/av/filter.go b/kernel/av/filter.go index 52d185f81..16fe4df4d 100644 --- a/kernel/av/filter.go +++ b/kernel/av/filter.go @@ -978,10 +978,10 @@ func calcRelativeTimeRegion(count int, unit RelativeDateUnit, direction Relative // 结束时间:本周的周日 end = time.Date(now.Year(), now.Month(), now.Day()-weekday+7, 23, 59, 59, 999999999, now.Location()) case RelativeDateDirectionAfter: - // 开始时间:本周的周日 - start = time.Date(now.Year(), now.Month(), now.Day()-weekday+7, 23, 59, 59, 999999999, now.Location()) - // 结束时间:开始时间加上 count*7 天 - end = start.AddDate(0, 0, count*7) + // 开始时间:本周的周一加上 count*7 天 + start = time.Date(now.Year(), now.Month(), now.Day()-weekday+1, 0, 0, 0, 0, now.Location()).AddDate(0, 0, count*7) + // 结束时间:开始时间的周日 + end = time.Date(start.Year(), start.Month(), start.Day()-int(start.Weekday())+7, 23, 59, 59, 999999999, now.Location()) } case RelativeDateUnitMonth: switch direction { @@ -996,10 +996,10 @@ func calcRelativeTimeRegion(count int, unit RelativeDateUnit, direction Relative // 结束时间:下个月的 1 号减去 1 纳秒 end = time.Date(now.Year(), now.Month()+1, 1, 0, 0, 0, 0, now.Location()).Add(-time.Nanosecond) case RelativeDateDirectionAfter: - // 开始时间:下个月的 1 号减去 1 纳秒 - start = time.Date(now.Year(), now.Month()+1, 1, 0, 0, 0, 0, now.Location()).Add(-time.Nanosecond) - // 结束时间:开始时间加上 count 个月 - end = start.AddDate(0, count, 0) + // 开始时间:count 个月后的 1 号 + start = time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location()).AddDate(0, count, 0) + // 结束时间:开始时间的下个月的 1 号减去 1 纳秒 + end = time.Date(start.Year(), start.Month()+1, 1, 0, 0, 0, 0, now.Location()).Add(-time.Nanosecond) } case RelativeDateUnitYear: switch direction { @@ -1014,10 +1014,10 @@ func calcRelativeTimeRegion(count int, unit RelativeDateUnit, direction Relative // 结束时间:明年的 1 月 1 号减去 1 纳秒 end = time.Date(now.Year()+1, 1, 1, 0, 0, 0, 0, now.Location()).Add(-time.Nanosecond) case RelativeDateDirectionAfter: - // 开始时间:今年的 12 月 31 号 - start = time.Date(now.Year(), 12, 31, 23, 59, 59, 999999999, now.Location()) - // 结束时间:开始时间加上 count 年 - end = start.AddDate(count, 0, 0) + // 开始时间:count 年后的 1 月 1 号 + start = time.Date(now.Year(), 1, 1, 0, 0, 0, 0, now.Location()).AddDate(count, 0, 0) + // 结束时间:开始时间的 count+1 年的 1 月 1 号减去 1 纳秒 + end = time.Date(start.Year()+1, 1, 1, 0, 0, 0, 0, now.Location()).Add(-time.Nanosecond) } } return diff --git a/kernel/go.mod b/kernel/go.mod index 23808b9a1..e239eeacd 100644 --- a/kernel/go.mod +++ b/kernel/go.mod @@ -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.20260124101918-98654a7ca98a - github.com/88250/lute v1.7.7-0.20260223100631-acdd6c2153d9 + github.com/88250/lute v1.7.7-0.20260225092249-74bb97dab3e6 github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4 github.com/ConradIrwin/font v0.2.1 diff --git a/kernel/go.sum b/kernel/go.sum index 8a46c9e1f..560136545 100644 --- a/kernel/go.sum +++ b/kernel/go.sum @@ -14,8 +14,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.20260124101918-98654a7ca98a h1:s86WMolaqommXG1k2vXg9Gf1iXvgtHSdeD0eeJTQVR8= github.com/88250/gulu v1.2.3-0.20260124101918-98654a7ca98a/go.mod h1:D+Db16m0N7r9MLZCMcj1a0ZsEGQAxDZkadOn79Gh0vI= -github.com/88250/lute v1.7.7-0.20260223100631-acdd6c2153d9 h1:QWE7YZH8TDC8ULDRuEOfpcrRpQExjIVsDaCkpaUBPkY= -github.com/88250/lute v1.7.7-0.20260223100631-acdd6c2153d9/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o= +github.com/88250/lute v1.7.7-0.20260225092249-74bb97dab3e6 h1:4MrqDppSGkgymxYMmkmlZOHNF0SCbDsLPJYULJJJHME= +github.com/88250/lute v1.7.7-0.20260225092249-74bb97dab3e6/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o= github.com/88250/pdfcpu v0.3.14-0.20250424122812-f10e8d9d8d46 h1:Bq1JsDfVbHKUxNL/B2JXd8cC/1h6aFjrlXpGycnh0Hk= github.com/88250/pdfcpu v0.3.14-0.20250424122812-f10e8d9d8d46/go.mod h1:fVfOloBzs2+W2VJCCbq60XIxc3yJHAZ0Gahv1oO0gyI= github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY= diff --git a/kernel/model/block.go b/kernel/model/block.go index 557045451..5871eb744 100644 --- a/kernel/model/block.go +++ b/kernel/model/block.go @@ -1015,58 +1015,42 @@ func GetBlockKramdown(id, mode string) (ret string) { return } - addBlockIALNodes(tree, false) - node := treenode.GetNodeInTree(tree, id) - root := &ast.Node{Type: ast.NodeDocument} - root.AppendChild(node.Next) // IAL - root.PrependChild(node) luteEngine := NewLute() - if "md" == mode { - // `/api/block/getBlockKramdown` link/image URLs are no longer encoded with spaces https://github.com/siyuan-note/siyuan/issues/15611 - luteEngine.SetPreventEncodeLinkSpace(true) - - ret = treenode.ExportNodeStdMd(root, luteEngine) - } else { - tree.Root = root - formatRenderer := render.NewFormatRenderer(tree, luteEngine.RenderOptions, luteEngine.ParseOptions) - ret = string(formatRenderer.Render()) - } - return + return getBlockKramdown0(tree, id, mode, luteEngine) } func GetBlockKramdowns(ids []string, mode string) (ret map[string]string) { - ret = map[string]string{} + ret = make(map[string]string, len(ids)) if 0 == len(ids) { return } luteEngine := NewLute() + for _, id := range ids { + // 节点会被移走,tree 不能共享,需重新加载 + tree, err := LoadTreeByBlockID(id) + if err != nil { + continue + } + ret[id] = getBlockKramdown0(tree, id, mode, luteEngine) + } + return +} + +func getBlockKramdown0(tree *parse.Tree, id, mode string, luteEngine *lute.Lute) (ret string) { + addBlockIALNodes(tree, false) + node := treenode.GetNodeInTree(tree, id) + root := &ast.Node{Type: ast.NodeDocument} + root.AppendChild(node.Next) // IAL + root.PrependChild(node) if "md" == mode { // `/api/block/getBlockKramdown` link/image URLs are no longer encoded with spaces https://github.com/siyuan-note/siyuan/issues/15611 luteEngine.SetPreventEncodeLinkSpace(true) - } - - trees := filesys.LoadTrees(ids) - for id, tree := range trees { - node := treenode.GetNodeInTree(tree, id) - if nil == node { - continue - } - - addBlockIALNodes(tree, false) - root := &ast.Node{Type: ast.NodeDocument} - root.AppendChild(node.Next) // IAL - root.PrependChild(node) - - var kramdown string - if "md" == mode { - kramdown = treenode.ExportNodeStdMd(root, luteEngine) - } else { - tree.Root = root - formatRenderer := render.NewFormatRenderer(tree, luteEngine.RenderOptions, luteEngine.ParseOptions) - kramdown = string(formatRenderer.Render()) - } - ret[id] = kramdown + ret = treenode.ExportNodeStdMd(root, luteEngine) + } else { + tree.Root = root + formatRenderer := render.NewFormatRenderer(tree, luteEngine.RenderOptions, luteEngine.ParseOptions) + ret = string(formatRenderer.Render()) } return }