Configuration options
Maximum size of the content in bytes (up to 2^53-1). Defaults to ~5MB if not set or zero.
Hint for the editor whether to apply URL conversion (e.g., stripping the domain name if URLs use the same domain as the editor). This is primarily used by the frontend editor component.
When true, requires the field value to be a non-empty string.
Validation rules
The editor field validates:- Type: Value must be a string
- Size: Content size must not exceed
maxSizebytes - Required: If enabled, value cannot be empty
The editor field does NOT perform HTML sanitization or validation. You should sanitize HTML content in your application layer if storing user-generated content.
Go examples
- Basic usage
- With size limit
- With URL conversion
- Multiple editor fields
Database column type
Frontend integration
TheconvertURLs option is used by frontend editors like TinyMCE:
Common use cases
HTML sanitization
The editor field does not sanitize HTML. You should implement sanitization in your application:Handling images and files
When storing HTML with embedded images, you have several options:Best practices
- Set appropriate
maxSizebased on expected content length - Implement HTML sanitization to prevent XSS attacks when storing user content
- Use file fields for images and reference them in HTML
- Consider separating very long content into multiple fields
- For plain text editors, use the text field instead
- The
convertURLsoption is a UI hint; it doesn’t modify stored data - Consider implementing content versioning for important editable content
Content size estimation
HTML content size includes all tags and attributes:
- Plain text: ~1 byte per character
- HTML tags add overhead:
<p>text</p>is 12 bytes total - Embedded styles and scripts significantly increase size
- Base64 images are ~33% larger than binary equivalents
maxSize accordingly!Zero value
The zero value for editor fields is an empty string"".