Skip to content

EditorJS Tool that allows adding a block with syntax highlighting powered by CodeMirror 6 with a language picker

License

Notifications You must be signed in to change notification settings

tltoulson/editorjs-codemirror

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodeMirror Tool for EditorJS

CodeMirror tool for EditorJS allows adding Code blocks with syntax highlighing to the EditorJS content. This block uses CodeMirror 6 for the editor and exposes a language selector for choosing the languages supported by CodeMirror's base packages.

Installation

Install via NPM

Get the package

npm i --save-dev @tltoulson/editorjs-codemirror

Include module in your application

import { CodeMirrorTool } from '@tltoulson/editorjs-codemirror';

Add to your project manually

Copy the dist/index.js file into your project to use the CommonJS module.

Copy the dist/index.mjs file into your project to use the ES Module.

Usage

Add a new Tool to the tools property of the Editor.js initial config.

var editor = EditorJS({
  ...
  
  tools: {
    ...
    codemirror: CodeMirrorTool,
  }
  
  ...
});

Output data

This Tool returns code.

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

About

EditorJS Tool that allows adding a block with syntax highlighting powered by CodeMirror 6 with a language picker

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published