UNPKG

insta-toc

Version:

Simultaneously generate, update, and maintain a table of contents for your notes in real time.

60 lines (54 loc) 1.31 kB
import { defaultExcludedChars } from "../constants"; import type { FileKey, FoldKey, HeadingLevel, LocalTocSettings } from "../types"; type UpdateDelay = | 500 | 1000 | 1500 | 2000 | 2500 | 3000 | 3500 | 4000 | 4500 | 5000 | 5500 | 6000 | 6500 | 7000 | 7500 | 8000 | 8500 | 9000 | 9500 | 10000; export interface InstaTocSettings { updateDelay: UpdateDelay; tocTitle: string; tocTitleLevel: HeadingLevel; tocTitleCentered: boolean; excludedHeadingLevels: HeadingLevel[]; excludedHeadingText: string[]; excludedChars: string[]; } export const DEFAULT_SETTINGS: InstaTocSettings = { updateDelay: 2000, tocTitle: "Table of Contents", tocTitleLevel: 1, tocTitleCentered: false, excludedHeadingLevels: [], excludedHeadingText: [], excludedChars: defaultExcludedChars }; export type InstaTocPersistedData = { settings: Partial<InstaTocSettings>; tocFoldState: Record<FoldKey, boolean>; tocBlockCollapseState: Record<FileKey, boolean>; }; export function getDefaultLocalSettings(): LocalTocSettings { return { title: { name: null, level: null, center: null }, exclude: null, omit: null, levels: { min: null, max: null } }; }