🎨 Add template type column to Attribute View https://github.com/siyuan-note/siyuan/issues/8766

This commit is contained in:
Daniel 2023-10-01 10:42:12 +08:00
parent e8359edebc
commit c0424caf67
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 95 additions and 21 deletions

View file

@ -55,16 +55,17 @@ type KeyValues struct {
type KeyType string
const (
KeyTypeBlock KeyType = "block"
KeyTypeText KeyType = "text"
KeyTypeNumber KeyType = "number"
KeyTypeDate KeyType = "date"
KeyTypeSelect KeyType = "select"
KeyTypeMSelect KeyType = "mSelect"
KeyTypeURL KeyType = "url"
KeyTypeEmail KeyType = "email"
KeyTypePhone KeyType = "phone"
KeyTypeMAsset KeyType = "mAsset"
KeyTypeBlock KeyType = "block"
KeyTypeText KeyType = "text"
KeyTypeNumber KeyType = "number"
KeyTypeDate KeyType = "date"
KeyTypeSelect KeyType = "select"
KeyTypeMSelect KeyType = "mSelect"
KeyTypeURL KeyType = "url"
KeyTypeEmail KeyType = "email"
KeyTypePhone KeyType = "phone"
KeyTypeMAsset KeyType = "mAsset"
KeyTypeTemplate KeyType = "template"
)
// Key 描述了属性视图属性列的基础结构。
@ -100,15 +101,16 @@ type Value struct {
Type KeyType `json:"type,omitempty"`
IsDetached bool `json:"isDetached,omitempty"`
Block *ValueBlock `json:"block,omitempty"`
Text *ValueText `json:"text,omitempty"`
Number *ValueNumber `json:"number,omitempty"`
Date *ValueDate `json:"date,omitempty"`
MSelect []*ValueSelect `json:"mSelect,omitempty"`
URL *ValueURL `json:"url,omitempty"`
Email *ValueEmail `json:"email,omitempty"`
Phone *ValuePhone `json:"phone,omitempty"`
MAsset []*ValueAsset `json:"mAsset,omitempty"`
Block *ValueBlock `json:"block,omitempty"`
Text *ValueText `json:"text,omitempty"`
Number *ValueNumber `json:"number,omitempty"`
Date *ValueDate `json:"date,omitempty"`
MSelect []*ValueSelect `json:"mSelect,omitempty"`
URL *ValueURL `json:"url,omitempty"`
Email *ValueEmail `json:"email,omitempty"`
Phone *ValuePhone `json:"phone,omitempty"`
MAsset []*ValueAsset `json:"mAsset,omitempty"`
Template *ValueTemplate `json:"template,omitempty"`
}
func (value *Value) String() string {
@ -139,6 +141,8 @@ func (value *Value) String() string {
ret = append(ret, v.Content)
}
return strings.Join(ret, " ")
case KeyTypeTemplate:
return value.Template.RenderedContent
default:
return ""
}
@ -345,6 +349,11 @@ type ValueAsset struct {
Content string `json:"content"`
}
type ValueTemplate struct {
Content string `json:"content"`
RenderedContent string `json:"renderedContent"`
}
// View 描述了视图的结构。
type View struct {
ID string `json:"id"` // 视图 ID