Rich Text Editor Plugin

PreviousNext

A plugin for the rich text editor.

Docs
shadcn-editorui

Preview

Loading preview…
registry/new-york-v4/editor/editor-ui/content-editable.tsx
import { JSX } from "react"
import { ContentEditable as LexicalContentEditable } from "@lexical/react/LexicalContentEditable"

type Props = {
  placeholder: string
  className?: string
  placeholderClassName?: string
}

export function ContentEditable({
  placeholder,
  className,
  placeholderClassName,
}: Props): JSX.Element {
  return (
    <LexicalContentEditable
      className={
        className ??
        `ContentEditable__root relative block min-h-72 min-h-full overflow-auto px-8 py-4 focus:outline-none`
      }
      aria-placeholder={placeholder}
      placeholder={
        <div
          className={
            placeholderClassName ??
            `text-muted-foreground pointer-events-none absolute top-0 left-0 overflow-hidden px-8 py-[18px] text-ellipsis select-none`
          }
        >
          {placeholder}
        </div>
      }
    />
  )
}

Installation

npx shadcn@latest add @shadcn-editor/rich-text-editor-plugin

Usage

import { RichTextEditorPlugin } from "@/components/ui/rich-text-editor-plugin"
<RichTextEditorPlugin />