text

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Rendered for js/wasm

Overview

Package text provides a w-text rich-text editor custom element for wings.

w-text is a pluggable contenteditable editor whose every write passes through the epubhtml content policy (package epubhtml), so forbidden markup cannot exist in its content by construction. The editing engine lives in package wtext; this package is the widget shell: the w-input family anatomy (label/field/feedback, sizes, form participation), a toolbar rendered from the active profile with wings' own widgets, and the i18n/a11y wiring.

Dependencies

The toolbar renders w-button and w-combobox elements, so an app using w-text must also register those widgets (widget/button, widget/combobox). A profile with InputItem controls (StyleToolbar, for one) also renders w-input (widget/input) inside the item's popover.

Usage in parent template

<w-text label="Biography" profile="basic"
        helper="Tell readers about yourself."
        &value="{{bio}}">
</w-text>

value binds a wings.FieldCodec (e.g. field.NewText()); the codec's String seeds the editor and Get reads it back on blur. A plain string value works too (read-only-ish: replaced wholesale on external change).

Attributes

  • label — label text (or slot="label" for rich content)
  • profile — registered wtext profile name (default: "basic")
  • placeholder — shown while the editor is empty
  • helper — helper text below the field (or slot="helper")
  • error — error message (or slot="error")
  • required — "true" shows the required mark
  • disabled — standard HTML; makes the surface non-editable

Events fired to parent

@change — fires on blur after the two-way write-back, so a bound
          FieldCodec/Validator has already run; args[0] = epub-html string
@input  — fires (coalesced) as content changes; args[0] = epub-html string

Native form participation

w-text is form-associated: its serialized content is submitted under the host name, a bound Validator gates submission, form.reset() restores the initial content and clears undo history, and an ancestor <fieldset disabled> disables the surface.

Index

Constants

This section is empty.

Variables

G is the logger for this module.

Functions

This section is empty.

Types

type Text

type Text struct{}

Text implements wings.PranaMod and wings.Customizable for w-text.

func New

func New() *Text

New creates a new Text instance.

func (*Text) InitData

func (t *Text) InitData() map[string]any

InitData seeds the template bindings.

func (*Text) ListCSS

func (t *Text) ListCSS() []wings.CSSPart

ListCSS returns the named CSS parts in order.

func (*Text) Render

func (t *Text) Render(obj *wings.PranaObj)

func (*Text) ReplaceCSS

func (t *Text) ReplaceCSS(key, content string)

ReplaceCSS replaces a CSS part and updates live instances.

Jump to

Keyboard shortcuts

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