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

Bug: HR (horizontal divider) duplicating many times on enter key #89

Closed
lukakostic opened this issue Dec 3, 2024 · 3 comments · Fixed by #91
Closed

Bug: HR (horizontal divider) duplicating many times on enter key #89

lukakostic opened this issue Dec 3, 2024 · 3 comments · Fixed by #91

Comments

@lukakostic
Copy link

Im using the basic example setup of hosted and simplest example with toolbar (default editor and command bar).

This seems to always happen when typing "***" except on the last line of editor.

To replicate:

  1. open editor, press enter a few times, enter some text.
  2. now go above that text (cursor, arrow keys): must be on an empty line, and not last (bottom) line of editor.
  3. type *** to create a horizontal divider. Now press enter a few times. (while cursor is just after last *)

you will get endlessly replicating dividers on all the new lines you make, until you enter some text.

  • at which point the last duplicate divider dissapears but all previous remain until you type text on those lines.

image

@jefago
Copy link
Owner

jefago commented Dec 3, 2024

Hi Luka, I will look into this. What browser are you using?

@lukakostic
Copy link
Author

lukakostic commented Dec 5, 2024

Apologies for late reply. Ive tested on two versions and both have same issue:
Im on Ubuntu.
Firefox Devloper Edition 133.0b9 (64bit)
Firefox 119.0.1 (64bit) (snap for Ubuntu)

More info:

There are actually multiple HR DOM elements, its not just a visual bug of the first (actual) HR.
Fake HRs contain a BR inside them, real HR has *** in it (see pic below).
Doing editor.setContent( editor.getContent() ); removes the fake HRs as expected.

And if you select a line with one of those 'fake' HRs (doesnt have to be last/first one) you can do one of following :

  1. type text -> the hr gets deleted on that line ,
  2. press enter again -> more fake HRs get created !

So it seems like the editor script keeps duplicating any HR , even the fake ones, if you press enter. Unless its on the last line, for some reason. And if you instead type text, it deletes the (fake) HR on that line.

image

Fake HRs contain a BR inside them, real HR has *** in it.

image

And if you delete the original HR line (where you have ***) , the fake HRs still exist.

(ive changed the HR width and *** font size, issue is same with original.css)

Another curious thing, you may type more than 3 asterisks and its still an HR
(I'd expect 20 asterisks to be normal text not HR?) , but thats not really an issue.

@jefago
Copy link
Owner

jefago commented Dec 13, 2024

the issue was that the CSS class on the inserted line didn't get removed because the editor code thought the line was unchanged (because it was still blank). Fixed in v0.1.31. This should fix any related issues in Firefox because it wasn't specific to the HR, but rather an issue in how Firefox handles new paragraphs differently than Chromium or WebKit.

Regarding this:

Another curious thing, you may type more than 3 asterisks and its still an HR (I'd expect 20 asterisks to be normal text not HR?) , but thats not really an issue.

The CommonMark spec, which I am following as closely as possible, says "three or more".

A line consisting of optionally up to three spaces of indentation, followed by a sequence of three or more matching -, _, or * characters, each followed optionally by any number of spaces or tabs, forms a thematic break.

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 a pull request may close this issue.

2 participants