fix(editor): preserve leading newlines in plain text editor#8787
Conversation
Signed-off-by: omnizs38 <omnizs@proton.me>
max-nextcloud
left a comment
There was a problem hiding this comment.
Thanks a lot @omnizs38
This looks great. A simple fix for a long running problem as the skipped tests indicate.
|
static analysis and playwright failures are known and not related. |
|
/backport to stable34 please |
|
/backport to stable33 please |
|
The backport to # Switch to the target branch and update it
git checkout stable33
git pull origin stable33
# Create the new backport branch
git checkout -b backport/8787/stable33
# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts, resolve them
git cherry-pick 0580bf9c
# Push the cherry pick commit to the remote repository and open a pull request
git push origin backport/8787/stable33Error: Failed to check for changes with origin/stable33: No changes found in backport branch Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports. |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
📝 Summary
This PR fixes an issue where the plain text editor stripped leading newlines and trailing whitespace on empty first lines of plain text documents.
When setting or updating the content of the plain text editor, the raw content is escaped and wrapped inside HTML
<pre>...</pre>tags. By standard HTML rules,DOMParserstrips a single leading newline character inside<pre>tags. Prepending a newline (\n) to<pre>content ensures thatDOMParserstrips only our prepended newline, leaving the document's original leading newlines and whitespace intact.This change also re-enables the previously skipped CommonMark plain text tests
97and117, which now pass successfully.🖼️ Screenshots
🚧 TODO
🏁 Checklist
npm run lint/npm run stylelint/composer run cs:check)🤖 AI (if applicable)