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

@baigiel/editor

v1.4.7

Published

Baigiel rich text editor

Downloads

180

Readme

RichText Editor Library

A fully-featured rich text editor built with React and Tiptap. This library provides customizable components and extensions to create a seamless and interactive text editing experience.

Table of Contents

Features

  • Rich Text Editing: Bold, italic, underline, strikethrough, and more.
  • Lists: Support for ordered and unordered lists.
  • Links: Easily add and remove hyperlinks.
  • Tables: Advanced table management.
  • Images: Insert and manage images seamlessly.
  • Responsive Design: Built with Tailwind CSS for responsive and modern UI.
  • Extensible: Easily extendable with custom extensions and plugins.
  • Input Components: Various input types including text, number, date, select, and textarea.

Installation

Ensure you have Node.js installed.

  1. Install the package:

    npm install @baigiel/editor
    # or
    yarn add @baigiel/editor
  2. Import the CSS:

    import "@baigiel/editor/editor.css";

Usage

Basic Setup

Import the RichEditor component and include it in your React application:

import React, { useState } from "react";
import RichEditor from "@baigiel/editor";
import "@baigiel/editor/editor.css";

const App = () => {
  const [content, setContent] = useState("");

  return (
    <RichEditor
      value={content}
      onChange={(doc, raw) => setContent(raw)}
      editorClassName="custom-editor"
      contentClassName="custom-content"
      alwaysActive={true}
    />
  );
};

export default App;

RichEditor Options

The RichEditor component accepts the following props:

  • id (string): Optional identifier for the editor instance.
  • value (Content): The current content of the editor.
  • readonly (boolean): If set to true, the editor is in read-only mode.
  • closeOnBlur (boolean): Determines if the editor should lose focus when clicking outside.
  • onChange (function): Callback function triggered when the content changes. Receives the document and raw content as parameters.
  • editorClassName (string): Custom CSS classes for the editor container.
  • contentClassName (string): Custom CSS classes for the content area.
  • alwaysActive (boolean): If true, the editor remains active without needing to click to focus.

Input Component Options

The Input component provides versatile form input elements with various options. Here's how to use it along with its available props:

import React, { useState } from "react";
import Input from "@baigiel/editor";

const Form = () => {
  const [text, setText] = useState("");
  const [number, setNumber] = useState(0);
  const [date, setDate] = useState("");
  const [select, setSelect] = useState("");
  const [textarea, setTextarea] = useState("");

  return (
    <form>
      <Input
        label="Text Input"
        type="text"
        value={text}
        onChange={setText}
        placeholder="Enter some text"
      />
      <Input
        label="Number Input"
        type="number"
        value={number}
        onChange={setNumber}
        placeholder="Enter a number"
      />
      <Input label="Date Input" type="date" value={date} onChange={setDate} />
      <Input
        label="Select Input"
        type="select"
        value={select}
        onChange={setSelect}
        options={[
          { label: "Option 1", value: "option1" },
          { label: "Option 2", value: "option2" },
          { label: "Option 3", value: "option3" },
        ]}
      />
      <Input
        label="Textarea Input"
        type="textarea"
        value={textarea}
        onChange={setTextarea}
        placeholder="Enter multiple lines of text"
      />
    </form>
  );
};

export default Form;

Input Component Props

The Input component accepts the following props:

  • label (string): The label for the input field.
  • type (string): The type of input. Supported types:
    • "text": Single-line text input.
    • "number": Numeric input.
    • "date": Date picker.
    • "select": Dropdown selection.
    • "textarea": Multi-line text input.
    • "json": JSON input with monospace font.
    • "textarea-lb": Textarea with line break support.
  • value (any): The current value of the input.
  • onChange (function): Callback function triggered when the input value changes.
  • onSave (function): Optional callback for saving the input value asynchronously.
  • options (array): Required for select type. An array of options with label and value.
  • placeholder (string): Placeholder text for the input field.
  • className (string): Custom CSS classes for styling.
  • error (string): Error message to display below the input.
  • disabled (boolean): If true, the input is disabled.
  • valueMapper (object): Optional value mapper for transforming input values.