How hizzgdev/jsmind works
Project type and purpose
• jsMind is an open‑source pure‑JavaScript library for rendering and editing mind maps on the web, based on HTML5 Canvas and SVG.
• It is a front‑end reusable component (not a full‑stack app), embeddable via script tags or module bundlers.
• Key use cases: embedding a mind‑map viewer/editor in any web page or SPA; providing a plugin API for extensions.
File structure
• Top‑level:
• config files (.prettierrc, rollup.config.js, GitHub workflows, .gitignore, .npmignore) → build, lint, CI/CD
• src/ → core library source modules (common, data_provider, dom, graph, layout_provider, mind, node, option, plugin, shortcut_provider, util, view_provider)
• src/plugins/ → first‑class plugins (draggable‑node, screenshot)
• js/ and es6/ and js‑legacy/ → distributed builds (ES5/legacy, ES6, UMD or requirejs)
• style/ → CSS for themes
• example/ → HTML/JS samples showing integration
• docs/ → multi‑language user/developer documentation
• tests/ → unit and legacy tests
• Patterns: modular architecture with clear separation of concerns (data, layout, rendering, DOM interaction, plugins).
README for additional insights
• Confirms HTML5 Canvas & SVG rendering layers.
• Mentions three supported data formats.
• Highlights plugin mechanism and theme options.
• Build and distribution via NPM, CDN; CI on GitHub Actions.
a. Main components
• Core Library Modules
– Data Provider: parses & normalizes mind‑map data formats
– Graph Manager: constructs node/edge graph model
– Layout Provider: computes node positions
– View Provider: renders via canvas/SVG
– DOM Adapter: attaches event handlers, resizing, container management
– Utilities & Options Manager: default configs, theming, i18n
– Plugin Manager: lifecycle hooks, plugin registry
• Plugins (draggable‑node, screenshot, future custom plugins)
• Consumer Application (HTML page or SPA)
– Embedding container div
– jsMind API invocations (new jsMind, show, edit callbacks)
• Build & Distribution
– Rollup bundler → produce UMD/ES6/CJS builds
– Prettier & linting → code style
– NPM registry & CDN (jsDelivr, UNPKG)
• Testing
– Unit tests (tests/unit)
– Legacy tests (tests/legacy)
• Documentation & Examples (docs/, example/)
b. Relationships & interactions
• Consumer app calls the Core API → Core loads data via Data Provider → Graph Manager builds model → Layout Provider computes positions → View Provider renders to Canvas/SVG within DOM container → Plugin Manager invokes plugin hooks before/after each stage → DOM Adapter wires user interactions (drag, click, keyboard shortcuts) back to Core → Core updates model and re‑renders
• Build pipeline takes src/ and src/plugins/ → Rollup → output to es6/, js/, js‑legacy/ → published to NPM/CDN
• Tests import core modules or built outputs and run via test runner
c. Architectural patterns
• Modular, layered architecture (data → model → layout → view → DOM)
• Observer/event hook pattern in Plugin Manager
• Separation of concerns: core engine distinct from plugins & UI
• Build/distribution pipeline decoupled from runtime library
d. Key technologies/frameworks
• JavaScript (ES6 modules)
• HTML5 Canvas & SVG for rendering
• Rollup for bundling
• Prettier/ESLint for style
• Mocha/Jest (or similar) for tests
• GitHub Actions for CI/CD