import { MantineThemeOverride } from "@mantine/core";
import {
  BlockNoteEditor,
  BlockSchema,
  FormattingToolbarDynamicParams,
  FormattingToolbarStaticParams,
} from "bocknoat-core";
import { FC } from "react";
import { ReactElementFactory } from "../ElementFactory/components/ReactElementFactory";
import { FormattingToolbar as ReactFormattingToolbar } from "./components/FormattingToolbar";

export const createReactFormattingToolbarFactory = <
  BSchema extends BlockSchema
>(
  theme: MantineThemeOverride,
  toolbar: FC<{
    editor: BlockNoteEditor<BSchema>;
  }> = ReactFormattingToolbar<BSchema>
) => {
  return (staticParams: FormattingToolbarStaticParams<BSchema>) =>
    ReactElementFactory<
      FormattingToolbarStaticParams<BSchema>,
      FormattingToolbarDynamicParams
    >(staticParams, toolbar, theme, {
      animation: "fade",
      placement: "top-start",
    });
};
