Home

Awesome

Editorjs List Tool

Use Tab and Shift+Tab keys to create or remove sublist with a padding.

Installation

Get the package

yarn add @editorjs/list

Include module at your application

import EditorjsList from '@editorjs/list';

Optionally, you can load this tool from CDN JsDelivr CDN

Usage

Add the List Tool to the tools property of the Editor.js initial config.

import EditorJS from '@editorjs/editorjs';
import EditorjsList from '@editorjs/list';

var editor = EditorJS({
  // ...
  tools: {
    ...
    list: {
      class: EditorjsList,
      inlineToolbar: true,
      config: {
        defaultStyle: 'unordered'
      },
    },
  },
});

[!IMPORTANT] Note that in List 2.0 class name changed from List to EditorjsList.

Config Params

FieldTypeDescription
defaultStylestringdefault list style: ordered, unordered or checklist, default is unordered
maxLevelnumbermaximum level of the list nesting, could be set to 1 to disable nesting, unlimited by default

Output data

FieldTypeDescription
stylestringlist will be rendered with this style: ordered, unordered or checklist, default is defaultStyle from tool config
metaItemMetaItem meta based on the list style
itemsItem[]the array of list's items

Object Item:

FieldTypeDescription
contentstringitem's string content
metaItemMetameta information about item
itemsItem[]the array of list's items

Object ItemMeta for Checklist:

FieldTypeDescription
checkedbooleanstate of the checkbox

Object ItemMeta for Ordered list

FieldTypeDescription
startnumbernumber for list to start with, default is 1
counterTypestringcounter type for list, it could be numeric, lower-roman, upper-roman, lower-alpha, upper-alpha, default is numeric

Object ItemMeta for Unordered list would be empty.

Example of the content for Unordered List

{
  "type" : "list",
  "data" : {
    "style": "unordered",
    "items": [
      {
        "content": "Apples",
        "meta": {},
        "items": [
          {
            "content": "Red",
            "meta": {},
            "items": []
          },
        ]
      },
    ]
  }
},

Example of the content for Ordered List

{
  "type" : "list",
  "data" : {
    "style": "ordered",
    "meta": {
      "start": 2,
      "counterType": "upper-roman",
    },
    "items" : [
      {
        "content": "Apples",
        "meta": {},
        "items": [
          {
            "content": "Red",
            "meta": {},
            "items": []
          },
        ]
      },
    ]
  }
},

Example of the content for Checklist

{
  "type" : "list",
  "data" : {
    "style": "checklist",
    "items" : [
      {
        "content": "Apples",
        "meta": {
          "checked": false
        },
        "items": [
          {
            "content": "Red",
            "meta": {
              "checked": true
            },
            "items": []
          },
        ]
      },
    ]
  }
},