### Set Up SimpleMindMap Local Development Environment Source: https://wanglin2.github.io/mind-map-docs/start/start These bash commands outline the steps to clone the SimpleMindMap repository, navigate to the core library and web example directories, install dependencies, and link the library. This setup enables local development and testing of the SimpleMindMap library. ```bash git clone https://github.com/wanglin2/mind-map.git cd mind-map cd simple-mind-map npm i npm link cd .. cd web npm i npm link simple-mind-map npm run serve ``` -------------------------------- ### Local Development Setup for Simple Mind Map Source: https://wanglin2.github.io/mind-map-docs/en/start/start Provides steps to clone the repository, navigate into the `simple-mind-map` and `web` directories, install dependencies, link packages, and start the development server. Includes notes on Node.js version and handling paid plugin dependencies. ```bash git clone https://github.com/wanglin2/mind-map.git cd mind-map cd simple-mind-map npm i npm link cd .. cd web npm i npm link simple-mind-map npm run serve ``` -------------------------------- ### Compile Project Documentation Source: https://wanglin2.github.io/mind-map-docs/en/start/start Command to build the project's documentation files. ```bash cd web npm run buildDoc ``` -------------------------------- ### Initialize simple-mind-map Instance Source: https://wanglin2.github.io/mind-map-docs/en/start/start This JavaScript code imports the `MindMap` class and creates a new instance, linking it to the `mindMapContainer` HTML element. It initializes the mind map with a basic root node, demonstrating the fundamental setup for displaying a mind map. ```javascript import MindMap from "simple-mind-map"; const mindMap = new MindMap({ el: document.getElementById('mindMapContainer'), data: { "data": { "text": "Root Node" }, "children": [] } }); ``` -------------------------------- ### Package Web Demo Application Source: https://wanglin2.github.io/mind-map-docs/en/start/start Command to build the web demo application, which automatically moves the `index.html` file to the root directory. ```bash cd web npm run build ``` -------------------------------- ### Build SimpleMindMap Core Library Source: https://wanglin2.github.io/mind-map-docs/start/start This bash command executes the build script for the `simple-mind-map` core library. It reuses the build tools from the `web` example project to generate distributable files, allowing for custom builds with specific plugins. ```bash cd web npm run buildLibrary ``` -------------------------------- ### SimpleMindMap.MindMap Constructor Source: https://wanglin2.github.io/mind-map-docs/start/start Initializes a new SimpleMindMap instance. The constructor accepts an options object to configure the mind map's rendering element and initial data. This allows for flexible setup and dynamic mind map creation. ```APIDOC MindMap(options: object) options: el: HTMLElement | string Description: The DOM element or its ID where the mind map will be rendered. (e.g., document.getElementById('mindMapContainer')) data: object Description: The initial data structure for the mind map. Properties of data: data: object Description: Core node data. Properties of data.data: text: string Description: The text content of the root node. (e.g., "根节点") children: array Description: An array of child nodes. Each child node follows a similar structure to the root data. (e.g., []) ``` -------------------------------- ### Install simple-mind-map via npm Source: https://wanglin2.github.io/mind-map-docs/en/start/start Installs the simple-mind-map package using npm. This is the primary method for adding the library to your project. This command is applicable for versions before 0.2.0 as well. ```bash npm i simple-mind-map ``` -------------------------------- ### Package Simple Mind Map Core Library Source: https://wanglin2.github.io/mind-map-docs/en/start/start Commands to build the core `simple-mind-map` library. Explains that `full.js` includes all plugins by default and suggests modifying it to reduce file size if not all plugins are needed. ```bash cd web npm run buildLibrary ``` -------------------------------- ### Install SimpleMindMap via npm Source: https://wanglin2.github.io/mind-map-docs/start/start This command installs the SimpleMindMap library using npm. It's the primary method for integrating the library into your project, ensuring all dependencies are managed correctly. ```bash npm i simple-mind-map ``` -------------------------------- ### Simple Mind Map Library Package.json Export Fields Source: https://wanglin2.github.io/mind-map-docs/en/start/start Illustrates the `module` and `main` fields in `package.json` for the `simple-mind-map` library, explaining how different environments use `index.js` or `simpleMindMap.umd.min.js` as entry points. ```json { "module": "index.js", "main": "./dist/simpleMindMap.umd.min.js" } ``` -------------------------------- ### Asynchronously Load and Register SimpleMindMap Plugin Source: https://wanglin2.github.io/mind-map-docs/start/start This JavaScript example shows how to dynamically import a specific plugin, such as `Export.js`, and register it with an existing `mindMap` instance using `addPlugin`. This approach is beneficial for optimizing bundle size by loading plugins on demand rather than including them all initially. ```javascript import('simple-mind-map/src/plugins/Export.js').then(res => { mindMap.addPlugin(res.default) }) ``` -------------------------------- ### Asynchronously Load and Register simple-mind-map Plugin Source: https://wanglin2.github.io/mind-map-docs/en/start/start This JavaScript snippet demonstrates how to asynchronously load and register a plugin, specifically the `Export.js` plugin, after the `simple-mind-map` instance has been created. This method allows for lazy loading of features, reducing the initial bundle size. ```javascript import('simple-mind-map/src/plugins/Export.js').then(res => { mindMap.addPlugin(res.default) }) ``` -------------------------------- ### Instantiate SimpleMindMap in JavaScript Source: https://wanglin2.github.io/mind-map-docs/start/start This JavaScript code demonstrates how to import the `MindMap` class and create a new instance. It requires a DOM element (`el`) to render into and an initial mind map `data` structure. ```javascript import MindMap from "simple-mind-map"; const mindMap = new MindMap({ el: document.getElementById('mindMapContainer'), data: { "data": { "text": "根节点" }, "children": [] } }); ``` -------------------------------- ### Generate TypeScript Type Definitions for Simple Mind Map Source: https://wanglin2.github.io/mind-map-docs/en/start/start Command to generate TypeScript declaration files for the `simple-mind-map` library, which will be located in the `types/` directory. ```bash cd simple-mind-map npm run types ``` -------------------------------- ### Include SimpleMindMap via CDN in HTML Source: https://wanglin2.github.io/mind-map-docs/start/start This HTML snippet demonstrates how to include the SimpleMindMap library and its associated CSS file directly from a CDN. This method creates a global `window.simpleMindMap` object, making the library accessible without a build step. ```html ``` -------------------------------- ### Import simple-mind-map via CDN (UMD Module) Source: https://wanglin2.github.io/mind-map-docs/en/start/start This HTML snippet shows how to include the `simple-mind-map` library and its associated CSS using CDN links or local UMD module files. This method is suitable for direct browser usage without a module bundler, making the `MindMap` constructor available via `window.simpleMindMap.default`. ```html ``` -------------------------------- ### Start Local Development Server for SimpleMindMap Web Project Source: https://wanglin2.github.io/mind-map-docs/en/start/deploy After setting up the project, this command starts a local development server, allowing you to preview the application in your browser. This is useful for testing changes before packaging for deployment. ```bash npm run serve ``` -------------------------------- ### simple-mind-map CDN URLs for UMD and CSS Source: https://wanglin2.github.io/mind-map-docs/en/start/start These URLs provide direct access to the `simple-mind-map` UMD module JavaScript file and its minified ES module CSS file via unpkg CDN. They allow for quick integration of the library into web projects without requiring a local `npm` installation. ```APIDOC https://unpkg.com/simple-mind-map@0.10.2/dist/simpleMindMap.esm.css https://unpkg.com/simple-mind-map@0.10.2/dist/simpleMindMap.umd.min.js ``` -------------------------------- ### SimpleMindMap package.json Module Export Fields Source: https://wanglin2.github.io/mind-map-docs/start/start This JSON snippet illustrates the `module` and `main` fields in the `simple-mind-map`'s `package.json`. These fields define the entry points for ES modules and CommonJS modules respectively, influencing how bundlers resolve the library. ```json { "module": "index.js", "main": "./dist/simpleMindMap.umd.min.js" } ``` -------------------------------- ### simple-mind-map CDN URL for ES Modules Source: https://wanglin2.github.io/mind-map-docs/en/start/start This URL points to the unpkg CDN directory for a specific version of `simple-mind-map`, allowing users to browse and access all packaged ES module files. It provides an alternative for direct browser usage when ES module support is desired. ```APIDOC https://unpkg.com/browse/simple-mind-map@0.9.2/dist/ ``` -------------------------------- ### Example Usage of walk Method Source: https://wanglin2.github.io/mind-map-docs/en/api/utils An example demonstrating how to call the `walk` method with a tree, null parent, empty callbacks, and default parameters for `isRoot`, `layerIndex`, and `index`. ```js walk(tree, null, () => {}, () => {}, false, 0, 0); ``` -------------------------------- ### Configure Vue CLI for simple-mind-map transpilation Source: https://wanglin2.github.io/mind-map-docs/en/start/start Adds a configuration to the vue.config.js file for Vue CLI-created projects. This ensures that the simple-mind-map dependency is properly compiled by babel-loader, addressing potential compilation failures due to the library being published in source code form. ```js module.exports = { transpileDependencies: ["simple-mind-map"] }; ``` -------------------------------- ### Start Web Development Server Source: https://wanglin2.github.io/mind-map-docs/en/plugins/cooperate This bash command executes the development server for the web application. It should be run from the `web` directory after configuring the Cooperate plugin. ```bash // Execute under web path npm run serve ``` -------------------------------- ### Define HTML Container for Mind Map Source: https://wanglin2.github.io/mind-map-docs/en/start/start This HTML snippet defines a `div` element with the ID `mindMapContainer`, which serves as the essential container for rendering the `simple-mind-map` instance. It must have non-zero width and height for the mind map to display correctly. ```html
``` -------------------------------- ### Clone Project and Install Dependencies for Mind Map Source: https://wanglin2.github.io/mind-map-docs/en/plugins/cooperate This bash script outlines the steps to clone the `mind-map` repository, navigate into its subdirectories (`simple-mind-map` and `web`), and install their respective npm dependencies. It also demonstrates linking `simple-mind-map` locally for development. ```bash git clone https://github.com/wanglin2/mind-map.git cd mind-map cd simple-mind-map npm i npm link cd .. cd web npm i npm link simple-mind-map ``` -------------------------------- ### Clone and Set Up Simple Mind Map Web Project Source: https://wanglin2.github.io/mind-map-docs/start/deploy This sequence of bash commands clones the `mind-map` repository, navigates into the `simple-mind-map` and `web` directories, installs necessary dependencies using npm, and links the `simple-mind-map` package locally. This prepares the project for development or building. ```bash git clone https://github.com/wanglin2/mind-map.git cd mind-map cd simple-mind-map npm i npm link cd .. cd web npm i npm link simple-mind-map ``` -------------------------------- ### Define HTML Container for Mind Map Source: https://wanglin2.github.io/mind-map-docs/start/start This HTML snippet provides a `div` element with the ID `mindMapContainer`, which serves as the rendering target for the SimpleMindMap instance. It is crucial that this container has non-zero dimensions for the mind map to display correctly. ```html ``` -------------------------------- ### Install SimpleMindMap Themes Plugin Source: https://wanglin2.github.io/mind-map-docs/en/plugins/themes This command installs the `simple-mind-map-plugin-themes` package using npm, making it available for use in your project. It's a prerequisite for using the plugin's functionalities. ```bash npm i simple-mind-map-plugin-themes ``` -------------------------------- ### Configure Vue CLI for SimpleMindMap Transpilation Source: https://wanglin2.github.io/mind-map-docs/start/start For Vue CLI projects, this configuration in `vue.config.js` ensures that `simple-mind-map` is transpiled by `babel-loader`. This resolves potential compilation issues with newer JavaScript syntax, especially for versions prior to 0.2.0. ```javascript module.exports = { transpileDependencies: ['simple-mind-map'] } ``` -------------------------------- ### Install SimpleMindMap Themes Plugin via npm Source: https://wanglin2.github.io/mind-map-docs/plugins/themes This snippet provides the command to install the `simple-mind-map-plugin-themes` package using npm, which is required to use additional themes beyond the default. ```bash npm i simple-mind-map-plugin-themes ``` -------------------------------- ### Apply Basic CSS Reset for Mind Map Container Source: https://wanglin2.github.io/mind-map-docs/en/start/start This CSS snippet applies a basic reset to all elements within the `mindMapContainer`, setting `margin` and `padding` to `0`. This helps in ensuring consistent rendering of the mind map by removing default browser styles. ```css #mindMapContainer * { margin: 0; padding: 0; } ``` -------------------------------- ### Run or Build Simple Mind Map Web Project Source: https://wanglin2.github.io/mind-map-docs/start/deploy After setting up the project, these commands allow you to either start a local development server or build the project for production deployment. The `npm run serve` command launches a local server, while `npm run build` generates static assets in the `dist` directory. ```bash npm run serve ``` ```bash npm run build ``` -------------------------------- ### Clone and Set Up SimpleMindMap Project for Static Deployment Source: https://wanglin2.github.io/mind-map-docs/en/start/deploy This sequence of bash commands clones the 'mind-map' repository, navigates into the 'simple-mind-map' and 'web' directories, installs dependencies, and links the 'simple-mind-map' package locally. This prepares the project for development or static deployment. ```bash git clone https://github.com/wanglin2/mind-map.git cd mind-map cd simple-mind-map npm i npm link cd .. cd web npm i npm link simple-mind-map ``` -------------------------------- ### Example package.json for SimpleMindMap Plugin Source: https://wanglin2.github.io/mind-map-docs/course/course24 This snippet provides a reference `package.json` file structure for publishing a `simple-mind-map` plugin to npm. It includes common fields like `name`, `version`, `description`, `module`, `main`, `scripts` for building with `esbuild`, `author`, `license`, and `dependencies`. ```JSON { "name": "simple-mind-map-plugin-xxx", "version": "1.0.0", "description": "插件的描述", "module": "index.js", "main": "./dist/xxx.esm.min.js", "scripts": { "build": "esbuild ./index.js --bundle --minify --external:buffer --format=esm --outfile=./dist/xxx.esm.min.js && esbuild ./index.js --bundle --minify --external:buffer --format=cjs --outfile=./dist/xxx.cjs.min.js" }, "author": "作者名字", "license": "MIT", "dependencies": { "esbuild": "^0.17.15" } } ``` -------------------------------- ### Start Yjs Signaling Server Source: https://wanglin2.github.io/mind-map-docs/en/plugins/cooperate This bash command initiates the signaling server required for Yjs collaborative editing. It runs a script located in `simple-mind-map/bin/wsServer.mjs`, which is based on `y-webrtc` and may not be complete for production use. ```bash // Execute under simple-mind-map path npm run wsServe ``` -------------------------------- ### Import KaTeX Stylesheet for npm Installation Source: https://wanglin2.github.io/mind-map-docs/en/plugins/formula This JavaScript import statement demonstrates how to include the necessary KaTeX stylesheet when 'simple-mind-map' is installed via npm. This is particularly relevant for scenarios where KaTeX renders in HTML mode, which might be triggered automatically for older browser versions. ```js import 'simple-mind-map/node_modules/katex/dist/katex.min.css' ``` -------------------------------- ### Get Custom Theme Configuration Source: https://wanglin2.github.io/mind-map-docs/en/api/constructor/constructor-methods Retrieves the custom theme configuration applied to the mind map. ```APIDOC getCustomThemeConfig() ``` -------------------------------- ### Integrate and Use Themes Plugin in SimpleMindMap Source: https://wanglin2.github.io/mind-map-docs/plugins/themes This JavaScript example demonstrates how to import the `MindMap` and `Themes` modules, register the Themes plugin with the `MindMap` class, and then instantiate `MindMap` with a specific theme, such as 'dark7'. ```js import MindMap from 'simple-mind-map' import Themes from 'simple-mind-map-plugin-themes' // 注册主题 Themes.init(MindMap) // 实例化 new MindMap({ theme: 'dark7' }) ``` -------------------------------- ### Example Usage of copyRenderTree Source: https://wanglin2.github.io/mind-map-docs/en/api/utils Demonstrates how to copy the current mind map's renderer tree into an empty object, effectively creating a duplicate of the render structure. ```js copyRenderTree({}, this.mindMap.renderer.renderTree); ``` -------------------------------- ### Example MindMap Theme Configuration Properties Source: https://wanglin2.github.io/mind-map-docs/course/course10 Illustrates common style and layout properties that can be defined within a simple-mind-map theme, such as font sizes, colors, border styles, and gradient settings. This snippet shows a partial configuration object, typically found within a theme definition. ```js fontSize: 16, fontWeight: 'noraml', fontStyle: 'normal', lineHeight: 1.5, borderColor: '#549688', borderWidth: 1, borderDasharray: 'none', borderRadius: 5, textDecoration: 'none', gradientStyle: false, startColor: '#549688', endColor: '#fff', startDir: [0, 0], endDir: [1, 0], hoverRectColor: '', hoverRectColor: '', hoverRectRadius: 5, textAlign: 'left', imgPlacement: 'top', tagPlacement: 'right' } } ``` -------------------------------- ### MindMap: Get Configuration Source: https://wanglin2.github.io/mind-map-docs/en/api/constructor/constructor-methods Retrieves the current configuration of the mind map instance. If a property name is provided, it returns the value of that specific property; otherwise, it returns the entire configuration object. ```APIDOC getConfig(prop?: string): any prop: string | undefined - Get the value of the specified configuration, and return the entire configuration if not passed. Returns: any - The configuration value or the entire configuration object. ``` -------------------------------- ### Demonstrate Plugin Configuration Source: https://wanglin2.github.io/mind-map-docs/api/constructor/constructor-options Configuration options for the Demonstrate plugin, allowing customization of presentation mode settings. Note: The detailed 'Demonstrate Plugin Configuration' section mentioned in the source text was not provided. ```APIDOC demonstrateConfig (v0.9.11+): Object | null (Default: null) Configuration for the Demonstrate plugin. If not passed, default configuration will be used. An object can be passed; if only a specific property is configured, only that property needs to be set, and other unset properties will still use default configurations. For complete configuration, please refer to the 'Demonstrate Plugin Configuration' section below. ``` -------------------------------- ### Apply Basic CSS Styles to Mind Map Container Source: https://wanglin2.github.io/mind-map-docs/start/start This CSS rule resets margin and padding for all elements within the `mindMapContainer`. This provides a clean slate for the mind map rendering, preventing default browser styles from interfering with the layout. ```css #mindMapContainer * { margin: 0; padding: 0; } ``` -------------------------------- ### Demonstration Plugin Configuration Source: https://wanglin2.github.io/mind-map-docs/en/api/constructor/constructor-options Configuration options for the demonstration plugin, allowing customization of highlight box appearance and behavior. The 'demonstrateConfig' object can be partially or fully configured, with unconfigured properties reverting to defaults. ```APIDOC demonstrateConfig: type: Object | null defaultValue: null description: Demonstration plugin configuration. If not transmitted, the default configuration will be used. An object can be transmitted. If only a certain property is configured, only that property can be set. Other properties that have not been set will also use the default configuration. properties: boxShadowColor: type: String defaultValue: rgba(0, 0, 0, 0.8) description: The color of the area around the highlighted box borderRadius: type: String defaultValue: 5px description: The size of the rounded corners of the highlighted box transition: type: String defaultValue: all 0.3s ease-out description: Transition properties of highlight box animation and CSS transition properties zIndex: type: Number defaultValue: 9999 description: The hierarchy of highlighted box elements padding: type: Number defaultValue: 20 description: The inner margin of the highlighted box margin: type: Number defaultValue: 50 description: The outer margin of the highlighted box openBlankMode: type: Boolean defaultValue: true description: Is enable fill in the blank mode, where underlined text is not displayed by default and only displayed sequentially by pressing the enter key ``` -------------------------------- ### Example Node Data Before NodeBase64ImageStorage Plugin Source: https://wanglin2.github.io/mind-map-docs/en/plugins/nodeBase64ImageStorage This JSON structure shows how node data is typically organized before the NodeBase64ImageStorage plugin is applied. It highlights the issue of duplicate base64 image data when the same image is used across multiple nodes. ```JSON { "data": { "text": "xxx" }, "children": [ { "data": { "text": "xxx2", "image": "data:image/png,xxx" } }, { "data": { "text": "xxx3", "image": "data:image/png,xxx" } } ] } ``` -------------------------------- ### Install Mind Map Application via Docker Run Command Source: https://wanglin2.github.io/mind-map-docs/en/start/deploy This Docker command pulls the latest mind map application image and runs it as a detached container. It maps the host's port 8081 to the container's internal port 8080, making the web service accessible from the host machine. ```Shell docker run -d -p 8081:8080 shuiche/mind-map:latest ``` -------------------------------- ### Demonstrate Plugin API Reference Source: https://wanglin2.github.io/mind-map-docs/en/plugins/demonstrate Detailed API documentation for the SimpleMindMap Demonstrate plugin, including events, properties, and methods for controlling demonstration mode. ```APIDOC Events: exit_demonstrate: Triggered when exiting the demonstration. demonstrate_jump: Triggered when jumping. Properties: stepList: Array