1.0.2 • Published 1 year ago

@coolbytes/editorjs-paragraph v1.0.2

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

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

FieldTypeOptionalDefaultDescription
placeholderstringYes''Placeholder text when empty
preserveBlankbooleanYesfalseIndicates whether to include blank paragraphs when saving editor data
alignTypesstring[]Yes'left', 'center', 'right', 'justify'All supported alignment options
defaultAlignTypestringYes'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

FieldTypeDescription
textstringParagraph's text
alignstringAlignment type

 

Example:

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

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago