import type { Editor } from "@tiptap/core"; import type * as Y from "yjs"; import type { FrontmatterStore } from "./frontmatter/frontmatter-store"; import type { EmbedStore } from "./embeds/embed-store"; import { seedFrontmatter } from "./frontmatter/seed-frontmatter"; import { DEFAULT_CONTENT, SEED_CITATIONS } from "./default-content"; import { SEED_BANNER_HTML, SEED_SCALING_CHART_HTML, SEED_MEMORY_BAR_HTML, SEED_CONFUSION_MATRIX_HTML, } from "./seed-embeds"; /** * Replace the current document with the demo content. * Called explicitly by the user via /demo slash command or a UI button. */ export function loadDemoContent( editor: Editor, frontmatterStore: FrontmatterStore, citationsMap: Y.Map, settingsMap: Y.Map, embedStore?: EmbedStore | null, ) { editor.commands.setContent(DEFAULT_CONTENT); seedFrontmatter(frontmatterStore, true); for (const [key, entry] of Object.entries(SEED_CITATIONS)) { citationsMap.set(key, entry); } settingsMap.set("citationStyle", "apa"); if (embedStore) { embedStore.set("banner.html", SEED_BANNER_HTML); embedStore.set("d3-scaling-chart.html", SEED_SCALING_CHART_HTML); embedStore.set("d3-memory-bar.html", SEED_MEMORY_BAR_HTML); embedStore.set("d3-confusion-matrix.html", SEED_CONFUSION_MATRIX_HTML); } }