1.4.0 • Published 1 year ago

@medistream/editorjs-nested-list v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

npm.io

Nested List Tool for Editor.js

Multi-leveled lists for the Editor.js.

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

npm.io

Installation

Install via NPM

Get the package

npm i --save @editorjs/nested-list

Or

yarn add @editorjs/nested-list

Include module at your application

import NestedList from '@editorjs/nested-list';

Load from CDN

Load the script from jsDelivr CDN and connect to your page.

<script src="https://cdn.jsdelivr.net/npm/@editorjs/nested-list@latest"></script>

Usage

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

import EditorJS from '@editorjs/editorjs';
import NestedList from '@editorjs/nested-list';

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

Config Params

FieldTypeDescription
defaultStylestringdefault list style: ordered or unordered, default is unordered

Tool's settings

npm.io

You can choose list`s type.

Output data

FieldTypeDescription
stylestringtype of a list: ordered or unordered
itemsItem[]the array of list's items

Object Item:

FieldTypeDescription
contentstringitem's string content
itemsItem[]the array of list's items
{
    "type" : "list",
    "data" : {
        "style" : "unordered",
        "items" : [
            {
              "content": "Apples",
              "items": [
                {
                  "content": "Red",
                  "items": []
                },
                {
                  "content": "Green",
                  "items": []
                },
              ]
            },
            {
              "content": "Bananas",
              "items": [
                {
                  "content": "Yellow",
                  "items": []
                },
              ]
            },
        ]
    }
},
1.4.0

1 year ago