Commit 1b95886
authored
fix(message-editor): stop pasted CSS and escapes leaking into composer
Pasting rich text into the chat composer inserted garbage before the real
text. Two causes in the HTML->Markdown paste conversion (Turndown):
- macOS puts a `<style>` block on the clipboard when copying from native
apps (Notes, Mail, Slack). Turndown emitted its CSS as text, so pasting
"Yo dude" produced
"p.p1 {margin: 0.0px ...; font: 18.0px Helvetica}\n\nYo dude".
Fixed by removing non-content elements (style/script/head/title/meta/link).
- Turndown's default escaping backslash-mangled ordinary punctuation
("1." -> "1\.", "snake_case" -> "snake\_case", "[x]" -> "\[x\]"). Because
the escaped output no longer equalled the plain-text fallback, plain
pastes were also forced down the inline-Markdown path instead of the
editor's native paste. Disabling escaping keeps plain text intact so it
equals the fallback and defers to native paste; only genuinely formatted
content (bold, lists, links, tables, code) takes the Markdown path.
Added regression tests covering the macOS style-block leak, the escaping
cases, and that real formatting is still preserved. Verified against the
running app's bundled module over CDP.
Generated-By: PostHog Code
Task-Id: 0f5214ac-2b22-4769-92cb-39967a9b67ed1 parent 7b32529 commit 1b95886
2 files changed
Lines changed: 50 additions & 0 deletions
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
39 | 77 | | |
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
16 | 28 | | |
17 | 29 | | |
18 | 30 | | |
| |||
0 commit comments