Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/editor-js/nested-list
Multi-leveled lists for the Editor.js.
https://github.com/editor-js/nested-list
Last synced: 3 months ago
JSON representation
Multi-leveled lists for the Editor.js.
- Host: GitHub
- URL: https://github.com/editor-js/nested-list
- Owner: editor-js
- License: mit
- Created: 2021-02-18T16:16:24.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-02T19:26:44.000Z (3 months ago)
- Last Synced: 2024-08-02T22:08:15.761Z (3 months ago)
- Language: TypeScript
- Homepage:
- Size: 544 KB
- Stars: 41
- Watchers: 3
- Forks: 43
- Open Issues: 36
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-editorjs - @editorjs/nested-list - leveled lists (Tools / Block Tools)
README
![](https://badgen.net/badge/Editor.js/v2.19.2/blue)
# Nested List Tool for Editor.js
Multi-leveled lists for the [Editor.js](https://editorjs.io).
Use `Tab` and `Shift+Tab` keys to create or remove sublist with a padding.
![](assets/example.gif)
## Installation
Get the package
```shell
yarn add @editorjs/nested-list
```Include module at your application
```javascript
import NestedList from '@editorjs/nested-list';
```Optionally, you can load this tool from CDN [JsDelivr CDN](https://cdn.jsdelivr.net/npm/@editorjs/nested-list@latest)
## Usage
Add the NestedList Tool to the `tools` property of the Editor.js initial config.
```javascript
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
| Field | Type | Description |
|--------------|----------|----------------------------------------------------------------|
| defaultStyle | `string` | default list style: `ordered` or `unordered`, default is `unordered` |## Tool's settings
![](assets/bf5a42e4-1350-499d-a728-493b0fcaeda4.jpg)
You can choose list`s type.
## Output data
| Field | Type | Description |
| ----- | --------- | ---------------------------------------- |
| style | `string` | type of a list: `ordered` or `unordered` |
| items | `Item[]` | the array of list's items |Object `Item`:
| Field | Type | Description |
| ------- | --------- | ------------------------- |
| content | `string` | item's string content |
| items | `Item[]` | the array of list's items |```json
{
"type" : "list",
"data" : {
"style" : "unordered",
"items" : [
{
"content": "Apples",
"items": [
{
"content": "Red",
"items": []
},
{
"content": "Green",
"items": []
},
]
},
{
"content": "Bananas",
"items": [
{
"content": "Yellow",
"items": []
},
]
},
]
}
},
```