richtext

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 10 Imported by: 0

README

Ridu rich-text plugin

github.com/riducms/ridu/plugins/richtext provides the rich-text field, portable Lexical document schema, server validation, reference metadata, and safe Go HTML renderer. Pair it with @riducms/plugin-richtext for the Svelte/Lexical editor.

Register the backend once, then use its field constructor:

ridu.Config{
	Plugins: []ridu.Plugin{richtext.New()},
	Collections: []ridu.Collection{{
		Slug: "posts",
		Fields: []field.Definition{
			richtext.Field("content", field.Required()),
		},
	}},
}

In an existing project, add both packages:

ridu add richtext \
  --go-package github.com/riducms/ridu/plugins/richtext \
  --admin-package @riducms/plugin-richtext

Then generate and create the selected adapter's migration. The generated registry imports the admin pair and rejects incompatible pairing metadata.

See the Rich text guide for installation, features, constraints, verification, SDK values, and server rendering.

Documentation

Overview

Package richtext provides Ridu's official versioned rich-text field plugin.

Index

Constants

View Source
const (
	Key                       = "richtext"
	DocumentVersion           = 1
	AdminPluginPairingVersion = 1
)

Variables

This section is empty.

Functions

func Field

func Field(name string, options ...field.PluginOption) field.Definition

Field constructs a rich-text field with Ridu's recommended authoring defaults.

func FieldWithConfig

func FieldWithConfig(name string, config Config, options ...field.PluginOption) field.Definition

func New

func New() ridu.Plugin

func RenderHTML

func RenderHTML(value store.Value, renderers map[string]func(store.Values) (string, error)) (string, error)

RenderHTML renders the portable core nodes. Custom feature nodes use a caller-owned renderer, keeping application presentation outside storage.

Types

type Config

type Config struct {
	Features                []Feature `json:"features"`
	UploadCollections       []string  `json:"uploadCollections,omitempty"`
	RelationshipCollections []string  `json:"relationshipCollections,omitempty"`
}

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a defensive copy of Ridu's recommended authoring defaults.

type Document

type Document map[string]any

Document is the serialized Lexical document stored by the rich-text field. Node shapes remain extensible and are validated against the field's enabled feature configuration at runtime. Document is the exact generated Go value type for a versioned rich-text document.

type Feature

type Feature string
const (
	FeatureLinks          Feature = "links"
	FeatureLists          Feature = "lists"
	FeatureCode           Feature = "code"
	FeatureHorizontalRule Feature = "horizontal-rule"
	FeatureUploads        Feature = "uploads"
	FeatureRelationships  Feature = "relationships"
	FeatureBlocks         Feature = "blocks"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL