Definition list block (dlist). Renders as <dl> with <dt>/<dd> pairs. JSON data: { items: [{ term, desc }], ...common }.
Type: dlist · Class: DefinitionListBlock
Access:
app.block.get()
app.blocks.findByEl(el)
app.blocks.create(type)
App code:
const block = app.block.get();
Plugin:
const block = this.app.block.get();
getData#
Returns the serializable JSON data object for this block, including type-specific fields.
Returns: object
block.getData();
update#
Applies common fields, optionally sets the root class attribute, and rebuilds all term/description pairs when items is an array.
Parameters:
- data (
object) — object with the keys below- items (
Array) — replaces the whole list; each item is{ term: string, desc: string } - class (
string) — setsel.classNamedirectly (separate from commonclassname) - id, classname, styles, attrs, … — common block fields (see Common
update)
- items (
Returns: void
block.update({
items: [
{ term: 'API', desc: 'Application Programming Interface' },
{ term: 'JSON', desc: 'JavaScript Object Notation' }
]
});
block.update({ class: 'glossary' });
block.update({
items: [{ term: 'HTML', desc: 'HyperText Markup Language' }],
classname: 'defs'
});
addItem#
Appends a new <dt>/<dd> pair to the definition list and registers it in the internal items array.
Parameters:
- term (
string) — search term - desc (
string) — description text
Returns: void
block.addItem('API', 'Application Programming Interface');
removeItem#
Removes the term/description pair at the given index from the DOM and internal items array.
Parameters:
- index (
number) — zero-based index
Returns: void
block.removeItem(0);