Editor.js: Strange caret behavior

Created on 26 Jul 2019  路  11Comments  路  Source: codex-team/editor.js

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?

Most helpful comment

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

All 11 comments

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

Any updates on this issue? Thanks.

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

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

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

Determining caret position when DOWN key pressed:

ezgif com-gif-maker

Awesome! We'll check it

@grimalschi
@neSpecc
Sorry! I gave up this PR: https://github.com/codex-team/editor.js/pull/1453

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

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cossssmin picture cossssmin  路  3Comments

sei-jdshimkoski picture sei-jdshimkoski  路  5Comments

vsvanshi picture vsvanshi  路  4Comments

hata6502 picture hata6502  路  3Comments

vincentdesmares picture vincentdesmares  路  3Comments