0.0.19 • Published 8 months ago

@connectedxm/editor v0.0.19

Weekly downloads
-
License
MIT*
Repository
-
Last release
8 months ago

Editor Component

A reusable rich-text editor component built with React, TipTap, and Tailwind CSS. This editor allows you to initialize with existing content, handle content changes, and toggle read-only mode.

Table of Contents

Installation

Install the editor component via npm:

npm install @connectedxm/editor

Peer Dependencies

Ensure your project has the following packages installed:

  • React
  • React DOM

You can install them using

npm install react react-dom

Usage

Importing the Component

Import the Editor component into your React application:

import Editor from "@connectedxm/editor";

Importing Styles

The Editor component relies on a style sheet styling.

import "@connectedxm/editor/dist/styles.css";

Example Usage

Use the Editor component in your React components:

import "@connectedxm/editor/dist/styles.css";

function MyComponent() {
  const [content, setContent] = useState("<p>Initial content</p>");

  const handleContentChange = (newContent) => {
    setContent(newContent);
  };

  return (
    <Editor
      initialContent={content}
      onChange={handleContentChange}
      readOnly={false}
      className="custom-editor-class"
    />
  );
}

Props

The Editor component accepts the following props:

NameDescriptionTypeRequired
initialContentThe initial HTML content to load into the editor.stringYes
onChangeCallback function that is called whenever the content changes.(content: string) => voidYes
readOnlyIf set to true, the editor will be in read-only mode.booleanNo
classNameAdditional custom classes to apply to the editor container.stringNo

License

This project is licensed under the MIT License.