Convert Figma logo to code with AI

codex-team logoeditor.js

A block-style editor with clean JSON output

30,534
2,179
30,534
681

Top Related Projects

12,021

📝 the simplest and smallest WYSIWYG text editor for web, with no dependencies

45,838

Quill is a modern WYSIWYG editor built for compatibility and extensibility

15,726

The world's #1 JavaScript library for rich text editing. Available for React, Vue and Angular

10,179

Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.

Medium.com WYSIWYG editor clone. Uses contenteditable API to implement a rich text solution.

19,552

A rich text editor for everyday writing

Quick Overview

Editor.js is an open-source WYSIWYG editor for web applications, designed to be a block-styled editor that allows users to create rich and structured content. It is highly customizable and provides a wide range of built-in blocks, as well as the ability to create custom blocks.

Pros

  • Flexible and Customizable: Editor.js allows developers to create custom blocks and integrate them into the editor, making it highly adaptable to different use cases.
  • Rich Content Creation: The editor supports a wide range of content types, including text, images, videos, tables, and more, allowing users to create complex and visually appealing content.
  • Lightweight and Performant: Editor.js is designed to be lightweight and efficient, with a small footprint and fast load times.
  • Open-Source and Community-Driven: The project is open-source and has a growing community of contributors, ensuring ongoing development and support.

Cons

  • Learning Curve: Integrating Editor.js into a project may have a steeper learning curve, especially for developers who are not familiar with the block-based content creation model.
  • Limited Undo/Redo Functionality: The built-in undo/redo functionality in Editor.js may not be as robust as some users might expect, which could be a limitation for certain use cases.
  • Dependency on Third-Party Libraries: Editor.js relies on several third-party libraries, which could introduce additional complexity and potential compatibility issues.
  • Limited Offline Support: The editor may not work as well in offline or low-connectivity scenarios, as it relies on remote resources and APIs.

Code Examples

Here are a few examples of how to use Editor.js:

  1. Initializing the Editor:
const editor = new EditorJS({
  holder: 'editorjs',
  tools: {
    header: Header,
    image: Image,
    list: List,
    // Add more tools as needed
  },
  // Other configuration options
});
  1. Adding a Header Block:
editor.render({
  blocks: [
    {
      type: 'header',
      data: {
        text: 'Welcome to Editor.js',
        level: 2
      }
    }
  ]
});
  1. Saving the Editor Content:
const saveButton = document.getElementById('save-button');
saveButton.addEventListener('click', () => {
  editor.save().then((outputData) => {
    // Send the outputData to the server for storage
    console.log('Saved data', outputData);
  });
});
  1. Handling Custom Blocks:
const myCustomBlock = {
  type: 'my-custom-block',
  isInline: false,
  // Implement the required methods for the custom block
  render(data) {
    // Render the custom block
  },
  save(blockContent) {
    // Save the custom block data
  }
};

const editor = new EditorJS({
  holder: 'editorjs',
  tools: {
    'my-custom-block': myCustomBlock
  }
});

Getting Started

To get started with Editor.js, follow these steps:

  1. Install the library using npm or yarn:
npm install @editorjs/editorjs
  1. Create an HTML element to hold the editor:
<div id="editorjs"></div>
  1. Initialize the editor in your JavaScript code:
const editor = new EditorJS({
  holder: 'editorjs',
  tools: {
    header: Header,
    image: Image,
    list: List,
    // Add more tools as needed
  },
  // Other configuration options
});
  1. Implement event listeners to save the editor content:
const saveButton = document.getElementById('save-button');
saveButton.addEventListener('click', () => {
  editor.save().then((outputData) => {
    // Send the outputData to the server for storage
    console.log('Saved data', outputData);
  });
});
  1. Customize the editor by adding or modifying the available tools:

Competitor Comparisons

12,021

📝 the simplest and smallest WYSIWYG text editor for web, with no dependencies

Pros of pell

  • Extremely lightweight (1.5KB gzipped) compared to Editor.js
  • Simple API with minimal setup required
  • No dependencies, making it easy to integrate into any project

Cons of pell

  • Limited features compared to Editor.js's block-based editing
  • Less customizable and extensible than Editor.js
  • Lacks advanced formatting options and plugins available in Editor.js

Code Comparison

pell:

import pell from 'pell'

pell.init({
  element: document.getElementById('editor'),
  onChange: html => console.log(html)
})

Editor.js:

import EditorJS from '@editorjs/editorjs'

const editor = new EditorJS({
  holder: 'editor',
  tools: {
    header: Header,
    list: List
  }
})

The code comparison shows that pell has a simpler initialization process, while Editor.js requires more configuration but offers greater flexibility with tools and plugins.

pell is ideal for projects requiring a basic, lightweight editor with minimal setup. Editor.js is better suited for applications needing a feature-rich, block-based editing experience with extensive customization options.

