Skip to content

PHPtoday-ru/editorjs-codemirror

 
 

Repository files navigation

CodeMirror Tool for Editor.js

CodeMirror Tool for the Editor.js allows to include code examples in your articles using CodeMirror code editor.

Installation

Install via NPM

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');

Download to your project's source dir

  1. Upload folder dist from repository
  2. Add dist/bundle.js file to your page.

Usage

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
            }
        }
    },
  }
  
  ...
});

Output data

This Tool returns code.

{
    "type" : "code",
    "data" : {
        "code": "body {\n font-size: 14px;\n line-height: 16px;\n}",
        "language": "php"
    }
}

About

CodeMirror Tool for Editor.js 2.0

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.5%
  • CSS 0.5%