ianstormtaylor / slate

A completely customizable framework for building rich text editors. (Currently in beta.)
http://slatejs.org
MIT License
29.71k stars 3.24k forks source link

shouldComponentUpdate in isVoid nodes #536

Closed Mangatt closed 7 years ago

Mangatt commented 7 years ago

Hi, I'm currently not able to determine, which nodes are inside selection, not with help of docs anyway.

It can be demonstrated at emoji demo (http://slatejs.org/#/emojis). When I click on emoji, it has blue border around it. But when I make selection with text around emoji, it doesn't have selected style.

Is there a way how to achieve that? To indicate that node is within selection?

emoji

Mangatt commented 7 years ago

Ok, I just found that state.blocks contain this information that I need. But there's another problem - selection change does not trigger isVoid node within selection re-render. What now?

thesunny commented 7 years ago

Hmm... yeah, I can confirm this on blocks as well. Feels like this is a bug.

Mangatt commented 7 years ago

Is there a way how to trigger re-render? Or do I have to change all void blocks into normal ones?

Mangatt commented 7 years ago

I guess that it is components/node.js shouldComponentUpdate that is to blame. It is not taking void nodes into account at all.

Since I am not familiar with slate updating logic, is it possible to look into this? I found that @ianstormtaylor , you're author of this code, right?

Mangatt commented 7 years ago

I am currently bypassing that with redux, but that is far from ideal. It is not just about selecting, but in my case void blocks need to know about who are their immediate siblings.

michaelpietrykowski commented 7 years ago

How did you end up handling this? I also need to force a re-render on my void nodes but haven't been able to do it.

Mangatt commented 7 years ago

@michaelpietrykowski I'm using Redux to do that.