Skip to main content
The editor field stores HTML-formatted text content, typically from rich text editors like TinyMCE. It validates content size and provides options for URL conversion handling.

Configuration options

int64
default:"5242880"
Maximum size of the content in bytes (up to 2^53-1). Defaults to ~5MB if not set or zero.
bool
default:"false"
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.
bool
default:"false"
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 maxSize bytes
  • 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

Database column type

Frontend integration

The convertURLs 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:
Avoid storing large base64-encoded images in editor fields as they significantly increase field size. Instead, use a separate file field and reference the URLs.

Best practices

  • Set appropriate maxSize based 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 convertURLs option 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
Plan your maxSize accordingly!

Zero value

The zero value for editor fields is an empty string "".