Skip to content

Attributed editing: paragraph-scoped rich-textarea on TextBuffer + TextSpan #413

Description

@alextingiris

Summary

Proposal for paragraph-scoped attributed editing in Native: keep UTF-8 TextBuffer as the source of truth (same IME / undo / clipboard path as textarea), attach parallel style runs, and expose <rich-textarea> that stamps WidgetRuntimeFlags.rich_editor.

Dogfooded in Tonic desktop (TONIC_NATIVE_RICH_EDITOR=1 + local NATIVE_SDK_PATH) before opening this issue — Source + Bold/Italic/Strike + GFM preview from runs; Lexical webview remains the full-GFM path.

Motivation

Today Native splits plain editable text from display-only rich spans / <markdown> render. Apps that need styled editing fall back to WebView. We want toolkit-native attributed editing without inventing a second edit engine.

v1 design (locked)

  • SoT: contiguous UTF-8 TextBuffer bytes.
  • Style runs: bold / italic / underline / monospace / strikethrough keyed by byte ranges (text_attr.zig@native-sdk/core/text-attr).
  • Markup: <rich-textarea>WidgetKind.textarea + runtime_flags.rich_editor.
  • IME: composition range stays unstyled until commit.
  • Style undo: parallel stack (pushStyleUndo / popStyleUndo); text undo stays on the buffer.
  • One paragraph first (matches non-nesting span model + per-widget selection).

Capacities / a11y (from dogfood)

  • Style-run budget matches max_text_spans_per_paragraph.
  • Hit-test: Zig hitTestAttributed uses span layout + snap; TS has a proportional fallback until paint is wired.
  • Should expose the same textbox semantics as textarea.

Non-goals for v1

Tables, mermaid, math, nested spans, cross-block selection, Lexical feature parity.

Later (v2)

Multi-block document model (text_doc.zig sketch) + GFM round-trip — separate PR series after v1 lands.

Implementation status (local branch feat/attributed-rich-textarea)

  • text_attr.zig + TS twin + tests
  • Schema element rich-textarea (code 71) + markup stamp + docs/skills
  • examples/rich-textarea
  • Tonic dogfood wiring documented in Tonic’s apps/desktop/README.md

Stacked PRs to follow once this design direction is confirmed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions