Tune for Editor.js adding color notice with caption for any block.
Caption field will be shown only for the first block of one type.
Get the package
$ npm i editorjs-notice
Include module at your application
import NoticeTune from 'editorjs-notice';
You can load a specific version of the package from jsDelivr CDN.
Require this script on a page with Editor.js.
<script src="https://cdn.jsdelivr.net/npm/editorjs-notice"></script>
- Upload folder
dist
from repository - Add
dist/bundle.js
file to your page.
var editor = EditorJS({
// ...
tools: {
// ...
noticeTune: NoticeTune
},
tunes: ['noticeTune']
// ...
});
var editor = EditorJS({
// ...
tools: {
// ...
noticeTune: NoticeTune,
header: {
class: Header,
tunes: ['noticeTune']
}
}
// ...
});
You can add a localized string into notice caption placeholder
new Editorjs({
// ...
tools: {
noticeTune: NoticeTune
},
i18n: {
tools: {
noticeTune: {
'Notice caption': 'Заголовок'
}
}
},
})
If style is not set, then the tune data will not be serialized into JSON. Also data returns in this format:
Field | Type | Description |
---|---|---|
style | string |
(spoiler or info or warning ) Notice style |
caption | string |
Notice caption |
{
// Block data
"tunes": {
"noticeTune": {
"style": "spoiler",
"caption": "Hidden content"
}
}
}