Commit 7192bac
authored
[CLNP-4962] fix: prevent HTML entity conversion by using insertText in document.execCommand (#1208)
Fixes the issue https://sendbird.atlassian.net/browse/CLNP-4962
where HTML entities like `§` or `<` were being automatically
converted to their corresponding symbols (§ or >) when pasting content
into a contentEditable element.
### Changes
The `document.execCommand('insertHTML', false, sanitizeString(text))`
command was replaced with `document.execCommand('insertText', false,
sanitizeString(text))`.
This change ensures that HTML entities are inserted as plain text rather
than being interpreted and converted by the browser. Now it prevents
unintended conversion of HTML entities, maintaining the original text as
expected when pasting content.
### How to test?
Try this on the preview.
Type `§` and copy & paste the text to the input box. The exact same
text(=`§`) should be on the input not `§`.1 parent d0eb89d commit 7192bac
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
0 commit comments