1.0.4 • Published 12 months ago

@coolbytes/editorjs-alerts v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Alerts block tool for Editor.js

This block tool provides alert banners for Editor.js. The tool also provides configuration to choose from different styles (see Styles) and to enable alignment options.

Preview

Block Tool

alerts

Block Settings

settings

Styles

Pastel (Default)

pastel

Solid

solid

Outlined

outlined

Installation

Using npm

npm install @coolbytes/editorjs-alerts

Using yarn

yarn add @coolbytes/editorjs-alerts

Usage

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

const editor = new EditorJS({
  tools: {
    alert: Alert
  }
});

Config Params

FieldTypeOptionalDefaultDescription
alertTypesstring[]Yes'info', 'success', 'blocked', 'warning', 'danger'All supported alert types
defaultAlertTypestringYes'info'Preferred alert type
alertStylesstring[]Yes'pastel', 'solid', 'outlined'All supported alert styles
defaultAlertStylestringYes'pastel'Preferred alert style
alignTypesstring[]Yes'left', 'center', 'right', 'justify'All supported alignment options
defaultAlignTypestringYes'left'Preferred alignment type

 

const editor = EditorJS({
  tools: {
    alert: {
      class: Alert,
      config: {
        alertTypes: ['info', 'success', 'blocked', 'warning', 'danger'],
        defaultAlertType: 'info',
        alertStyles: ['pastel', 'solid', 'outlined'],
        defaultAlertStyle: 'pastel',
        alignTypes: ['left', 'center', 'right', 'justify'],
        defaultAlignType: 'left'
      }
    }
  }
});

Output data

FieldTypeDescription
textstringAlert's text
alertstringAlert type
alertStylestringAlert style
alignstringAlignment type

 

Example:

{
  "time": 1715969561758,
  "blocks": [
    {
      "id": "_K5QcJHHuK",
      "type": "alert",
      "data": {
        "text": "This is an info alert",
        "alert": "info",
        "alertStyle": "pastel",
        "align": "left"
      }
    }
  ],
  "version": "2.29.1"
}
1.0.4

12 months ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago