1.0.5 â€ĸ Published 6 months ago

mertz-rich-text v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

mertz-rich-text

A flexible, accessible and customizable rich text editor and viewer component for React applications. Features a live preview mode, responsive design, and comprehensive text formatting options.

Features

  • 📝 Rich text editing with common formatting options (bold, italic, underline)
  • 🔤 Headings support (H1, H2)
  • 🔗 Link insertion
  • đŸ–ŧī¸ Image insertion with captions and alt text
  • đŸ‘ī¸ Live preview mode
  • 📱 Mobile-friendly and responsive design
  • â™ŋ Fully accessible with ARIA attributes
  • â†Šī¸ Undo/redo functionality
  • 🎨 Customizable styling
  • 📖 Read-only mode support

Installation

npm install mertz-rich-text
# or
yarn add mertz-rich-text
# or
pnpm add mertz-rich-text
# or
bun add mertz-rich-text

Usage

Basic example:

import { RichTextEditor } from 'mertz-rich-text';

function MyEditor() {
  const handleChange = (newContent) => {
    console.log('Content updated:', newContent);
  };

  return (
    <RichTextEditor
      initialContent="<p>Start typing here...</p>"
      onChange={handleChange}
    />
  );
}

Props

PropTypeDefaultDescription
initialContentstring""Initial HTML content for the editor
readOnlybooleanfalseWhen true, displays content in read-only mode
onChangefunction-Callback function that receives the updated HTML content
classNamestring""Additional CSS class for the container
showToolbarbooleantrueControls visibility of the formatting toolbar
showPreviewbooleantrueControls visibility of the live preview pane

Read-only Mode

Use the read-only mode to display formatted content without editing capabilities:

<RichTextEditor
  initialContent={myContent}
  readOnly={true}
  showToolbar={false}
/>

Styling

The component comes with default styling but can be customized using CSS variables:

.rich-text-container {
  --primary-color: #024a43;
  --secondary-color: #db783e;
  --background-color: #f5f5f5;
  --text-color: #142d25;
  --body-background-color: #fbf5f0;
}

Browser Support

  • Chrome
  • Firefox
  • Safari
  • Edge
  • Mobile browsers with touch support

Development

To build the package locally:

npm install
npm run build

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago