Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/editor-js/code

Code Tool for Editor.js 2.0
https://github.com/editor-js/code

Last synced: about 2 months ago
JSON representation

Code Tool for Editor.js 2.0

Awesome Lists containing this project

README

        

![](https://badgen.net/badge/Editor.js/v2.0/blue)

# Code Tool for Editor.js

Code Tool for the [Editor.js](https://ifmo.su/editor) allows to include code examples in your articles.

![](https://capella.pics/8df022f5-b4d5-4d30-a527-2a0efb63f291.jpg)

## Installation

Get the package

```shell
yarn add @editorjs/code
```

Include module at your application

```javascript
import CodeTool from '@editorjs/code';
```

Optionally, you can load this tool from CDN [JsDelivr CDN](https://cdn.jsdelivr.net/npm/@editorjs/code@latest)

## Usage

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

```javascript
var editor = EditorJS({
...

tools: {
...
code: CodeTool,
}

...
});
```

## Config Params

| Field | Type | Description |
| ----------- | -------- | -------------------------------|
| placeholder | `string` | Code Tool's placeholder string |

## Output data

This Tool returns code.

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