Skip to main content

Overview

The EditorContent component is responsible for rendering the actual editor interface where users can interact with content. It must be used in conjunction with the useEditor hook.

Type Signature

Props

Editor | null
required
The editor instance created by the useEditor hook. Can be null during initialization.
HTMLProps<HTMLDivElement>
All standard HTML div attributes are supported and will be passed to the wrapper element. This includes:
  • className - CSS class names
  • style - Inline styles
  • id - Element ID
  • onClick, onFocus, etc. - Event handlers
  • Any other valid div attributes

Ref Forwarding

The component supports ref forwarding, allowing you to get a reference to the underlying HTMLDivElement:

Usage Examples

Basic Usage

With Custom Styling

With Loading State

Multiple Editors

With Click Handler

Combining with Toolbar

Styling

CSS Classes

The editor content is wrapped in a div that you can style. The actual ProseMirror editor will be nested inside:

Tailwind CSS

Important Notes

The EditorContent component uses React portals internally to render node views. This ensures that React components used in custom node views maintain their context and state properly.
Do not conditionally render EditorContent based on the editor instance. Instead, handle the loading state by checking if the editor is null before rendering your component, or show a loading indicator.
You can render multiple EditorContent components with the same editor instance, but this is generally not recommended as it can lead to unexpected behavior. Each editor instance should typically have one content component.

Behavior

Mounting and Unmounting

  • When mounted, EditorContent attaches the ProseMirror view to the DOM
  • When unmounted, it properly cleans up the view and removes event listeners
  • The editor instance itself is not destroyed when EditorContent unmounts

Node Views

EditorContent automatically manages React-based node views:
  • Node views are rendered using React portals
  • They maintain full React context (hooks, context API, etc.)
  • Updates are synchronized with the editor state