import * as react_jsx_runtime from 'react/jsx-runtime'; import { BaseMetadata, ThreadData } from '@liveblocks/client'; import { DTM, DCM, HistoryVersion } from '@liveblocks/core'; import { ThreadProps, ComposerProps } from '@liveblocks/react-ui'; import * as react from 'react'; import { ComponentPropsWithoutRef, ComponentType, HTMLAttributes, ReactNode, ComponentProps } from 'react'; import * as lexical from 'lexical'; import { LexicalCommand, LexicalEditor, LexicalNode, TextFormatType } from 'lexical'; import { InitialConfigType } from '@lexical/react/LexicalComposer'; type AnchoredThreadsComponents = { Thread: ComponentType; }; interface AnchoredThreadsProps extends Omit, "children"> { /** * The threads to display. */ threads: ThreadData[]; /** * Override the component's components. */ components?: Partial; } declare function AnchoredThreads({ threads, components, className, style, ...props }: AnchoredThreadsProps): react_jsx_runtime.JSX.Element | null; /** * Returns whether the associated thread annotation for the given thread id is selected or not in the editor. * @param threadId The id of the thread to check if the associated annotation is selected or not. * @returns true if the associated annotation for the thread is selected, false otherwise. */ declare function useIsThreadActive(threadId: string): boolean; type ExcludeProps> = Omit, keyof K>; type ComposerPropsCreateThread = ExcludeProps, { threadId: string; commentId: string; }>; type FloatingComposerComponents = { Composer: ComponentType>; }; /** * Dispatching OPEN_FLOATING_COMPOSER_COMMAND will display the FloatingComposer * * @example * import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext"; * import { OPEN_FLOATING_COMPOSER_COMMAND } from "@liveblocks/react-lexical"; * * function Toolbar() { * const [editor] = useLexicalComposerContext(); * * return ( * * ); * } */ declare const OPEN_FLOATING_COMPOSER_COMMAND: LexicalCommand; /** * Dispatching ATTACH_THREAD_COMMAND will attach a comment to the current selection. */ declare const ATTACH_THREAD_COMMAND: LexicalCommand; type FloatingComposerProps = ComposerPropsCreateThread & { /** * Override the component's components. */ components?: Partial; }; /** * Displays a `Composer` near the current lexical selection. * * To open it, dispatch `OPEN_FLOATING_COMPOSER_COMMAND`. * * Submitting a comment will attach an annotation thread at the current selection. * Should be nested inside `LiveblocksPlugin`. */ declare const FloatingComposer: react.ForwardRefExoticComponent & { /** * Override the component's components. */ components?: Partial; } & react.RefAttributes>; type FloatingThreadsComponents = { Thread: ComponentType; }; interface FloatingThreadsProps extends Omit, "children"> { /** * The threads to display. */ threads: ThreadData[]; /** * Override the component's components. */ components?: Partial; } declare function FloatingThreads({ threads, components, ...props }: FloatingThreadsProps): react_jsx_runtime.JSX.Element | null; /** * Checks if a block node is active in the current selection. * If the selection contains multiple block nodes, it will return * `true` only if all of them are of the same type. */ declare function isBlockNodeActive(editor: LexicalEditor, isActive: (node: LexicalNode) => boolean): boolean; /** * Checks if a text format (e.g. bold, italic, โ€ฆ) is active in * the current selection. */ declare function isTextFormatActive(editor: LexicalEditor, format: TextFormatType): boolean; /** * Function that takes a Lexical editor config and modifies it to add the necessary * `nodes` and `theme` to make `LiveblocksPlugin` works correctly. * * @example * import { LexicalComposer } from "@lexical/react/LexicalComposer"; * import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin"; * import { ContentEditable } from "@lexical/react/LexicalContentEditable"; * import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary"; * import { liveblocksConfig, LiveblocksPlugin } from "@liveblocks/react-lexical"; * * const initialConfig = liveblocksConfig({ * namespace: "MyEditor", * theme: {}, * nodes: [], * onError: (err) => console.error(err), * }); * * function Editor() { * return ( * * * } * placeholder={
Enter some text...
} * ErrorBoundary={LexicalErrorBoundary} * /> *
* ); * } */ declare function liveblocksConfig(editorConfig: Omit): { nodes: (lexical.KlassConstructor | lexical.LexicalNodeReplacement)[]; editorState: null; html?: lexical.HTMLConfig; onError: (error: Error, editor: lexical.LexicalEditor) => void; namespace: string; editable?: boolean; theme?: lexical.EditorThemeClasses; }; /** * Returns whether the editor has loaded the initial text contents from the * server and is ready to be used. */ declare function useIsEditorReady(): boolean; type LiveblocksPluginProps = { children?: ReactNode; }; /** * Liveblocks plugin for Lexical that adds collaboration to your editor. * * `LiveblocksPlugin` should always be nested inside `LexicalComposer`. * * @example * * import { LexicalComposer } from "@lexical/react/LexicalComposer"; * import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin"; * import { ContentEditable } from "@lexical/react/LexicalContentEditable"; * import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary"; * import { liveblocksConfig, LiveblocksPlugin } from "@liveblocks/react-lexical"; * * const initialConfig = liveblocksConfig({ * namespace: "MyEditor", * theme: {}, * nodes: [], * onError: (err) => console.error(err), * }); * * function Editor() { * return ( * * * } * placeholder={
Enter some text...
} * ErrorBoundary={LexicalErrorBoundary} * /> *
* ); * } */ declare const LiveblocksPlugin: ({ children, }: LiveblocksPluginProps) => JSX.Element; type FloatingPosition = "top" | "bottom"; interface ToolbarSlotProps { editor: LexicalEditor; } type ToolbarSlot = ReactNode | ComponentType; interface ToolbarProps extends Omit, "children"> { /** * The content of the toolbar, overriding the default content. * Use the `before` and `after` props if you want to keep and extend the default content. */ children?: ToolbarSlot; /** * The content to display at the start of the toolbar. */ before?: ToolbarSlot; /** * The content to display at the end of the toolbar. */ after?: ToolbarSlot; } interface ToolbarButtonProps extends ComponentProps<"button"> { /** * The name of this button displayed in its tooltip. */ name: string; /** * An optional icon displayed in this button. */ icon?: ReactNode; /** * An optional keyboard shortcut displayed in this button's tooltip. * * @example * "Mod-Alt-B" โ†’ "โŒ˜โŒฅB" in Apple environments, "โŒƒโŒฅB" otherwise * "Ctrl-Shift-Escape" โ†’ "โŒƒโ‡งโŽ‹" * "Space" โ†’ "โฃ" */ shortcut?: string; } interface ToolbarToggleProps extends ToolbarButtonProps { /** * Whether the button is toggled. */ active: boolean; } type ToolbarSeparatorProps = ComponentProps<"div">; interface ToolbarBlockSelectorItem { /** * The name of this block element, displayed as the label of this item. */ name: string; /** * Optionally replace the name used as the label of this item by any content. */ label?: ReactNode; /** * An optional icon displayed in this item. */ icon?: ReactNode; /** * Whether this block element is currently active. * Set to `"default"` to display this item when no other item is active. */ isActive: ((editor: LexicalEditor) => boolean) | "default"; /** * A callback invoked when this item is selected. */ setActive: (editor: LexicalEditor) => void; } interface ToolbarBlockSelectorProps extends ComponentProps<"button"> { /** * The items displayed in this block selector. * When provided as an array, the default items are overridden. To avoid this, * a function can be provided instead and it will receive the default items. * * @example * { ... }, * }, * { * name: "Heading 1", * isActive: () => { ... }, * setActive: () => { ... }, * }, * ]} * /> * * @example * [ * ...defaultItems, * { * name: "Custom block", * isActive: () => { ... }, * setActive: () => { ... }, * }, * ]} * /> */ items?: ToolbarBlockSelectorItem[] | ((defaultItems: ToolbarBlockSelectorItem[]) => ToolbarBlockSelectorItem[]); } declare function ToolbarSectionHistory(): react_jsx_runtime.JSX.Element; declare function ToolbarSectionInline(): react_jsx_runtime.JSX.Element | null; declare function ToolbarSectionCollaboration(): react_jsx_runtime.JSX.Element; /** * A static toolbar containing actions and values related to the editor. * * @example * * * @example * * * * * * { ... }} icon={} /> * */ declare const Toolbar: react.ForwardRefExoticComponent & react.RefAttributes> & { /** * A button for triggering actions. * * @example * { ... }} /> * * @example * } onClick={() => { ... }} /> */ Button: react.ForwardRefExoticComponent & react.RefAttributes>; /** * A toggle button for values that can be active or inactive. * * @example * * * @example * } shortcut="Mod-I" active={isItalic} onClick={() => { ... }} /> */ Toggle: react.ForwardRefExoticComponent & react.RefAttributes>; /** * A dropdown selector to switch between different block types. * * @example * */ BlockSelector: react.ForwardRefExoticComponent & react.RefAttributes>; /** * A visual (and accessible) separator to separate sections in a toolbar. */ Separator: react.ForwardRefExoticComponent, HTMLDivElement>, "ref"> & react.RefAttributes>; /** * A section containing history actions. (e.g. undo, redo) */ SectionHistory: typeof ToolbarSectionHistory; /** * A section containing inline formatting actions. (e.g. bold, italic, underline, ...) */ SectionInline: typeof ToolbarSectionInline; /** * A section containing collaborative actions. (e.g. adding a comment) */ SectionCollaboration: typeof ToolbarSectionCollaboration; }; interface FloatingToolbarProps extends Omit, "children"> { /** * The vertical position of the floating toolbar. */ position?: FloatingPosition; /** * The vertical offset of the floating toolbar from the selection. */ offset?: number; /** * The content of the floating toolbar, overriding the default content. * Use the `before` and `after` props if you want to keep and extend the default content. */ children?: ToolbarSlot; /** * The content to display at the start of the floating toolbar. */ before?: ToolbarSlot; /** * The content to display at the end of the floating toolbar. */ after?: ToolbarSlot; } /** * A floating toolbar attached to the selection and containing actions and values related to the editor. * * @example * * * @example * * * * * * { ... }} icon={} /> * */ declare const FloatingToolbar: react.ForwardRefExoticComponent & react.RefAttributes> & { /** * A component that can be wrapped around elements which are rendered outside of the floating * toolbar (e.g. portals) to prevent the toolbar from closing when clicking/focusing within them. * * @example * * * * Open popover * * * * * This popover is rendered outside of the floating toolbar, but the toolbar will not close when clicking/focusing within it. * * * * * */ External: react.ForwardRefExoticComponent, HTMLDivElement>, "ref"> & react.RefAttributes>; }; interface HistoryVersionPreviewProps extends ComponentPropsWithoutRef<"div"> { version: HistoryVersion; onVersionRestore?: (version: HistoryVersion) => void; } /** * Displays a specific version of the current Lexical document. * * @example * */ declare const HistoryVersionPreview: react.ForwardRefExoticComponent>; export { ATTACH_THREAD_COMMAND, AnchoredThreads, AnchoredThreadsProps, FloatingComposer, FloatingComposerProps, FloatingThreads, FloatingThreadsProps, FloatingToolbar, FloatingToolbarProps, HistoryVersionPreview, HistoryVersionPreviewProps, LiveblocksPlugin, OPEN_FLOATING_COMPOSER_COMMAND, Toolbar, ToolbarBlockSelectorItem, ToolbarBlockSelectorProps, ToolbarButtonProps, ToolbarProps, ToolbarSeparatorProps, ToolbarToggleProps, isBlockNodeActive, isTextFormatActive, liveblocksConfig, useIsEditorReady, useIsThreadActive };