

import type { Editor } from "@tiptap/react";
import { EditorContent } from "@tiptap/react";
import type { ReactNode } from "react";

type Props = {
  className?: string;
  children?: ReactNode;
  editor: Editor | null;
  id: string;
  tabIndex?: number;
};

export function EditorContentWrapper(props: Props) {
  const { editor, className, children, tabIndex, id } = props;

  return (
    <div
      tabIndex={tabIndex}
      onFocus={() =>
        editor?.chain().focus(undefined, { scrollIntoView: false }).run()
      }
      className={className}
    >
      <EditorContent editor={editor} id={id} />
      {children}
    </div>
  );
}
