Heading Tool for Editor.js
npm install @editorjs/header!Version of EditorJS that the plugin is compatible with
Provides Headings Blocks for the Editor.js.
Get the package
``shell`
yarn add @editorjs/header
Include module at your application
`javascript`
import Header from '@editorjs/header';
Optionally, you can load this tool from CDN JsDelivr CDN
Add a new Tool to the tools property of the Editor.js initial config.
`javascript
var editor = EditorJS({
...
tools: {
...
header: Header,
},
...
});
`
You can insert this Block by a useful shortcut. Set it up with the tools[].shortcut property of the Editor's initial config.
`javascript
var editor = EditorJS({
...
tools: {
...
header: {
class: Header,
shortcut: 'CMD+SHIFT+H',
},
},
...
});
`
All properties are optional.
| Field | Type | Description |
| ------------ | ---------- | --------------------------- |
| placeholder | string | header's placeholder string |number[]
| levels | | enabled heading levels |number
| defaultLevel | | default heading level |
`javascript
var editor = EditorJS({
...
tools: {
...
header: {
class: Header,
config: {
placeholder: 'Enter a header',
levels: [2, 3, 4],
defaultLevel: 3
}
}
}
...
});
`
!An image showing the header block tool
You can select one of six levels for heading.
| Field | Type | Description |
| ----- | -------- | ------------------------------------------------ |
| text | string | header's text |number
| level | | level of header: 1 for H1, 2 for H2 ... 6 for H6 |
`json``
{
"type": "header",
"data": {
"text": "Why Telegram is the best messenger",
"level": 2
}
}