JSPM

editorjs-header-with-anchor

2.5.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1563
  • Score
    100M100P100Q114511F
  • License MIT

Header Tool with anchor for Editor.js

Package Exports

  • editorjs-header-with-anchor

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (editorjs-header-with-anchor) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Heading Tool with anchor

Version of EditorJS that the plugin is compatible with

Provides Headings Blocks with the ability to set an anchor text for the Editor.js. Forked by Header Tool

Screenshot

header-with-anchor

Installation

Install via NPM

Get the package

npm i --save editorjs-header-with-anchor

Include module at your application

const Header = require('editorjs-header-with-anchor');

Download to your project's source dir

  1. Upload folder dist from repository
  2. Add dist/bundle.js file to your page.

Usage

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

var editor = EditorJS({
  ...

  tools: {
    ...
    header: Header,
  },

  ...
});

Available characters: all Latin letters, digitals, dash, and underscore. In the 'cyrToLat' branch, you can find additional functionality: Cyrillic characters are replaced by Latin letters, for example, ш to sch.

P.S. The anchor value is displayed next to the header block only when there is text in the header block.

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.

Field Type Description
placeholder string header's placeholder string
levels number[] enabled heading levels
defaultLevel number default heading level
allowAnchor boolean Anchor enabling (default: true)
anchorLength number Anchor length (default: 50)
var editor = EditorJS({
  ...

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

  ...
});

Output data

Field Type Description
text string header's text
level number level of header: 1 for H1, 2 for H2 ... 6 for H6
anchor string anchor's text
{
  "type": "header",
  "data": {
    "text": "Why Telegram is the best messenger",
    "level": 2,
    "anchor": "Anchor"
  }
}