Skip to content

fix(editor): preserve leading newlines in plain text editor#8787

Merged
max-nextcloud merged 1 commit into
nextcloud:mainfrom
omnizs38:fix/preserve-plaintext-leading-newlines
Jun 29, 2026
Merged

fix(editor): preserve leading newlines in plain text editor#8787
max-nextcloud merged 1 commit into
nextcloud:mainfrom
omnizs38:fix/preserve-plaintext-leading-newlines

Conversation

@omnizs38

Copy link
Copy Markdown
Contributor

📝 Summary

  • Resolves: N/A

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, DOMParser strips a single leading newline character inside <pre> tags. Prepending a newline (\n) to <pre> content ensures that DOMParser strips 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 97 and 117, which now pass successfully.

🖼️ Screenshots

🏚️ Before 🏡 After
N/A (No visual changes) N/A (No visual changes)

🚧 TODO

  • None

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests
  • Documentation (README or documentation) has been updated or is not required

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI tools
  • The AI-generated content was reviewed, comprehended and tested by a human

Signed-off-by: omnizs38 <omnizs@proton.me>

@max-nextcloud max-nextcloud left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @omnizs38

This looks great. A simple fix for a long running problem as the skipped tests indicate.

@max-nextcloud

Copy link
Copy Markdown
Collaborator

static analysis and playwright failures are known and not related.

@max-nextcloud max-nextcloud self-assigned this Jun 29, 2026
@github-project-automation github-project-automation Bot moved this to 🧭 Planning evaluation (don't pick) in 📝 Productivity team Jun 29, 2026
@max-nextcloud max-nextcloud moved this from 🧭 Planning evaluation (don't pick) to 👀 In review in 📝 Productivity team Jun 29, 2026
@max-nextcloud max-nextcloud merged commit ddc6a30 into nextcloud:main Jun 29, 2026
61 of 64 checks passed
@github-project-automation github-project-automation Bot moved this from 👀 In review to ☑️ Done in 📝 Productivity team Jun 29, 2026
@max-nextcloud

Copy link
Copy Markdown
Collaborator

/backport to stable34 please

@max-nextcloud

Copy link
Copy Markdown
Collaborator

/backport to stable33 please

@backportbot

backportbot Bot commented Jun 29, 2026

Copy link
Copy Markdown

The backport to stable33 failed. Please do this backport manually.

# 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/stable33

Error: 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.

@omnizs38 omnizs38 deleted the fix/preserve-plaintext-leading-newlines branch June 29, 2026 06:11
@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: ☑️ Done

Development

Successfully merging this pull request may close these issues.

2 participants