Skip to content

Commit

Permalink
Docs update
Browse files Browse the repository at this point in the history
  • Loading branch information
pavittarx committed May 23, 2020
1 parent 806db92 commit f15d851
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ A utility to parse editorjs clean data to HTML.
npm install editorjs-html

### CDN
* https://cdn.jsdelivr.net/npm/editorjs-html@1.1.0/build/edjsHTML.js
* (Browser Only Build): https://cdn.jsdelivr.net/npm/editorjs-html@1.1.0/build/edjsHTML.browser.js
* https://cdn.jsdelivr.net/npm/editorjs-html@2.0.0/build/edjsHTML.js
* (Browser Only Build): https://cdn.jsdelivr.net/npm/editorjs-html@2.0.0/build/edjsHTML.browser.js

## Usage

### Browser
```js
const edjsParser = edjsHTML();
const edjsParser = edjsHTML();

let html = edjsParser.parse(editorjs_clean_data);
let html = edjsParser.parse(editorjs_clean_data);

console.log(html);
console.log(html);
```

### Nodejs
Expand All @@ -41,20 +41,25 @@ npm install editorjs-html
console.log(html);
```

## Updates

See [Releases](https://github.com/pavittarx/editorjs-html/releases)

### Supported Block Types

* Header (H1-H6)
* Lists (Ordered & Unordered)
* Images
* Delimiter
* Paragraph

## Parse Single Clean Data Blocks

```js
const edjsParser = edjsHTML();
const blockHTML = edjsParser.parseBlock(editorjs_clean_data_block);
const edjsParser = edjsHTML();
const blockHTML = edjsParser.parseBlock(editorjs_clean_data_block);

console.log(blockHTML);
console.log(blockHTML);
```

### Extend For Custom Blocks
Expand All @@ -65,23 +70,23 @@ npm install editorjs-html
* The name of the function must match with editor-js custom block type.

```js
// Your custom editorjs generated block
// Your custom editorjs generated block
{
type: "custom",
data: {
text: "Hello World"
}
type: "custom",
data: {
text: "Hello World"
}
}

```

```js
// Parse this block in editorjs-html
function customParser(data){
return `<custom-tag> ${data.text} </custom-tag>`;
}
// Parse this block in editorjs-html
function customParser(block){
return `<custom-tag> ${block.data.text} </custom-tag>`;
}

const edjsParser = edjsHTML({custom: customParser});
const edjsParser = edjsHTML({custom: customParser});

```

Expand Down

0 comments on commit f15d851

Please sign in to comment.