🎨 Update av

This commit is contained in:
Daniel 2023-07-01 10:23:58 +08:00
parent 30bfa6e5d8
commit ee583e3cec
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
4 changed files with 74 additions and 33 deletions

View file

@ -16,35 +16,46 @@
package av
import "github.com/88250/lute/ast"
import (
"github.com/88250/gulu"
"github.com/88250/lute/ast"
)
type Cell struct {
ID string `json:"id"`
Value string `json:"value"`
Value *Value `json:"value"`
ValueType ColumnType `json:"valueType"`
RenderValue interface{} `json:"renderValue"`
Color string `json:"color"`
BgColor string `json:"bgColor"`
}
type Value struct {
Block string `json:"block"`
Text string `json:"text"`
Number float64 `json:"number"`
Date string `json:"date"`
Select string `json:"select"`
MSelect []string `json:"mSelect"`
}
func (value *Value) ToJSONString() string {
data, err := gulu.JSON.MarshalJSON(value)
if nil != err {
return ""
}
return string(data)
}
func NewCellBlock(blockID, blockContent string) *Cell {
return &Cell{
ID: ast.NewNodeID(),
Value: blockID,
Value: &Value{Block: blockID},
ValueType: ColumnTypeBlock,
RenderValue: &RenderValueBlock{ID: blockID, Content: blockContent},
}
}
func NewCellText(text string) *Cell {
return &Cell{
ID: ast.NewNodeID(),
Value: text,
ValueType: ColumnTypeText,
RenderValue: &RenderValueText{Content: text},
}
}
func NewCell(valueType ColumnType) *Cell {
return &Cell{
ID: ast.NewNodeID(),
@ -56,7 +67,3 @@ type RenderValueBlock struct {
ID string `json:"id"`
Content string `json:"content"`
}
type RenderValueText struct {
Content string `json:"content"`
}