You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, basic HTML formatting tags (b, i, strong, em) are allowed to be typed into a thought and rendered as HTML. All other tags are stripped out. In practice, this has not been very useful, and has gotten in the way of typing literal representations of HTML.
Instead, encode the HTML as character entities so it is rendered literally.
Handling of HTML in pasted content depends on the content-type:
When the pasted content-type is text/html, we should render the formatting tags as HTML as done currently.
When the pasted content content-type is text/plain but contains HTML (i.e. htmlText is empty and isHTML is true), we should escape the HTML and render character entities.
Three cases:
Type HTML: Escape HTML and render literal character entities (changed behavior)
Paste text/plain with HTML: Escape HTML and render literal character entities (changed behavior)
It is very likely that fixing one could break another if you are not careful. Therefore, it is recommended that you test all three cases after fixing one to avoid a regression. We currently do not have testing logic to mock pasting text with different content-types. You could try to mock e.clipboardData.getData, or it is acceptable to just do manual testing.
1. Type HTML
Steps to Reproduce
Create a new thought
Type hello <b>world</b>
Hit escape or move the cursor
Current Behavior
The HTML is NOT escaped. The thought gets rendered as "hello world".
Expected Behavior
Typed angled brackets should be escaped, i.e. converted to character entities.
The thought's value should be hello <b>world</b>
Which should get rendered literally as hello <b>world</b>
2. Paste text/plain
Steps to reproduce
Type hello <b>world</b> in your text editor.
Copy hello <b>world</b> from your text editor. This will ensure text/html is not added to the clipboard.
Paste into a new thought
Current Behavior
The HTML is NOT escaped. The thought gets rendered as "hello world".
Expected Behavior
Same as typing text/plain.
The thought's value should be hello <b>world</b>
Which should get rendered literally as hello <b>world</b>
3. Paste text/html
Steps to Reproduce
Copy and paste this text into a new thought: hello world
(Copying the rendered text from the browser will copy the HTML into the text/html part of the clipboard.)
Current Behavior
The HTML is not escaped. The thought gets rendered as "hello world".
Expected Behavior
The current behavior should not change.
Testing
Add tests for each case.
I'm not sure what testing level to go for here: importText reducer or RTL tests, or a combination. Prefer reducer tests when possible.
The text was updated successfully, but these errors were encountered:
Currently, basic HTML formatting tags (b, i, strong, em) are allowed to be typed into a thought and rendered as HTML. All other tags are stripped out. In practice, this has not been very useful, and has gotten in the way of typing literal representations of HTML.
Instead, encode the HTML as character entities so it is rendered literally.
Handling of HTML in pasted content depends on the content-type:
Three cases:
It is very likely that fixing one could break another if you are not careful. Therefore, it is recommended that you test all three cases after fixing one to avoid a regression. We currently do not have testing logic to mock pasting text with different content-types. You could try to mock
e.clipboardData.getData
, or it is acceptable to just do manual testing.1. Type HTML
Steps to Reproduce
hello <b>world</b>
Current Behavior
The HTML is NOT escaped. The thought gets rendered as "hello world".
Expected Behavior
Typed angled brackets should be escaped, i.e. converted to character entities.
The thought's
value
should behello <b>world</b>
Which should get rendered literally as
hello <b>world</b>
2. Paste text/plain
Steps to reproduce
hello <b>world</b>
in your text editor.hello <b>world</b>
from your text editor. This will ensuretext/html
is not added to the clipboard.Current Behavior
The HTML is NOT escaped. The thought gets rendered as "hello world".
Expected Behavior
Same as typing text/plain.
The thought's
value
should behello <b>world</b>
Which should get rendered literally as
hello <b>world</b>
3. Paste text/html
Steps to Reproduce
Copy and paste this text into a new thought: hello world
(Copying the rendered text from the browser will copy the HTML into the
text/html
part of the clipboard.)Current Behavior
The HTML is not escaped. The thought gets rendered as "hello world".
Expected Behavior
The current behavior should not change.
Testing
Add tests for each case.
I'm not sure what testing level to go for here:
importText
reducer or RTL tests, or a combination. Prefer reducer tests when possible.The text was updated successfully, but these errors were encountered: