mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
09051c43b3
3 changed files with 53 additions and 4 deletions
|
|
@ -257,6 +257,9 @@ func NewGalleryView() (ret *View) {
|
|||
Sorts: []*ViewSort{},
|
||||
PageSize: GalleryViewDefaultPageSize,
|
||||
},
|
||||
CoverFrom: CoverFromContentImage,
|
||||
CardSize: CardSizeMedium,
|
||||
ShowIcon: true,
|
||||
},
|
||||
}
|
||||
return
|
||||
|
|
|
|||
|
|
@ -22,12 +22,25 @@ import "sort"
|
|||
type LayoutGallery struct {
|
||||
*BaseLayout
|
||||
|
||||
CoverFrom CoverFrom `json:"coverFrom"` // 封面来源,0:无,1:内容图,2:资源字段
|
||||
CoverFromAssetKeyID string `json:"coverFromAssetKeyId,omitempty"` // 资源字段 ID,CoverFrom 为 2 时有效
|
||||
CardFields []*ViewGalleryCardField `json:"fields"` // 画廊卡片字段
|
||||
CardIDs []string `json:"cardIds"` // 卡片 ID,用于自定义排序
|
||||
CoverFrom CoverFrom `json:"coverFrom"` // 封面来源,0:无,1:内容图,2:资源字段
|
||||
CoverFromAssetKeyID string `json:"coverFromAssetKeyId,omitempty"` // 资源字段 ID,CoverFrom 为 2 时有效
|
||||
CardSize CardSize `json:"cardSize"` // 卡片大小
|
||||
FitImage bool `json:"fitImage"` // 是否适应图片大小
|
||||
ShowIcon bool `json:"showIcon"` // 是否显示图标
|
||||
WrapField bool `json:"wrapField"` // 是否换行字段
|
||||
|
||||
CardFields []*ViewGalleryCardField `json:"fields"` // 画廊卡片字段
|
||||
CardIDs []string `json:"cardIds"` // 卡片 ID,用于自定义排序
|
||||
}
|
||||
|
||||
type CardSize int
|
||||
|
||||
const (
|
||||
CardSizeSmall CardSize = iota // 小卡片
|
||||
CardSizeMedium // 中卡片
|
||||
CardSizeLarge // 大卡片
|
||||
)
|
||||
|
||||
// CoverFrom 描述了画廊中的卡片封面来源的枚举类型。
|
||||
type CoverFrom int
|
||||
|
||||
|
|
|
|||
|
|
@ -2169,6 +2169,22 @@ func addAttributeViewBlock(now int64, avID, blockID, previousBlockID, addingBloc
|
|||
} else {
|
||||
v.Table.RowIDs = append([]string{addingBlockID}, v.Table.RowIDs...)
|
||||
}
|
||||
case av.LayoutTypeGallery:
|
||||
if "" != previousBlockID {
|
||||
changed := false
|
||||
for i, id := range v.Gallery.CardIDs {
|
||||
if id == previousBlockID {
|
||||
v.Gallery.CardIDs = append(v.Gallery.CardIDs[:i+1], append([]string{addingBlockID}, v.Gallery.CardIDs[i+1:]...)...)
|
||||
changed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !changed {
|
||||
v.Gallery.CardIDs = append(v.Gallery.CardIDs, addingBlockID)
|
||||
}
|
||||
} else {
|
||||
v.Gallery.CardIDs = append([]string{addingBlockID}, v.Gallery.CardIDs...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2781,6 +2797,23 @@ func AddAttributeViewKey(avID, keyID, keyName, keyType, keyIcon, previousKeyID s
|
|||
if !added {
|
||||
view.Table.Columns = append(view.Table.Columns, &av.ViewTableColumn{ID: key.ID})
|
||||
}
|
||||
case av.LayoutTypeGallery:
|
||||
if "" == previousKeyID {
|
||||
view.Gallery.CardFields = append([]*av.ViewGalleryCardField{{ID: key.ID}}, view.Gallery.CardFields...)
|
||||
break
|
||||
}
|
||||
|
||||
added := false
|
||||
for i, field := range view.Gallery.CardFields {
|
||||
if field.ID == previousKeyID {
|
||||
view.Gallery.CardFields = append(view.Gallery.CardFields[:i+1], append([]*av.ViewGalleryCardField{{ID: key.ID}}, view.Gallery.CardFields[i+1:]...)...)
|
||||
added = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !added {
|
||||
view.Gallery.CardFields = append(view.Gallery.CardFields, &av.ViewGalleryCardField{ID: key.ID})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue