editorjs-syntax-hljs
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

EditorJS-Syntax-HLJS

Syntax highlighting for EditorJS using HLJS (highlight.js)

Note: Requires Highlight.js

Usage

import Syntax from 'editorjs-syntax-hljs'

// import any custom style from highlight.js to use it, default is atom-one-dark
import 'highlight.js/styles/atom-one-light.css' 

const editor = new EditorJS({
    // rest of the stuff
    code: {
        class: Syntax,
        shortcut: 'CTRL+SHIFT+C',
        config: {
            lineNumber: '', // 'checked' | ''  Disable/Enable line number
            lineOffset: 1, //Default line number to start from
            defaultLanguage: 'plaintext', // Default language for Syntax Highlight etc.
            languages: {
                // Provide in similar format { key: 'languageName in hljs', label: 'Name to display in dropdown' }
                { key: 'python', label: 'Python'},
                { key: 'java', label: 'Java'},
                { key: 'xml', label: 'HTML/XML'},
            }
        }
    }
})

Package Sidebar

Install

npm i editorjs-syntax-hljs

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

21.9 kB

Total Files

7

Last publish

Collaborators

  • creatorsroom