Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject custom prop to remirror context #291

Closed
1 task done
lanyusan opened this issue Apr 20, 2020 · 5 comments
Closed
1 task done

Inject custom prop to remirror context #291

lanyusan opened this issue Apr 20, 2020 · 5 comments
Labels
type: feature ✨ A new feature is being added to the public API

Comments

@lanyusan
Copy link
Contributor

Description

useRemirrorContext is very convenient. I need to pass some extra props for useRemirrorConext to capture, for example a GraphQL client instance.

Is there a way to do it now? If not, can I propose such a feature. For max flexibility, it should use a template type for user to define what to pass to the context.

Thanks in advance

Possible Implementation

Checklist

@lanyusan lanyusan changed the title Inject custom prop to prosemirror context Inject custom prop to remirror context Apr 20, 2020
@ifiokjr
Copy link
Member

ifiokjr commented Apr 21, 2020

This is an interesting suggestion. In the next version #251 of the codebase, I’ve sought to make the underlying core more extensible. So much so that, now, all core functionality is implemented withbuiltin extensions.

However, I’m not sure I see the benefit in adding extra props to the context of the react provider. Could you shed more light on what it is you’re trying to achieve and how passing the extra props will make that possible?

@lanyusan
Copy link
Contributor Author

lanyusan commented Apr 21, 2020

My use case is that my extensions would need to access remote resources, through graphql. The graphql client could be passed down through extension options, but since the client is a shared resource, it would be nice to put it in editor context. And functions that would be called by the extensions can access the client conveniently without the need to further pass the client down as function variable.

Generally speaking, context is a nice place for shared resources.

@ifiokjr
Copy link
Member

ifiokjr commented Apr 21, 2020

What would you suggest the API should look like? Perhaps it's a change that can be added to the next version.

@lanyusan
Copy link
Contributor Author

May be as a prop of <RemirrorManager extensions={extensions}> , as expanded to <RemirrorManager extensions={extensions} externalContext={{gqlClient, credentials, ... }}>

@ifiokjr ifiokjr added the type: feature ✨ A new feature is being added to the public API label Jul 7, 2020
@ifiokjr
Copy link
Member

ifiokjr commented Jul 7, 2020

Thinking about this again. It seems possible to just create your context provider that can also be used within the editor. Adding this to useRemirror would complicate the types unnecessarily.

@ifiokjr ifiokjr closed this as completed Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature ✨ A new feature is being added to the public API
Projects
None yet
Development

No branches or pull requests

2 participants