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

remove props.state from node components #277

Closed cobbweb closed 6 years ago

cobbweb commented 8 years ago

That state prop passed into a Block instance is often stale or behind the real state, and props.editor.getState() is the preferred method for transforming state from within a block. Having state as its own prop seems overkill and a trap for the unsuspecting, I think the best way to fix this is just remove the prop!

Is there a use case for having state as it's own prop?

Steps to reproduce:

  1. Go to http://slatejs.org/#/embeds
  2. Add a new paragraph at the very end, type ‘Testing’ into it
  3. Click into the YouTube node , type ‘c’
  4. ‘Testing’ paragraph is gone
ianstormtaylor commented 7 years ago

@cobbweb I'm down for this change. Can you write up a PR with it?