editorjs-html is a robust, lightweight, and highly customizable utility designed to transform Editor.js's clean JSON output into standard HTML. The current stable version is 4.0.5, which represents a complete rewrite focusing on improved modularity, readability, and modern dependency usage. This library offers flexible integration across various JavaScript environments including plain JavaScript/TypeScript, React, Angular, and Vue. It supports all common Editor.js blocks out-of-the-box and provides a clear mechanism for extending its capabilities to parse custom Editor.js blocks. A key differentiator is its emphasis on strict parsing options and type safety, leveraging Editor.js's own type definitions for development ease. While a specific release cadence isn't explicitly stated, the rapid iteration to v4 suggests active maintenance and responsiveness to the Editor.js ecosystem.
npm install editorjs-htmlVerified import paths — ran on the pinned version, not inferred.
Demonstrates initializing the parser and converting a full Editor.js data object into an array of HTML strings, then joining them.
Review the v4 documentation for changes in API, particularly `edjsHTML` instantiation and options. Ensure custom parsers align with the new structure.
Replace calls to `parseStrict()` and `validate()` with `edjsHTML({}, { strict: true }).parse(data)`. The `parse` method will now return an `Error` instance if strict mode is enabled and an issue occurs.Always define parser functions for all expected custom or third-party Editor.js blocks when initializing `edjsHTML(plugins)`. For critical applications, enable strict mode to catch missing parsers as errors.
When using strict mode, always check the return value of `parse()`: `const HTML = edjsParser.parse(editorjs_data); if (HTML instanceof Error) throw HTML;` and handle the error appropriately.
If you need different parsing behaviors (e.g., strict vs. non-strict, or different sets of custom parsers), create a new `edjsHTML()` instance for each specific configuration.
Use the `parse` method with the `strict: true` option during parser initialization: `const edjsParser = edjsHTML({}, { strict: true }); const html = edjsParser.parse(data);`If using a browser-only CDN build, ensure the script is loaded before your code. If using the npm package, `import edjsHTML from 'editorjs-html'` (ESM) or `const edjsHTML = require('editorjs-html')` (CJS).Provide a parser function for 'myCustomBlock' when initializing `edjsHTML`. Example: `const plugins = { myCustomBlock: (block) => `<div class="custom">${block.data.text}</div>` }; const edjsParser = edjsHTML(plugins, { strict: true });`Ensure the argument passed to `edjsParser.parse()` is a valid Editor.js data object with a `blocks` array, e.g., `{ blocks: [...] }`.No dependency data recorded yet.