mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 10:00:13 +01:00
🎨 Limit the database title to 256 characters https://github.com/siyuan-note/siyuan/issues/15459
This commit is contained in:
parent
3d9b0bfa6f
commit
0d3a2479cb
2 changed files with 13 additions and 0 deletions
|
|
@ -2922,6 +2922,10 @@ func (tx *Transaction) setAttributeViewName(operation *Operation) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
attrView.Name = strings.TrimSpace(operation.Data.(string))
|
attrView.Name = strings.TrimSpace(operation.Data.(string))
|
||||||
|
attrView.Name = strings.ReplaceAll(attrView.Name, "\n", " ")
|
||||||
|
if 256 < len(attrView.Name) {
|
||||||
|
attrView.Name = gulu.Str.SubStr(attrView.Name, 256)
|
||||||
|
}
|
||||||
err = av.SaveAttributeView(attrView)
|
err = av.SaveAttributeView(attrView)
|
||||||
|
|
||||||
_, nodes := tx.getAttrViewBoundNodes(attrView)
|
_, nodes := tx.getAttrViewBoundNodes(attrView)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,9 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/88250/gulu"
|
"github.com/88250/gulu"
|
||||||
"github.com/88250/lute/ast"
|
"github.com/88250/lute/ast"
|
||||||
|
|
@ -93,6 +95,13 @@ func checkAttrView(attrView *av.AttributeView, view *av.View) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 截断超长的数据库标题 Limit the database title to 256 characters https://github.com/siyuan-note/siyuan/issues/15459
|
||||||
|
if 256 < utf8.RuneCountInString(attrView.Name) {
|
||||||
|
attrView.Name = strings.ReplaceAll(attrView.Name, "\n", " ")
|
||||||
|
attrView.Name = gulu.Str.SubStr(attrView.Name, 256)
|
||||||
|
changed = true
|
||||||
|
}
|
||||||
|
|
||||||
if changed {
|
if changed {
|
||||||
av.SaveAttributeView(attrView)
|
av.SaveAttributeView(attrView)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue