1.0.4 • Published 2 years ago

editorjs-hyperlink-browse v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

npm.io

Hyperlink Tool

A tool link with target & rel attribute for Editor.js.

Screen Shot 2020-11-08 at 23 51 36

Screen Shot 2020-11-08 at 23 51 43

Screen Shot 2020-11-08 at 23 52 04

Installation

Get the package via NPM

npm i editorjs-hyperlink -D

or via Yarn

yarn add editorjs-hyperlink -D

Include module at your application

const Hyperlink = require('editorjs-hyperlink');

Usage

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

var editor = EditorJS({
  ...
  
  tools: {
    ...

    hyperlink: {
      class: Hyperlink,
      config: {
        shortcut: 'CMD+L',
        target: '_blank',
        rel: 'nofollow',
        availableTargets: ['_blank', '_self'],
        availableRels: ['author', 'noreferrer'],
        validate: false,
      }
    },

    ...
  },

  ...

  i18n: {
    toolNames: {
      Hyperlink: 'Link'
    },
    tools: {
      hyperlink: {
        Save: 'Salvar',
        'Select target': 'Seleziona destinazione',
        'Select rel': 'Wählen rel'
      }
    }
  }
  
  ...
});

Config Params (optional)

FieldTypeDescription
shortcutstringShortcut, defaults to 'CMD+L'
targetstringDefines a default target, defaults to null
relstringDefines a default rel, defaults to null
availableTargetsstring[]Available link targets, defaults to all targets.If empty array is provided, the control will be hidden and the default value applied.
availableRelsstring[]Available link rels, defaults to all rels.If empty array is provided, the control will be hidden and the default value applied.
validatebooleanDefines if an URL should be validated on saving

License

MIT