Skip to content

Desktop: Fixes #12059: Fix Rich Text Editor deletes paragraphs when pressing enter after a resized image #12090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

personalizedrefrigerator
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator commented Apr 11, 2025

Summary

Before this change, Markdown documents in the Rich Text Editor were wrapped in a <div id="rendered-md">. TinyMCE seems to be unable to handle this in some cases. This pull request removes the rendered-md wrapper when rendering in the Rich Text Editor.

Resolves #12059.

Important

Although this change resolves #12059, it will break custom CSS that relies on the presence of the <div id="rendered-md"> wrapping element.

Testing plan

This pull request includes an automated test.

In addition to the automated test, the following manual testing has been done:

  1. Create a new note.
  2. Attach an image.
  3. Add a new paragraph after the image with text.
  4. Resize the image.
  5. Switch to the Markdown editor.
  6. Switch back to the Rich Text Editor.
  7. Move the cursor after the image.
  8. Press enter.
  9. Verify that the cursor is moved to a new paragraph and that the text added in step 3 is still present.

It has also been verified that changing the "editor maximum width" setting changes the spacing on either side of the editor content.

…image

This change removes the wrapping <div id="rendered-md">, which seems to
fix the removal of text after a resized image.
@personalizedrefrigerator personalizedrefrigerator changed the title Desktop: Resolves #12059: Fix TinyMCE deletes text after an image Desktop: Fixes #12059: Fix TinyMCE deletes text after an image Apr 11, 2025
@personalizedrefrigerator personalizedrefrigerator changed the title Desktop: Fixes #12059: Fix TinyMCE deletes text after an image Desktop: Fixes #12059: Fix Rich Text Editor deletes paragraphs when pressing enter after a resized image Apr 11, 2025
@laurent22
Copy link
Owner

laurent22 commented Apr 12, 2025

I see that #rendered-md is used a few times in CSS selectors. Is this change not going to affect this?

Comment on lines -153 to +164
#rendered-md > h1:first-child,
#rendered-md > h2:first-child,
#rendered-md > h3:first-child,
#rendered-md > h4:first-child,
#rendered-md > ul:first-child,
#rendered-md > ol:first-child,
#rendered-md > table:first-child,
#rendered-md > blockquote:first-child,
#rendered-md > img:first-child,
#rendered-md > p:first-child {
${contentWrapperTarget} > h1:first-child,
${contentWrapperTarget} > h2:first-child,
${contentWrapperTarget} > h3:first-child,
${contentWrapperTarget} > h4:first-child,
${contentWrapperTarget} > ul:first-child,
${contentWrapperTarget} > ol:first-child,
${contentWrapperTarget} > table:first-child,
${contentWrapperTarget} > blockquote:first-child,
${contentWrapperTarget} > img:first-child,
${contentWrapperTarget} > p:first-child {
Copy link
Collaborator Author

@personalizedrefrigerator personalizedrefrigerator Apr 12, 2025

Choose a reason for hiding this comment

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

I see that #rendered-md is used a few times in CSS selectors. Is this change not going to affect this?

It shouldn't, at least not for the references to #rendered-md in the core application. The above selectors are the relevant instances of #rendered-md that I found. This pull request updates them to use a different selector when running in the Rich Text Editor and continue using #rendered-md in the note viewer.

As commented in the pull request description, user-specified CSS and 3rd-party plugins may also rely on #rendered-md.

Notes:

  • An alternative to this pull request might be to try to patch TinyMCE to fix the upstream issue.
    • I've briefly tried to do this, but was unsuccessful.
  • Since TinyMCE v6 is no longer supported upstream and we can't upgrade to v7, it seems unlikely that Joplin will be able to apply an upstream fix (unless we switch to a fork of TinyMCE or locally apply a patch from a TinyMCE fork).

Copy link
Owner

Choose a reason for hiding this comment

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

Ok that sounds good, so let's merge it as it is then. There's just one conflict to be fixed first

@laurent22 laurent22 merged commit 81f5a84 into laurent22:dev Apr 14, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Text destruction after an image (RTE)
2 participants