Skip to content

Repository files navigation

Editor.js Retool Component

A powerful rich text editor custom component for Retool built with Editor.js, providing a modern WYSIWYG editing experience with clean JSON output.

Preview

darkmode preview

lightmode preview

Features

  • Block-Style Editing: Create structured content with various block types
  • Clean JSON Output: All content is stored as structured JSON data
  • Customizable Styling: Change background and text colors
  • Dynamic Tool Configuration: Enable/disable specific formatting tools as needed
  • Rich Formatting Tools:
    • Headers (H1-H4)
    • Lists (ordered and unordered)
    • Quotes
    • Code blocks
    • Checklists
    • Tables
    • Embeds (YouTube, CodePen)
    • Inline formatting (marker, underline, inline code)
    • Delimiters
    • Warnings
    • Footnotes
    • Links

Installation

  1. Clone this repository:

    git clone https://github.com/StackdropCO/editorjs-retool-component.git
  2. Install dependencies:

    npm install
  3. Log in to Retool:

    npx retool-ccl login

    Note: You'll need an API access token with read and write scopes for Custom Component Libraries.

  4. Create a component library:

    npx retool-ccl init
  5. Start development mode:

    npx retool-ccl dev
  6. Deploy your component:

    npx retool-ccl deploy
  7. Switch component versions:

    To pin your app to the component version you just published, navigate to the Custom Component settings in your Retool app and change dev to the latest version. This may require you to refresh the page to see the newly published version.

Configuration

The component exposes the following properties in Retool:

PropertyTypeDescription
contentStringThe current editor content as JSON string
backgroundColorStringBackground color of the editor (defaults to #f8fafc)
textColorStringText color in the editor (defaults to #000)

Tool Configuration

Each formatting tool can be enabled or disabled independently through Retool's inspector panel:

Tool PropertyTypeDescription
enableHeaderBooleanEnable/disable header formatting
enableListBooleanEnable/disable list formatting
enableQuoteBooleanEnable/disable quote blocks
enableChecklistBooleanEnable/disable checklist blocks
enableCodeBooleanEnable/disable code blocks
enableInlineCodeBooleanEnable/disable inline code formatting
enableMarkerBooleanEnable/disable marker/highlight formatting
enableDelimiterBooleanEnable/disable delimiter blocks
enableEmbedBooleanEnable/disable embed blocks
enableTableBooleanEnable/disable table blocks
enableWarningBooleanEnable/disable warning blocks
enableLinkBooleanEnable/disable link tool
enableUnderlineBooleanEnable/disable underline formatting
enableFootnotesBooleanEnable/disable footnotes

Usage Example

Basic Setup

  1. Drag the Editor.js component onto your Retool canvas
  2. Configure the component settings:
    • Set backgroundColor and textColor if desired
    • Connect content to load existing content
    • Enable/disable specific formatting tools as needed

Saving and Loading Content

  1. The content property serves as both input and output:
    • To load content: Set the content property to your existing JSON data
    • To save content: The component will automatically update the content property as the user types
  2. You can use the content value in queries to save to your database

Data Structure

Editor.js outputs structured JSON data. Example output:

{
"time": 1635603431943,
"blocks": [
{
"id": "12345",
"type": "header",
"data": {
"text": "Editor.js",
"level": 2
}
},
{
"id": "67890",
"type": "paragraph",
"data": {
"text": "This is a paragraph block."
}
}
],
"version": "2.23.2"
}

Development

Prerequisites

  • Node.js >= 20.0.0
  • Retool developer account

Local Development

  1. Run npm install to install dependencies
  2. Make changes to the component in the src directory
  3. Test your changes using the development mode

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Created by Stackdrop

About

A port of editor.js to a Retool component

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages