"use client";

import {
  BlockNoteSchema,
  createHeadingBlockSpec,
  defaultBlockSpecs,
  defaultInlineContentSpecs,
  defaultStyleSpecs,
} from "@blocknote/core";
import { pageReferenceBlock } from "./blocks/PageReferenceBlock";
import { advancedTodoBlock } from "./blocks/AdvancedTodoBlock";
import { progressBlock } from "./blocks/ProgressBlock";
import { mediaBlock } from "./blocks/MediaBlock";
import { onlineTableBlock } from "./blocks/OnlineTableBlock";
import { mindmapBlock } from "./blocks/MindmapBlock";
import { blockReferenceBlock } from "./blocks/BlockReferenceBlock";

const headingSpec = createHeadingBlockSpec({
  levels: [1, 2, 3, 4, 5],
  allowToggleHeadings: true,
});

export const customBlockSchema = BlockNoteSchema.create({
  blockSpecs: {
    ...defaultBlockSpecs,
    heading: headingSpec,
    pageReference: pageReferenceBlock,
    blockReference: blockReferenceBlock,
    advancedTodo: advancedTodoBlock,
    progressMeter: progressBlock,
    media: mediaBlock,
    onlineTable: onlineTableBlock(),
    mindmap: mindmapBlock(),
  },
  inlineContentSpecs: defaultInlineContentSpecs,
  styleSpecs: defaultStyleSpecs,
});

export type CustomBlockSchema = typeof customBlockSchema.blockSchema;
