Overview
TheEditorContent 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 namesstyle- Inline stylesid- Element IDonClick,onFocus, etc. - Event handlers- Any other valid div attributes
Ref Forwarding
The component supports ref forwarding, allowing you to get a reference to the underlyingHTMLDivElement:
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.Behavior
Mounting and Unmounting
- When mounted,
EditorContentattaches 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
EditorContentunmounts
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
Related
- useEditor - Hook for creating the editor instance
- BubbleMenu - Contextual menu component
- FloatingMenu - Floating menu component
- Editor - Core editor API