pavittarx / editorjs-html

A javascript library to parse editorjs clean data to html. It is adaptable and usable in all kind of projects.
https://runkit.com/pavittarx/editorjs-html-example
MIT License
331 stars 61 forks source link

Custom Block Parser doesn't work #29

Closed air-hand closed 3 years ago

air-hand commented 3 years ago

Description

I have tried to implement a custom parser like below, but returned ParseFunctionError when parse().

import edjsHTML from 'editorjs-html';

function checklistParser(block) {
    return '<ul><li>bar</li><li>bar</li></ul>';
}

const parser = edjsHTML({
  checklist: checklistParser,
});
parser.parse(data); // ParseFunctionError of "checklist"

I think, the following parts are the cause.

// src/app.ts

const parser = (plugins = {}): parser => {
    Object.assign(plugins, transforms); // ignored plugins, just use default transforms.

Environment

editorjs latest editorjs-html v3.2.1

There is no error with editorjs-html v3.0.5 .

Thanks.