crossnote
    Preparing search index...

    Class Notebook

    Index

    Properties

    currentRenderFilePath: string = ''

    The notebook-relative path of the note currently being rendered. Set by MarkdownEngine.parseMD() before calling renderMarkdown(). Used by the wikilink renderer to call resolveWikilink() with the correct context.

    hasLoadedNotes: boolean = false
    markdownYoRenderer: MarkdownRenderer | null = null

    Optional markdown_yo WASM renderer. Used for HTML rendering when markdownParser === 'markdown_yo'.

    md: MarkdownIt
    notebookPath: URI
    notes: Notes = {}
    previewScriptsEnabled: boolean = false

    Whether user-provided preview scripts may run in the preview webview: <script src> tags in .crossnote/head.html and @import "*.js" file imports. Defaults to false, which keeps both channels inert.

    SECURITY: deliberately NOT part of NotebookConfig — config values are merged from the repository's .crossnote/config.js, which is untrusted content. Only the host application may set this flag (e.g. from a user-scoped, application-scope setting); repository files must never be able to turn it on.

    referenceMap: ReferenceMap = ...
    tagReferenceMap: TagReferenceMap = ...

    Global #tag index. Independent of the file system: tags are notebook-wide metadata, not phantom paths. See src/notebook/reference.ts for shape.

    trustedScriptRoots: string[] = []

    Extra absolute directories that <script src> tags in head.html may resolve into when previewScriptsEnabled is on, in addition to the notebook directory. Hosts use this to let the global config directory's head.html load the scripts sitting next to it — those files are user-owned (like the global head.html itself), but live outside every notebook. Defaults to [].

    SECURITY: deliberately NOT part of NotebookConfig — config values are merged from the repository's .crossnote/config.js, which is untrusted content. Only the host application may name a trusted root, and only from user-scoped settings; repository files must never be able to point this at a directory they control. Resolution is still containment-checked per root (realpath, symlinks included), and the @import "*.js" channel stays notebook-directory-only.

    Methods

    • Build markdown_yo render options from the current notebook config.

      Parameters

      • isForPreview: boolean

      Returns RenderOptions

    • Delete a note and update the internal note relations and search index.

      Parameters

      • filePath: string

        Note to delete.

      • alreadyDeleted: boolean = false

        Set to true when the caller has already removed the file from disk (e.g. a filesystem watcher reacting to a deletion event). In that case the file is left untouched — a replacement file recreated at the same path (e.g. by a Git checkout) must survive — and only the internal bookkeeping is refreshed.

      Returns Promise<void>

    • List every tag that has been mentioned anywhere in the notebook. Tags are case-folded, so the returned values are lowercase.

      Returns string[]

    • Parameters

      • filePath: string
      • refreshNoteRelations: boolean = false

      Returns Promise<Note | null>

    • Read a note's markdown body, lazily. Always reads from disk and runs the same front-matter normalisation as getNote — the body is intentionally not cached on Note, so this is the canonical way to fetch it.

      Returns null for files that aren't markdown (extension not in markdownFileExtensions), are missing, or exceed maxNoteFileSize.

      Parameters

      • filePath: string

      Returns Promise<string | null>

    • Notes that mention a given #tag, anywhere in the notebook. Tag is matched case-insensitively.

      Reads from the in-memory notes map — same rationale as getBacklinkedNotes: re-loading each referrer from disk would be N async hops for no win, since the index can only contain referrers we already loaded.

      Parameters

      • tag: string

      Returns Promise<Notes>

    • Parameters

      • noteFilePath: string
      • backlinkedNoteFilePath: string

      Returns Promise<Reference[]>

    • Same shape as getNoteBacklinks, but for a #tag rather than a note filepath. Each Backlink groups a referrer note with the individual #tag references inside it (token + rendered HTML).

      Parameters

      • tag: string

      Returns Promise<Backlink[]>

    • A markdown-it instance for rendering the sidebar TOC, with source maps disabled. parseMD renders the TOC on every preview update, so the instance is created lazily and reused until the live-updated markdown-it options change.

      Returns MarkdownIt

    • Parameters

      • filePath: string
      • OptionalmarkdownOverride: string

      Returns Promise<void>

    • Process wiki link

      Parameters

      • content: string

        content is string like "Test", "test.md | Test"

      Returns { blockRef?: string; hash?: string; link: string; text: string }

    • Parameters

      • __namedParameters: RefreshNotesIfNotLoaded

      Returns Promise<Notes>

    • Incremental version of refreshNotes: instead of wiping the indices and rebuilding from scratch, walk the workspace and only re-process files whose on-disk mtime has advanced past the value recorded in processedMtimes (set during the most recent full refresh or prior incremental refresh). Newly-added files are processed; cached entries that no longer exist on disk are removed (their reference / tag entries cleaned up).

      Designed to be cheap to call from a file-system watcher. The directory walk still has to stat every file under dir, but the O(N) markdown re-tokenisation is skipped for unchanged files.

      Shares the refreshNotesMutex with refreshNotes so the two can't race against each other.

      Parameters

      • args: RefreshNotesArgs

      Returns Promise<Notes>

    • Parameters

      • filePath: string

      Returns Promise<void>

    • Render markdown to HTML using markdown_yo (WASM) if available, otherwise falls back to markdown-it.

      Parameters

      • markdown: string
      • Optionaloptions: { isForPreview?: boolean }

      Returns string

    • Get the absolute path of the note

      Parameters

      • filePath: string

      Returns string

    • Get the relative path of the note to the notebook directory

      Parameters

      • filePath: string

      Returns string

    • Resolve a wiki link file path to a notebook-root-relative path. Used by both index-time mention tracking and render-time embed resolution so both paths agree on link resolution.

      Parameters

      • link: string

        — the file portion of the link (after processWikilink, without fragment/hash/block-id)

      • currentNoteFilePath: string

        — the notebook-relative path of the note containing this link

      Returns string

      notebook-root-relative file path