SuperOleg39 / mind-basket

4 stars 1 forks source link

Feature: Arrow navigation and multiple blocks text selection #1

Open SuperOleg39 opened 10 months ago

SuperOleg39 commented 10 months ago

For now, every block is separate tag with contenteditable attribute.

Unfortunately, you can select text only in one focused contenteditable element, and native keyboard navigation not working between blocks.

One possible solution - add contenteditable attribute to editor root element. All of mentioned features will work natively.

There is a big disadvantage - some event handlers to nested contenteditable blocks will not works, example of this problem - https://stackoverflow.com/a/24930829

So, there is a few ways to solve this problem:

  1. Handle text selection and arrow navigation manually - possible rabbit hole of problems and workarounds
  2. Handle root contenteditable elements tree outside of React - need to rewrite existings blocks

Need to investigate and select optimal solution.

SuperOleg39 commented 10 months ago

Another solution - is custom events propagation, e.g. https://codepen.io/surf4sites/pen/rNogYzN

But event will be not "trusted", can be problems for example with save content to buffer.

Too many problems with this solution

SuperOleg39 commented 10 months ago

Good source of information how this can work (also with Notion source code research)

And another useful info about contenteditable

SuperOleg39 commented 7 months ago

More about root contenteditable issues and possible solutions - https://github.com/Dashibase/lotion/issues/13#issuecomment-1201343949