@coolbytes/editorjs-paragraph
v1.0.2
Published
Paragraph block tool for Editor.js
Downloads
47
Maintainers
Readme
Paragraph block tool for Editor.js
This Editor.js block tool extends @editorjs/paragraph to include alignment options (see Preview).
Preview
Block Tool
Block 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"
}