Repository navigation
Bootstrap some documentation for the block editor module - #14566
Conversation
fc8fcf1 to
f4bf8b6
Compare
gziolo
left a comment
There was a problem hiding this comment.
It looks like a very nice improvement. I left some minor comments (mostly with typos) which should be addressed before the merge. There is also an open question left solely out of curiosity.
| const [ blocks, updateBlocks ] = useState( [] ); | ||
|
|
||
| return ( | ||
| <BlockEditorProvider |
There was a problem hiding this comment.
Any plans to introduce another wrapping component to make it as simple as:
return (
<BlockEditor
value={ blocks }
onInput={ updateBlocks }
onChange={ updateBlocks }
>
<BlockList />
</BlockEditor
);or something like that.
There was a problem hiding this comment.
I ultimately think all these wrappers I'm using here should be part of BlockEditorProvider which is basically what you're proposing.
There was a problem hiding this comment.
Awesome, I like where it is heading 👍
Co-Authored-By: youknowriad <benguella@gmail.com>
| <BlockEditorProvider | ||
| value={ blocks } | ||
| onInput={ updateBlocks } | ||
| onChange={ updateBlocks } |
There was a problem hiding this comment.
For someone who doesn't care about "Undo" levels, I wonder if the simplest example can just include onInput (or conversely, for one who cares only about important updates, only include onChange).
Though as I write this, I guess it assumes that onInput and onChange aren't mutually exclusive (i.e. onInput would always precede an onChange). I think this was an original intention, but by the final implementation it didn't end up this way:
gutenberg/packages/block-editor/src/components/provider/index.js
Lines 95 to 99 in d9768ad
The original thinking being that you could have onInput and onChange, or just individually one or the other of onInput or onChange.
There was a problem hiding this comment.
Good thoughts, and yeah I think you're right, it would have been better to have the two calls at the same time. I recall something related to the state making this harder for us but I think we can probably revisit specifically.
Related #14043
This PR enhances the README of the block editor module explaining how we can use it in a any context.