Node: This a fork of editor-js-code for the Editor.js that allows to include code examples along with language codes that are supported by PrismJs in your articles.
The list of languages supported is in languages.txt
- Upload folder
dist
from repository - Add
dist/bundle.js
file to your page.
You can load latest version of this package from jsDelivr CDN.
https://cdn.jsdelivr.net/gh/paraswaykole/editor-js-code@latest/dist/bundle.js
Require this script on a page with Editor.js.
<script src="..."></script>
Add a new Tool to the tools
property of the Editor.js initial config.
var editor = EditorJS({
tools: {
code: CodeTool,
config: {
languages: {
'js': 'JavaScript',
'php': 'PHP',
'css': 'CSS',
'twig': 'TWIG',
}
}
}
});
Field | Type | Description |
---|---|---|
placeholder | string |
Code Tool's placeholder string |
languages | Object |
The object containing language code |
This Tool returns code.
{
"type" : "code",
"data" : {
"code": "body {\n font-size: 14px;\n line-height: 16px;\n}",
"languageCode": "css"
}
}