This Editor.js block tool extends @editorjs/paragraph to include alignment options (see Preview).
Using npm
npm install @coolbytes/editorjs-paragraph
Using yarn
yarn add @coolbytes/editorjs-paragraph
Include it in the tools
property of Editor.js config:
const editor = new EditorJS({
tools: {
paragraph: Paragraph
}
});
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'
}
}
}
});
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"
}