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

wix-rich-content-monorepo

v7.1.4

Published

[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lernajs.io/) [![Build Status](https://travis-ci.org/wix-incubator/rich-content.svg?branch=master)](https://travis-ci.org/wix-incubator/rich-content)

Downloads

10

Readme

Wix Rich Content

lerna Build Status

A React based, super charged rich text editor with an extensible plugin system

Demo

You can try it here: https://wix-rich-content.herokuapp.com/

Installation

To install this package as editor, use the following command (draft-js version):

npm install --save wix-rich-content-editor draft-js

To install this package as viewer, use the following command:

npm install --save wix-rich-content-viewer

To use the editor with <script> tag, consume the following JS file: dist/EditorCommon.js and dist/Editor.js from the bundle, and load the matching CSS files:

<html>
  <head>
    <script src="https://unpkg.com/wix-rich-content-editor-common/dist/EditorCommon.js"></script>
    <script src="https://unpkg.com/wix-rich-content-editor/dist/Editor.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/wix-rich-content-editor-common/dist/styles.min.css" />
    <link rel="stylesheet" href="https://unpkg.com/wix-rich-content-editor/dist/styles.min.css" />
  </head>
  <body>
    <script>
      const { RichContentEditor, EditorState } = window.WixRichContentEditor;
    </script>

    <!-- ...rest of your app code... -->
  </body>
</html>

Getting Started

1. Basic Editor

To get started with the editor, create a simple React.Component, and import the editor component:

import { EditorState, RichContentEditor } from 'wix-rich-content-editor';

Then, create an empty editorState in your state:

export class MyApp extends React.Component {
  state = {
    editorState: EditorState.createEmpty(),
  };
}

Use the RichContentEditor component in your render function, and implement onChange function:

import React from 'react';
import { EditorState, RichContentEditor } from 'wix-rich-content-editor';

export class MyApp extends React.Component {
  state = {
    editorState: EditorState.createEmpty(),
  };

  onChange = editorState => {
    this.setState({
      editorState,
    });
  };

  render() {
    return (
      <div>
        <RichContentEditor onChange={this.onChange} editorState={this.state.editorState} />
      </div>
    );
  }
}

Now, to make sure you are getting the most of the rich-content editor, include the compiled CSS files in your app's main file:

app.js

import 'wix-rich-content-editor-common/dist/styles.min.css';
import 'wix-rich-content-editor/dist/styles.min.css';
import 'wix-rich-content-plugin-...'/dist/styles.min.css';

You can also import the CSS files using @import '~...;` from a SCSS file.

2. Add Plugins

To add plugins to your editor, choose one of the implemented plugins from the list of available plugins.

Install the plugin you wish use from NPM:

npm install wix-rich-content-plugin-divider

Import the plugin's stylesheet file in your main app's file:

import 'wix-rich-content-plugin-divider/dist/styles.min.css';

Then, add plugins prop with the plugin's creation method:

import React from 'react';
import { EditorState, RichContentEditor } from 'wix-rich-content-editor';
import { createDividerPlugin } from 'wix-rich-content-plugin-divider';

const PLUGINS = [createDividerPlugin];

export class MyApp extends React.Component {
  state = {
    editorState: EditorState.createEmpty(),
  };

  onChange = editorState => {
    this.setState({
      editorState,
    });
  };

  render() {
    return (
      <div>
        <RichContentEditor
          plugins={PLUGINS}
          onChange={this.onChange}
          editorState={this.state.editorState}
        />
      </div>
    );
  }
}

3. Theme and Custom Styling

To customize the look and feel of the editor, you can use theme prop, and override the styles as you wish.

Use the style's className to override. It also support css-modules imports.

my-style.css

.divider {
  backgorund-color: red;
}

.divider-container {
  border: 1px blue solid;
}
import React from 'react';
import { EditorState, RichContentEditor } from 'wix-rich-content-editor';
import { createDividerPlugin } from 'wix-rich-content-plugin-divider';
import dividerTheme from './my-style.css';

const PLUGINS = [createDividerPlugin];

const THEME = {
  ...dividerTheme,
};

export class MyApp extends React.Component {
  state = {
    editorState: EditorState.createEmpty(),
  };

  onChange = editorState => {
    this.setState({
      editorState,
    });
  };

  render() {
    return (
      <div>
        <RichContentEditor
          theme={THEME}
          plugins={PLUGINS}
          onChange={this.onChange}
          editorState={this.state.editorState}
        />
      </div>
    );
  }
}

You can find a full list of classes you can override in here.

Plugins

wix-rich-content-plugin-divider add dividers to your content

wix-rich-content-plugin-emoji add emojis to your content

wix-rich-content-plugin-hashtag convert plain text #hastags into dynamic elements

wix-rich-content-plugin-html embed html code or sites in your content

wix-rich-content-plugin-link convert plain text URLs into <a> tags

wix-rich-content-plugin-video add videos to your content

wix-rich-content-plugin-mentions mention users in your content

wix-rich-content-plugin-code-block displays code block

wix-rich-content-plugin-image embed images in your content

wix-rich-content-plugin-gallery embed Wix pro-gallery component in your content

Usage with Yoshi

To use the editor with Yoshi, you should do the same bootstrapping process, but make sure to include the package's .css files from a .global.scss file. For example, create a file named rich-content.global.scss with the following content (make sure to import styles from any plugins you are using as well):

@import '~wix-rich-content-editor-common/dist/styles.min.css';
@import '~wix-rich-content-editor/dist/styles.min.css';

This workaround is required because Yoshi re-compiles CSS files, and applies css-modules again.

SSR support

The compiled package also contains a CommonJS bundle, which you can consume if you are using SSR.

Development

Run Locally

  1. cd rich-content
  2. npm i - installs all dependencies and links any cross-dependencies.
  3. Build the modules by running one of the following:
    1. npm run build - build once and bundles
    2. npm run watch - rebuild on changes
  4. Choose an example and run:
    1. npm start

Examples

rich-content-editor-example to see how to consume the Component as:

rich-content-viewer-ssr to see how to consume the Component as a viewer within a Yoshi-based SSR Application.

Modules

wix-rich-content-editor is the rich content editor React Component.

wix-rich-content-viewer is the rich content viewer React Component.

wix-rich-content-editor-common is a shared library utilized by the rest of the modules.