UNPKG

@lexical/react

Version:

This package provides Lexical components and hooks for React applications.

42 lines (36 loc) • 1.24 kB
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import { newContext, CollaborationContext } from '@lexical/react/LexicalCollaborationContextUtils'; export { CollaborationContext, useCollaborationContext } from '@lexical/react/LexicalCollaborationContextUtils'; import { useMemo } from 'react'; import { jsx } from 'react/jsx-runtime'; /** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ /** * A provider component that creates a fresh {@link CollaborationContextType} * and makes it available to descendant editors via {@link CollaborationContext}. * Wrap a group of editors that should share collaboration state in this * component. * * @returns A context provider wrapping `children`. */ function LexicalCollaboration({ children }) { const collabContext = useMemo(() => newContext(), []); return /*#__PURE__*/jsx(CollaborationContext.Provider, { value: collabContext, children: children }); } export { LexicalCollaboration };