jefago / tiny-markdown-editor

TinyMDE: A tiny, dependency-free embeddable HTML/JavaScript Markdown editor.
MIT License
110 stars 15 forks source link

window.getSelection() returns different results on Firefox and Chrome... #57

Closed movsb closed 5 months ago

movsb commented 5 months ago

...which causes flicker cursor position.

https://github.com/jefago/tiny-markdown-editor/blob/d1558b09b4bce9b20643162513502be3ad77aec5/src/TinyMDE.js#L1007

Steps to reproduce:

  1. Enter * 1
  2. Press backspace to delete the last 1

On Firefox, it logs Object { row: 0, col: 0, node: div.TMUL }
On Chrome, it logs {row: 0, col: 2, node: text}

Tried many times, reproduces every time. Not available for Firefox yet?

jefago commented 5 months ago

Thanks for the repro steps. I hadn't really tested this on Firefox, and turns out window.getSelection() behaves a bit different there. I managed to fix this.

jefago commented 5 months ago

Fixed in #59

movsb commented 5 months ago

As a long term Firefox user, it's very glad to hear that!

Wait, did you just tag v0.1.14 on v0.1.13😂?

tiny-markdown-editor (main) → git log --oneline --graph v0.1.13^..
*   caef0bd (HEAD -> main, origin/main, origin/HEAD) Merge pull request #59 from jefago/dev
|\
| * c9a4ad4 (origin/dev) 0.1.14
| * 5e5cd36 Fix node hierarchy in Firefox
| * e1da3d1 Fixes window.getSelection() returns different results on Firefox and Chrome... #57
| * bbe1467 Reformat with prettier
| * c57629e Fix #56
|/
* d1558b0 (tag: v0.1.14, tag: v0.1.13) 0.1.13

I think caef0bd is where the new tag should be at?

jefago commented 5 months ago

you are right. I think my release script is somewhat broken. In any case, the npm release is correct, that's generated independent of the GitHub release, and you can see that the new code is in the latest release. I will fix the release script, though.

https://www.npmjs.com/package/tiny-markdown-editor?activeTab=code