1.0.2 • Published 6 months ago

@juratbek/editorjs-header v1.0.2

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

Heading Tool For EditorJs

Provides Headings Blocks for the Editor.js.

Installation

Installation

npm

npm i --save @juratbek/editorjs-header

yarn

npm i --save @juratbek/editorjs-header

Usage

Add the Code tool to the tools property of the Editor.js initial config.

import EditorJs from "@editorjs/editorjs";
import Header from "@juratbek/editorjs-header";

const editor = EditorJs({
  // ...
  tools: {
    header: Header,
  },
});

Shortcut

You can insert this Block by a useful shortcut. Set it up with the tools[].shortcut property of the Editor's initial config.

var editor = EditorJS({
  ...

  tools: {
    ...
    header: {
      class: Header,
      shortcut: 'CMD+SHIFT+H',
    },
  },

  ...
});

Config Params

All properties are optional.

FieldTypeDescription
placeholderstringheader's placeholder string
levelsnumber[]enabled heading levels
defaultLevelnumberdefault heading level

var editor = EditorJS({
  ...

  tools: {
    ...
    header: {
      class: Header,
      config: {
        placeholder: 'Enter a header',
        levels: [2, 3, 4],
        defaultLevel: 3
      }
    }
  }

  ...
});

You can select one of six levels for heading.

Output data

FieldTypeDescription
textstringheader's text
levelnumberlevel of header: 1 for H1, 2 for H2 ... 6 for H6

{
  "type": "header",
  "data": {
    "text": "Why Telegram is the best messenger",
    "level": 2
  }
}
1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago