feat(composer): live markdown highlight overlay (LC-399) #414
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/lc-399-composer-live-markdown-overlay"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Live markdown highlight overlay for the chat composer (LC-399). Formatting now renders as you type (Discord-style) instead of showing literal Markdown that only resolves after sending or via the manual Write/Preview toggle.
How
Keeps the server-rendered, plain-textarea model rather than swapping in a contenteditable WYSIWYG (which would have meant rebuilding ~900 lines of textarea-bound JS: mention/emoji/channel/slash autocompletes, draft autosave, optimistic echo, voice recorder, caret restore, edit-last).
A
.lc-mdbackbackdrop div behind the<textarea name="body">mirrors the text with Markdown tokens styled (bold, italic,strike,code, headings, blockquotes, lists, links). The marker characters (**,`,>,-,#,[]()) stay visible but dimmed. The textarea sits on top with transparent text/background and a visible caret, so it remains the single source of truth: every existing composer handler still reads and writestextarea[name=body]unchanged.Key invariant: the highlighter only WRAPS characters in spans (never adds, removes, or substitutes any) and styles with colour / weight / decoration / background only, never font-size or font-family. So the backdrop wraps identically to the textarea and the caret never drifts. Any line the tokenizer does not recognise falls through as plain dimmed text (today's behavior), so it can never corrupt the submitted value, which is the textarea's, untouched.
.lc-mdbackand.lc-mdinputare pinned identical in CSS.:has(> .lc-mdinput.hidden)rule collapses the overlay when the LC-276 preview pane is shown, so the pane (its flex sibling) takes the slot.room/composer.html).Scope
Frontend only:
server/templates/room/composer.html(wrapper + highlighter IIFE) andserver/assets/main.css(overlay + token styles). No Rust change. The server-side pulldown-cmark renderer remains the source of truth for posted messages and the Preview pane; the overlay is decorative.Tests
just check(standalone + saas compile, clippy, fmt),just test, andjust test-saasall pass.just build-cssregenerated.