2.0.0 • Published 5 months ago

@mongez/react-rte v2.0.0

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

Rich Text Editor (Moonlight)

A powerful Rich Text Editor using Tiptap and Mantine, powered by Moonlight as well.

Installation

npm i @mongez/react-rte

OR

yarn add @mongez/react-rte

OR

pnpm install @mongez/react-rte

The package requires peer dependencies, so you need to install them as well:

yarn add @mongez/moonlight

Usage

import { RichTextEditor } from '@mongez/react-rte';
import { useState } from 'react';

export function App() {
    const [value, setValue] = useState('');

    return (    
        <RichTextEditor
            value={value}
            onChange={setValue}
            placeholder="Type here..."
            label="Content"
            required
        />
    );
}

The Component by default uses the following:

  • Color Selector
  • Text Highlighter
  • Text Aligner
  • Youtube Embedder
  • Image Uploader (Drag & Drop)
  • Link
  • Font Style
  • Lists

Available Props

The following table shows all available props:

NameTypeDefaultDescription
valuestring''The value of the editor, used for controlled value
onChange(value: string) => void() => {}The function to be called when the value changes
placeholderstring''The placeholder of the editor
labelstring''The label of the editor
requiredbooleanfalseWhether the editor is required or not
defaultValuestring''The default value of the editor, used for uncontrolled value
hintstring''Display a hint message below the label
toolbarPropsToolbarProps{}The props of the toolbar, see Mantine ToolbarProps

Using as reactive form component

Simply use richTextInput function to get the Rich Text Editor as a form component.

import { richTextInput } from '@mongez/react-rte';
import { createReactiveForm, textInput } from "@mongez/moonlight";

createReactiveForm(reactiveForm => {
    reactiveForm.setInputs([
        textInput('title'),
        richTextInput('content'),
    ]);
})

TODO

  • Expose toolbar configurations per component or globally.
  • Expose extensions.