45,838

Quill is a modern WYSIWYG editor built for compatibility and extensibility

Pros of Quill

  • More mature and widely adopted, with a larger community and ecosystem
  • Extensive documentation and API, making it easier for developers to customize
  • Better cross-browser compatibility and mobile support

Cons of Quill

  • Larger file size and potentially heavier performance impact
  • Less modular architecture, making it harder to add or remove specific features
  • More opinionated design, which may limit flexibility for some use cases

Code Comparison

Editor.js:

const editor = new EditorJS({
  holder: 'editorjs',
  tools: {
    header: Header,
    list: List
  }
});

Quill:

const quill = new Quill('#editor', {
  modules: {
    toolbar: [['bold', 'italic'], ['link', 'image']]
  },
  theme: 'snow'
});

Both editors allow for easy initialization and configuration, but Editor.js focuses on a block-based structure, while Quill provides a more traditional rich text editing experience. Editor.js offers more granular control over individual content blocks, whereas Quill provides a more seamless editing interface with a built-in toolbar.

15,726

The world's #1 JavaScript library for rich text editing. Available for React, Vue and Angular

Pros of TinyMCE

  • More mature and feature-rich, with a wider range of plugins and customization options
  • Better support for complex document structures and formatting
  • Extensive documentation and community support

Cons of TinyMCE

  • Larger file size and potentially slower load times
  • Steeper learning curve for developers due to its complexity
  • Less modern and modular architecture compared to Editor.js

Code Comparison

Editor.js:

const editor = new EditorJS({
  holder: 'editorjs',
  tools: {
    header: Header,
    list: List
  }
});

TinyMCE:

tinymce.init({
  selector: '#mytextarea',
  plugins: 'advlist autolink lists link image charmap print preview',
  toolbar: 'undo redo | formatselect | bold italic | alignleft aligncenter alignright'
});

Both editors allow for customization, but Editor.js has a more modular approach with individual tools, while TinyMCE uses a more traditional configuration object with plugins and toolbar options.

Editor.js focuses on a block-based structure, making it easier to create modern, customizable content editors. TinyMCE, on the other hand, provides a more traditional rich text editing experience with extensive formatting options and compatibility with various content types.

10,179

Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.

Pros of CKEditor 5

  • More mature and feature-rich, with a wider range of plugins and customization options
  • Better documentation and community support
  • Stronger focus on accessibility and internationalization

Cons of CKEditor 5

  • Larger file size and potentially heavier performance impact
  • Steeper learning curve for developers due to its complexity
  • Less flexibility in terms of output format (primarily focused on HTML)

Code Comparison

Editor.js:

const editor = new EditorJS({
  holder: 'editorjs',
  tools: {
    header: Header,
    list: List
  }
});

CKEditor 5:

ClassicEditor
  .create(document.querySelector('#editor'), {
    plugins: [Heading, List],
    toolbar: ['heading', 'bulletedList', 'numberedList']
  })
  .catch(error => {
    console.error(error);
  });

Both editors allow for easy initialization and configuration, but CKEditor 5 offers a more plugin-centric approach with a predefined structure. Editor.js provides a more modular and flexible setup, allowing developers to define custom block types more easily.

Medium.com WYSIWYG editor clone. Uses contenteditable API to implement a rich text solution.

Pros of medium-editor

  • Lightweight and simple to implement
  • Extensive browser support, including older versions
  • Large community and ecosystem of extensions

Cons of medium-editor

  • Less structured content output
  • Limited built-in block types
  • Fewer modern features and customization options

Code Comparison

medium-editor:

var editor = new MediumEditor('.editable', {
    toolbar: {
        buttons: ['bold', 'italic', 'underline', 'anchor', 'h2', 'h3', 'quote']
    }
});

editor.js:

const editor = new EditorJS({
    holder: 'editorjs',
    tools: {
        header: Header,
        list: List,
        image: SimpleImage
    }
});

Key Differences

  1. Architecture: editor.js uses a block-based approach, while medium-editor focuses on inline editing.
  2. Output: editor.js produces structured JSON data, whereas medium-editor generates HTML content.
  3. Customization: editor.js offers more extensive tool customization and plugin system.
  4. Modern features: editor.js includes features like undo/redo and read-only mode out of the box.
  5. Learning curve: medium-editor may be easier to set up initially, but editor.js provides more powerful capabilities for complex implementations.

Both editors have their strengths, and the choice between them depends on specific project requirements, desired output format, and level of customization needed.

19,552

A rich text editor for everyday writing

Pros of Trix

  • More mature and stable project with longer development history
  • Simpler API and easier integration for basic rich text editing
  • Better support for mobile devices and touch interfaces

Cons of Trix

  • Less flexible and customizable compared to Editor.js
  • Limited block-based editing capabilities
  • Smaller ecosystem of plugins and extensions

