// imports import clsx from 'clsx'; import { Combobox } from '@headlessui/react'; import React, { useRef, useEffect } from 'react'; // Component for rendering the slash command combobox const SlashCombobox = ({ items, onSelect, editor, editorRef, selectedIndex }) => { // Reference to the combobox DOM element const ref = useRef(null); // Position the combobox above the editor useEffect(() => { if (items.length > 0 && editorRef.current) { // Get the combobox element const el = ref.current; // Get the bounding rectangle of the editor const editorRect = editorRef.current.getBoundingClientRect(); // Position the combobox above the editor el.style.bottom = `${window.innerHeight - editorRect.top}px`; el.style.left = `${editorRect.left}px`; el.style.width = `${editorRect.width}px`; } }, [items.length, editorRef]); // Render the combobox return (