Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Some emoji exceptions in the document title https://github.com/siyuan-note/siyuan/issues/11480

Daniel47f884f2bbda
diff --git a/kernel/model/file.go b/kernel/model/file.go
index 60301ef00d..e5b73b0276 100644
--- a/kernel/model/file.go
+++ b/kernel/model/file.go
@@ -1666,7 +1666,7 @@ func RenameDoc(boxID, p, title string) (err error) {
return
}
- title = gulu.Str.RemoveInvisible(title)
+ title = removeInvisibleCharsInTitle(title)
if 512 < utf8.RuneCountInString(title) {
// 限制笔记本名和文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299
return errors.New(Conf.Language(106))
@@ -1706,7 +1706,7 @@ func RenameDoc(boxID, p, title string) (err error) {
}
func createDoc(boxID, p, title, dom string) (tree *parse.Tree, err error) {
- title = gulu.Str.RemoveInvisible(title)
+ title = removeInvisibleCharsInTitle(title)
if 512 < utf8.RuneCountInString(title) {
// 限制笔记本名和文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299
err = errors.New(Conf.Language(106))
@@ -1819,6 +1819,14 @@ func createDoc(boxID, p, title, dom string) (tree *parse.Tree, err error) {
return
}
+func removeInvisibleCharsInTitle(title string) string {
+ // 不要踢掉 零宽连字符,否则有的 Emoji 会变形 https://github.com/siyuan-note/siyuan/issues/11480
+ title = strings.ReplaceAll(title, string(gulu.ZWJ), "__@ZWJ@__")
+ title = gulu.Str.RemoveInvisible(title)
+ title = strings.ReplaceAll(title, "__@ZWJ@__", string(gulu.ZWJ))
+ return title
+}
+
func moveSorts(rootID, fromBox, toBox string) {
root := treenode.GetBlockTree(rootID)
if nil == root {