Code Comparison

Trix initialization:

<trix-editor class="trix-content"></trix-editor>

<script>
  var element = document.querySelector("trix-editor")
  element.editor // is a Trix.Editor instance
</script>

Editor.js initialization:

const editor = new EditorJS({
  holder: 'editorjs',
  tools: {
    header: Header,
    list: List,
    image: SimpleImage
  }
});

Both editors offer different approaches to rich text editing. Trix provides a more traditional WYSIWYG experience, while Editor.js focuses on a block-based structure. The choice between them depends on specific project requirements, desired customization level, and target audience.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Editor.js Logo

editorjs.io | documentation | changelog

npm Minzipped size Backers on Open Collective Sponsors on Open Collective

About

Editor.js is an open-source text editor offering a variety of features to help users create and format content efficiently. It has a modern, block-style interface that allows users to easily add and arrange different types of content, such as text, images, lists, quotes, etc. Each Block is provided via a separate plugin making Editor.js extremely flexible.

Editor.js outputs a clean JSON data instead of heavy HTML markup. Use it in Web, iOS, Android, AMP, Instant Articles, speech readers, AI chatbots — everywhere. Easy to sanitize, extend and integrate with your logic.

  • 😍  Modern UI out of the box
  • 💎  Clean JSON output
  • ⚙️  Well-designed API
  • 🛍  Various Tools available
  • 💌  Free and open source
Editor.js Overview

Installation

It's quite simple:

  1. Install Editor.js
  2. Install tools you need
  3. Initialize Editor's instance

Install using NPM, Yarn, or CDN:

npm i @editorjs/editorjs

Choose and install tools:

See the 😎 Awesome Editor.js list for more tools.

Initialize the Editor:

<div id="editorjs"></div>
import EditorJS from '@editorjs/editorjs'

const editor = new EditorJS({
  tools: {
   // ... your tools
  }
})

See details about Installation and Configuration at the documentation.

Saving Data

Call editor.save() and handle returned Promise with saved data.

const data = await editor.save()

Example

Take a look at the example.html to view more detailed examples.

Roadmap

  • Unified Toolbars
    • Block Tunes moved left
    • Toolbox becomes vertical
    • Ability to display several Toolbox buttons by the single Tool
    • Block Tunes become vertical
    • Block Tunes support nested menus
    • Block Tunes support separators
    • Conversion Menu added to the Block Tunes
    • Unified Toolbar supports hints
    • Conversion Toolbar uses Unified Toolbar
    • Inline Toolbar uses Unified Toolbar
  • Collaborative editing
    • Implement Inline Tools JSON format
    • Operations Observer, Executor, Manager, Transformer
    • Implement Undo/Redo Manager
    • Implement Tools API changes
    • Implement Server and communication
    • Update basic tools to fit the new API
  • Other features
    • Blocks drag'n'drop
    • New cross-block selection
    • New cross-block caret moving
  • Ecosystem improvements
    • CodeX Icons — the way to unify all tools and core icons
    • New Homepage and Docs
    • @editorjs/create-tool for Tools bootstrapping
    • Editor.js DevTools — stand for core and tools development
    • Editor.js Design System
    • Editor.js Preset Env
    • Editor.js ToolKit
    • New core bundle system
    • New documentation and guides
Support Editor.js

Like Editor.js?

You can support project improvement and development of new features with a donation to our team.

Donate via OpenCollective
Donate via Crypto
Donate via Patreon

Why donate

Donations to open-source products have several advantages for your business:

  • If your business relies on Editor.js, you'll probably want it to be maintained
  • It helps Editor.js to evolve and get the new features
  • We can support contributors and the community around the project. You'll receive well organized docs, guides, etc.
  • We need to pay for our infrastructure and maintain public resources (domain names, homepages, docs, etc). Supporting it guarantees you to access any resources at the time you need them.
  • You can advertise by adding your brand assets and mentions on our public resources

Sponsors

Support us by becoming a sponsor. Your logo will show up here with a link to your website.

Mister Auto UPLUCID, K.K. Kane Jamison Content Harmony

Become a Sponsor

Backers

Thank you to all our backers

Become a Backer

Contributors

This project exists thanks to all the people who contribute.

Need something special?

Hire CodeX experts to resolve technical challenges and match your product requirements.

  • Resolve a problem that has high value for you
  • Implement a new feature required by your business
  • Help with integration or tool development
  • Provide any consultation

Contact us via team@codex.so and share your details

Community

About CodeX

CodeX is a team of digital specialists around the world interested in building high-quality open source products on a global market. We are open for young people who want to constantly improve their skills and grow professionally with experiments in cutting-edge technologies.

🌐Join 👋TwitterInstagram
codex.socodex.so/join@codex_team@codex_team

NPM DownloadsLast 30 Days