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

This commit is contained in:
Daniel 2024-05-20 23:21:59 +08:00
parent ffddff7436
commit 47f884f2bb
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -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 {