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

@avp1598/react-beautiful-editor

v0.2.2

Published

[Live Demo](https://editor.avp1598.dev/)

Downloads

13

Readme

React Beautiful Editor

Live Demo

A React component that allows you to create a beautiful rich text editor with resizable embeds, images, links, and more.

It is built on top of tiptap and it is an all batteries included editor.

Demo

How to use

Install the package:

yarn add @avp1598/react-beautiful-editor

pnpm install @avp1598/react-beautiful-editor

npm install @avp1598/react-beautiful-editor

Import the editor and the css

import { Editor } from "@avp1598/react-beautiful-editor";

const Home = () => {
  const [description, setDescription] = useState("");

  const onSave = () => {
    console.log("description", description);
  };

  const theme = "dark";

  return (
    <div
      // set text color based on the theme
      style={{
        color: theme === "dark" ? "white" : "black",
      }}
    >
      <Editor
        value={description}
        onChange={(value) => {
          setDescription(value);
        }}
        theme={theme}
        uploadImage={async (file) => {
          console.log("file", file);
          // upload the file to your server and return the url
          return "https://picsum.photos/400/600";
        }}
        placeholder="Enter description"
        embedBoundsSelector=".bounds"
        onBlur={onSave}
        readonly={false}
      />
    </div>
  );
};
// import the css
import "@avp1598/react-beautiful-editor/dist/Editor.css";

Features

Slash commands (Type / to see the list of commands)

Text

Heading 1

Heading 2

To-do list

Bulleted list

Numbered list

Divider

Image

Youtube

Twitter

Figma

Resizable embeds and Images

Node marks (Bold, Italic, Underline, Strikethrough, Link)

API (Available props)

You can pass the following props to the Editor component.

value (string)

The string value of the editor.

onChange (function)

A function that will be called whenever the value of the editor changes, with the new value as the first argument.

uploadImage (function)

A function that will be called whenever the user uploads an image, with the image file as the first argument. This function should return a promise that resolves to the URL of the uploaded image.

placeholder? (string)

The placeholder text for the editor.

default: Start typing and enter / for commands

theme? (string)

The theme of the editor.

default: light

embedBoundsSelector? (string)

The selector for the element that will be used to calculate the bounds of the embeds.

default: window

readonly? (boolean)

Whether the editor is readonly or not.

default: false

onBlur? (function)

A function that will be called whenever the editor loses focus.

onFocus? (function)

A function that will be called whenever the editor gains focus.

onReady? (function)

A function that will be called whenever the editor is ready to be used.

Props marked with ? are optional.

Working with server side rendering (SSR)

The editor component will not work if the page is server side rendered using next.js. To get around this, dynamic import the editor component.

import dynamic from "next/dynamic";

const Editor = dynamic(() => import("@avp1598/react-beautiful-editor"), {
  ssr: false,
});

Working with tailwindCSS

Tailwind css overrides the default heading and list styles of the editor. To fix this, you can add the following to your global css file where your tailwind directives are defined.

@tailwind base;

@layer base {
  ul,
  ol {
    list-style: revert;
  }

  h1,
  h2 {
    font-size: revert;
    font-weight: revert;
  }
}