BlockNode
s. Each BlockNode
has:block
- A single block valuechildren
- Another list of BlockNodes
Block
has:id
- short string, usually 8 characters of randomized a-zA-Z0-9_
type
- Designate the block type which may each define additional fieldsref
- The Hypermedia or IPFS URL of the resourcetext
fieldattributes
field: TextAttributes
annotations
field: Array<TextAnnotation>
type
- The type of annotationstarts
- Array of numbers where the annotation startsends
- Array of numbers where the annotation ends.{
type: 'strong',
starts: [0],
ends: [14]
}
{
type: 'emphasis',
starts: [0],
ends: [14]
}
{
type: 'underline',
starts: [0],
ends: [14]
}
{
type: 'strikethrough',
starts: [0],
ends: [14]
}
{
type: 'code',
starts: [0],
ends: [14]
}
{
type: 'link',
starts: [0],
ends: [14],
ref: 'https://example.com' // 'hm://weoiruwoeiru?v=aldkjalksdjal'
}
{
type: 'color',
starts: [0],
ends: [14],
attributes: {
color: '#f00'
}
}
paragraph
- Text Blocktext
field, the raw value of the textattributes
field, TextAttribute
sannotations
field, array of TextAnnotations
heading
- Heading Block code
- Code Blockequation
- Equation Blockimage
- Image Blockvideo
- Video Blockfile
- File Blockembed
- Embed Blockweb-embed
- Web Embed BlockX
(twitter) content is supportednostr
- Nostr BlockDocumentChange
objects.setTitle
DocumentOperationchange.case
is setTitle
, change the title of the Document. new DocumentChange({
op: {
case: 'setTitle',
value: title,
},
})
moveBlock
DocumentChangenew DocumentChange({
op: {
case: 'moveBlock',
value: {
blockId: 'a-zA-Z0-9_',
leftSibling: '37as897s',
parent: 'vi098smp',
}
},
})
operation.value.blockId
- What blockId will be placed or movedoperation.value.leftSibling
- What blockId appears before this block within the same doc hierarchy level. Empty if it is the first blockoperation.value.parent
- What is the parent blockId. Empty if it is a top-level block in the documentreplaceBlock
DocumentChangenew DocumentChange({
op: {
case: 'replaceBlock',
value: {
id: 'a-zA-Z0-9_',
type: 'paragraph',
text: 'Hello world',
annotations: [],
attributes: {
childrenType: 'group'
}
}
},
})
replaceBlock
operation is the whole block, including the id
. Each new block must be replaced right after it is moved into place with moveBlock
in order to add its content.operation.value.id
- The blockIdoperation.value.type
- The block type. This is important only for the visual representation. For the backend, this attribute is a opaque string.operation.value
- The value is the new block values: text, attributes, annotations. Including the IddeleteBlock
DocumentChangenew DocumentChange({
op: {
case: 'deleteBlock',
value: 'a-zA-Z0-9_'
},
})
DocumentChange
object specifying only the blockId you want to remove.replaceBlock
usually) that affect the deleted block, those will be ignored.moveBlock
changes for each children.