Editorjs2html
editorjs2html is a utility that converts Editor.js output into HTML.
Features
- Supports multiple Editor.js block types
- Converts structured JSON data into clean HTML with semantic CSS classes
- Easy to use and integrate into projects
- Includes custom CSS classes for styling flexibility
Supported Block Types
This library supports conversion for the following Editor.js block types with corresponding CSS classes:
| Block Type | Class Name |
|---|---|
| Header / Header with alignment | js-head |
| Paragraph | js-para |
| List / Nested List / Checklist | js-list |
| Table | js-table |
| Quote | js-quote |
| Code | js-code |
| Link | js-link |
| Inline Text | js-inline |
| Warning | js-warning |
| Image / Simple Image | js-image |
| Embed | js-embed |
| Raw Input | js-raw |
| Alert | js-alert |
| Title | js-title |
| Attaches | js-attaches |
| Delimiter | - |
Note:
Inline Textblocks (js-inline) support the following styles based on flags (in order):bold→<b>italic→<i>underline→<u>marker→<mark>inline_code→<code>
The styles are applied in sequence and the final HTML is wrapped in a div like:
Text- Checklist blocks (
js-checklist) contain individual checkbox items each wrapped in adivwith thejs-checkboxclass. (this only for older version of checklist) - Alert blocks (
js-alert) have subclasses for different alert types:js-alert-primaryjs-alert-secondaryjs-alert-infojs-alert-successjs-alert-warningjs-alert-dangerjs-alert-lightjs-alert-dark
- Image blocks (
js-image) support the following modifier classes:js-image--stretched(ifstretchedistrue)js-image--bordered(ifwithBorderistrue)js-image--background(ifwithBackgroundistrue)
- We support both delimiter block plugins:
Installation
Usage
Example Output for Image Block
For the above JSON input, the generated HTML for the Image block will look like this:
Roadster // tesla.com
Example Output for Inline Text Block
Hello
Styling
The generated HTML includes semantic CSS classes for each block type, allowing you to apply custom styles. Use the corresponding class names from the Supported Block Types table to target specific elements in your CSS.
Example styling for headers:
}
Styling checklist items:
}
Styling image blocks:
}
}
}
}
One-Time Setup
Git Message Validator
This repository includes a Git message validator to enforce structured commit messages.
Contributor Setup
To ensure all contributors follow the same commit message format, run:
After setup, commit messages must follow the format:
<type>: <subject>
Example:
feat: add button component
Allowed Commit Types
- feat - New feature implementation
- fix - Bug fixes
- docs - Documentation updates
- style - Code style changes (formatting, missing semicolons, etc.)
- ref - Code refactoring without changing functionality
- test - Adding or updating tests
- rev - Code review changes
- perf - Performance improvements
- proj - Project-related tasks (configuration, build scripts, dependencies, etc.)
- lint - Linting fixes and improvements
Contributing
Contributions are welcome! Feel free to open issues or submit pull requests.