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

@synapsestudios/draftjs-editor

v3.1.0

Published

A customized WYSIWYG editor utilizing Facebook's Draft.js library

Downloads

175

Readme

@synapsestudios/draftjs-editor

A simple WYSIWYG text editor utilizing Facebook's Draft.js library– customized by Synapse Studios

npm version

Demo

A demo is available at https://synapsestudios.github.io/draftjs-editor/

Usage

Installing via CLI

// yarn
yarn add @synapsestudios/draftjs-editor

// npm
npm install --save @synapsestudios/draftjs-editor

Importing JS

The default export is the React editor component itself:

import SynapseDraft from '@synapsestudios/draftjs-editor';

It also exports the following utilities:

  • DraftJSEditor - The default React component
  • Renderer(customBlocks) - A constructor that creates a new Draft to HTML renderer, currently only exposes the method convertRawToHTML(rawContent)
  • defaultBlocks - A default set of blocks to pass into the Renderer, these can be used or overridden in your own project as well
  • convertFromRaw() - Simple passthrough of DraftJS's convertFromRaw utility

Importing CSS

// Minified, autoprefixed css
import '@synapsestudios/draftjs-editor/lib/draftjs-editor.min.css';

// Not-minified, not-autoprefixed css
import '@synapsestudios/draftjs-editor/lib/draftjs-editor.css';

Styling

The two main component classNames are DraftJSEditor-root for the container and DraftJSEditor-editor for the editor itself.

If you are using Stylus you can import the .styl file into your build:

@import '@synapsestudios/draftjs-editor/lib/draftjs-editor.styl';

API

Props

Props are automatically passed onto the DraftJS Editor component. Anything usable from the api can also be passed into DraftJSEditor.

  • containerStyle (object) - passes inline styling directly into the parent component of the editor. This can also be modified by using CSS to style the class name DraftJSEditor-root
  • className (string) - Classes to add to the editor component
  • id (string) - ID to add to the editor component
  • customBlocks (object) - An object containing the custom blocks you want the editor to render, see defaultBlocks for examples
  • customBlockControls (array) - An array of keys of custom blocks to render the controls for

Renderer Methods

  • convertRawToHTML(rawContent) - Takes raw DraftJS state object and renders it to HTML

Contributing

To run the project on your own computer:

  • Clone this repository
  • yarn install or npm install
  • yarn run storybook or npm run storybook
  • Visit http://localhost:5000/
  • Changes made to files in the src directory should immediately compile and be visible in your browser.