editor

package
v0.0.0-...-6e56996 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package editor defines the WYSIWYG editor provider interface for workflow-plugin-cms.

The CMS engine stores page content in TWO complementary forms:

  • body_blocks: structured block JSON (provider-specific shape)
  • body_html: rendered HTML for serve-time output

Providers translate between the two and render block trees to HTML.

Per gocodealone-multisite SPEC.md V10: provider impls share a common interface; swap = config flag, no code change.

Default provider = TipTap (MIT, ProseMirror-based). Alt providers (Editor.js, Lexical, TinyMCE community) implement the same interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider interface {
	// Name returns the provider's short identifier (e.g. "tiptap",
	// "editorjs", "lexical"). Matches the `provider` config key.
	Name() string

	// FrontendBundleID returns the identifier of the editor's JS bundle
	// shipped with the admin UI. Empty string = host serves no bundle
	// for this provider (rare; usually only true for stub/test).
	FrontendBundleID() string

	// EmptyBlocks returns the canonical "empty document" block JSON for
	// new pages. Callers persist this as `body_blocks` for newly-created
	// drafts.
	EmptyBlocks() json.RawMessage

	// Render translates block JSON to HTML for serve-time output.
	// Returns ("", false) on bad input — caller falls back to last
	// known good body_html (V14: dynamic rendering is server-side
	// deterministic, never client-fetch).
	Render(blocks json.RawMessage) (html string, ok bool)

	// Validate returns nil if the block JSON is structurally valid for
	// this provider; otherwise an error suitable for surfacing to the
	// admin UI.
	Validate(blocks json.RawMessage) error
}

Provider is the contract every WYSIWYG backend implements.

Methods are intentionally minimal — the CMS engine owns persistence, auth, and route resolution. The provider owns block-format <→> HTML rendering and front-end-component identity.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry holds the set of available providers and resolves the currently-configured default by name.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty Registry. Use Register to add providers at process start; lookup is concurrency-safe thereafter.

func (*Registry) Count

func (r *Registry) Count() int

Count returns the number of registered providers.

func (*Registry) Get

func (r *Registry) Get(name string) (Provider, bool)

Get returns the provider with the given name. ok=false if not registered.

func (*Registry) Names

func (r *Registry) Names() []string

Names returns the sorted list of registered provider names. Stable output suits diagnostic dumps + admin UI provider lists.

func (*Registry) Register

func (r *Registry) Register(p Provider) error

Register adds a provider keyed by its Name(). Returns an error if a provider with the same name is already registered (duplicate config is a hard error to surface mismatches early).

Directories

Path Synopsis
Package editorjs implements the alternative Editor.js WYSIWYG provider — example T23 / SPEC V10.
Package editorjs implements the alternative Editor.js WYSIWYG provider — example T23 / SPEC V10.
Package tiptap implements the TipTap WYSIWYG editor.Provider for the CMS engine.
Package tiptap implements the TipTap WYSIWYG editor.Provider for the CMS engine.

Jump to

Keyboard shortcuts

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