Reading attribute values from the Chalk element — types, body content, and TypeScript patterns
Attributes are the values an educator writes in the Chalk element. They are declared in the manifest, validated by the Chalk parser, and delivered to the plugin at load time via InitContext.
Attribute values arrive in InitContext.attrs when the plugin loads. Every attribute declared in the manifest is present — optional attributes that were omitted carry their declared default value, or undefined if no default was declared.
Types correspond to what the manifest declares:
"number" → number"string" → string"boolean" → boolean"dimensions" → [number, number]"colour" → string (the colour name, e.g. 'teal')Plugin elements support both a body block {} and a detail block []. Both are passed to the plugin as structured arrays of child elements — InitContext.body and InitContext.detail respectively. If a block is omitted, the corresponding field is null.
Each child element in the array is a plain object:
Body content also forms part of the element's content hash, which is the key used for interaction storage. Including meaningful body content ensures distinct element instances have distinct hashes — see Storage for details.
The allowed child element types for each block are declared in the manifest under chalk.childElements — see Manifest Reference.
Declare a typed interface matching your manifest's chalk.attributes to avoid casting unknown throughout your plugin:
Keep the interface in sync with manifest.json. Add the TypeScript field whenever you add an attribute to the manifest so the compiler catches usage errors early.