npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@coolbytes/editorjs-link

v1.0.0

Published

Link inline tool for Editor.js

Downloads

25

Readme

Link inline tool for Editor.js

This Editor.js inline tool enables users to add or remove a hyperlink. This takes inspiration from editorjs-hyperlink and makes some adjustments.

A few points to note:

  • This inline tool can be accessed from the Inline Toolbar (see Preview).
  • The inline button functions as a toggle, allowing you to show or hide the action menu.
  • When a link already exists in the selected text, the action menu automatically detects it and gives you the option to Remove it.

Preview

preview

add-link

remove-link

Installation

Using npm

npm install @coolbytes/editorjs-link

Using yarn

yarn add @coolbytes/editorjs-link

Usage

Include it in the tools property of Editor.js config:

const editor = new EditorJS({
  tools: {
    link: Link
  }
});

Config Params

|Field|Type|Optional|Default|Description| |---|---|---|---|---| |shortcut|string|Yes|'CMD+L'|Shortcut to toggle link action menu| |placeholder|string|Yes|'Enter URL'|Placeholder text for URL| |targets|string[]|Yes|['_self', '_blank', '_parent', '_top']|All supported link targets| |defaultTarget|string|Yes|'_self'|Preferred link target| |relations|string[]|Yes|['', 'alternate', 'author', 'bookmark', 'canonical', 'external', 'help', 'license', 'manifest', 'me', 'next', 'nofollow', 'noopener', 'noreferrer', 'prev', 'search', 'tag']|All supported link rels| |defaultRelation|string|Yes|''|Preferred link rel| |validate|boolean|Yes|true|Defines if an URL should be validated|

 

const editor = EditorJS({
  tools: {
    link: {
      class: Link,
      config: {
        shortcut: 'CMD+L',
        placeholder: "Enter URL",
        targets: ['_self', '_blank', '_parent', '_top'],
        defaultTarget: '_self',
        relations: ['', 'alternate', 'author', 'bookmark', 'canonical', 'external', 'help', 'license', 'manifest', 'me', 'next', 'nofollow', 'noopener', 'noreferrer', 'prev', 'search', 'tag'],
        defaultRelation: '',
        validate: true
      }
    }
  }
});

Output data

The block output would include a hyperlink (<a> tag) with ce-link CSS class.

Example for Paragraph Tool:

{
  "type": "paragraph",
  "data": {
    "text": "This is some <a class=\"ce-link\" href=\"https://example.com\" target=\"_self\" rel=\"alternate\">hyperlink</a> to demonstrate."
  }
}