// This file is auto-generated by "@aria-ui/cli". Do not edit this file directly. import { registerBlockHandleAddElement, type BlockHandleAddElement, type BlockHandleAddProps as BlockHandleAddElementProps } from '@prosekit/web/block-handle'; import { createElement, forwardRef, useCallback, useRef, type ForwardedRef, type ForwardRefExoticComponent, type HTMLAttributes, type RefAttributes, useLayoutEffect } from 'react'; import { useEditorContext } from '../../contexts/editor-context.ts'; /** Props for the {@link BlockHandleAdd} React component. */ export interface BlockHandleAddProps { /** * The ProseKit editor instance. * * @default null * @hidden */ editor?: BlockHandleAddElementProps['editor']; } function BlockHandleAddComponent(props: BlockHandleAddProps, forwardedRef: ForwardedRef) { registerBlockHandleAddElement(); const elementRef = useRef(null); const p0Fallback = useEditorContext(); const { editor: p0, ...restProps } = props; useLayoutEffect(() => { const element = elementRef.current as Record | null; if (!element) return; Object.assign(element, { editor: p0 ?? p0Fallback }); }); const mergedRef = useCallback( (element: BlockHandleAddElement | null) => { elementRef.current = element; if (typeof forwardedRef === 'function') { forwardedRef(element); } else if (forwardedRef) { forwardedRef.current = element; } }, [forwardedRef], ); return createElement('prosekit-block-handle-add', { ...restProps, ref: mergedRef, suppressHydrationWarning: true }); } /** A React component that renders an `prosekit-block-handle-add` custom element. */ export const BlockHandleAdd: ForwardRefExoticComponent & RefAttributes> = /* @__PURE__ */ forwardRef(BlockHandleAddComponent);