mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-03 07:18:49 +01:00
🎨 Update av
This commit is contained in:
parent
30bfa6e5d8
commit
ee583e3cec
4 changed files with 74 additions and 33 deletions
|
|
@ -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"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue