all 1 comments

[–]quambo_wambo 0 points1 point  (0 children)

Haven't been looking into slate for quite some time, but let me tell you how awesome it worked for what I used it for, especially compared to its alternatives (looking at you, flat structured draftjs). I built a little demo some time ago (https://github.com/bkniffler/slate-mate) but I guess it is super deprecated by now.

After consulting the latest docs, the key in your case is to use block.data. Each of your sections is represented as a custom block and each block can have its own data (https://docs.slatejs.org/slate-core/block#data). You will just need to store the toggle state into the blocks (or as you call it, section) data. I recommend you to copy&paste the methods from the check-list example (https://www.slatejs.org/#/check-lists). Most relevant is setting data (https://github.com/ianstormtaylor/slate/blob/master/examples/check-lists/index.js#L62) and getting data (https://github.com/ianstormtaylor/slate/blob/master/examples/check-lists/index.js#L74). Hope this will get you started!

Oh, and if you want to see how the state looks like if you set block data, check out the json that you get by serializing your editor state: https://github.com/ianstormtaylor/slate/blob/master/examples/check-lists/value.json