Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Strange caret behavior #857

Closed
grimalschi opened this issue Jul 26, 2019 · 14 comments
Closed

Strange caret behavior #857

grimalschi opened this issue Jul 26, 2019 · 14 comments

Comments

@grimalschi
Copy link

grimalschi commented Jul 26, 2019

Hello! When I press "Down" many times, I'm getting strange caret behavior.

What i expect:
image

What I get:
image

Any plans to fix this?

@hadrysmateusz
Copy link

Any progress on this? It's one of the things that keeps me from using the library as it's super un-intuitive.

@alexanderisora
Copy link

Any updates on this issue? Thanks.

@hata6502
Copy link
Contributor

Absolutely, this issue is valid to improve UI.
But I have no idea to resolve it.
It may need a DOM hacking.

@grimalschi
Copy link
Author

In my project I have solved this problem for another block editor.

I am checking every possible caret position and detect closest one for jump.

Screenshot 2020-11-30 at 16 04 18

On picture red is current caret, blue is candidates and green is a closest position for caret.

There is also some optimisation like line break detection, because there may be 2000 lines and its too much to check every possible caret position.

So it is a solution, it works fast enough and I am ready to share some production code and explain this more.

If you (EditorJS team) are interested, write me https://t.me/grimalschi

@hata6502
Copy link
Contributor

hata6502 commented Dec 2, 2020

Great!
By using Range and getBoundingClientRect(), it may be able to resolve this behavior.

@hata6502
Copy link
Contributor

hata6502 commented Dec 2, 2020

Determining caret position when DOWN key pressed:

ezgif com-gif-maker

@neSpecc
Copy link
Member

neSpecc commented Dec 2, 2020

Awesome! We'll check it

@hata6502
Copy link
Contributor

hata6502 commented Dec 19, 2020

@grimalschi
@neSpecc
Sorry! I gave up this PR: #1453

Is there anyone who can resolve this good feature?
I think it is a good feature request.

@hata6502
Copy link
Contributor

@hata6502
Copy link
Contributor

Are force options in Caret.navigateNext(force = false) and Caret.navigatePrevious(force = false) used?
I couldn't find where using force options.

$ git grep "navigateNext(" src/
src/components/modules/blockEvents.ts:    const isNavigated = navigateNext ? this.Editor.Caret.navigateNext() : this.Editor.Caret.navigatePrevious();
src/components/modules/blockEvents.ts:    const isNavigated = navigatePrevious ? this.Editor.Caret.navigatePrevious() : this.Editor.Caret.navigateNext();
src/components/modules/caret.ts:  public navigateNext(force = false): boolean {

$ git grep "navigatePrevious(" src/
src/components/modules/blockEvents.ts:      if (Caret.navigatePrevious()) {
src/components/modules/blockEvents.ts:    const isNavigated = navigateNext ? this.Editor.Caret.navigateNext() : this.Editor.Caret.navigatePrevious();
src/components/modules/blockEvents.ts:    const isNavigated = navigatePrevious ? this.Editor.Caret.navigatePrevious() : this.Editor.Caret.navigateNext();
src/components/modules/caret.ts:  public navigatePrevious(force = false): boolean {

If force options are not used, Caret.navigateNext() and Caret.navigatePrevious() should be simplified by removing force options first of all.

@hata6502
Copy link
Contributor

hata6502 commented Feb 1, 2021

I did it! 🎉
Please check this PR:
#1526
https://deploy-preview-1526--editor-js.netlify.app/

@alexanderjulmer
Copy link

alexanderjulmer commented Feb 16, 2021

Nice. I found some bugs using Safari (Version 14.0.2 (16610.3.7.1.9)) related to the marker.

Situation: Hitting the down arrow key in a line which also contains a marker.
Expected behavior: Caret jumps into the next line
Actual behavior: Caret jumps in front of the marker and is stuck there

Situation: Hitting the down arrow key while caret is inside a marker.
Expected behaviour: Caret jumps into the next line.
Actual behaviour: Caret jumps to the end of the block. Once jumped to the end of the block, the up arrow key doesn't work anymore (left, right and down work).

Situation: Hitting the up arrow key while caret is in approx. second half of last line of a block which also contains a marker.
Expected behaviour: Caret jumps to second last line.
Actual behaviour: Caret jumps to end of block, up arrow key doesn't work anymore.
Note: Only happens, if block contains a marker.

Please see attached a video of the first two issues.

Bildschirmaufnahme.2021-02-16.um.10.24.41.mov

@hata6502
Copy link
Contributor

hata6502 commented Feb 20, 2021

@alexanderjulmer
Thank you for reporting the critical bug on Safari!
This bug occurs not only #1526 but also next branch.

@neSpecc
I think this bug should be fixed by the next release.

@hata6502
Copy link
Contributor

This bug occurs as <mark> element in Safari only.
This caret moving is uncontrolled by Editor.js, and relied on each browser's behavior.

Umm... I can't know why this bug occurs in next branch rather than https://editorjs.io

@codex-team codex-team locked and limited conversation to collaborators Jan 17, 2022
@talyguryn talyguryn converted this issue into discussion #1873 Jan 17, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants