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

react-texteditor-toolkit

v1.0.12

Published

A simple text editor component with formatting options using React.

Downloads

693

Readme

TextEditor Component

A fully customizable and easy-to-use rich text editor built with React. Includes support for formatting, alignment, lists, and more.

Features

  • Formatting: Bold, italic, underline, and capitalization toggle.
  • Alignment: Left, center, and right text alignment.
  • Lists: Ordered (numbered) and unordered (bulleted) lists.
  • Clear Formatting: Remove all applied styles.
  • Customizable Toolbar Actions.

Installation

Install the package via npm:

npm i react-texteditor-toolkit

Usage

Here's how to use the TextEditor in your project:

import React, { useState } from "react";
import TextEditor from "react-texteditor-toolkit";

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

  const handleContentChange = (e: { target: { value: string } }) => {
    setContent(e.target.value);
    console.log("Editor Content:", e.target.value);
  };

  return (
    <div>
      <h1>My Rich Text Editor</h1>
      <TextEditor
        placeholder="Start typing here..."
         defaultValue="<p>This is the default content!</p>"
        onChange={handleContentChange}
        toolbarActions={["bold", "italic", "underline", "unorderedList", "clear"]}
        contentStyle={{ border: "1px solid #ddd", padding: "10px" }}
      />
      <p>Output:</p>
      <div dangerouslySetInnerHTML={{ __html: content }} />
    </div>
  );
};

export default App;

Customization

Styling the Editor

You can customize the editor's appearance using the contentStyle, iconStyle, and headerStyle props.

<TextEditor
  contentStyle={{ border: "2px solid #000", minHeight: "200px" }}
  iconStyle={{ color: "blue" }}
  headerStyle={{ backgroundColor: "#f4f4f4", padding: "10px" }}
  defaultValue="<p>This is the default content!</p>"
/>

Read-Only Mode

To prevent edits, set readOnly to true:

<TextEditor readOnly={true} />

TextEditorProps

| Prop | Type | Default | Description | | ---------------- | -------------------------------------------- | ----------------------------------------------- | ----------------------------------------------------- | | iconStyle | React.CSSProperties | {} | Customize the style of toolbar icons. | | contentStyle | React.CSSProperties | { border: '1px solid #ccc', padding: '10px' } | Customize the editor's content area style. | | headerStyle | React.CSSProperties | {} | Customize the style of the toolbar container. | | placeholder | string | "Type here..." | Placeholder text shown in the editor when it's empty. | | onChange | (e: { target: { value: string } }) => void | undefined | Callback triggered when the editor's content changes. | | readOnly | boolean | false | Sets the editor to read-only mode. | | defaultValue | string | "<p>This is the default content!</p>" | Default value shown in the editor. | | toolbarActions | Array<string> | See below | Specify the available toolbar actions. |

Available Toolbar Actions

You can customize the toolbarActions prop to include any of the following options:

  • "bold": Toggle bold formatting.
  • "italic": Toggle italic formatting.
  • "underline": Toggle underline formatting.
  • "unorderedList": Insert a bulleted list.
  • "orderedList": Insert a numbered list.
  • "alignLeft": Align text to the left.
  • "alignCenter": Align text to the center.
  • "alignRight": Align text to the right.
  • "capitalize": Toggle text capitalization.
  • "clear": Clear all formatting.