Open lanthias opened 5 years ago
Hey, @lanthias. I was working on something similar in #141, though I haven't gotten back to it yet. Do you think that approach could help? The general idea is something like this:
let editor = new ColonelKurtz({
// ...
blockTypeOptions: {
youtube: { name: 'Chris' }
}
})
In this example, youtube
is the block type key, and the object value would be passed as props to the component.
Hi @cwmanning - yes, that would be excellent! Exactly what I'm looking for.
Considering this, I think the part about not being able to use context inside a block is perhaps a separate ticket / outside the scope of this issue.
Hi there,
I'm trying to create a
blockType
which makes use of data and functions from a React context. I could either implement this context inside theblockType
itself, or would be happy to pass the data from the context in as props to the blockType from the top-level component.It seems if I implement a context inside a
blockType
, it is empty (even if I nest some components), and I can't figure out the right pattern for passing props into ablockType
. I'm presuming the right pattern is not to usecontent
to pass in things like API functions and data which won't be displayed to the user.Apologies if I am missing something very obvious here, but what is the right pattern to pass props/context into a BlockType?
Thanks!