How pengzz9527/mind-map works
Project Type and Purpose
• This is a monorepo hosting two related but distinct products:
a. simple-mind-map: A framework-agnostic JavaScript mind-map library (packaged to npm) that exposes a plugin-based architecture for rendering and manipulating mind maps in any web page.
b. web: A Vue2+ElementUI single-page application that serves both as an online demo/editor for mind maps (with file import/export) and as comprehensive documentation (multi-language) for the library.
High-Level File Structure
• /simple-mind-map – the library source:
• src/core, src/layouts, src/parse, src/plugins, src/themes, src/utils
• bin/ (WS server example), example/, build scripts, package.json
• /web – the Vue application:
• Build/config scripts (babel.config.js, vue.config.js, custom scripts for docs)
• /dist – compiled output (CSS, JS bundles, static assets) for deployment
• Root files: README.md, LICENSE, top-level index.html, copy.js, .gitignore
Key Architectural Patterns
• Plugin Architecture (Library): Core rendering and event loop are extended via first-class plugins (e.g., Export, Formula, MiniMap). Each plugin registers hooks with the core command/event/render pipeline.
• Layer Separation:
• Core: data model, command & event dispatch, rendering abstraction.
• Layout: algorithms for positioning nodes (mind-map, fishbone, timeline).
• Parse/Serialize: import/export to JSON, Markdown, XMind, PDF, SVG.
• UI App (Vue): Presentation layer, user actions → calls library API → core modifies canvas.
• Vue SPA Structure:
• Pages: Entry points (Index, Edit, Doc)
• Components: Reusable UI (sidebars, toolbars, node editors)
• Router & Store: Navigation and global state
• API Module: interacts with local file system (via browser APIs) and possibly remote endpoints
Main Components and Interactions (
A. Library Core (simple-mind-map):
• Core Engine: Command, Event, Render subsystems
• Layout Manager: selects and runs layout algorithms
• Parser/Serializer: modules for Markdown, XMind, JSON, PDF, SVG
• Plugin Manager: loads and executes optional features
• Themes & Utils: styling, helper functions
B. Web Application (Vue2 SPA):
• UI Pages:
• Index.vue (marketing/home)
• Edit.vue (interactive canvas for creating/editing maps)
• Doc.vue (documentation pages)
• Components: Toolbar, Sidebar, Node editors, Export/import dialogs, Search, MiniMap
• Router & Vuex Store: route definitions, locale and theme state
• API Layer: wraps library calls and file I/O
C. Build & Deployment:
• Build Scripts: Webpack/Vue CLI, babel config, custom scripts to generate docs
• Output: /dist directory with static assets (CSS/JS chunks, fonts, images), index.html
Relationships and Data Flows
• User Interaction (Web UI) → Vue Components dispatch actions → Vuex store / direct calls to the library API → Library Core processes commands/events → Render updates canvas (SVG/Canvas element) → Vue detects changes if needed (e.g. side panels).
• Import/Export: UI triggers parser/serializer modules in library → generates or consumes data streams (JSON, XMind, Markdown) → triggers file download or canvas update.
• Documentation Build: Custom scripts read Markdown under web/src/pages/Doc → transform to Vue components → integrated into SPA.
Essential Elements
• User → Vue Components
• Components → Library API
• Library API → Core Engine → Render
• Build Scripts → Dist
• Blue for library internals
• Green for SPA structures
• Gray for build/deployment
• Yellow for external inputs (Markdown, JSON, XMind)