import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js"; import { DefaultSuggestionItem } from "../../extensions/SuggestionMenu/DefaultSuggestionItem.js"; import { insertOrUpdateBlockForSlashMenu } from "../../extensions/SuggestionMenu/getDefaultSlashMenuItems.js"; import { BlockSchema, InlineContentSchema, StyleSchema, } from "../../schema/index.js"; import { createPageBreakBlockConfig } from "./block.js"; export function checkPageBreakBlocksInSchema< I extends InlineContentSchema, S extends StyleSchema, >( editor: BlockNoteEditor, ): editor is BlockNoteEditor< { pageBreak: ReturnType; }, I, S > { return "pageBreak" in editor.schema.blockSchema; } export function getPageBreakSlashMenuItems< BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema, >(editor: BlockNoteEditor) { const items: (Omit & { key: "page_break" })[] = []; if (checkPageBreakBlocksInSchema(editor)) { items.push({ ...editor.dictionary.slash_menu.page_break, onItemClick: () => { insertOrUpdateBlockForSlashMenu(editor, { type: "pageBreak", }); }, key: "page_break", }); } return items; }