joplin
joplin copied to clipboard
Desktop: Fixes #9264: Preserve indentation from plain text when pasting on Rich Text Editor
Fixes: https://github.com/laurent22/joplin/issues/9264
When pasting plain text with leading space or tabs the content in the Rich Text Editor, this information is lost. This PR aims to address that.
Files that are using escapeHtml
function and might be affected:
packages/lib/htmlUtils.ts
packages/lib/services/interop/InteropService_Exporter_Html.ts
packages/server/src/routes/index/home.ts
packages/server/src/utils/csrf.ts
packages/tools/update-readme-sponsors.ts
Testing
When pasting the text below in the RTE, the indentation should not be lost:
Some text with indented by a tab:
Indented
Some text with indented by four spaces:
Indented
Files that are using
escapeHtml
function and might be affected:packages/lib/htmlUtils.ts packages/lib/services/interop/InteropService_Exporter_Html.ts packages/server/src/routes/index/home.ts packages/server/src/utils/csrf.ts packages/tools/update-readme-sponsors.ts
Are they affected or not, and if so in which way?
Files that are using
escapeHtml
function and might be affected:packages/lib/htmlUtils.ts packages/lib/services/interop/InteropService_Exporter_Html.ts packages/server/src/routes/index/home.ts packages/server/src/utils/csrf.ts packages/tools/update-readme-sponsors.ts
Are they affected or not, and if so in which way?
I don't think there are any major risks elsewhere, the biggest one would be in the Rich Text Editor where we actually want to change the behavior.
packages/lib/services/interop/InteropService_Exporter_Html.ts
The two calls for escapeHtml
are using item.title as the argument, so I don't think it is going to change much of the behavior
packages/server/src/routes/index/home.ts
Is being used with config().appName
, so it is probably ok too
packages/server/src/utils/csrf.ts
CSRF is a token without whitespace so it shouldn't affect it either
packages/tools/update-readme-sponsors.ts
It is used by the sponsor information from the tools/sponsors.json
file. It is called with the url, title and imageName properties, so it shouldn't change anything.
packages/lib/htmlUtils.ts
This might be the hardest place to predict since the code is not very clear to me.
The function is called inside the method replaceEmbedUrls
(for escaping src
parameter (which seems to be a URL) that is ultimately used by the extractNoteFromHTML
used in the Web Clipper and Joplin Cloud email processing.
It is also used by the plainTextToHtml
to change the behavior we want to change in this PR.
That looks good, thanks Pedro!