UNPKG

@liveblocks/react-ui

Version:

A set of React pre-built components for the Liveblocks products. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.

49 lines (46 loc) 1.98 kB
import { nn } from '@liveblocks/core'; import { createContext, useContext } from 'react'; const ComposerContext = createContext(null); const ComposerEditorContext = createContext(null); const ComposerAttachmentsContext = createContext(null); const ComposerSuggestionsContext = createContext(null); const ComposerFloatingToolbarContext = createContext(null); function useComposerEditorContext() { const composerEditorContext = useContext(ComposerEditorContext); return nn( composerEditorContext, "Composer.Form is missing from the React tree." ); } function useComposerAttachmentsContextOrNull() { return useContext(ComposerAttachmentsContext); } function useComposerAttachmentsContext() { const composerAttachmentsContext = useComposerAttachmentsContextOrNull(); return nn( composerAttachmentsContext, "Composer.Form is missing from the React tree." ); } function useComposerSuggestionsContext(source = "useComposerSuggestionsContext") { const composerSuggestionsContext = useContext(ComposerSuggestionsContext); return nn( composerSuggestionsContext, `${source} can\u2019t be used outside of Composer.Editor.` ); } function useComposerFloatingToolbarContext(source = "useComposerFloatingToolbarContext") { const composerFloatingToolbarContext = useContext( ComposerFloatingToolbarContext ); return nn( composerFloatingToolbarContext, `${source} can\u2019t be used outside of Composer.Editor.` ); } function useComposer() { const composerContext = useContext(ComposerContext); return nn(composerContext, "Composer.Form is missing from the React tree."); } export { ComposerAttachmentsContext, ComposerContext, ComposerEditorContext, ComposerFloatingToolbarContext, ComposerSuggestionsContext, useComposer, useComposerAttachmentsContext, useComposerAttachmentsContextOrNull, useComposerEditorContext, useComposerFloatingToolbarContext, useComposerSuggestionsContext }; //# sourceMappingURL=contexts.js.map