Home

Awesome

Anchor block tune for Editor.js

This Editor.js block tune enables users to add or remove an anchor to any block tool. Anchors provide the ability to target specific HTML elements within a webpage, aiding in seamless navigation.

A few points to note:

Preview

preview

Installation

Using npm

npm install @coolbytes/editorjs-anchor

Using yarn

yarn add @coolbytes/editorjs-anchor

Usage

To make it available to all block tools:

const editor = new EditorJS({
  tools: {
    anchor: Anchor
  },
  tunes: ['anchor']
});

To make it available to a particular block tool:

const editor = new EditorJS({
  tools: {
    anchor: Anchor,
    paragraph: {
      class: Paragraph,
      tunes: ['anchor']
    }
  }
});

Config Params

FieldTypeDefaultDescription
anchorLengthnumber30Maximum length (no. of characters) of the anchor value

 

const editor = EditorJS({
  tools: {
    anchor: {
      class: Anchor,
      config: {
        anchorLength: 30
      }
    }
  },
  tunes: ['anchor']
});

Output data

TypeDescription
stringAnchor value

 

Example for Paragraph Tool:

{
  "type": "paragraph",
  "data": {
    "text": "Some paragraph to test the anchor block tune"
  },
  "tunes": {
    "anchor": "Some_paragraph_to_test_the_anc"
  }
}