Skip to content

VolgaIgor/editorjs-anchor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anchor Block Tune for Editor.js

Append field with anchor to any block.

Preview

Preview image

Required

  • Editor.js v2.20+

Installation

Install via NPM

Get the package

$ npm i editorjs-anchor

Include module at your application

import AnchorTune from 'editorjs-anchor';

Load from CDN

You can load a specific version of the package from jsDelivr CDN.

Require this script on a page with Editor.js.

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

Download to your project's source dir

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

Usage

For all blocks

var editor = EditorJS({
  // ...
  tools: {
    // ...
    anchorTune: AnchorTune
  },
  tunes: ['anchorTune']
  // ...
});

For particular block

var editor = EditorJS({
  // ...
  tools: {
    // ...
    anchorTune: AnchorTune,
    header: {
      class: Header,
      tunes: ['anchorTune']
    }
  }
  // ...
});

Config Params

You can add a localized string

new Editorjs({
  // ...
  tools: {
    anchorTune: AnchorTune
  },
  i18n: {
    tools: {
      anchorTune: {
        'Anchor': 'Якорь'
      }
    }
  },
})

Output data

Example for Header block

{
  "type": "header",
  "data": {
    "text": "Header",
    "level": 2
  },
  "tunes": {
    "anchorTune": {
      "anchor": "header-anchor"
    }
  }
}

If the anchor field is empty, then the tune data will not be serialized into JSON.

About

Append field with anchor to any Editor.js block

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published