ember-mobiledoc-editor
ember-mobiledoc-editor copied to clipboard
Passing context or metadata into component cards/atoms
I'd like to be able to pass some arbitrary metadata about a mobiledoc down into the Ember components that render cards and/or atoms. Is there any good way to do this at the moment?
Here's a use case: I have some metadata about a mobiledoc's author. I'd like to refer to this in building the payload for certain atoms.
At the moment, it seems to me that the only way to do this is to subclass the mobiledoc-editor
component and write a custom template that passes in the additional properties here. That doesn't seem optimal to me, because there's no way to inherit a parent template and override only a subsection thereof. Among other things, it's hard for maintainability; every time the component template changed upstream, consumers would have to manually review changes to the code upstream and update...
I understand if you don't want unnecessary clutter in the code, but I think it would be quite helpful to provide some way for consumers to pass context into their atom/card components. Any suggestions? (I'd be happy to provide a PR if appropriate.)
@decasia I believe you want to pass cardOptions
to the editor? They are then passed options
to card invocations.
See: https://github.com/bustlelabs/mobiledoc-kit/blob/master/CARDS.md
ah, grand. Thanks!
Hi @mixonic, I checked into this a bit more and it looks like there are a couple of changes that we'd need in ember-mobiledoc-editor in order to use the options hash in an Ember atom/card component. Basically, to get the end user's cardOptions
passed into the ember card components, we'd need to do the following:
- merge the consumer's options hash into the
cardOptions
callback hash that ember-mobiledoc-editor uses. - pass the options hash into the Ember component invocations.
I've tested this myself in this branch and it seems to work well. Would you be amenable to seeing this as a PR? I'd be happy to add unit tests.
@decasia that change seems totally reasonable to me- would be great to have in a PR with some tests 😄 Please tag me on the PR to review!