百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
E

editorjs-html

> 前端框架
开源

JavaScript 库用于解析 editorjs 清洁数据为 HTML。它具有适应性强,可在各种项目中使用。

381 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

JavaScript 库用于解析 editorjs 清洁数据为 HTML。它具有适应性强,可在各种项目中使用。

editorjs-html

A utility to parse editorjs clean data to HTML.

  • Use it with plain Javascript/Typescript, React, Angular, Vue or any templating engine/framework of your choice.
  • Fast, Efficient and Lightweight.
  • Fully customizable to the core.
  • Supports basic editorjs blocks which are customizable as well.
  • Extend to parse your own blocks.

Whats' new in v4?

  • Complete Rewrite, latest dependencies with minimal API changes.
  • Redundant parseStrict() and validate() functions are removed.
  • Strict mode is configurable via options.
  • Console errors if parser functions for block is not avaiable. Strict Mode throws errors.
  • Code is more readable, modular. It would make it easier to contribute and track changes.
  • Type definitions directly fetched from Editor.js, so development becomes easier.
  • Unit Testing with Jest.

Installation

Self Host, precompiled versions.

  • Browser - Get /.build/edjsHTML.browser.js

  • NodeJs - Get /.build/edjsHTML.node.js

  • For Both Browser & Node - Get /.build/edjsHTML.js

NPM

bash
npm install editorjs-html

CDN

  • https://cdn.jsdelivr.net/npm/[email protected]/.build/edjsHTML.js
  • (Browser Only Build): https://cdn.jsdelivr.net/npm/[email protected]/.build/edjsHTML.browser.js

Usage

Browser

javascript
const edjsParser = edjsHTML();
let html = edjsParser.parse(editorjs_clean_data);
console.log(html);

Nodejs

javascript
const edjsHTML = require("editorjs-html");
const edjsParser = edjsHTML();
const html = edjsParser.parse(editorjs_clean_data);

console.log(html);

Updates

See Releases

Docs

Supported Block Types

  • Header (H1-H6)
  • Lists (Ordered & Unordered)
  • Nested Lists
  • Image
  • Delimiter
  • Paragraph
  • Quote
  • Code
  • Embed

Parse Entire EditorJS Data Object

javascript
const edjsParser = edjsHTML();
const HTML = edjsParser.parse(editorjs_data);
// returns array of html strings per block
console.log(HTML);

Parse Entire EditorJS Data Object (Strict Mode)

javascript
const edjsParser = edjsHTML();
const HTML = edjsParser.parse(editorjs_data);
// returns an error
if (HTML instanceof Error) throw HTML;

// in case of success, returns an array of strings
console.log(HTML);

Parse Single Clean Data Block

javascript
const edjsParser = edjsHTML();
const blockHTML = edjsParser.parseBlock(editorjs_data_block);
// returns string of html for this block
console.log(blockHTML);

Strict Mode

javascript
const edjsParser = edjsHTML({}, { strict: true });
// returns the list of missing parser functions
const blockHTML = edjsParser.parse(editorjs_data);
console.log(blockHTML);

Extend For Custom Blocks

editorjs-html supports extending and overriding parser functions for blocks.

javascript
  // Example Custom or Unrecognised Block
  {
    type: "custom",
    data: {
      text: "Hello World"
    }
 }
javascript
// Parse this block in editorjs-html
function customParser(block) {
  return ` ${block.data.text} `;
}

const plugins = {
  // The keyname must match with the type of block you want to parse with this funcion
  custom: customParser,
  // ... add more or overwrite
};

const edjsParser = edjsHTML(plugins);

Contribution

Please add an issue, or open a PR for any bugs, review or suggestions.

New Parser Functions

  1. For additional parser functions, please add them to parsers/block-name. Check existing functions for suggestions.
  2. Test everyting works fine, with pnpm test && pnpm build.
  3. Open a PR, for review.
  4. Add tests in tests directory. Make sure your tests pass with appropriate coverage.

Suggestions & Recommendations

I would love to have your feedback and any suggestions. You can also let me know, if you need support for any more editorjs blocks.

Support

If you find this helpful, consider giving this repository a Star. You can also buy me a coffee here

License

MIT Public License

Author

@pavittarx

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScripteditoreditorjseditorjs-htmlhtml

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架