Skip to content
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

Desktop: Fixes #6055: Preserve empty newlines created by pressing Enter repeatedly in the rich text editor #8549

Merged

Conversation

personalizedrefrigerator
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator commented Jul 24, 2023

Summary

Fixes #6055.

TinyMCE was outputting <p></p> for empty newlines, which is both ignored by turndown and renders to an element with zero height.

Using extended_valid_elements rather than valid_elements to allow additional HTML elements, however, causes TinyMCE to output <p>&nbsp;</p> instead. This can be handled by TinyMCE without breaking existing tests that rely on TinyMCE ignoring empty <p> elements.

Note: This does not fix the issue where repeated newlines created by shift+enter are lost.

Testing

  1. Open the rich text editor
  2. Create a new note with several empty paragraphs
    • Note: In an empty new note, TinyMCE creates empty <div>s instead of empty paragraphs. It may be necessary to add a non-empty line to the note and switch to another note before pressing enter adds paragraphs.
  3. Switch to the markdown editor
  4. Switch back to the rich text editor

In step 4, the same number of empty paragraphs should be present as in step 2.

Additionally, to verify that custom elements are still supported,

  1. Open the markdown editor in a new note
  2. Add a custom element (e.g. <x-custom-element>test</x-custom-element>)
  3. Switch to the rich text editor
  4. Update the content of the custom element
  5. Switch back to the markdown editor.

To verify that KaTeX rendering still works:

  1. Create a new math block with the following KaTeX: $$ \int_0^1 x^2 dx $$
  2. Switch to the rich text editor

@personalizedrefrigerator personalizedrefrigerator marked this pull request as draft July 24, 2023 18:10
@personalizedrefrigerator personalizedrefrigerator marked this pull request as ready for review July 24, 2023 20:09
@personalizedrefrigerator personalizedrefrigerator changed the title Desktop: Fixes #6055: Preserve empty newlines created by "Enter" Desktop: Fixes #6055: Preserve empty newlines created by pressing Enter repeatedly Jul 24, 2023
@personalizedrefrigerator personalizedrefrigerator changed the title Desktop: Fixes #6055: Preserve empty newlines created by pressing Enter repeatedly Desktop: Fixes #6055: Preserve empty newlines created by pressing Enter repeatedly in the rich text editor Jul 24, 2023
@laurent22
Copy link
Owner

I wonder how this change affects the Web Clipper? There are often a lot of empty elements and newlines that are left after conversion, probably because certain elements are removed. If we now preserve more newlines, I wonder if it will create Markdown text with a lot of extra newlines compared to what we have now. Could you do some tests for this please?

@personalizedrefrigerator
Copy link
Collaborator Author

personalizedrefrigerator commented Jul 26, 2023

I've tested with

  1. https://learn.microsoft.com/en-us/sharepoint/dev/general-development/how-to-avoid-getting-throttled-or-blocked-in-sharepoint-online
  2. https://www.usa.gov/file-taxes
  3. http://neuralnetworksanddeeplearning.com/chap2.html
  4. https://github.com/laurent22/joplin
  5. https://en.wikipedia.org/wiki/Multinomial_theorem

I searched for (with ctrl+F) and didn't find any &nbsp;s in the converted Markdown.

(In 3 and 5, however, math->KaTeX conversion failed, and in 2, 4, and 5, images within links failed, but neither of these are new issues — they seem to be present in v2.11.)

@laurent22 laurent22 merged commit 35f375d into laurent22:dev Jul 27, 2023
10 checks passed
@laurent22
Copy link
Owner

Ok, sounds good then!

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.

Selecting 'enter' does not Create Line Break [WYSIWYG editor]
2 participants