Skip to content

Commit

Permalink
Merge pull request #11 from TCOTC/dev
Browse files Browse the repository at this point in the history
🐛 Some emoji exceptions in the document title https://github.com/…
  • Loading branch information
TCOTC authored May 20, 2024
2 parents 105200e + 47f884f commit 2a8c233
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions kernel/model/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 2a8c233

Please sign in to comment.