Skip to content

batkor/editorjs-code-lang

Repository files navigation

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.

Code Language tool for Editor.js with language choose

The list of languages supported is in languages.txt

Installation

Download to your project's source dir

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

Load from CDN

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>

Usage

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

Config Params

Field Type Description
placeholder string Code Tool's placeholder string
languages Object The object containing language code

Output data

This Tool returns code.

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

About

The plugin for EditorJs. This plugin provides feature for choose code language.

Resources

License

Stars

Watchers

Forks

Packages

No packages published