1.0.2 • Published 5 years ago

katex-editorjs v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

KaTeX Plugin for EditorJs

Enable your EditorJS to write mathematical symbol with KaTeX.

Credits

Created with ❤ by Muhammad Affandes

Installation

With package manager NPM or Yarn

Run following command to install plugins.

npm install katex-editorjs

Or

yarn add katex-editorjs

Load via CDN

Place following line at the end of your HTML body tag.

...
<script src="https://cdn.jsdelivr.net/npm/katex-editorjs"></script>
...

Usage

Insert following snippets to your EditorJs configuration object.

import KatexEditor from "./katex-editor"

// Your EditorJs init
const editorjs = new EditorJS({
    // ...
    tools: {
        katexBlock: {
            class: KatexEditor
        },
    },
    // ...
});

Config Params

ParamsDescription
emptyEditModeString. (Optional) Text shows if TeX is empty (in edit mode).
emptyViewModeString. (Optional) Text shows if TeX is empty (in view mode).
delimiterString. (Optional) Delimiter character. Default is '$$'.
throwOnErrorBoolean. (Optional) See KaTeX Documentation. Default is false.
displayModeBoolean. (Optional) See KaTeX Documentation. Default is true.
legnoBoolean. (Optional) See KaTeX Documentation. Default is false.
fleqnBoolean. (Optional) See KaTeX Documentation. Default is true.
outputString. (Optional) See KaTeX Documentation. Default is 'html'.

Output Data

Math symbol will be wrapped with div tag with .aff-katex-wrapper class.

{
    "type": "katexBlock",
    "data": {
        "tex": "\\sum{x}"
    }
}