This directory contains the VS Code extension for editing .learningmap files.
The extension consists of two main parts:
- Extension Host (
src/extension.ts,src/LearningmapEditorProvider.ts): Runs in Node.js and manages the VS Code integration - Webview (
src/webview.tsx): Runs in a browser context and hosts the React-based LearningMapEditor
- Registers a custom editor for
.learningmapfiles - Provides a command to create new learningmap files
- Manages file I/O and document synchronization
- Communicates with the webview via message passing
- Renders the LearningMapEditor React component
- Syncs state with the editor store (Zustand)
- Sends save messages to the extension host on changes (debounced)
- Receives update messages when the file changes externally
# From the root of the repository
pnpm build
# Or build just the vscode extension
pnpm --filter learningmap-studio buildThe build process:
- Compiles TypeScript and bundles extension code with esbuild (target: Node.js)
- Bundles webview code with esbuild (target: Browser)
- Copies CSS from the learningmap package
# Watch mode for development
pnpm --filter learningmap-studio watchTo test the extension:
- Open VS Code
- Press F5 to launch Extension Development Host
- Open or create a
.learningmapfile - The visual editor should appear
Learningmap files are JSON files with the .learningmap extension. The structure includes:
nodes: Array of nodes (topics, tasks, text, images)edges: Array of connections between nodessettings: Map settings (background color, title, etc.)version: Schema versiontype: Always "learningmap"
Some features from the web platform may not work in the VS Code webview:
- Share functionality: Uses
window.locationwhich doesn't work in webviews - External JSON store: Loading from external IDs via URL hash won't work
These are optional features and don't affect core editing capabilities.
To create a .vsix package for distribution:
cd platforms/vscode
pnpm packageThis requires the extension to be built first.