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

draft-regex

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

draft-regex

Plugin for checking text with regular expressions

  • 1.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23
decreased by-73.56%
Maintainers
1
Weekly downloads
 
Created
Source

Draft Regex

Greenkeeper badge

These plugins are written for Draft.js and React to improve TextEditor capabilities.

To use static typing, make sure that you have installed Flow.

Getting started

npm install draft-regex

or

yarn add draft-regex

How to use

Draft Regex

API

All plugin as an argument are taken by EditorState and options and returned EditorState.

clearEmptyBlock

Prevents the ability to add blank lines more than 3 (varies in settings).

A second argument can take a number for remove blank lines (number + 1).

function clearEmptyBlocks(editorState: EditorState, maxEmptyLines?: number = 2): EditorState

replaceTextRegex

Apply regular expressions to the entire text, in the process of typing or after copy/pasting text.

A second argument can take an array of rules. typoRules is a set of basic rules that you can not use.

A third argument can take an object that can contain options, which you can expand to use the plugin is very flexible.

extraSpaces are simple regular expressions that forbid doing more than one space in a row.

function replaceTextRegex(
  editorState: EditorState,
  rulesArray?: Array<Rule> = typoRules,
  options?: Options = { extraSpaces: true }
): EditorState

The rule looks like this: { reg: new RegExp(), shift: '' }

clearPastedStyle

Clears styles of copy/pasted text to those that you have.

A second argument can take an object that can contain options.

blockTypes is an array of strings that contains all the types of blocks that you use in your editor. This is useful if you want to clear all styles, except those you can already ask yourself.

If you do not want to use all six kinds of headings, you can bring the headers to the same view using replaceHeader and shiftHeader.

The same applies to lists.

function clearPastedStyle(
  editorState: EditorState,
  options?: {
    blockTypes?: Array<string>,
    replaceHeader?: boolean,
    shiftHeader?: string,
    replaceList?: boolean,
    shiftList?: string,
  }
): EditorState

Keywords

FAQs

Package last updated on 18 Jan 2018

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