Home

Awesome

Editor.js Alert Tool

npm Version of EditorJS that the plugin is compatible with

Provides Alert blocks for the Editor.js.

Features

How does it look like?

Watch this tool in action in the following short GIF movie.

<p align="center"> <img src="https://user-images.githubusercontent.com/876195/87923460-294ee780-ca9b-11ea-8a73-009453d77478.gif" alt="Alert sneak peek GIF!">

Try it out yourself on the demo page.

Installation

Install via NPM

Get the package

npm i --save editorjs-alert

Include module at your application

const Header = require('editorjs-alert');

// OR

import Alert from 'editorjs-alert';

Download to your project's source dir

Copy dist/bundle.js file to your page.

Load from CDN

You can load specific version of package from jsDelivr CDN.

<script src="https://cdn.jsdelivr.net/npm/editorjs-alert@latest"></script>

Usage

Add a new Tool Alert to the tools property of the Editor.js initial config.

var editor = EditorJS({
  // ...

  tools: {
    // ...
    alert: Alert,
  },

  // ...
});

Or initialize Alert tool with additional optional settings

var editor = EditorJS({
  //...

  tools: {
    //...
    alert: {
      class: Alert,
      inlineToolbar: true,
      shortcut: 'CMD+SHIFT+A',
      config: {
        alertTypes: ['primary', 'secondary', 'info', 'success', 'warning', 'danger', 'light', 'dark'],
        defaultType: 'primary',
        messagePlaceholder: 'Enter something',
      },
    },
  },

  //...
});

Config Params

All properties are optional.

FieldTypeDefault ValueDescription
alertTypesarray['primary', 'secondary', 'info', 'success', 'warning', 'danger', 'light', 'dark']Alert types that can be used in the editor
defaultTypestringinfodefault Alert type (should be either of primary, secondary, info, success, warning, danger, light or dark)
defaultAlignstringleftdefault Alert alignment (should be either of left, center or right)
messagePlaceholderstringType here...placeholder to show in Alert`s message

Output data

FieldTypeDescription
messagestringAlert message
typestringAlert type among one of primary, secondary, info, success, warning, danger, light or dark
alignstringAlign type should be one of left, center or right
{
  "type": "alert",
  "data": {
    "type": "danger",
    "align" : "center",
    "text": "<strong>Holy smokes!</strong><br>Something seriously <em>bad</em> happened."
  }
}

Local Development

Publishing to NPM

License

This project is licensed under the MIT License.