CodeMirror Tool for the Editor.js allows to include code examples in your articles using CodeMirror code editor.
Get the package
npm i --save-dev https://github.com/PHPtoday-ru/editorjs-codemirror#1.0.0
Include module at your application
const CodeMirrorTool = require('editorjs-codemirror');
- Upload folder
dist
from repository - Add
dist/bundle.js
file to your page.
Add a new Tool to the tools
property of the Editor.js initial config.
var editor = EditorJS({
...
tools: {
...
code: {
class: CodeMirrorTool,
config: {
cm: {
//... codemirror config
}
}
},
}
...
});
This Tool returns code.
{
"type" : "code",
"data" : {
"code": "body {\n font-size: 14px;\n line-height: 16px;\n}",
"language": "php"
}
}