@lexical/react
Version:
This package provides Lexical components and hooks for React applications.
39 lines (38 loc) • 1.41 kB
TypeScript
/**
* 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 type { Doc } from 'yjs';
/**
* The value stored in the {@link CollaborationContext}: the local user's
* display `name` and cursor `color`, whether collaboration is currently active,
* and the map of Yjs documents shared by the editors under this provider.
*/
export type CollaborationContextType = {
color: string;
isCollabActive: boolean;
name: string;
yjsDocMap: Map<string, Doc>;
};
/**
* The React context that holds the shared {@link CollaborationContextType} for
* collaborative editors. Provide it with {@link LexicalCollaboration} and read
* it with {@link useCollaborationContext}.
*/
export declare const CollaborationContext: import("react").Context<CollaborationContextType | null>;
/**
* @internal
* @__NO_SIDE_EFFECTS__
*/
export declare function newContext(): CollaborationContextType;
/**
* Reads the current {@link CollaborationContextType} from the nearest
* {@link LexicalCollaboration} provider. Optionally pass `username` and `color`
* to set the local user's display name and cursor color.
*
* @returns The active collaboration context.
*/
export declare function useCollaborationContext(username?: string, color?: string): CollaborationContextType;