RichTextEditorContent
A secure component for rendering HTML-based rich text content from WellPlayed, such as tournament descriptions, event descriptions, and other user-generated content.Overview
TheRichTextEditorContent component uses TipTap to safely render rich text content with support for:
- Text formatting (bold, italic, underline)
- Headings and paragraphs
- Lists and code blocks
- Text alignment
- Subscript and superscript
- Syntax highlighting
- Links
This component is read-only and designed for displaying content. It’s not an editor component.
Props
The rich text content to render, in HTML or TipTap JSON format.
Optional CSS styles to apply to the container div.
Basic Usage
With Custom Styling
Apply custom styles to the content container:Use Cases
Tournament Info
Display tournament descriptions and rules
Event Details
Show event descriptions and schedules
Announcements
Render formatted announcements
User Profiles
Display rich user bios and profiles
Supported Extensions
The component includes the following TipTap extensions:StarterKit
StarterKit
Includes essential editing features:
- Bold, italic, strike
- Headings (h1-h6)
- Paragraphs
- Lists (ordered and unordered)
- Code blocks
- Blockquotes
- Hard breaks
- Horizontal rules
Underline
Underline
Renders underlined text.
Superscript
Superscript
Renders superscript text (e.g., x²).
Subscript
Subscript
Renders subscript text (e.g., H₂O).
Highlight
Highlight
Renders highlighted/marked text.
TextAlign
TextAlign
Supports text alignment for headings and paragraphs:
- Left
- Center
- Right
- Justify
Security
The component:- Does not execute scripts in the content
- Sanitizes HTML to prevent XSS vulnerabilities
- Validates content structure
- Is read-only by default (editable=)
Full Example
Complete example fetching and displaying tournament content:Styling Tips
- CSS Modules
- Tailwind CSS
- Inline Styles
content.module.css
Source Reference
Component implementation:rich-text-editor-content.tsx:9-30-RichTextEditorContentcomponentrich-text-editor-content.tsx:1-7- TipTap extension imports