vercel-labs / vercel-labs/native

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

Open
#413 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Zig
Stars
7.7k
Forks
314
Avg merge
5h
Merged PRs (30d)
13

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the locked v1 design alongside text_attr.zig, its TypeScript twin and tests, the rich-textarea schema and markup stamp, and examples/rich-textarea. The local feat/attributed-rich-textarea branch already contains these pieces; the remaining outcome is confirmation of the design direction before stacked PRs follow.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, zig
Domain
desktop
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.