Content
Block editor
The BlockEditor
component is the main component of the editor. It is responsible for rendering the content editor.
- Component - simple
- Component - advanced
- Schema
export class BlockEditor {
blocks = def.oneHasMany(ContentBlock, 'blockEditor')
}
export class ContentBlock {
order = def.intColumn().notNull()
type = def.enumColumn(ContentBlockType).notNull()
content = def.stringColumn()
blockEditor = def.manyHasOne(BlockEditor, 'blocks')
references = def.oneHasMany(ContentReference, 'contentPart')
}
export class ContentReference {
type = def.enumColumn(def.createEnum('gallery', 'quote')).notNull()
contentPart = def.manyHasOne(ContentBlock, 'references')
content = def.stringColumn()
author = def.stringColumn()
images = def.oneHasMany(ContentGallery, 'contentReference')
}
export class ContentGallery {
order = def.intColumn().notNull()
image = def.manyHasOne(Image).notNull()
contentReference = def.manyHasOne(ContentReference, 'images').cascadeOnDelete()
}
Props
Prop | Description |
---|---|
| string Field name of string field in entities referenced by field prop. Required |
| string The name of the column in Contember schema where to store data. Required |
| ReactNode The label for the field. Required |
| undefined | string The name of the column in Contember schema that is used to sort the options. Required |
| undefined | string | SugaredRelativeEntityList Field name of the references. |
| undefined | string | SugaredRelativeSingleField Field name of the reference discrimination. |
| undefined | ToolbarButtonSpec[] | ToolbarButtonSpec[][] Buttons to be displayed in the inline toolbar. |
| undefined | BlockHoveringToolbarConfig[] | BlockHoveringToolbarConfig[][] | Buttons to be displayed in the block toolbar. |
| undefined | ((baseEditor: BaseEditor) => BaseEditor) Function to be called when the editor is created. |
Block repeater
The BlockRepeater
component is a simple way to repeat blocks of content. Use Block
for wrapping fields.
- Component - simple
- Component - advanced
- Schema
export class BlockRepeater {
blocks = def.oneHasMany(RepeaterBlock, 'blockRepeater').orderBy('order')
}
export class RepeaterBlock {
order = def.intColumn().notNull()
type = def.enumColumn(ContentBlockType).notNull()
content = def.stringColumn()
author = def.stringColumn()
images = def.oneHasMany(RepeaterGallery, 'repeaterReference').orderBy('order')
blockRepeater = def.manyHasOne(BlockRepeater, 'blocks')
}
export class RepeaterGallery {
order = def.intColumn().notNull()
image = def.manyHasOne(Image).notNull()
repeaterReference = def.manyHasOne(RepeaterBlock, 'images').cascadeOnDelete()
}
Props
Prop | Description |
---|---|
| string The name of the column in Contember schema where to store data. Required |
| ReactNode The label for the field. Required |
| string | SugaredRelativeSingleField Required |
| undefined | string The name of the column in Contember schema that is used to sort the options. Required |
| undefined | string |