An object used to define block level elements in a rich text document.
In rich text documents, elements such as paragraphs, list items, images, etc. are created using RTBlockElement
objects.
In addition to the fields below, rich text elements can contain custom fields for any custom data they require.
Property | Type | Description |
---|---|---|
id* | string | The element ID. |
parents* | ParentReference[] | The references of the element's parents. Typically, will contain a reference to a |
children | RTFragment | The rich text content of the element. |
nestedElements | string[] | The IDs of nested |
files | string[] | The IDs of the element's files. All files attached to the element must be listed here. |
deleted | true | When |
deletedAt | Date | Timestamp at which the element was deleted. Not present if the element is not deleted. |
A 'to-do' element with nested elements.
interface ToDoElement extends RTBlockElement {
/**
* The element type, always 'to-do'.
*/
type: 'to-do';
/**
* The to-do's 'done' state.
*/
done: boolean;
}
const element: ToDoElement = {
type: 'to-do',
id: 'b2a55c36-f241-45d3-a312-80d4ba076b5d',
parents: [
// The parent rich text document in which this element is found
{ type: 'document', id: '9315f3d2-71ff-420f-8e28-2e1da4812126' },
],
// Custom field for 'done' state
done: false,
// The to-do item label
children: [{ text: 'Do the laundry' }],
// Nested elements, could be other to-do items indented below this one
nestedElements: [
'1c055d08-3cf0-40a3-acc1-405ee2bbdc50',
'60fdd4f3-ef9c-41d8-9fc4-696eecd93a13',
],
};
A void 'image' element with an attached file.
interface ImageElement extends RTBlockElement {
/**
* The element type, always 'image'.
*/
type: 'image';
/**
* Makes files required.
*/
files: string[];
/**
* An optional caption.
*/
caption?: string;
}
const element: ImageElement = {
type: 'image',
id: 'b2a55c36-f241-45d3-a312-80d4ba076b5d',
parents: [
// The parent rich text document in which this element is found
{ type: 'document', id: '9315f3d2-71ff-420f-8e28-2e1da4812126' },
],
// The image file's FileReference ID
files: ['8ddb85bb-12f5-4348-b7f7-95cc98092bd9'],
// Custom 'caption' field
caption: 'My cute cat',
};