nenadpnc / cl-editor

Lightweight text editor built with svelte, typescript
https://nenadpnc.github.io/cl-editor/
MIT License
293 stars 23 forks source link

Problem toggling bold/italics tag when there is a new line #29

Open daevid66 opened 3 years ago

daevid66 commented 3 years ago

How to reproduce:

  1. Go to the demo page: https://nenadpnc.github.io/cl-editor/
  2. Scroll to the "Custom action example"
  3. Place cursor somewhere in the placeholder text and pressing enter, moving some of the text to a new line.
  4. Select the new line, and make it bold. This works as expected...
  5. .But you cannot toggle off the bold, nothing happens when you click the button. image

It seems like it's somehow connected to the div tags that are created when you press enter. Possibly a work-around would be to only add br tags when pressing enter.

daevid66 commented 3 years ago

Oh, forgot to say, except for this problem it's a really nice component!

nenadpnc commented 3 years ago

Hi @daevid66 , just tried to reproduce bug following your instructions, but no luck. I can toggle bold text on/off without an issue. Tested on Chrome v86, MacOS Catalina. Problem may be that library uses document.executeCommand underneath, which heavily depends on browser vendor/version implementation of this command. Implementing it this way keeps the lib lightweight, but on the downside bugs like this can surface out due to inconsistencies in browsers implementations.

daevid66 commented 3 years ago

Hi, sorry for not including my browser spec. I'm using Chrome (Version 85.0.4183.102) on windows 10.

Tested in Firefox now and the use case works fine there.

/David

daevid66 commented 3 years ago

Updated Chrome to version 86.0.4240.75 now, but I am sorry to say that the problem still exists.

/David

aam-git commented 2 years ago

Just tested in here windows 10 Version 96.0.4664.45 (Official Build) (64-bit) and it seems to work...

EDIT: oops didn't notice the date you submitted this