@coolbytes/editorjs-paragraph

1.0.2 • Public • Published

Paragraph block tool for Editor.js

This Editor.js block tool extends @editorjs/paragraph to include alignment options (see Preview).

Preview

Block Tool

paragraph

Block Settings

settings

Installation

Using npm

npm install @coolbytes/editorjs-paragraph

Using yarn

yarn add @coolbytes/editorjs-paragraph

Usage

Include it in the tools property of Editor.js config:

const editor = new EditorJS({
  tools: {
    paragraph: Paragraph
  }
});

Config Params

Field Type Optional Default Description
placeholder string Yes '' Placeholder text when empty
preserveBlank boolean Yes false Indicates whether to include blank paragraphs when saving editor data
alignTypes string[] Yes ['left', 'center', 'right', 'justify'] All supported alignment options
defaultAlignType string Yes 'left' Preferred alignment type

 

const editor = EditorJS({
  tools: {
    paragraph: {
      class: Paragraph,
      config: {
        placeholder: 'Start Typing...',
        preserveBlank: false,
        alignTypes: ['left', 'center', 'right', 'justify'],
        defaultAlignType: 'left'
      }
    }
  }
});

Output data

Field Type Description
text string Paragraph's text
align string Alignment type

 

Example:

{
  "time": 1715969561758,
  "blocks": [
    {
      "id": "_K5QcJHHuK",
      "type": "paragraph",
      "data": {
        "text": "Cool Bytes",
        "align": "center"
      }
    }
  ],
  "version": "2.29.1"
}

Package Sidebar

Install

npm i @coolbytes/editorjs-paragraph

Weekly Downloads

16

Version

1.0.2

License

MIT

Unpacked Size

15.5 kB

Total Files

4

Last publish

Collaborators

  • coolbytes.in