1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 09:35:00 +09:00

GO-2801: Do not migrate files that belong to another space as objects; add tests

This commit is contained in:
Sergey 2024-02-05 14:01:24 +01:00
parent e4964a3985
commit db9b96f933
No known key found for this signature in database
GPG key ID: 3B6BEF79160221C6
8 changed files with 1340 additions and 4 deletions

View file

@ -77,10 +77,12 @@ type options struct {
color string
restrictions *model.BlockRestrictions
textStyle model.BlockContentTextStyle
textIconImage string
marks *model.BlockContentTextMarks
fields *types.Struct
id string
backgroundColor string
fileHash string
}
type Option func(*options)
@ -127,6 +129,12 @@ func TextStyle(s model.BlockContentTextStyle) Option {
}
}
func TextIconImage(id string) Option {
return func(o *options) {
o.textIconImage = id
}
}
func TextMarks(m model.BlockContentTextMarks) Option {
return func(o *options) {
o.marks = &m
@ -182,10 +190,11 @@ func Text(s string, opts ...Option) *Block {
return mkBlock(&model.Block{
Content: &model.BlockContentOfText{
Text: &model.BlockContentText{
Text: s,
Style: o.textStyle,
Color: o.color,
Marks: o.marks,
Text: s,
Style: o.textStyle,
Color: o.color,
Marks: o.marks,
IconImage: o.textIconImage,
},
},
}, opts...)
@ -198,3 +207,25 @@ func Row(opts ...Option) *Block {
func Column(opts ...Option) *Block {
return Layout(model.BlockContentLayout_Column, opts...)
}
func FileHash(hash string) Option {
return func(o *options) {
o.fileHash = hash
}
}
func File(targetObjectId string, opts ...Option) *Block {
var o options
for _, apply := range opts {
apply(&o)
}
return mkBlock(&model.Block{
Content: &model.BlockContentOfFile{
File: &model.BlockContentFile{
Hash: o.fileHash,
TargetObjectId: targetObjectId,
},
},
}, opts...)
}