Mindmap NextGen

repository·main·Indexed 18 days ago

https://github.com/james-tindal/obsidian-mindmap-nextgen

An Obsidian plugin (v1.16.0) that visualizes Markdown notes as interactive mindmaps using the Markmap engine. It supports rendering via the command palette or inline `markmap` code blocks. Key features include LaTeX support, checkboxes, syntax highlighting, and per-node styling via HTML comments. Users can configure global settings for coloring and layout, or override them using document frontmatter.

Tokens
5.1K
Snippets
22
Records
27
Agent score
64%

What's inside obsidian-mindmap-nextgen

  1. Use Mindmap NextGen in Obsidian

    main

    You can view your notes as mindmaps using two primary methods:

    1. Command Palette: Open the command palette (Cmd/Ctrl+P) and search for the Mindmap NextGen commands to open a mindmap view.
    2. Inline Markmaps: Insert a mindmap directly into your document using a Markdown code block tagged with markmap.

    Pinned vs. Unpinned Mindmaps:

    • Pinned: Linked to a single specific Markdown document.
    • Unpinned: Dynamically updates to show the mindmap for whichever document you last clicked on.
    # Mindmap
    ## Mindmap
  2. Use Checkboxes, LaTeX, and Syntax Highlighting in Mindmaps

    main

    Mindmap NextGen supports several advanced Markdown features:

    • Checkboxes: Standard Markdown checkboxes (- [ ] and - [x]) are rendered in the mindmap. This also works within document titles.
    • LaTeX: Render mathematical expressions using dollar signs. Use single $ for inline expressions and double $$ for multiline blocks.
    • Syntax Highlighting: Uses highlightjs. To use custom themes, download a highlightjs compatible CSS file, place it in your Obsidian Snippets folder, and enable it via Settings > Appearance.
    # Housework
    ## Main
    - [x] Dishes
    - [ ] Cleaning the bathroom
    
    $\frac{\partial f}{\partial t}$
    
  3. Manage Mindmap view via the "More options" menu

    main

    The "More options" menu is located in the top right of each mindmap tab and provides the following actions:

    • Pin/Unpin: Toggle whether the mindmap is locked to the current document or follows your navigation.
    • Copy screenshot: Copies a PNG of the current mindmap to your clipboard. Colors for the background and text can be configured in plugin settings or document frontmatter.
    • Collapse all: Immediately closes all nodes, leaving only the root node visible.
    • Toggle toolbar: Shows or hides the toolbar located in the bottom right of the mindmap.
  4. Configure global Mindmap settings

    main

    Global settings can be adjusted in the Obsidian plugin settings menu:

    • Coloring approaches:
      • Branch coloring: Assigns random colors per branch. Use Color freeze level to stop color changes at a specific depth.
      • Depth coloring: Colors branches based on their depth. You can define colors for the first three levels and a default for deeper levels.
      • Single color: All branches use the same color.
    • Line thickness: Set specific thicknesses for the first three depth levels and a default for deeper levels.
    • Highlight inline markmaps: Toggle background highlighting for inline code blocks.
    • Use title as root node: Automatically uses the document title as the root of the mindmap.
    • Markmap settings: Fine-tune the shape and size of various mindmap components.
  5. Configure Mindmap settings via Frontmatter

    main

    Document frontmatter can override global plugin settings. The plugin accepts most Markmap JSON options (excluding extraJs and extraCss).

    Available Frontmatter Keys:

    • markmap.highlight: (boolean) Adds a background to inline markmaps to make them stand out.
    • markmap.titleAsRootNode: (boolean) Uses the document title as the root node to avoid repetition.
    • markmap.screenshotTextColor: Sets the text color for screenshots.
    • markmap.screenshotBgColor: Sets the background color for screenshots.

    Example:

    ---
    markmap:
      screenshotTextColor: #28F48D
      highlight: true
      titleAsRootNode: true
    ---
  6. Apply per-node styling and folding

    main

    You can customize individual nodes using inline HTML comments with CSS-style declarations.

    Supported Parameters:

    ParameterEffectPropagates to children
    nodeColorSets branch line/circle color✅ Yes
    bgColorSets node label background❌ No
    colorSets node label text color❌ No
    fold: thisCollapses this node by default❌ No
    fold: treeCollapses this node and all descendants❌ No

    Example:

    # Project <!-- nodeColor: #663366 -->
    ## Risks <!-- bgColor: red; color: white; fold: this -->
    - Item one
    # Project <!-- nodeColor: #663366 -->
    ## Risks <!-- bgColor: red; color: white; fold: this -->
    - Item one
    - Item two
    ## Goals <!-- nodeColor: #2e86de; fold: tree -->
    ### Short term
    ### Long term
  7. Configure Global Settings for Mindmap NextGen

    main

    Global settings control the visual appearance and behavior of the mindmap across the entire plugin. These settings include layout spacing, animation durations, coloring modes, and screenshot styles.

    Key configuration categories include:

    • Layout & Spacing: splitDirection, nodeMinHeight, lineHeight, spacingVertical, spacingHorizontal, paddingX, maxWidth.
    • Expansion & Interaction: initialExpandLevel (controls starting depth), colorFreezeLevel, animationDuration, highlight.
    • Coloring: coloring (options: 'depth', 'branch', or 'single'), depth-specific colors and thicknesses (e.g., depth1Color, depth1Thickness), and defaultColor.
    • Screenshots: screenshotBgStyle (options: ScreenshotBgStyle.Transparent, ScreenshotBgStyle.Color, or ScreenshotBgStyle.Theme), screenshotBgColor, screenshotTextColor, and screenshotTextColorEnabled.
    • Root Node: titleAsRootNode (boolean).
    // Example of the shape of GlobalSettings
    const settings: GlobalSettings = {
      splitDirection: 'horizontal',
      nodeMinHeight: 16,
      lineHeight: '1em',
      spacingVertical: 5,
      spacingHorizontal: 80,
      paddingX: 8,
      initialExpandLevel: -1,
      colorFreezeLevel: 0,
      animationDuration: 500,
      maxWidth: 0,
      highlight: true,
      coloring: 'depth',
      depth1Color: '#cb4b16',
      depth1Thickness: '3',
      depth2Color: '#6c71c4',
      depth2Thickness: '1.5',
      depth3Color: '#859900',
      depth3Thickness: '1',
      defaultColor: '#b58900',
      defaultThickness: '1',
      screenshotBgColor: '#002b36',
      screenshotBgStyle: ScreenshotBgStyle.Color,
      screenshotTextColor: '#fdf6e3',
      screenshotTextColorEnabled: false,
      titleAsRootNode: true,
    };
  8. Extract Markmap settings from Markdown frontmatter or code blocks

    main

    The splitMarkdown<Type>(type, markdown) function allows you to separate the actual content body from the configuration settings defined in Markdown.

    • type: Must be either 'file' (for frontmatter in a file) or 'codeBlock' (for settings inside a code block).
    • Returns an object containing the body (the Markdown content) and settings (the parsed YAML configuration).

    Settings are extracted from the markmap key within the YAML block.

    // For a code block
    const { body, settings } = splitMarkdown('codeBlock', markdownContent);
    
    // For a file with frontmatter
    const { body, settings } = splitMarkdown('file', fileContent);
  9. Listen for setting changes

    main

    You can react to changes in the global settings by listening to the settingChanges event emitter. This is useful for updating UI components or re-rendering views when a user modifies a setting.

    Use settingChanges.listen(key, callback) where key is a key of GlobalSettings.

    import { settingChanges } from 'src/settings/filesystem';
    
    settingChanges.listen('animationDuration', (newValue) => {
      console.log(`Animation duration changed to: ${newValue}`);
    });
  10. Map CodeBlockSettings to MarkmapOptions with getOptions()

    main

    The getOptions(settings: CodeBlockSettings) function converts project-specific CodeBlockSettings into the standard IMarkmapOptions format used by the markmap-view library.

    It handles complex logic for:

    • Coloring modes: Supports branch, depth, and single coloring strategies.
    • Animation: Maps animationDuration to duration.
    • Layout: Passes through properties like initialExpandLevel, maxWidth, nodeMinHeight, paddingX, spacingVertical, and spacingHorizontal.
    • Coloring Logic:
      • branch: Uses branch-based coloring.
      • depth: Uses depth1Color, depth2Color, and depth3Color for the first three levels, falling back to defaultColor.
      • single: Uses defaultColor.
    // settings is an object of type CodeBlockSettings
    const markmapOptions = getOptions(settings);
  11. Access loaded global settings

    main

    Because settings are loaded asynchronously from the filesystem, you should use the settingsLoaded promise to ensure the globalSettings object is fully initialized before attempting to access it.

    import { settingsLoaded, globalSettings } from 'src/settings/filesystem';
    
    async function init() {
      await settingsLoaded;
      console.log('Current split direction:', globalSettings.splitDirection);
    }