The codeBlock node is a container for lines of code.
codeBlock is a top-level block node.
1 2{ "type": "codeBlock", "attrs": { "language": "javascript", "wrap": true, "hideLineNumbers": true }, "content": [ { "type": "text", "text": "var foo = {};\nvar bar = [];" } ] }
| Name | Required | Type | Value |
|---|---|---|---|
| type | ✔ | string | "codeBlock" |
| content | array | An array of nodes | |
| attrs | object | ||
| attrs.language | string | Language of the code lines | |
| attrs.wrap | boolean | Whether long lines of code wrap | |
| attrs.hideLineNumbers | boolean | Whether line numbers are hidden |
content takes an array of one or more text nodes without marks.
language for syntax highlighting, a code language supported by Prism.
See available languages imports
for a list of the languages supported in Prism. If set to text or an unsupported value, code is
rendered as plain, monospaced text.wrap (optional) controls whether long lines of code wrap onto the next line instead of overflowing
horizontally. Accepts a boolean, and defaults to null when not set. Unlike other boolean attributes,
wrap is tri-state (null, true, or false) so that a missing value can be distinguished from an
explicit user choice. A null value means the user has expressed no preference, allowing the default
wrapping behaviour to be applied, whereas true or false records an explicit choice that should be
preserved. In practice, existing code blocks are left with wrapping off, while newly created code blocks
(including those added via copy-paste) default to wrapping on unless an explicit value is provided.hideLineNumbers (optional) controls whether the line number gutter is hidden. Accepts a boolean.
Defaults to false.Rate this page: