Skip to content

9.1.0: MarkdownEditor rich text (WYSIWYG) mode - #16

Open
RonRadtke wants to merge 5 commits into
masterfrom
feature/wysiwyg
Open

RonRadtke wants to merge 5 commits into
masterfrom
feature/wysiwyg

Conversation

@RonRadtke

Copy link
Copy Markdown
Owner

Summary

  • New MarkdownEditor (plain/rich toggle) and standalone MarkdownWysiwygEditor / EditorToolbar, with a CommonMark-faithful model shared with the renderer's inline rules. Typed and pasted text reaches value unchanged, and untouched lines are never rewritten.
  • Pending toolbar commands and async payload resolvers apply to the latest committed value and do nothing while the input is disabled.
  • Merges master (9.0.3), re-runs prettier over src/, bumps the version to 9.1.0 and adds MarkdownEditor to the README.

Public API: additions only, nothing removed (checked against the published 9.0.3 typings).

Test plan

  • npm run typecheck, npm run lint, npm run format-check
  • npm test -- --runInBand: 13 suites, 306 tests passing
  • npm run build, npm pack --dry-run
  • Example app: jest passing
  • On-device checklist on iOS + Android: doc/wysiwyg-device-checklist.md (blocks release)

🤖 Generated with Claude Code

https://claude.ai/code/session_01MAgGTHfWZVVvwSK1rJYbVn

RonRadtke and others added 5 commits June 13, 2026 11:30
The rich-text surface rewrote typed text: the inline scanner paired any
marker with a later identical one, so identifiers, math and code such as
snake_case_name, 2 * 3 * 4 or C++ were turned into emphasis and the source
was re-serialized around them. For an LLM chat input the value sent must
equal what the user typed, so the model is rebuilt around that contract.

- Parser: port of markdown-it's inline rules (delimiter runs with flanking,
  rule of three, backtick runs, escapes, entities, ~~ and the ins plugin's
  ++) using markdown-it's own character classes, so the editor hides exactly
  the markers the renderer consumes. Lists keep indentation and accept `1)`;
  CRLF fences are recognised. Lines are parsed independently and cached, and
  models are cached per source, so a keystroke re-parses only its line.
- Edits: new wysiwygEdit module applies display edits between the surviving
  source bytes and verifies by re-parsing that every span survived. Repairs
  escalate from escaping typed markers to swapping _/* families to
  re-serializing only the edited line. Untouched lines stay byte-identical.
  Typed markdown takes effect once valid and the caret continues outside
  the closed span (`caretOutside`). Code spans are not extended by typing at
  their end; Enter continues bullet, ordered and quote prefixes and exits an
  empty one; trailing whitespace moves outside closing delimiters.
- Toolbar toggles format the selection, or the word around a collapsed
  caret, and never split a surrogate pair.
- Tests: wysiwygFidelity.test.ts asserts typed/pasted text reaches the
  value unchanged and that other lines are never rewritten.
- Docs: MarkdownEditor section in INPUT.md, architecture notes, STATUS and a
  device validation checklist. The lint scripts drop the env prefix so they
  run on Windows.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Brings in the 9.0.x release commits: version bump, the cleanup that moved
the streaming cursor style into StyleSheet (same fix on both sides), the
prettier config change, README updates and the disabled npm publish
workflow. src/ is re-run through prettier so format-check passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MAgGTHfWZVVvwSK1rJYbVn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant