[lexical-react] Breaking change: enforce use of collab context provider#7818
[lexical-react] Breaking change: enforce use of collab context provider#7818etrepum merged 5 commits intofacebook:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
ed95aaa to
4138064
Compare
| } | ||
| ErrorBoundary={LexicalErrorBoundary} | ||
| /> | ||
| <LexicalCollaboration> |
There was a problem hiding this comment.
I think this might really need to go around LexicalComposer because if any DecoratorNode needs the context it might not find it from here
etrepum
left a comment
There was a problem hiding this comment.
This looks right to me but we could make the transition a bit easier if we choose to
| invariant( | ||
| collabContext != null, | ||
| 'useCollaborationContext: no context provider found', | ||
| ); |
There was a problem hiding this comment.
We could possibly make this transition a little smoother by transitionally having a global context default that we use when the context is null and print a warning. There's devInvariant which compiles to an error in dev and warning in prod that would maybe be good for this. The warning or error could also have a reference to this PR or some brief instructions to wrap your composer with <LexicalCollaboration>
f599040 to
53d9063
Compare
|
Will approve again once the conflict from merging #7816 is resolved |
Description
Flagged by @etrepum in #7816,
useCollaborationContextdidn't enforce that a provider was used. Indeed, neither the playground nor any of the examples used a provider. This could lead to significant issues with collab if two editors with the same ID were used on the page.useCollaborationContextnow requires that a context provider is usedUsers of the
CollaborationPluginoruseCollaborationContextmust wrap the top-levelLexicalComposerwith aLexicalCollaborationcomponent. For example:The collaboration context is shared for nested editors, so the provider must only be used on the top-level editor.