Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

delta-detect-links

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

delta-detect-links

Detect links in a delta object.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
52
decreased by-8.77%
Maintainers
1
Weekly downloads
 
Created
Source

NPM Version Build Status Dependencies

Detect links in a delta object.

This small library is based on linkify-it to detect links in a rich text Delta object. The main purpose for this library is to automatically detect links in Quill documents.

API

This function detects all links in the given insert-only delta object.

const detectLinks = require('delta-detect-links');

detectLinks((new Delta()).insert('Visit www.example.com\n'));
// → [ { insert: 'Visit ' }, { insert: 'www.example.com', attributes: { link: 'http://www.example.com' } }, { insert: '\n' } ]

Already existing links in the given delta object will be skipped and not highlighted a second time.

Options

detectLinks supports an optional second parameter to set the following options:

  • skipTrailingMatch (default: false): This is useful when you want to detect links in real-time while the user types. In order to prevent detection of partial links the link will only be detected after another stop word has been encountered.
  • lastIndex: This option is only used in combination with skipTrailingMatch. This value is used to determine the trailing match. It is useful in scenarios where the current cursor is not at the same position as the end of the document.

detectLinksDelta

Similar to detectLinks but only contains the changes delta object.

const detectLinksDelta = require('delta-detect-links').detectLinksDelta;

detectLinksDelta((new Delta()).insert('Visit www.example.com\n'));
// → [ { retain: 6 }, { retain: 15, attributes: { link: 'http://www.example.com' } } ]

Keywords

FAQs

Package last updated on 08 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc