<div id="mindMapContainer"></div>
+ Basic use
+ <div id="mindMapContainer"></div>
-import MindMap from "simple-mind-map";
+ import MindMap from "simple-mind-map";
const mindMap = new MindMap({
el: document.getElementById("mindMapContainer"),
@@ -16,478 +16,539 @@
}
});
-Instantiation options
-
-
-
-Field Name
-Type
-Default Value
-Description
-Required
-
-
-
-
-el
-Element
-
-Container element, must be a DOM element
-Yes
-
-
-data
-Object
-{}
-Mind map data, Please refer to the introduction of 【Data structure】 below
-
-
-
-layout
-String
-logicalStructure
-Layout type, options: logicalStructure (logical structure diagram), mindMap (mind map), catalogOrganization (catalog organization diagram), organizationStructure (organization structure diagram)、timeline(v0.5.4+, timeline)、timeline2(v0.5.4+, up down alternating timeline)、fishbone(v0.5.4+, fishbone diagram)
-
-
-
-fishboneDeg(v0.5.4+)
-Number
-45
-Set the diagonal angle of the fishbone structure diagram
-
-
-
-theme
-String
-default
-Theme, options: default, classic, minions, pinkGrape, mint, gold, vitalityOrange, greenLeaf, dark2, skyGreen, classic2, classic3, classic4(v0.2.0+), classicGreen, classicBlue, blueSky, brainImpairedPink, dark, earthYellow, freshGreen, freshRed, romanticPurple, simpleBlack(v0.5.4+), courseGreen(v0.5.4+), coffee(v0.5.4+), redSpirit(v0.5.4+), blackHumour(v0.5.4+), lateNightOffice(v0.5.4+), blackGold(v0.5.4+)、、avocado(v.5.10-fix.2+)、autumn(v.5.10-fix.2+)、orangeJuice(v.5.10-fix.2+)
-
-
-
-themeConfig
-Object
-{}
-Theme configuration, will be merged with the selected theme, available fields refer to: default.js
-
-
-
-scaleRatio
-Number
-0.1
-The incremental scaling ratio
-
-
-
-maxTag
-Number
-5
-The maximum number of tags displayed in the node, any additional tags will be discarded
-
-
-
-exportPadding
-Number
-20
-The padding for exporting images
-
-
-
-imgTextMargin
-Number
-5
-The spacing between the image and text in the node
-
-
-
-textContentMargin
-Number
-2
-The spacing between various text information in the node, such as the spacing between the icon and text
-
-
-
-selectTranslateStep
-Number
-3
-The canvas offset when mouse moves to the edge during multi-select node
-
-
-
-selectTranslateLimit
-Number
-20
-The distance from the edge when the canvas begins to offset during multi-select node
-
-
-
-customNoteContentShow(v0.1.6+)
-Object
-null
-Custom node note content display, object type, structure: {show: (noteContent, left, top) => {// your display node note logic }, hide: () => {// your hide node note logic }}
-
-
-
-readonly(v0.1.7+)
-Boolean
-false
-Whether it is read-only mode
-
-
-
-enableFreeDrag(v0.2.4+)
-Boolean
-false
-Enable node free drag
-
-
-
-watermarkConfig(v0.2.4+)
-Object
-
-Watermark config, Please refer to the table 【Watermark config】 below for detailed configuration
-
-
-
-textAutoWrapWidth(v0.3.4+)
-Number
-500
-Each line of text in the node will wrap automatically when it reaches the width
-
-
-
-customHandleMousewheel(v0.4.3+)
-Function
-null
-User-defined mouse wheel event processing can pass a function, and the callback parameter is the event object
-
-
-
-mousewheelAction(v0.4.3+)
-String
-zoom
-The behavior of the mouse wheel, zoom(Zoom in and out)、move(Move up and down). If customHandleMousewheel passes a custom function, this property will not take effect
-
-
-
-mousewheelMoveStep(v0.4.3+)
-Number
-100
-When the mousewheelAction is set to move, you can use this attribute to control the step length of the view movement when the mouse scrolls. The unit is px
-
-
-
-mousewheelZoomActionReverse(v0.6.5+)
-Boolean
-false
-When mousewheelAction is set to zoom, the default scrolling forward is to zoom out, and scrolling backward is to zoom in. If this property is set to true, it will be reversed
-
-
-
-defaultInsertSecondLevelNodeText(v0.4.7+)
-String
-二级节点
-Text of the default inserted secondary node
-
-
-
-defaultInsertBelowSecondLevelNodeText(v0.4.7+)
-String
-分支主题
-Text for nodes below the second level inserted by default
-
-
-
-expandBtnStyle(v0.5.0+)
-Object
-{ color: '#808080', fill: '#fff', fontSize: 13, strokeColor: '#333333' }
-Expand the color of the stow button, (The fontSize and strokeColor fields were added in version 0.7.0+to set the text style for displaying the number of nodes when folded)
-
-
-
-expandBtnIcon(v0.5.0+)
-Object
-{ open: '', close: '' }
-Customize the icon of the expand/collapse button, and you can transfer the svg string of the icon
-
-
-
-expandBtnNumHandler(v0.7.0+)
-Function
-
-Used to customize the content of displaying the number of nodes when folding, receiving a parameter that represents the instance of the folding node, and returning a number or string that represents the final displayed content. For example, when the number is greater than 99, 99 can be displayed+
-
-
-
-isShowExpandNum(v0.7.0+)
-Boolean
-true
-Display the number of folded nodes when they are folded up
-
-
-
-enableShortcutOnlyWhenMouseInSvg(v0.5.1+)
-Boolean
-true
-Only respond to shortcut key events when the mouse is inside the canvas
-
-
-
-enableNodeTransitionMove(v0.5.1+)(v0.6.7+ is remove this feature)
-Boolean
-true
-Whether to enable node animation transition
-
-
-
-nodeTransitionMoveDuration(v0.5.1+)(v0.6.7+ is remove this feature)
-Number
-300
-If node animation transition is enabled, the transition time can be set using this attribute, in milliseconds
-
-
-
-initRootNodePosition(v0.5.3+)
-Array
-null
-The position of the initial root node can be passed as an array, default is ['center', 'center'], Represents the root node at the center of the canvas, In addition to center, keywords can also be set to left, top, right, and bottom, In addition to passing keywords, each item in the array can also pass a number representing a specific pixel, Can pass a percentage string, such as ['40%', '60%'], Represents a horizontal position at 40% of the canvas width, and a vertical position at 60% of the canvas height
-
-
-
-exportPaddingX(v0.5.5+)
-Number
-10
-Horizontal padding of graphics when exporting PNG, SVG, and PDF
-
-
-
-exportPaddingY(v0.5.5+)
-Number
-10
-Vertical padding of graphics when exporting PNG, SVG, and PDF
-
-
-
-nodeTextEditZIndex(v0.5.5+)
-Number
-3000
-
-z-index of node text edit box elements
-
-
-nodeNoteTooltipZIndex(v0.5.5+)
-Number
-3000
-z-index of floating layer elements in node comments
-
-
-
-isEndNodeTextEditOnClickOuter(v0.5.5+)
-Boolean
-true
-Whether to end the editing status of node text when clicking on an area outside the canvas
-
-
-
-maxHistoryCount(v0.5.6+)
-Number
-1000
-
-Maximum number of history records
-
-
-alwaysShowExpandBtn(v0.5.8+)
-Boolean
-false
-Whether to always display the expand and collapse buttons of nodes, which are only displayed when the mouse is moved up and activated by default
-
-
-
-iconList(v0.5.8+)
-Array
-[]
-The icons that can be inserted into the extension node, and each item in the array is an object. Please refer to the "Icon Configuration" table below for the detailed structure of the object
-
-
-
-maxNodeCacheCount(v0.5.10+)
-Number
-1000
-The maximum number of cached nodes. To optimize performance, an internal node cache pool is maintained to reuse nodes. This attribute allows you to specify the maximum number of caches in the pool
-
-
-
-defaultAssociativeLineText(v0.5.11+)
-String
-关联
-Association Line Default Text
-
-
-
-fitPadding(v0.6.0+)
-Number
-50
-The padding of mind mapping when adapting to canvas size, Unit: px
-
-
-
-enableCtrlKeyNodeSelection(v0.6.0+)
-Boolean
-true
-Whether to enable the function of holding down the Ctrl key to select multiple nodes
-
-
-
-useLeftKeySelectionRightKeyDrag(v0.6.0+)
-Boolean
-false
-Setting to left click to select multiple nodes and right click to drag the canvas.
-
-
-
-beforeTextEdit(v0.6.0+)
-Function/null
-null
-The callback method before the node is about to enter editing. If the method returns a value other than true, the editing will be canceled. The function can return a value or a promise, and the callback parameter is the node instance
-
-
-
-isUseCustomNodeContent(v0.6.3+)
-Boolean
-false
-Whether to customize node content
-
-
-
-customCreateNodeContent(v0.6.3+)
-Function/null
-null
-If isUseCustomNodeContent is set to true, then this option needs to be used to pass in a method that receives the node instance node as a parameter (if you want to obtain data for that node, you can use node.nodeData.data). You need to return the custom node content element, which is the DOM node. If a node does not require customization, you can return null
-
-
-
-mouseScaleCenterUseMousePosition(v0.6.4-fix.1+)
-Boolean
-true
-Is the mouse zoom centered around the current position of the mouse, otherwise centered around the canvas
-
-
-
-customInnerElsAppendTo(v0.6.12+)
-null/HTMLElement
-null
-Specify the location where some internal elements (node text editing element, node note display element, associated line text editing element, node image adjustment button element) are added, and default to document.body
-
-
-
-nodeDragPlaceholderMaxSize(v0.6.12+)
-Number
-20
-When dragging an element, the maximum height of the block indicating the new position of the element
-
-
-
-enableCreateHiddenInput(v0.6.13+)(v0.6.14+ remove this feature)
-Boolean
-true
-Is it allowed to create a hidden input box that will be focused when the node is activated for pasting data and automatically entering the text editing state
-
-
-
-enableAutoEnterTextEditWhenKeydown(v0.6.13+)
-Boolean
-true
-Does it automatically enter text editing mode when pressing the Chinese, English, or numeric buttons when there is an activation node?
-
-
-
-richTextEditFakeInPlace(v0.6.13+)
-Boolean
-false
-Set the rich text node edit box to match the size of the node, creating a pseudo in place editing effect. It should be noted that only when there is only text within the node and the shape is rectangular, can the effect be better
-
-
-
-customHandleClipboardText(v0.6.14+)
-Function
-null
-Customize the processing of clipboard text. When pressing ctrl+v to paste, it will read the text and images from the user's clipboard. By default, it will only determine whether the text is regular text and node data in simple mind map format. If you want to process data from other mind maps, such as process, zhixi, etc., you can pass a function that takes the text from the current clipboard as a parameter and returns the processed data, which can be of two types: 1.If a pure text is returned, a child node will be directly created with that text; 2.Returns a node object in the following format: { simpleMindMap: true, data: { data: { text: '' }, children: [] } }, The representative is data in simple bind map format, and the node data is in the same format as the simple bind map node data. If your processing logic has asynchronous logic, you can also return a promise
-
-
-
-errorHandler(v0.6.15+)
-Function
-
-Custom error handling functions currently only throw some asynchronous logic errors. Can pass a function that takes two parameters, the first being the wrong type and the second being the wrong object
-
-
-
-disableMouseWheelZoom(v0.6.15+)
-Boolean
-false
-Prohibit mouse wheel scaling, you can still use the API for scaling
-
-
-
-resetCss(v0.6.16+)
-String
-* { margin: 0; padding: 0; box-sizing: border-box; }
-When exporting images and SVGs, the default style overlay for rich text node content, which is embedded in HTML nodes in SVGs, will occur. If not overlaid, the node content will be offset
-
-
-
-enableDblclickReset(v0.6.17+)
-Boolean
-true(v0.7.0+changed to false)
-Turn on the mouse and double-click to reset the position and zoom of the mind map
-
-
-
-minExportImgCanvasScale(v0.7.0+)
-Number
-2
-The scaling factor of canvas when exporting images and PDFs, which is set to the maximum value of window.devicePixelRatio to improve image clarity
-
-
-
-hoverRectColor(v0.7.0+)
-String
-rgb(94, 200, 248)
-The node mouse hover and the rectangular border color displayed when activated will add a transparency of 0.6 when hovering
-
-
-
-hoverRectPadding(v0.7.0+)
-Number
-2
-The distance between the node mouse hover and the displayed rectangular border when activated and the node content
-
-
-
-selectTextOnEnterEditText(v0.7.0+)
-Boolean
-true
-Is the text selected by default when double-clicking a node to enter node text editing? By default, it will only be selected when creating a new node
-
-
-
-deleteNodeActive(v0.7.1+)
-Boolean
-true
-Enable the function of automatically activating adjacent nodes or parent nodes after deleting nodes
-
-
-
-autoMoveWhenMouseInEdgeOnDrag(v0.7.1+)
-Boolean
-true
-Whether to enable automatic canvas movement when the mouse moves to the edge of the canvas while dragging nodes
-
-
-
-
-Data structure
-The basic data structure is as follows:
-{
+ Instantiation options
+
+
+
+ Field Name
+ Type
+ Default Value
+ Description
+ Required
+
+
+
+
+ el
+ Element
+
+ Container element, must be a DOM element
+ Yes
+
+
+ data
+ Object
+ {}
+ Mind map data, Please refer to the introduction of 【Data structure】 below
+
+
+
+ layout
+ String
+ logicalStructure
+ Layout type, options: logicalStructure (logical structure diagram), mindMap (mind map), catalogOrganization
+ (catalog organization diagram), organizationStructure (organization structure diagram)、timeline(v0.5.4+,
+ timeline)、timeline2(v0.5.4+, up down alternating timeline)、fishbone(v0.5.4+, fishbone diagram)
+
+
+
+ fishboneDeg(v0.5.4+)
+ Number
+ 45
+ Set the diagonal angle of the fishbone structure diagram
+
+
+
+ theme
+ String
+ default
+ Theme, options: default, classic, minions, pinkGrape, mint, gold, vitalityOrange, greenLeaf, dark2,
+ skyGreen, classic2, classic3, classic4(v0.2.0+), classicGreen, classicBlue, blueSky, brainImpairedPink, dark,
+ earthYellow, freshGreen, freshRed, romanticPurple, simpleBlack(v0.5.4+), courseGreen(v0.5.4+),
+ coffee(v0.5.4+), redSpirit(v0.5.4+), blackHumour(v0.5.4+), lateNightOffice(v0.5.4+),
+ blackGold(v0.5.4+)、、avocado(v.5.10-fix.2+)、autumn(v.5.10-fix.2+)、orangeJuice(v.5.10-fix.2+)
+
+
+
+ themeConfig
+ Object
+ {}
+ Theme configuration, will be merged with the selected theme, available fields refer to: default.js
+
+
+
+
+ scaleRatio
+ Number
+ 0.1
+ The incremental scaling ratio
+
+
+
+ maxTag
+ Number
+ 5
+ The maximum number of tags displayed in the node, any additional tags will be discarded
+
+
+
+ exportPadding
+ Number
+ 20
+ The padding for exporting images
+
+
+
+ imgTextMargin
+ Number
+ 5
+ The spacing between the image and text in the node
+
+
+
+ textContentMargin
+ Number
+ 2
+ The spacing between various text information in the node, such as the spacing between the icon and text
+
+
+
+ selectTranslateStep
+ Number
+ 3
+ The canvas offset when mouse moves to the edge during multi-select node
+
+
+
+ selectTranslateLimit
+ Number
+ 20
+ The distance from the edge when the canvas begins to offset during multi-select node
+
+
+
+ customNoteContentShow(v0.1.6+)
+ Object
+ null
+ Custom node note content display, object type, structure: {show: (noteContent, left, top) => {// your
+ display node note logic }, hide: () => {// your hide node note logic }}
+
+
+
+ readonly(v0.1.7+)
+ Boolean
+ false
+ Whether it is read-only mode
+
+
+
+ enableFreeDrag(v0.2.4+)
+ Boolean
+ false
+ Enable node free drag
+
+
+
+ watermarkConfig(v0.2.4+)
+ Object
+
+ Watermark config, Please refer to the table 【Watermark config】 below for detailed configuration
+
+
+
+ textAutoWrapWidth(v0.3.4+)
+ Number
+ 500
+ Each line of text in the node will wrap automatically when it reaches the width
+
+
+
+ customHandleMousewheel(v0.4.3+)
+ Function
+ null
+ User-defined mouse wheel event processing can pass a function, and the callback parameter is the event
+ object
+
+
+
+ mousewheelAction(v0.4.3+)
+ String
+ zoom
+ The behavior of the mouse wheel, zoom(Zoom in and out)、move(Move up and down). If
+ customHandleMousewheel passes a custom function, this property will not take effect
+
+
+
+ mousewheelMoveStep(v0.4.3+)
+ Number
+ 100
+ When the mousewheelAction is set to move, you can use this attribute to control
+ the step length of the view movement when the mouse scrolls. The unit is px
+
+
+
+ mousewheelZoomActionReverse(v0.6.5+)
+ Boolean
+ false
+ When mousewheelAction is set to zoom, the default scrolling forward is to zoom
+ out, and scrolling backward is to zoom in. If this property is set to true, it will be reversed
+
+
+
+ defaultInsertSecondLevelNodeText(v0.4.7+)
+ String
+ 二级节点
+ Text of the default inserted secondary node
+
+
+
+ defaultInsertBelowSecondLevelNodeText(v0.4.7+)
+ String
+ 分支主题
+ Text for nodes below the second level inserted by default
+
+
+
+ expandBtnStyle(v0.5.0+)
+ Object
+ { color: '#808080', fill: '#fff', fontSize: 13, strokeColor: '#333333' }
+ Expand the color of the stow button, (The fontSize and strokeColor fields were added in version 0.7.0+to set
+ the text style for displaying the number of nodes when folded)
+
+
+
+ expandBtnIcon(v0.5.0+)
+ Object
+ { open: '', close: '' }
+ Customize the icon of the expand/collapse button, and you can transfer the svg string of the icon
+
+
+
+ expandBtnNumHandler(v0.7.0+)
+ Function
+
+ Used to customize the content of displaying the number of nodes when folding, receiving a parameter that
+ represents the instance of the folding node, and returning a number or string that represents the final
+ displayed content. For example, when the number is greater than 99, 99 can be displayed+
+
+
+
+ isShowExpandNum(v0.7.0+)
+ Boolean
+ true
+ Display the number of folded nodes when they are folded up
+
+
+
+ enableShortcutOnlyWhenMouseInSvg(v0.5.1+)
+ Boolean
+ true
+ Only respond to shortcut key events when the mouse is inside the canvas
+
+
+
+ enableNodeTransitionMove(v0.5.1+)(v0.6.7+ is remove this feature)
+ Boolean
+ true
+ Whether to enable node animation transition
+
+
+
+ nodeTransitionMoveDuration(v0.5.1+)(v0.6.7+ is remove this feature)
+ Number
+ 300
+ If node animation transition is enabled, the transition time can be set using this attribute, in
+ milliseconds
+
+
+
+ initRootNodePosition(v0.5.3+)
+ Array
+ null
+ The position of the initial root node can be passed as an array, default is
+ ['center', 'center'], Represents the root node at the center of the canvas, In addition to
+ center, keywords can also be set to left, top, right, and
+ bottom, In addition to passing keywords, each item in the array can also pass a number
+ representing a specific pixel, Can pass a percentage string, such as ['40%', '60%'], Represents a
+ horizontal position at 40% of the canvas width, and a vertical position at 60% of
+ the canvas height
+
+
+
+ exportPaddingX(v0.5.5+)
+ Number
+ 10
+ Horizontal padding of graphics when exporting PNG, SVG, and PDF
+
+
+
+ exportPaddingY(v0.5.5+)
+ Number
+ 10
+ Vertical padding of graphics when exporting PNG, SVG, and PDF
+
+
+
+ nodeTextEditZIndex(v0.5.5+)
+ Number
+ 3000
+
+ z-index of node text edit box elements
+
+
+ nodeNoteTooltipZIndex(v0.5.5+)
+ Number
+ 3000
+ z-index of floating layer elements in node comments
+
+
+
+ isEndNodeTextEditOnClickOuter(v0.5.5+)
+ Boolean
+ true
+ Whether to end the editing status of node text when clicking on an area outside the canvas
+
+
+
+ maxHistoryCount(v0.5.6+)
+ Number
+ 1000
+
+ Maximum number of history records
+
+
+ alwaysShowExpandBtn(v0.5.8+)
+ Boolean
+ false
+ Whether to always display the expand and collapse buttons of nodes, which are only displayed when the mouse
+ is moved up and activated by default
+
+
+
+ iconList(v0.5.8+)
+ Array
+ []
+ The icons that can be inserted into the extension node, and each item in the array is an object. Please
+ refer to the "Icon Configuration" table below for the detailed structure of the object
+
+
+
+ maxNodeCacheCount(v0.5.10+)
+ Number
+ 1000
+ The maximum number of cached nodes. To optimize performance, an internal node cache pool is maintained to
+ reuse nodes. This attribute allows you to specify the maximum number of caches in the pool
+
+
+
+ defaultAssociativeLineText(v0.5.11+)
+ String
+ 关联
+ Association Line Default Text
+
+
+
+ fitPadding(v0.6.0+)
+ Number
+ 50
+ The padding of mind mapping when adapting to canvas size, Unit: px
+
+
+
+ enableCtrlKeyNodeSelection(v0.6.0+)
+ Boolean
+ true
+ Whether to enable the function of holding down the Ctrl key to select multiple nodes
+
+
+
+ useLeftKeySelectionRightKeyDrag(v0.6.0+)
+ Boolean
+ false
+ Setting to left click to select multiple nodes and right click to drag the canvas.
+
+
+
+ beforeTextEdit(v0.6.0+)
+ Function/null
+ null
+ The callback method before the node is about to enter editing. If the method returns a value other than
+ true, the editing will be canceled. The function can return a value or a promise, and the callback parameter
+ is the node instance
+
+
+
+ isUseCustomNodeContent(v0.6.3+)
+ Boolean
+ false
+ Whether to customize node content
+
+
+
+ customCreateNodeContent(v0.6.3+)
+ Function/null
+ null
+ If isUseCustomNodeContent is set to true, then this option needs to be used to
+ pass in a method that receives the node instance node as a parameter (if you want to obtain data
+ for that node, you can use node.nodeData.data). You need to return the custom node content
+ element, which is the DOM node. If a node does not require customization, you can return null
+
+
+
+
+ mouseScaleCenterUseMousePosition(v0.6.4-fix.1+)
+ Boolean
+ true
+ Is the mouse zoom centered around the current position of the mouse, otherwise centered around the canvas
+
+
+
+
+ customInnerElsAppendTo(v0.6.12+)
+ null/HTMLElement
+ null
+ Specify the location where some internal elements (node text editing element, node note display element,
+ associated line text editing element, node image adjustment button element) are added, and default to
+ document.body
+
+
+
+ nodeDragPlaceholderMaxSize(v0.6.12+)
+ Number
+ 20
+ When dragging an element, the maximum height of the block indicating the new position of the element
+
+
+
+ enableCreateHiddenInput(v0.6.13+)(v0.6.14+ remove this feature)
+ Boolean
+ true
+ Is it allowed to create a hidden input box that will be focused when the node is activated for pasting data
+ and automatically entering the text editing state
+
+
+
+ enableAutoEnterTextEditWhenKeydown(v0.6.13+)
+ Boolean
+ true
+ Does it automatically enter text editing mode when pressing the Chinese, English, or numeric buttons when
+ there is an activation node?
+
+
+
+ richTextEditFakeInPlace(v0.6.13+)
+ Boolean
+ false
+ Set the rich text node edit box to match the size of the node, creating a pseudo in place editing effect. It
+ should be noted that only when there is only text within the node and the shape is rectangular, can the effect
+ be better
+
+
+
+ customHandleClipboardText(v0.6.14+)
+ Function
+ null
+ Customize the processing of clipboard text. When pressing ctrl+v to paste, it will read the text and images
+ from the user's clipboard. By default, it will only determine whether the text is regular text and node data
+ in simple mind map format. If you want to process data from other mind maps, such as process, zhixi, etc., you
+ can pass a function that takes the text from the current clipboard as a parameter and returns the processed
+ data, which can be of two types: 1.If a pure text is returned, a child node will be directly created with that
+ text; 2.Returns a node object in the following format: { simpleMindMap: true, data: { data: { text: '' },
+ children: [] } }, The representative is data in simple bind map format, and the node data is in the same
+ format as the simple bind map node data. If your processing logic has asynchronous logic, you can also return
+ a promise
+
+
+
+ errorHandler(v0.6.15+)
+ Function
+
+ Custom error handling functions currently only throw some asynchronous logic errors. Can pass a function
+ that takes two parameters, the first being the wrong type and the second being the wrong object
+
+
+
+ disableMouseWheelZoom(v0.6.15+)
+ Boolean
+ false
+ Prohibit mouse wheel scaling, you can still use the API for scaling
+
+
+
+ resetCss(v0.6.16+)
+ String
+ * { margin: 0; padding: 0; box-sizing: border-box; }
+ When exporting images and SVGs, the default style overlay for rich text node content, which is embedded in
+ HTML nodes in SVGs, will occur. If not overlaid, the node content will be offset
+
+
+
+ enableDblclickReset(v0.6.17+)
+ Boolean
+ true(v0.7.0+changed to false)
+ Turn on the mouse and double-click to reset the position and zoom of the mind map
+
+
+
+ minExportImgCanvasScale(v0.7.0+)
+ Number
+ 2
+ The scaling factor of canvas when exporting images and PDFs, which is set to the maximum value of
+ window.devicePixelRatio to improve image clarity
+
+
+
+ hoverRectColor(v0.7.0+)
+ String
+ rgb(94, 200, 248)
+ The node mouse hover and the rectangular border color displayed when activated will add a transparency of
+ 0.6 when hovering
+
+
+
+ hoverRectPadding(v0.7.0+)
+ Number
+ 2
+ The distance between the node mouse hover and the displayed rectangular border when activated and the node
+ content
+
+
+
+ selectTextOnEnterEditText(v0.7.0+)
+ Boolean
+ true
+ Is the text selected by default when double-clicking a node to enter node text editing? By default, it will
+ only be selected when creating a new node
+
+
+
+ deleteNodeActive(v0.7.1+)
+ Boolean
+ true
+ Enable the function of automatically activating adjacent nodes or parent nodes after deleting nodes
+
+
+
+ autoMoveWhenMouseInEdgeOnDrag(v0.7.1+)
+ Boolean
+ true
+ Whether to enable automatic canvas movement when the mouse moves to the edge of the canvas while dragging
+ nodes
+
+
+
+ fit
+ Boolean
+ false
+ Whether to fit view at first render
+
+
+
+
+ Data structure
+ The basic data structure is as follows:
+ {
data: {
text: '', // The text of the node can be rich text, which is in HTML format. In this case, richText should be set to true
richText: false, // Is the text of the node in rich text mode
@@ -520,91 +581,99 @@
]
}
-If you want to add custom fields, you can add them to the same level as 'data' and 'children'. If you want to add them to the 'data' object, please use the _ Name your custom field at the beginning, and it will be used internally to determine whether it is a custom field.
-Watermark config
-
-
-
-Field Name
-Type
-Default Value
-Description
-
-
-
-
-text
-String
-''
-Watermark text. If it is an empty string, the watermark will not be displayed
-
-
-lineSpacing
-Number
-100
-Spacing between watermark lines
-
-
-textSpacing
-Number
-100
-Spacing between watermarks in the same row
-
-
-angle
-Number
-30
-Tilt angle of watermark, range: [0, 90]
-
-
-textStyle
-Object
-{color: '#999', opacity: 0.5, fontSize: 14}
-Watermark text style
-
-
-
-Icon Configuration
-
-
-
-Field Name
-Type
-Default Value
-Description
-
-
-
-
-name
-String
-
-The name of the icon group
-
-
-type
-String
-
-Values for icon grouping
-
-
-list
-Array
-
-A list of icons under grouping, with each item in the array being an object, { name: '', icon: '' },namerepresents the name of the icon, iconrepresents the icon, Can be an svg icon, such as <svg ...><path></path></svg>, also can be a image url, or base64 icon, such as data:image/png;base64,...
-
-
-
-Static methods
-defineTheme(name, config)
-
-v0.2.23+
-
-Define new theme.
-name:New theme name
-config:New theme config
-Simple-mind-map Built-in many themes. In addition, you can register new theme. It is recommended to register before instantiation, so that you can directly use the newly registered theme during instantiation. Use example:
-import MindMap from 'simple-mind-map'
+ If you want to add custom fields, you can add them to the same level as 'data' and 'children'. If you want to add
+ them to the 'data' object, please use the _ Name your custom field at the beginning, and it will be
+ used internally to determine whether it is a custom field.
+ Watermark config
+
+
+
+ Field Name
+ Type
+ Default Value
+ Description
+
+
+
+
+ text
+ String
+ ''
+ Watermark text. If it is an empty string, the watermark will not be displayed
+
+
+ lineSpacing
+ Number
+ 100
+ Spacing between watermark lines
+
+
+ textSpacing
+ Number
+ 100
+ Spacing between watermarks in the same row
+
+
+ angle
+ Number
+ 30
+ Tilt angle of watermark, range: [0, 90]
+
+
+ textStyle
+ Object
+ {color: '#999', opacity: 0.5, fontSize: 14}
+ Watermark text style
+
+
+
+ Icon Configuration
+
+
+
+ Field Name
+ Type
+ Default Value
+ Description
+
+
+
+
+ name
+ String
+
+ The name of the icon group
+
+
+ type
+ String
+
+ Values for icon grouping
+
+
+ list
+ Array
+
+ A list of icons under grouping, with each item in the array being an object,
+ { name: '', icon: '' },namerepresents the name of the icon,
+ iconrepresents the icon, Can be an svg icon, such as
+ <svg ...><path></path></svg>, also can be a image url, or
+ base64 icon, such as data:image/png;base64,...
+
+
+
+ Static methods
+ defineTheme(name, config)
+
+ v0.2.23+
+
+ Define new theme.
+ name:New theme name
+ config:New theme config
+ Simple-mind-map Built-in many themes. In addition, you can register new theme. It is recommended to
+ register before instantiation, so that you can directly use the newly registered theme during instantiation. Use
+ example:
+ import MindMap from 'simple-mind-map'
// 注册新主题
MindMap.defineTheme('Theme name', {})
@@ -616,41 +685,49 @@ MindMap.defineTheme('Theme name', {})
// 2.动态切换新主题
mindMap.setTheme('Theme name')
-For all configurations of theme, please refer to Default Topic. The defineThememethod will merge the configuration you passed in with the default configuration. Most of the themes do not need custom many parts. For a typical customized theme configuration, please refer to blueSky.
-usePlugin(plugin, opt = {})
-
-v0.3.0+
-
-
-opt:v0.4.0+,Plugin options. If a plugin supports custom options, it can be passed in through this parameter.
-
-If you need to use some non-core functions, such as mini map, watermark, etc, you can register plugin through this method. Can be called in chain.
-Note: The plugin needs to be registered before instantiating MindMap.
-hasPlugin(plugin)
-
-v0.4.0+
-
-Get whether a plugin is registered, The index of the plugin in the registered plugin list is returned, If it is -1, it means that the plugin is not registered.
-Static props
-pluginList
-
-v0.3.0+
-
-List of all currently registered plugins.
-Instance methods
-destroy()
-
-v0.6.0+
-
-Destroy mind maps. It will remove registered plugins, remove listening events, and delete all nodes on the canvas.
-getSvgData({ paddingX = 0, paddingY = 0 })
-
-v0.3.0+
-
-paddingX: Padding x
-paddingY: Padding y
-Get the svg data and return an object. The detailed structure is as follows:
-{
+ For all configurations of theme, please refer to Default Topic. The
+ defineThememethod will merge the configuration you passed in with the default configuration. Most of
+ the themes do not need custom many parts. For a typical customized theme configuration, please refer to blueSky.
+ usePlugin(plugin, opt = {})
+
+ v0.3.0+
+
+
+ opt:v0.4.0+,Plugin options. If a plugin supports custom options, it can be passed in through this
+ parameter.
+
+ If you need to use some non-core functions, such as mini map, watermark, etc, you can register plugin through this
+ method. Can be called in chain.
+ Note: The plugin needs to be registered before instantiating MindMap.
+ hasPlugin(plugin)
+
+ v0.4.0+
+
+ Get whether a plugin is registered, The index of the plugin in the registered plugin list is returned, If it is
+ -1, it means that the plugin is not registered.
+ Static props
+ pluginList
+
+ v0.3.0+
+
+ List of all currently registered plugins.
+ Instance methods
+ destroy()
+
+ v0.6.0+
+
+ Destroy mind maps. It will remove registered plugins, remove listening events, and delete all nodes on the canvas.
+
+ getSvgData({ paddingX = 0, paddingY = 0 })
+
+ v0.3.0+
+
+ paddingX: Padding x
+ paddingY: Padding y
+ Get the svg data and return an object. The detailed structure is as follows:
+ {
svg, // Element, the overall svg element of the mind map graphics, including: svg (canvas container), g (actual mind map group)
svgHTML, // String, svg string, i.e. html string, can be directly rendered to the small map container you prepared
rect: // Object, position, size, etc. of mind map graphics before zoom
@@ -660,504 +737,557 @@ mindMap.setTheme('Theme name')
scaleY, // Number, vertical zoom value of mind map graphics
}
-render(callback)
-
-callback: v0.3.2+, Function, Called when the re-rendering is complete
-
-Triggers a full rendering, which will reuse nodes for better performance. If
-only the node positions have changed, this method can be called to reRender.
-reRender(callback)
-
-callback: v0.3.2+, Function, Called when the re-rendering is complete
-
-Performs a full re-render, clearing the canvas and creating new nodes. This has
-poor performance and should be used sparingly.
-resize()
-After the container size has changed, this method should be called to adjust.
-setMode(mode)
-
-v0.1.7+
-
-Switches between readonly and edit mode.
-mode:readonly、edit
-on(event, fn)
-Listen to an event. Event list:
-
-
-
-Event Name
-Description
-Callback Parameters
-
-
-
-
-data_change
-Tree rendering data change, listen to this method to get the latest data
-data (current tree rendering data)
-
-
-view_data_change(v0.1.1+)
-View change data, such as when dragging or zooming
-data (current view state data)
-
-
-back_forward
-Forward or backward
-activeHistoryIndex (current index in the history data array), length (current length of the history data array)
-
-
-draw_click
-Canvas click event
-e (event object)
-
-
-svg_mousedown
-svg canvas mouse down event
-e (event object)
-
-
-mousedown
-el element mouse down event
-e (event object), this (Event event class instance)
-
-
-mousemove
-el element mouse move event
-e (event object), this (Event event class instance)
-
-
-drag
-If it is a drag event while holding down the left button
-e (event object), this (Event event class instance)
-
-
-mouseup
-el element mouse up event
-e (event object), this (Event event class instance)
-
-
-mousewheel
-Mouse scroll event
-e (event object), dir (up or down scroll), this (Event event class instance) 、isTouchPad(v0.6.1+, Is it an event triggered by the touchpad)
-
-
-contextmenu
-svg canvas right mouse button menu event
-e (event object)
-
-
-node_click
-Node click event
-this (node instance), e (event object)
-
-
-node_mousedown
-Node mouse down event
-this (node instance), e (event object)
-
-
-node_mouseup
-node mouseup event
-this (node instance), e (event object)
-
-
-node_mouseup
-Node mouseup event
-this (node instance), e (event object)
-
-
-node_dblclick
-Node double-click event
-this (node instance), e (event object)
-
-
-node_contextmenu
-Node right-click menu event
-e (event object), this (node instance)
-
-
-node_mouseenter(v0.4.1+)
-Node mouseenter event
-this (node instance), e (event object)
-
-
-node_mouseleave(v0.4.1+)
-Node mouseleave event
-this (node instance), e (event object)
-
-
-before_node_active
-Event before node activation
-this (node instance), activeNodeList (current list of active nodes)
-
-
-node_active
-Node activation event
-this (node instance), activeNodeList (current list of active nodes)
-
-
-expand_btn_click
-Node expand or collapse event
-this (node instance)
-
-
-before_show_text_edit
-Event before node text edit box opens
-
-
-
-hide_text_edit
-Node text edit box close event
-textEditNode (text edit box DOM node), activeNodeList (current list of active nodes)
-
-
-scale
-Zoom event
-scale (zoom ratio)
-
-
-node_img_dblclick(v0.2.15+)
-Node image double-click event
-this (node instance), e (event object)
-
-
-node_img_mouseenter(v0.6.5+)
-Node image mouseenter event
-this(node instance)、imgNode(img node)、e(event object)
-
-
-node_img_mouseleave(v0.6.5+)
-Node image mouseleave event
-this(node instance)、imgNode(img node)、e(event object)
-
-
-node_img_mousemove(v0.6.5+)
-Node image mousemove event
-this(node instance)、imgNode(img node)、e(event object)
-
-
-node_tree_render_end(v0.2.16+)
-Node tree render end event
-
-
-
-rich_text_selection_change(v0.4.0+)
-Available when the RichText plugin is registered. Triggered when the text selection area changes when the node is edited
-hasRange(Whether there is a selection)、rectInfo(Size and location information of the selected area)、formatInfo(Text formatting information of the selected area)
-
-
-transforming-dom-to-images(v0.4.0+)
-Available when the RichText plugin is registered. When there is a DOM node in svg, the DOM node will be converted to an image when exporting to an image. This event will be triggered during the conversion process. You can use this event to prompt the user about the node to which you are currently converting
-index(Index of the node currently converted to)、len(Total number of nodes to be converted)
-
-
-node_dragging(v0.4.5+)
-Triggered when a node is dragged
-node(The currently dragged node)
-
-
-node_dragend(v0.4.5+)
-Triggered when the node is dragged and ends
-{ overlapNodeUid, prevNodeUid, nextNodeUid }(v0.6.12+,The node uid to which the node is moved this time, for example, if it is moved to node A, then the overlayNodeUid is the uid of node A. If it is moved to the front of node B, then the nextNodeUid is the uid of node B. You can obtain the node instance through the mindMap. extender.findNodeByUid(uid) method)
-
-
-associative_line_click(v0.4.5+)
-Triggered when an associated line is clicked
-path(Connector node)、clickPath(Invisible click line node)、node(Start node)、toNode(Target node)
-
-
-svg_mouseenter(v0.5.1+)
-Triggered when the mouse moves into the SVG canvas
-e(event object)
-
-
-svg_mouseleave(v0.5.1+)
-Triggered when the mouse moves out of the SVG canvas
-e(event object)
-
-
-node_icon_click(v0.6.10+)
-Triggered when clicking on an icon within a node
-this(node instance)、item(Click on the icon name)、e(event object)
-
-
-view_theme_change(v0.6.12+)
-Triggered after calling the setTheme method to set the theme
-theme(theme name)
-
-
-
-emit(event, ...args)
-Trigger an event, which can be one of the events listed above or a custom event.
-off(event, fn)
-Unbind an event.
-setTheme(theme)
-Switches the theme. Available themes can be found in the options table above.
-getTheme()
-Gets the current theme.
-setThemeConfig(config)
-Sets the theme configuration. config is the same as the themeConfig option
-in the options table above.
-getCustomThemeConfig()
-Gets the custom theme configuration.
-getThemeConfig(prop)
-Gets the value of a specific theme configuration property.
-getConfig(prop)
-
-0.2.24+
-
-prop:Get the value of the specified configuration, and return the entire configuration if not passed
-Get config, That is, opt of new MindMap (opt)
-updateConfig(opt = {})
-
-0.2.24+
-
-opt:Configuration to update
-Update config,That is update opt of new MindMap(opt),You can only update some data, such as:
-mindMap.updateConfig({
+ render(callback)
+
+ callback: v0.3.2+, Function, Called when the re-rendering is complete
+
+
+ Triggers a full rendering, which will reuse nodes for better performance. If
+ only the node positions have changed, this method can be called to reRender.
+ reRender(callback)
+
+ callback: v0.3.2+, Function, Called when the re-rendering is complete
+
+
+ Performs a full re-render, clearing the canvas and creating new nodes. This has
+ poor performance and should be used sparingly.
+ resize()
+ After the container size has changed, this method should be called to adjust.
+ setMode(mode)
+
+ v0.1.7+
+
+ Switches between readonly and edit mode.
+ mode:readonly、edit
+ on(event, fn)
+ Listen to an event. Event list:
+
+
+
+ Event Name
+ Description
+ Callback Parameters
+
+
+
+
+ data_change
+ Tree rendering data change, listen to this method to get the latest data
+ data (current tree rendering data)
+
+
+ view_data_change(v0.1.1+)
+ View change data, such as when dragging or zooming
+ data (current view state data)
+
+
+ back_forward
+ Forward or backward
+ activeHistoryIndex (current index in the history data array), length (current length of the history data
+ array)
+
+
+ draw_click
+ Canvas click event
+ e (event object)
+
+
+ svg_mousedown
+ svg canvas mouse down event
+ e (event object)
+
+
+ mousedown
+ el element mouse down event
+ e (event object), this (Event event class instance)
+
+
+ mousemove
+ el element mouse move event
+ e (event object), this (Event event class instance)
+
+
+ drag
+ If it is a drag event while holding down the left button
+ e (event object), this (Event event class instance)
+
+
+ mouseup
+ el element mouse up event
+ e (event object), this (Event event class instance)
+
+
+ mousewheel
+ Mouse scroll event
+ e (event object), dir (up or down scroll), this (Event event class instance) 、isTouchPad(v0.6.1+, Is it an
+ event triggered by the touchpad)
+
+
+ contextmenu
+ svg canvas right mouse button menu event
+ e (event object)
+
+
+ node_click
+ Node click event
+ this (node instance), e (event object)
+
+
+ node_mousedown
+ Node mouse down event
+ this (node instance), e (event object)
+
+
+ node_mouseup
+ node mouseup event
+ this (node instance), e (event object)
+
+
+ node_mouseup
+ Node mouseup event
+ this (node instance), e (event object)
+
+
+ node_dblclick
+ Node double-click event
+ this (node instance), e (event object)
+
+
+ node_contextmenu
+ Node right-click menu event
+ e (event object), this (node instance)
+
+
+ node_mouseenter(v0.4.1+)
+ Node mouseenter event
+ this (node instance), e (event object)
+
+
+ node_mouseleave(v0.4.1+)
+ Node mouseleave event
+ this (node instance), e (event object)
+
+
+ before_node_active
+ Event before node activation
+ this (node instance), activeNodeList (current list of active nodes)
+
+
+ node_active
+ Node activation event
+ this (node instance), activeNodeList (current list of active nodes)
+
+
+ expand_btn_click
+ Node expand or collapse event
+ this (node instance)
+
+
+ before_show_text_edit
+ Event before node text edit box opens
+
+
+
+ hide_text_edit
+ Node text edit box close event
+ textEditNode (text edit box DOM node), activeNodeList (current list of active nodes)
+
+
+ scale
+ Zoom event
+ scale (zoom ratio)
+
+
+ node_img_dblclick(v0.2.15+)
+ Node image double-click event
+ this (node instance), e (event object)
+
+
+ node_img_mouseenter(v0.6.5+)
+ Node image mouseenter event
+ this(node instance)、imgNode(img node)、e(event object)
+
+
+ node_img_mouseleave(v0.6.5+)
+ Node image mouseleave event
+ this(node instance)、imgNode(img node)、e(event object)
+
+
+ node_img_mousemove(v0.6.5+)
+ Node image mousemove event
+ this(node instance)、imgNode(img node)、e(event object)
+
+
+ node_tree_render_end(v0.2.16+)
+ Node tree render end event
+
+
+
+ rich_text_selection_change(v0.4.0+)
+ Available when the RichText plugin is registered. Triggered when the text selection area
+ changes when the node is edited
+ hasRange(Whether there is a selection)、rectInfo(Size and location information of the selected
+ area)、formatInfo(Text formatting information of the selected area)
+
+
+ transforming-dom-to-images(v0.4.0+)
+ Available when the RichText plugin is registered. When there is a DOM node in
+ svg, the DOM node will be converted to an image when exporting to an image. This
+ event will be triggered during the conversion process. You can use this event to prompt the user about the
+ node to which you are currently converting
+ index(Index of the node currently converted to)、len(Total number of nodes to be converted)
+
+
+ node_dragging(v0.4.5+)
+ Triggered when a node is dragged
+ node(The currently dragged node)
+
+
+ node_dragend(v0.4.5+)
+ Triggered when the node is dragged and ends
+ { overlapNodeUid, prevNodeUid, nextNodeUid }(v0.6.12+,The node uid to which the node is moved this time, for
+ example, if it is moved to node A, then the overlayNodeUid is the uid of node A. If it is moved to the front
+ of node B, then the nextNodeUid is the uid of node B. You can obtain the node instance through the mindMap.
+ extender.findNodeByUid(uid) method)
+
+
+ associative_line_click(v0.4.5+)
+ Triggered when an associated line is clicked
+ path(Connector node)、clickPath(Invisible click line node)、node(Start node)、toNode(Target node)
+
+
+ svg_mouseenter(v0.5.1+)
+ Triggered when the mouse moves into the SVG canvas
+ e(event object)
+
+
+ svg_mouseleave(v0.5.1+)
+ Triggered when the mouse moves out of the SVG canvas
+ e(event object)
+
+
+ node_icon_click(v0.6.10+)
+ Triggered when clicking on an icon within a node
+ this(node instance)、item(Click on the icon name)、e(event object)
+
+
+ view_theme_change(v0.6.12+)
+ Triggered after calling the setTheme method to set the theme
+ theme(theme name)
+
+
+
+ emit(event, ...args)
+ Trigger an event, which can be one of the events listed above or a custom event.
+ off(event, fn)
+ Unbind an event.
+ setTheme(theme)
+ Switches the theme. Available themes can be found in the options table above.
+ getTheme()
+ Gets the current theme.
+ setThemeConfig(config)
+ Sets the theme configuration. config is the same as the themeConfig option
+ in the options table above.
+ getCustomThemeConfig()
+ Gets the custom theme configuration.
+ getThemeConfig(prop)
+ Gets the value of a specific theme configuration property.
+ getConfig(prop)
+
+ 0.2.24+
+
+ prop:Get the value of the specified configuration, and return the entire configuration if not passed
+
+ Get config, That is, opt of new MindMap (opt)
+ updateConfig(opt = {})
+
+ 0.2.24+
+
+ opt:Configuration to update
+ Update config,That is update opt of new MindMap(opt),You can only update some data, such
+ as:
+ mindMap.updateConfig({
enableFreeDrag: true// 开启节点自由拖拽
})
-This method only updates the configuration and has no other side effects, such as triggering canvas re-rendering
-getLayout()
-Gets the current layout structure.
-setLayout(layout)
-Sets the layout structure. Available values can be found in the layout field
-in the options table above.
-execCommand(name, ...args)
-Executes a command, which will add a record to the history stack for undo or
-redo. All commands are as follows:
-
-
-
-Command name
-Description
-Parameters
-
-
-
-
-SELECT_ALL
-Select all
-
-
-
-BACK
-Go back a specified number of steps
-step (the number of steps to go back, default is 1)
-
-
-FORWARD
-Go forward a specified number of steps
-step (the number of steps to go forward, default is 1)
-
-
-INSERT_NODE
-Insert a sibling node, the active node or appoint node will be the operation node. If there are multiple active nodes, only the first one will be effective
-openEdit(v0.4.6+, Whether to activate the newly inserted node and enter editing mode, default is true) 、 appointNodes(v0.4.7+, Optional, appoint node, Specifying multiple nodes can pass an array)、 appointData(Optional, Specify the data for the newly created node, Such as {text: 'xxx', ...}, Detailed structure can be referred to exampleData.js )、 appointChildren(v0.6.14+, Optional, Specify the child nodes of the newly created node, array type)
-
-
-INSERT_CHILD_NODE
-Insert a child node, the active node or appoint node will be the operation node
-openEdit(v0.4.6+, Whether to activate the newly inserted node and enter editing mode, default is true)、 appointNodes(v0.4.7+, Optional, appoint node, Specifying multiple nodes can pass an array)、 appointData(Optional, Specify the data for the newly created node, Such as {text: 'xxx', ...}, Detailed structure can be referred to exampleData.js )、 appointChildren(v0.6.14+, Optional, Specify the child nodes of the newly created node, array type)
-
-
-UP_NODE
-Move node up, the active node will be the operation node. If there are multiple active nodes, only the first one will be effective. Using this command on the root node or the first node in the list will be invalid
-
-
-
-DOWN_NODE
-Move node down, the active node will be the operation node. If there are multiple active nodes, only the first one will be effective. Using this command on the root node or the last node in the list will be invalid
-
-
-
-REMOVE_NODE
-Remove node, the active node or appoint node will be the operation node
-appointNodes(v0.4.7+, Optional, appoint node, Specifying multiple nodes can pass an array)
-
-
-PASTE_NODE
-Paste node to a node, the active node will be the operation node
-data (the node data to paste, usually obtained through the renderer.copyNode() and renderer.cutNode() methods)
-
-
-SET_NODE_STYLE
-Modify node single style
-node (the node to set the style of), prop (style property), value (style property value), isActive (v0.7.0+has been abandoned, boolean, whether the style being set is for the active state)
-
-
-SET_NODE_STYLEs(v0.6.12+)
-Modify multiple styles of nodes
-node(the node to set the style of)、style(Style object,key is style prop,value is style value)、isActive(v0.7.0+has been abandoned, boolean, whether the style being set is for the active state)
-
-
-SET_NODE_ACTIVE
-Set whether the node is active
-node (the node to set), active (boolean, whether to activate)
-
-
-CLEAR_ACTIVE_NODE
-Clear the active state of the currently active node(s), the active node will be the operation node
-
-
-
-SET_NODE_EXPAND
-Set whether the node is expanded
-node (the node to set), expand (boolean, whether to expand)
-
-
-EXPAND_ALL
-Expand all nodes
-
-
-
-UNEXPAND_ALL
-Collapse all nodes
-
-
-
-UNEXPAND_TO_LEVEL (v0.2.8+)
-Expand to a specified level
-level (the level to expand to, 1, 2, 3...)
-
-
-SET_NODE_DATA
-Update node data, that is, update the data in the data object of the node data object
-node (the node to set), data (object, the data to update, e.g. {expand: true})
-
-
-SET_NODE_TEXT
-Set node text
-node (the node to set), text (the new text for the node), richText(v0.4.0+, If you want to set a rich text character, you need to set it to true)、resetRichText(v0.6.10+Do you want to reset rich text? The default is false. If true is passed, the style of the rich text node will be reset)
-
-
-SET_NODE_IMAGE
-Set Node Image
-node (node to set), imgData (object, image information, structured as: {url, title, width, height}, the width and height of the image must be passed)
-
-
-SET_NODE_ICON
-Set Node Icon
-node (node to set), icons (array, predefined image names array, available icons can be obtained in the nodeIconList list in the icons.js file, icon name is type_name, such as ['priority_1'])
-
-
-SET_NODE_HYPERLINK
-Set Node Hyperlink
-node (node to set), link (hyperlink address), title (hyperlink name, optional)
-
-
-SET_NODE_NOTE
-Set Node Note
-node (node to set), note (note text)
-
-
-SET_NODE_TAG
-Set Node Tag
-node (node to set), tag (string array, built-in color information can be obtained in constant.js)
-
-
-INSERT_AFTER (v0.1.5+)
-Move Node to After Another Node
-node (node to move), exist (target node)
-
-
-INSERT_BEFORE (v0.1.5+)
-Move Node to Before Another Node
-node (node to move), exist (target node)
-
-
-MOVE_NODE_TO (v0.1.5+)
-Move a node as a child of another node
-node (the node to move), toNode (the target node)
-
-
-ADD_GENERALIZATION (v0.2.0+)
-Add a node summary
-data (the data for the summary, in object format, all numerical fields of the node are supported, default is {text: 'summary'})
-
-
-REMOVE_GENERALIZATION (v0.2.0+)
-Remove a node summary
-
-
-
-SET_NODE_CUSTOM_POSITION (v0.2.0+)
-Set a custom position for a node
-node (the node to set), left (custom x coordinate, default is undefined), top (custom y coordinate, default is undefined)
-
-
-RESET_LAYOUT (v0.2.0+)
-Arrange layout with one click
-
-
-
-SET_NODE_SHAPE (v0.2.4+)
-Set the shape of a node
-node (the node to set), shape (the shape, all shapes: Shape.js)
-
-
-GO_TARGET_NODE(v0.6.7+)
-Navigate to a node, and if the node is collapsed, it will automatically expand to that node
-node(Node instance or node uid to locate)、callback(v0.6.9+, Callback function after positioning completion)
-
-
-
-setData(data)
-Dynamic setting of mind map data, pure node data
-data: mind map structure data
-setFullData(data)
-
-v0.2.7+
-
-Dynamic setting of mind map data, including node data, layout, theme, view
-data: complete data, structure can refer to
-exportFullData
-getData(withConfig)
-
-v0.2.9+
-
-Gets mind map data
-withConfig: Boolean, default is false, that is, the obtained data only
-includes the node tree, if true is passed, it will also include theme, layout,
-view, etc. data
-export(type, isDownload, fileName)
-
-You need to register the Export plugin first
-
-Export
-type: the type to be exported, optional values: png, svg, json, pdf (v0.2.1+),
-smm (essentially also json)
-isDownload: whether to directly trigger download, Boolean value, default is
-false
-fileName: (v0.1.6+) the name of the exported file, default is 思维导图 (mind
-map).
-If it is exported as png, the fourth parameter can be passed:
-transparent: v0.5.7+, Boolean, default is false, Specify whether the background of the exported image is transparent
-If it is exported as svg, the fourth parameter can be passed:
-plusCssText: Additional CSS style. If there is a dom node in svg, you can pass in some styles specific to the node through this parameter
-If it is exported as json or smm, the fourth parameter can be passed:
-withConfig: Boolean, default is true, Specify whether the exported data includes configuration data, otherwise only pure node tree data will be exported
-toPos(x, y)
-
-v0.1.5+
-
-Convert the coordinates of the browser's visible window to coordinates relative
-to the canvas.
-addPlugin(plugin, opt)
-
-v0.4.0+
-
-Register plugin, Use MindMap.usePlugin to register plugin only before instantiation, The registered plugin will not take effect after instantiation, So if you want to register the plugin after instantiation, you can use the addPlugin method of the instance.
-removePlugin(plugin)
-
-v0.4.0+
-
-Remove registered plugin, Plugins registered through the usePlugin or addPlugin methods can be removed.
+ This method only updates the configuration and has no other side effects, such as triggering canvas re-rendering
+
+ getLayout()
+ Gets the current layout structure.
+ setLayout(layout)
+ Sets the layout structure. Available values can be found in the layout field
+ in the options table above.
+ execCommand(name, ...args)
+ Executes a command, which will add a record to the history stack for undo or
+ redo. All commands are as follows:
+
+
+
+ Command name
+ Description
+ Parameters
+
+
+
+
+ SELECT_ALL
+ Select all
+
+
+
+ BACK
+ Go back a specified number of steps
+ step (the number of steps to go back, default is 1)
+
+
+ FORWARD
+ Go forward a specified number of steps
+ step (the number of steps to go forward, default is 1)
+
+
+ INSERT_NODE
+ Insert a sibling node, the active node or appoint node will be the operation node. If there are multiple
+ active nodes, only the first one will be effective
+ openEdit(v0.4.6+, Whether to activate the newly inserted node and enter editing mode, default is
+ true) 、 appointNodes(v0.4.7+, Optional, appoint node, Specifying multiple nodes can pass an
+ array)、 appointData(Optional, Specify the data for the newly created node, Such as {text: 'xxx', ...},
+ Detailed structure can be referred to exampleData.js
+ )、 appointChildren(v0.6.14+, Optional, Specify the child nodes of the newly created node, array type)
+
+
+ INSERT_CHILD_NODE
+ Insert a child node, the active node or appoint node will be the operation node
+ openEdit(v0.4.6+, Whether to activate the newly inserted node and enter editing mode, default is
+ true)、 appointNodes(v0.4.7+, Optional, appoint node, Specifying multiple nodes can pass an
+ array)、 appointData(Optional, Specify the data for the newly created node, Such as {text: 'xxx', ...},
+ Detailed structure can be referred to exampleData.js
+ )、 appointChildren(v0.6.14+, Optional, Specify the child nodes of the newly created node, array type)
+
+
+ UP_NODE
+ Move node up, the active node will be the operation node. If there are multiple active nodes, only the first
+ one will be effective. Using this command on the root node or the first node in the list will be invalid
+
+
+
+ DOWN_NODE
+ Move node down, the active node will be the operation node. If there are multiple active nodes, only the
+ first one will be effective. Using this command on the root node or the last node in the list will be invalid
+
+
+
+
+ REMOVE_NODE
+ Remove node, the active node or appoint node will be the operation node
+ appointNodes(v0.4.7+, Optional, appoint node, Specifying multiple nodes can pass an array)
+
+
+ PASTE_NODE
+ Paste node to a node, the active node will be the operation node
+ data (the node data to paste, usually obtained through the renderer.copyNode() and renderer.cutNode()
+ methods)
+
+
+ SET_NODE_STYLE
+ Modify node single style
+ node (the node to set the style of), prop (style property), value (style property value), isActive
+ (v0.7.0+has been abandoned, boolean, whether the style being set is for the active state)
+
+
+ SET_NODE_STYLEs(v0.6.12+)
+ Modify multiple styles of nodes
+ node(the node to set the style of)、style(Style object,key is style prop,value is style
+ value)、isActive(v0.7.0+has been abandoned, boolean, whether the style being set is for the active state)
+
+
+ SET_NODE_ACTIVE
+ Set whether the node is active
+ node (the node to set), active (boolean, whether to activate)
+
+
+ CLEAR_ACTIVE_NODE
+ Clear the active state of the currently active node(s), the active node will be the operation node
+
+
+
+ SET_NODE_EXPAND
+ Set whether the node is expanded
+ node (the node to set), expand (boolean, whether to expand)
+
+
+ EXPAND_ALL
+ Expand all nodes
+
+
+
+ UNEXPAND_ALL
+ Collapse all nodes
+
+
+
+ UNEXPAND_TO_LEVEL (v0.2.8+)
+ Expand to a specified level
+ level (the level to expand to, 1, 2, 3...)
+
+
+ SET_NODE_DATA
+ Update node data, that is, update the data in the data object of the node data object
+ node (the node to set), data (object, the data to update, e.g. {expand: true})
+
+
+ SET_NODE_TEXT
+ Set node text
+ node (the node to set), text (the new text for the node), richText(v0.4.0+, If you want to set a rich text
+ character, you need to set it to true)、resetRichText(v0.6.10+Do you want to reset rich text? The
+ default is false. If true is passed, the style of the rich text node will be reset)
+
+
+ SET_NODE_IMAGE
+ Set Node Image
+ node (node to set), imgData (object, image information, structured as:
+ {url, title, width, height}, the width and height of the image must be passed)
+
+
+ SET_NODE_ICON
+ Set Node Icon
+ node (node to set), icons (array, predefined image names array, available icons can be obtained in the
+ nodeIconList list in the icons.js file,
+ icon name is type_name, such as ['priority_1'])
+
+
+ SET_NODE_HYPERLINK
+ Set Node Hyperlink
+ node (node to set), link (hyperlink address), title (hyperlink name, optional)
+
+
+ SET_NODE_NOTE
+ Set Node Note
+ node (node to set), note (note text)
+
+
+ SET_NODE_TAG
+ Set Node Tag
+ node (node to set), tag (string array, built-in color information can be obtained in constant.js)
+
+
+
+ INSERT_AFTER (v0.1.5+)
+ Move Node to After Another Node
+ node (node to move), exist (target node)
+
+
+ INSERT_BEFORE (v0.1.5+)
+ Move Node to Before Another Node
+ node (node to move), exist (target node)
+
+
+ MOVE_NODE_TO (v0.1.5+)
+ Move a node as a child of another node
+ node (the node to move), toNode (the target node)
+
+
+ ADD_GENERALIZATION (v0.2.0+)
+ Add a node summary
+ data (the data for the summary, in object format, all numerical fields of the node are supported, default is
+ {text: 'summary'})
+
+
+ REMOVE_GENERALIZATION (v0.2.0+)
+ Remove a node summary
+
+
+
+ SET_NODE_CUSTOM_POSITION (v0.2.0+)
+ Set a custom position for a node
+ node (the node to set), left (custom x coordinate, default is undefined), top (custom y coordinate, default
+ is undefined)
+
+
+ RESET_LAYOUT (v0.2.0+)
+ Arrange layout with one click
+
+
+
+ SET_NODE_SHAPE (v0.2.4+)
+ Set the shape of a node
+ node (the node to set), shape (the shape, all shapes: Shape.js)
+
+
+
+ GO_TARGET_NODE(v0.6.7+)
+ Navigate to a node, and if the node is collapsed, it will automatically expand to that node
+ node(Node instance or node uid to locate)、callback(v0.6.9+, Callback function after positioning completion)
+
+
+
+
+ setData(data)
+ Dynamic setting of mind map data, pure node data
+ data: mind map structure data
+ setFullData(data)
+
+ v0.2.7+
+
+ Dynamic setting of mind map data, including node data, layout, theme, view
+ data: complete data, structure can refer to
+ exportFullData
+
+ getData(withConfig)
+
+ v0.2.9+
+
+ Gets mind map data
+ withConfig: Boolean, default is false, that is, the obtained data only
+ includes the node tree, if true is passed, it will also include theme, layout,
+ view, etc. data
+ export(type, isDownload, fileName)
+
+ You need to register the Export plugin first
+
+ Export
+ type: the type to be exported, optional values: png, svg, json, pdf (v0.2.1+),
+ smm (essentially also json)
+ isDownload: whether to directly trigger download, Boolean value, default is
+ false
+
+ fileName: (v0.1.6+) the name of the exported file, default is 思维导图 (mind
+ map).
+ If it is exported as png, the fourth parameter can be passed:
+ transparent: v0.5.7+, Boolean, default is false, Specify whether the
+ background of the exported image is transparent
+ If it is exported as svg, the fourth parameter can be passed:
+ plusCssText: Additional CSS style. If there is a dom node in
+ svg, you can pass in some styles specific to the node through this parameter
+ If it is exported as json or smm, the fourth parameter can be passed:
+ withConfig: Boolean, default is true, Specify whether the exported data
+ includes configuration data, otherwise only pure node tree data will be exported
+ toPos(x, y)
+
+ v0.1.5+
+
+ Convert the coordinates of the browser's visible window to coordinates relative
+ to the canvas.
+ addPlugin(plugin, opt)
+
+ v0.4.0+
+
+ Register plugin, Use MindMap.usePlugin to register plugin only before instantiation, The registered
+ plugin will not take effect after instantiation, So if you want to register the plugin after instantiation, you can
+ use the addPlugin method of the instance.
+ removePlugin(plugin)
+
+ v0.4.0+
+
+ Remove registered plugin, Plugins registered through the usePlugin or addPlugin methods
+ can be removed.
-
<div id="mindMapContainer"></div>
+ 基本使用
+ <div id="mindMapContainer"></div>
-import MindMap from "simple-mind-map";
+ import MindMap from "simple-mind-map";
const mindMap = new MindMap({
el: document.getElementById('mindMapContainer'),
@@ -16,478 +16,501 @@
}
});
-实例化选项
-
-
-
-字段名称
-类型
-默认值
-描述
-是否必填
-
-
-
-
-el
-Element
-
-容器元素,必须为DOM元素
-是
-
-
-data
-Object
-{}
-思维导图数据,可参考下方【数据结构】介绍
-
-
-
-layout
-String
-logicalStructure
-布局类型,可选列表:logicalStructure(逻辑结构图)、mindMap(思维导图)、catalogOrganization(目录组织图)、organizationStructure(组织结构图)、timeline(v0.5.4+,时间轴)、timeline2(v0.5.4+,上下交替型时间轴)、fishbone(v0.5.4+,鱼骨图)
-
-
-
-fishboneDeg(v0.5.4+)
-Number
-45
-设置鱼骨结构图的斜线角度
-
-
-
-theme
-String
-default
-主题,可选列表:default(默认)、classic(脑图经典)、minions(小黄人)、pinkGrape(粉红葡萄)、mint(薄荷)、gold(金色vip)、vitalityOrange(活力橙)、greenLeaf(绿叶)、dark2(暗色2)、skyGreen(天清绿)、classic2(脑图经典2)、classic3(脑图经典3)、classic4(脑图经典4,v0.2.0+)、classicGreen(经典绿)、classicBlue(经典蓝)、blueSky(天空蓝)、brainImpairedPink(脑残粉)、dark(暗色)、earthYellow(泥土黄)、freshGreen(清新绿)、freshRed(清新红)、romanticPurple(浪漫紫)、simpleBlack(v0.5.4+简约黑)、courseGreen(v0.5.4+课程绿)、coffee(v0.5.4+咖啡)、redSpirit(v0.5.4+红色精神)、blackHumour(v0.5.4+黑色幽默)、lateNightOffice(v0.5.4+深夜办公室)、blackGold(v0.5.4+黑金)、avocado(v.5.10-fix.2+牛油果)、autumn(v.5.10-fix.2+秋天)、orangeJuice(v.5.10-fix.2+橙汁)
-
-
-
-themeConfig
-Object
-{}
-主题配置,会和所选择的主题进行合并,可用字段可参考:default.js
-
-
-
-scaleRatio
-Number
-0.1
-放大缩小的增量比例
-
-
-
-maxTag
-Number
-5
-节点里最多显示的标签数量,多余的会被丢弃
-
-
-
-exportPadding
-Number
-20
-导出图片时的内边距
-
-
-
-imgTextMargin
-Number
-5
-节点里图片和文字的间距
-
-
-
-textContentMargin
-Number
-2
-节点里各种文字信息的间距,如图标和文字的间距
-
-
-
-selectTranslateStep
-Number
-3
-多选节点时鼠标移动到边缘时的画布移动偏移量
-
-
-
-selectTranslateLimit
-Number
-20
-多选节点时鼠标移动距边缘多少距离时开始偏移
-
-
-
-customNoteContentShow(v0.1.6+)
-Object
-null
-自定义节点备注内容显示,Object类型,结构为:{show: (noteContent, left, top) => {// 你的显示节点备注逻辑 }, hide: () => {// 你的隐藏节点备注逻辑 }}
-
-
-
-readonly(v0.1.7+)
-Boolean
-false
-是否是只读模式
-
-
-
-enableFreeDrag(v0.2.4+)
-Boolean
-false
-是否开启节点自由拖拽
-
-
-
-watermarkConfig(v0.2.4+)
-Object
-
-水印配置,详细配置请参考下方表格【水印配置】
-
-
-
-textAutoWrapWidth(v0.3.4+)
-Number
-500
-节点内每行文本达到该宽度后自动换行
-
-
-
-customHandleMousewheel(v0.4.3+)
-Function
-null
-自定义鼠标滚轮事件处理,可以传一个函数,回调参数为事件对象
-
-
-
-mousewheelAction(v0.4.3+)
-String
-zoom
-鼠标滚轮的行为,zoom(放大缩小)、move(上下移动)。如果customHandleMousewheel传了自定义函数,这个属性不生效
-
-
-
-mousewheelMoveStep(v0.4.3+)
-Number
-100
-当mousewheelAction设为move时,可以通过该属性控制鼠标滚动一下视图移动的步长,单位px
-
-
-
-mousewheelZoomActionReverse(v0.6.5+)
-Boolean
-false
-当mousewheelAction设为zoom时,默认向前滚动是缩小,向后滚动是放大,如果该属性设为true,那么会反过来
-
-
-
-defaultInsertSecondLevelNodeText(v0.4.7+)
-String
-二级节点
-默认插入的二级节点的文字
-
-
-
-defaultInsertBelowSecondLevelNodeText(v0.4.7+)
-String
-分支主题
-默认插入的二级以下节点的文字
-
-
-
-expandBtnStyle(v0.5.0+)
-Object
-{ color: '#808080', fill: '#fff', fontSize: 13, strokeColor: '#333333' }
-展开收起按钮的颜色,(fontSize及strokeColor字段为0.7.0+版本新增的,用于设置收起时显示节点数量的文字样式)
-
-
-
-expandBtnIcon(v0.5.0+)
-Object
-{ open: '', close: '' }
-自定义展开收起按钮的图标,可以传图标的svg字符串
-
-
-
-expandBtnNumHandler(v0.7.0+)
-Function
-
-用于自定义收起时显示节点数量的内容,接收一个参数,代表收起的节点实例,需要返回一个数字或字符串,代表最终显示的内容,比如你可以当数量大于99时,显示99+
-
-
-
-isShowExpandNum(v0.7.0+)
-Boolean
-true
-节点收起时是否显示收起的数量
-
-
-
-enableShortcutOnlyWhenMouseInSvg(v0.5.1+)
-Boolean
-true
-是否只有当鼠标在画布内才响应快捷键事件
-
-
-
-enableNodeTransitionMove(v0.5.1+)(v0.6.7+已去除该特性)
-Boolean
-true
-是否开启节点动画过渡
-
-
-
-nodeTransitionMoveDuration(v0.5.1+)(v0.6.7+已去除该特性)
-Number
-300
-如果开启节点动画过渡,可以通过该属性设置过渡的时间,单位ms
-
-
-
-initRootNodePosition(v0.5.3+)
-Array
-null
-初始根节点的位置,可传一个数组,默认为['center', 'center'],代表根节点处于画布中心位置,除了center,关键词还可以设置left、top、right、bottom,除了可以传关键词,数组的每项还可以传递一个数字,代表具体的像素,可以传递一个百分比字符串,比如['40%', '60%'],代表水平位置在画布宽度的40%的位置,垂直位置在画布高度的60%的位置
-
-
-
-exportPaddingX(v0.5.5+)
-Number
-10
-导出png、svg、pdf时的图形水平内边距
-
-
-
-exportPaddingY(v0.5.5+)
-Number
-10
-导出png、svg、pdf时的图形垂直内边距
-
-
-
-nodeTextEditZIndex(v0.5.5+)
-Number
-3000
-节点文本编辑框元素的z-index
-
-
-
-nodeNoteTooltipZIndex(v0.5.5+)
-Number
-3000
-节点备注浮层元素的z-index
-
-
-
-isEndNodeTextEditOnClickOuter(v0.5.5+)
-Boolean
-true
-是否在点击了画布外的区域时结束节点文本的编辑状态
-
-
-
-maxHistoryCount(v0.5.6+)
-Number
-1000
-最大历史记录数
-
-
-
-alwaysShowExpandBtn(v0.5.8+)
-Boolean
-false
-是否一直显示节点的展开收起按钮,默认为鼠标移上去和激活时才显示
-
-
-
-iconList(v0.5.8+)
-Array
-[]
-扩展节点可插入的图标,数组的每一项为一个对象,对象详细结构请参考下方【图标配置】表格
-
-
-
-maxNodeCacheCount(v0.5.10+)
-Number
-1000
-节点最大缓存数量。为了优化性能,内部会维护一个节点缓存池,用来复用节点,通过该属性可以指定池的最大缓存数量
-
-
-
-defaultAssociativeLineText(v0.5.11+)
-String
-关联
-关联线默认文字
-
-
-
-fitPadding(v0.6.0+)
-Number
-50
-思维导图适应画布大小时的内边距,单位:px
-
-
-
-enableCtrlKeyNodeSelection(v0.6.0+)
-Boolean
-true
-是否开启按住ctrl键多选节点的功能
-
-
-
-useLeftKeySelectionRightKeyDrag(v0.6.0+)
-Boolean
-false
-设置为左键多选节点,右键拖动画布
-
-
-
-beforeTextEdit(v0.6.0+)
-Function/null
-null
-节点即将进入编辑前的回调方法,如果该方法返回true以外的值,那么将取消编辑,函数可以返回一个值,或一个Promise,回调参数为节点实例
-
-
-
-isUseCustomNodeContent(v0.6.3+)
-Boolean
-false
-是否自定义节点内容
-
-
-
-customCreateNodeContent(v0.6.3+)
-Function/null
-null
-如果isUseCustomNodeContent设为true,那么需要使用该选项传入一个方法,接收节点实例node为参数(如果要获取该节点的数据,可以通过node.nodeData.data),需要返回自定义节点内容元素,也就是DOM节点,如果某个节点不需要自定义,那么返回null即可
-
-
-
-mouseScaleCenterUseMousePosition(v0.6.4-fix.1+)
-Boolean
-true
-鼠标缩放是否以鼠标当前位置为中心点,否则以画布中心点
-
-
-
-customInnerElsAppendTo(v0.6.12+)
-null/HTMLElement
-null
-指定内部一些元素(节点文本编辑元素、节点备注显示元素、关联线文本编辑元素、节点图片调整按钮元素)添加到的位置,默认添加到document.body下
-
-
-
-nodeDragPlaceholderMaxSize(v0.6.12+)
-Number
-20
-拖拽元素时,指示元素新位置的块的最大高度
-
-
-
-enableCreateHiddenInput(v0.6.13+)(v0.6.14+版本已去除该特性)
-Boolean
-true
-是否允许创建一个隐藏的输入框,该输入框会在节点激活时聚焦,用于粘贴数据和自动进入文本编辑状态
-
-
-
-enableAutoEnterTextEditWhenKeydown(v0.6.13+)
-Boolean
-true
-是否在存在一个激活节点时,当按下中文、英文、数字按键时自动进入文本编辑模式
-
-
-
-richTextEditFakeInPlace(v0.6.13+)
-Boolean
-false
-设置富文本节点编辑框和节点大小一致,形成伪原地编辑的效果,需要注意的是,只有当节点内只有文本、且形状是矩形才会有比较好的效果
-
-
-
-customHandleClipboardText(v0.6.14+)
-Function
-null
-自定义对剪贴板文本的处理。当按ctrl+v粘贴时会读取用户剪贴板中的文本和图片,默认只会判断文本是否是普通文本和simple-mind-map格式的节点数据,如果你想处理其他思维导图的数据,比如processon、zhixi等,那么可以传递一个函数,接受当前剪贴板中的文本为参数,返回处理后的数据,可以返回两种类型:1.返回一个纯文本,那么会直接以该文本创建一个子节点;2.返回一个节点对象,格式如下:{ simpleMindMap: true, data: { data: { text: '' }, children: [] } },代表是simple-mind-map格式的数据,节点数据同simple-mind-map节点数据格式,如果你的处理逻辑存在异步逻辑,也可以返回一个promise
-
-
-
-errorHandler(v0.6.15+)
-Function
-
-自定义错误处理函数,目前只会抛出一些异步逻辑出错的情况。可以传递一个函数,会接收两个参数,第一个为错误的类型,第二个为错误对象
-
-
-
-disableMouseWheelZoom(v0.6.15+)
-Boolean
-false
-禁止鼠标滚轮缩放,你仍旧可以使用api进行缩放
-
-
-
-resetCss(v0.6.16+)
-String
-* { margin: 0; padding: 0; box-sizing: border-box; }
-设置导出图片和svg时,针对富文本节点内容,也就是嵌入到svg中的html节点的默认样式覆盖,如果不覆盖,节点内容会发生偏移
-
-
-
-enableDblclickReset(v0.6.17+)
-Boolean
-true(v0.7.0+改为false)
-开启鼠标双击复位思维导图位置及缩放
-
-
-
-minExportImgCanvasScale(v0.7.0+)
-Number
-2
-导出图片和pdf时canvas的缩放倍数,该配置会和window.devicePixelRatio值取最大值,用于提升图片清晰度
-
-
-
-hoverRectColor(v0.7.0+)
-String
-rgb(94, 200, 248)
-节点鼠标hover和激活时显示的矩形边框颜色,hover时会添加0.6的透明度
-
-
-
-hoverRectPadding(v0.7.0+)
-Number
-2
-节点鼠标hover和激活时显示的矩形边框距节点内容的距离
-
-
-
-selectTextOnEnterEditText(v0.7.0+)
-Boolean
-true
-双击节点进入节点文本编辑时是否默认选中文本,默认只在创建新节点时会选中
-
-
-
-deleteNodeActive(v0.7.1+)
-Boolean
-true
-是否开启删除节点后自动激活节点相邻节点或父节点的功能
-
-
-
-autoMoveWhenMouseInEdgeOnDrag(v0.7.1+)
-Boolean
-true
-拖拽节点时鼠标移动到画布边缘是否开启画布自动移动
-
-
-
-
-数据结构
-基本的数据结构如下:
-{
+ 实例化选项
+
+
+
+ 字段名称
+ 类型
+ 默认值
+ 描述
+ 是否必填
+
+
+
+
+ el
+ Element
+
+ 容器元素,必须为DOM元素
+ 是
+
+
+ data
+ Object
+ {}
+ 思维导图数据,可参考下方【数据结构】介绍
+
+
+
+ layout
+ String
+ logicalStructure
+
+ 布局类型,可选列表:logicalStructure(逻辑结构图)、mindMap(思维导图)、catalogOrganization(目录组织图)、organizationStructure(组织结构图)、timeline(v0.5.4+,时间轴)、timeline2(v0.5.4+,上下交替型时间轴)、fishbone(v0.5.4+,鱼骨图)
+
+
+
+
+ fishboneDeg(v0.5.4+)
+ Number
+ 45
+ 设置鱼骨结构图的斜线角度
+
+
+
+ theme
+ String
+ default
+
+ 主题,可选列表:default(默认)、classic(脑图经典)、minions(小黄人)、pinkGrape(粉红葡萄)、mint(薄荷)、gold(金色vip)、vitalityOrange(活力橙)、greenLeaf(绿叶)、dark2(暗色2)、skyGreen(天清绿)、classic2(脑图经典2)、classic3(脑图经典3)、classic4(脑图经典4,v0.2.0+)、classicGreen(经典绿)、classicBlue(经典蓝)、blueSky(天空蓝)、brainImpairedPink(脑残粉)、dark(暗色)、earthYellow(泥土黄)、freshGreen(清新绿)、freshRed(清新红)、romanticPurple(浪漫紫)、simpleBlack(v0.5.4+简约黑)、courseGreen(v0.5.4+课程绿)、coffee(v0.5.4+咖啡)、redSpirit(v0.5.4+红色精神)、blackHumour(v0.5.4+黑色幽默)、lateNightOffice(v0.5.4+深夜办公室)、blackGold(v0.5.4+黑金)、avocado(v.5.10-fix.2+牛油果)、autumn(v.5.10-fix.2+秋天)、orangeJuice(v.5.10-fix.2+橙汁)
+
+
+
+
+ themeConfig
+ Object
+ {}
+ 主题配置,会和所选择的主题进行合并,可用字段可参考:default.js
+
+
+
+
+ scaleRatio
+ Number
+ 0.1
+ 放大缩小的增量比例
+
+
+
+ maxTag
+ Number
+ 5
+ 节点里最多显示的标签数量,多余的会被丢弃
+
+
+
+ exportPadding
+ Number
+ 20
+ 导出图片时的内边距
+
+
+
+ imgTextMargin
+ Number
+ 5
+ 节点里图片和文字的间距
+
+
+
+ textContentMargin
+ Number
+ 2
+ 节点里各种文字信息的间距,如图标和文字的间距
+
+
+
+ selectTranslateStep
+ Number
+ 3
+ 多选节点时鼠标移动到边缘时的画布移动偏移量
+
+
+
+ selectTranslateLimit
+ Number
+ 20
+ 多选节点时鼠标移动距边缘多少距离时开始偏移
+
+
+
+ customNoteContentShow(v0.1.6+)
+ Object
+ null
+ 自定义节点备注内容显示,Object类型,结构为:{show: (noteContent, left, top) => {// 你的显示节点备注逻辑 }, hide: () => {//
+ 你的隐藏节点备注逻辑 }}
+
+
+
+ readonly(v0.1.7+)
+ Boolean
+ false
+ 是否是只读模式
+
+
+
+ enableFreeDrag(v0.2.4+)
+ Boolean
+ false
+ 是否开启节点自由拖拽
+
+
+
+ watermarkConfig(v0.2.4+)
+ Object
+
+ 水印配置,详细配置请参考下方表格【水印配置】
+
+
+
+ textAutoWrapWidth(v0.3.4+)
+ Number
+ 500
+ 节点内每行文本达到该宽度后自动换行
+
+
+
+ customHandleMousewheel(v0.4.3+)
+ Function
+ null
+ 自定义鼠标滚轮事件处理,可以传一个函数,回调参数为事件对象
+
+
+
+ mousewheelAction(v0.4.3+)
+ String
+ zoom
+ 鼠标滚轮的行为,zoom(放大缩小)、move(上下移动)。如果customHandleMousewheel传了自定义函数,这个属性不生效
+
+
+
+
+ mousewheelMoveStep(v0.4.3+)
+ Number
+ 100
+ 当mousewheelAction设为move时,可以通过该属性控制鼠标滚动一下视图移动的步长,单位px
+
+
+
+ mousewheelZoomActionReverse(v0.6.5+)
+ Boolean
+ false
+ 当mousewheelAction设为zoom时,默认向前滚动是缩小,向后滚动是放大,如果该属性设为true,那么会反过来
+
+
+
+ defaultInsertSecondLevelNodeText(v0.4.7+)
+ String
+ 二级节点
+ 默认插入的二级节点的文字
+
+
+
+ defaultInsertBelowSecondLevelNodeText(v0.4.7+)
+ String
+ 分支主题
+ 默认插入的二级以下节点的文字
+
+
+
+ expandBtnStyle(v0.5.0+)
+ Object
+ { color: '#808080', fill: '#fff', fontSize: 13, strokeColor: '#333333' }
+ 展开收起按钮的颜色,(fontSize及strokeColor字段为0.7.0+版本新增的,用于设置收起时显示节点数量的文字样式)
+
+
+
+ expandBtnIcon(v0.5.0+)
+ Object
+ { open: '', close: '' }
+ 自定义展开收起按钮的图标,可以传图标的svg字符串
+
+
+
+ expandBtnNumHandler(v0.7.0+)
+ Function
+
+ 用于自定义收起时显示节点数量的内容,接收一个参数,代表收起的节点实例,需要返回一个数字或字符串,代表最终显示的内容,比如你可以当数量大于99时,显示99+
+
+
+
+ isShowExpandNum(v0.7.0+)
+ Boolean
+ true
+ 节点收起时是否显示收起的数量
+
+
+
+ enableShortcutOnlyWhenMouseInSvg(v0.5.1+)
+ Boolean
+ true
+ 是否只有当鼠标在画布内才响应快捷键事件
+
+
+
+ enableNodeTransitionMove(v0.5.1+)(v0.6.7+已去除该特性)
+ Boolean
+ true
+ 是否开启节点动画过渡
+
+
+
+ nodeTransitionMoveDuration(v0.5.1+)(v0.6.7+已去除该特性)
+ Number
+ 300
+ 如果开启节点动画过渡,可以通过该属性设置过渡的时间,单位ms
+
+
+
+ initRootNodePosition(v0.5.3+)
+ Array
+ null
+
+ 初始根节点的位置,可传一个数组,默认为['center', 'center'],代表根节点处于画布中心位置,除了center,关键词还可以设置left、top、right、bottom,除了可以传关键词,数组的每项还可以传递一个数字,代表具体的像素,可以传递一个百分比字符串,比如['40%', '60%'],代表水平位置在画布宽度的40%的位置,垂直位置在画布高度的60%的位置
+
+
+
+
+ exportPaddingX(v0.5.5+)
+ Number
+ 10
+ 导出png、svg、pdf时的图形水平内边距
+
+
+
+ exportPaddingY(v0.5.5+)
+ Number
+ 10
+ 导出png、svg、pdf时的图形垂直内边距
+
+
+
+ nodeTextEditZIndex(v0.5.5+)
+ Number
+ 3000
+ 节点文本编辑框元素的z-index
+
+
+
+ nodeNoteTooltipZIndex(v0.5.5+)
+ Number
+ 3000
+ 节点备注浮层元素的z-index
+
+
+
+ isEndNodeTextEditOnClickOuter(v0.5.5+)
+ Boolean
+ true
+ 是否在点击了画布外的区域时结束节点文本的编辑状态
+
+
+
+ maxHistoryCount(v0.5.6+)
+ Number
+ 1000
+ 最大历史记录数
+
+
+
+ alwaysShowExpandBtn(v0.5.8+)
+ Boolean
+ false
+ 是否一直显示节点的展开收起按钮,默认为鼠标移上去和激活时才显示
+
+
+
+ iconList(v0.5.8+)
+ Array
+ []
+ 扩展节点可插入的图标,数组的每一项为一个对象,对象详细结构请参考下方【图标配置】表格
+
+
+
+ maxNodeCacheCount(v0.5.10+)
+ Number
+ 1000
+ 节点最大缓存数量。为了优化性能,内部会维护一个节点缓存池,用来复用节点,通过该属性可以指定池的最大缓存数量
+
+
+
+ defaultAssociativeLineText(v0.5.11+)
+ String
+ 关联
+ 关联线默认文字
+
+
+
+ fitPadding(v0.6.0+)
+ Number
+ 50
+ 思维导图适应画布大小时的内边距,单位:px
+
+
+
+ enableCtrlKeyNodeSelection(v0.6.0+)
+ Boolean
+ true
+ 是否开启按住ctrl键多选节点的功能
+
+
+
+ useLeftKeySelectionRightKeyDrag(v0.6.0+)
+ Boolean
+ false
+ 设置为左键多选节点,右键拖动画布
+
+
+
+ beforeTextEdit(v0.6.0+)
+ Function/null
+ null
+ 节点即将进入编辑前的回调方法,如果该方法返回true以外的值,那么将取消编辑,函数可以返回一个值,或一个Promise,回调参数为节点实例
+
+
+
+ isUseCustomNodeContent(v0.6.3+)
+ Boolean
+ false
+ 是否自定义节点内容
+
+
+
+ customCreateNodeContent(v0.6.3+)
+ Function/null
+ null
+
+ 如果isUseCustomNodeContent设为true,那么需要使用该选项传入一个方法,接收节点实例node为参数(如果要获取该节点的数据,可以通过node.nodeData.data),需要返回自定义节点内容元素,也就是DOM节点,如果某个节点不需要自定义,那么返回null即可
+
+
+
+
+ mouseScaleCenterUseMousePosition(v0.6.4-fix.1+)
+ Boolean
+ true
+ 鼠标缩放是否以鼠标当前位置为中心点,否则以画布中心点
+
+
+
+ customInnerElsAppendTo(v0.6.12+)
+ null/HTMLElement
+ null
+ 指定内部一些元素(节点文本编辑元素、节点备注显示元素、关联线文本编辑元素、节点图片调整按钮元素)添加到的位置,默认添加到document.body下
+
+
+
+ nodeDragPlaceholderMaxSize(v0.6.12+)
+ Number
+ 20
+ 拖拽元素时,指示元素新位置的块的最大高度
+
+
+
+ enableCreateHiddenInput(v0.6.13+)(v0.6.14+版本已去除该特性)
+ Boolean
+ true
+ 是否允许创建一个隐藏的输入框,该输入框会在节点激活时聚焦,用于粘贴数据和自动进入文本编辑状态
+
+
+
+ enableAutoEnterTextEditWhenKeydown(v0.6.13+)
+ Boolean
+ true
+ 是否在存在一个激活节点时,当按下中文、英文、数字按键时自动进入文本编辑模式
+
+
+
+ richTextEditFakeInPlace(v0.6.13+)
+ Boolean
+ false
+ 设置富文本节点编辑框和节点大小一致,形成伪原地编辑的效果,需要注意的是,只有当节点内只有文本、且形状是矩形才会有比较好的效果
+
+
+
+ customHandleClipboardText(v0.6.14+)
+ Function
+ null
+
+ 自定义对剪贴板文本的处理。当按ctrl+v粘贴时会读取用户剪贴板中的文本和图片,默认只会判断文本是否是普通文本和simple-mind-map格式的节点数据,如果你想处理其他思维导图的数据,比如processon、zhixi等,那么可以传递一个函数,接受当前剪贴板中的文本为参数,返回处理后的数据,可以返回两种类型:1.返回一个纯文本,那么会直接以该文本创建一个子节点;2.返回一个节点对象,格式如下:{
+ simpleMindMap: true, data: { data: { text: '' }, children: [] }
+ },代表是simple-mind-map格式的数据,节点数据同simple-mind-map节点数据格式,如果你的处理逻辑存在异步逻辑,也可以返回一个promise
+
+
+
+ errorHandler(v0.6.15+)
+ Function
+
+ 自定义错误处理函数,目前只会抛出一些异步逻辑出错的情况。可以传递一个函数,会接收两个参数,第一个为错误的类型,第二个为错误对象
+
+
+
+ disableMouseWheelZoom(v0.6.15+)
+ Boolean
+ false
+ 禁止鼠标滚轮缩放,你仍旧可以使用api进行缩放
+
+
+
+ resetCss(v0.6.16+)
+ String
+ * { margin: 0; padding: 0; box-sizing: border-box; }
+ 设置导出图片和svg时,针对富文本节点内容,也就是嵌入到svg中的html节点的默认样式覆盖,如果不覆盖,节点内容会发生偏移
+
+
+
+ enableDblclickReset(v0.6.17+)
+ Boolean
+ true(v0.7.0+改为false)
+ 开启鼠标双击复位思维导图位置及缩放
+
+
+
+ minExportImgCanvasScale(v0.7.0+)
+ Number
+ 2
+ 导出图片和pdf时canvas的缩放倍数,该配置会和window.devicePixelRatio值取最大值,用于提升图片清晰度
+
+
+
+ hoverRectColor(v0.7.0+)
+ String
+ rgb(94, 200, 248)
+ 节点鼠标hover和激活时显示的矩形边框颜色,hover时会添加0.6的透明度
+
+
+
+ hoverRectPadding(v0.7.0+)
+ Number
+ 2
+ 节点鼠标hover和激活时显示的矩形边框距节点内容的距离
+
+
+
+ selectTextOnEnterEditText(v0.7.0+)
+ Boolean
+ true
+ 双击节点进入节点文本编辑时是否默认选中文本,默认只在创建新节点时会选中
+
+
+
+ deleteNodeActive(v0.7.1+)
+ Boolean
+ true
+ 是否开启删除节点后自动激活节点相邻节点或父节点的功能
+
+
+
+ autoMoveWhenMouseInEdgeOnDrag(v0.7.1+)
+ Boolean
+ true
+ 拖拽节点时鼠标移动到画布边缘是否开启画布自动移动
+
+
+
+
+ fit
+ Boolean
+ false
+ 初次加载是否适应视图
+
+
+
+
+ 数据结构
+ 基本的数据结构如下:
+ {
data: {
text: '', // 节点的文本,可以是富文本,也就是html格式的,此时richText要设为true
richText: false, // 节点的文本是否是富文本模式
@@ -520,91 +543,95 @@
]
}
-如果你要添加自定义的字段,可以添加到data、children同级,如果你要添加到data对象里,那么请使用_开头来命名你的自定义字段,内部会通过这个来判断是否是自定义字段。
-水印配置
-
-
-
-字段名称
-类型
-默认值
-描述
-
-
-
-
-text
-String
-''
-水印文字,如果为空字符串则不显示水印
-
-
-lineSpacing
-Number
-100
-水印每行之间的间距
-
-
-textSpacing
-Number
-100
-同一行水印之间的间距
-
-
-angle
-Number
-30
-水印的倾斜角度,范围:[0, 90]
-
-
-textStyle
-Object
-{color: '#999', opacity: 0.5, fontSize: 14}
-水印文字样式
-
-
-
-图标配置
-
-
-
-字段名称
-类型
-默认值
-描述
-
-
-
-
-name
-String
-
-图标分组的名称
-
-
-type
-String
-
-图标分组的值
-
-
-list
-Array
-
-分组下的图标列表,数组的每一项为一个对象,{ name: '', icon: '' },name代表图标的名称,icon代表图标,可以是svg图标,比如<svg ...><path></path></svg>,也可以是图片url,或者是base64图标,比如data:image/png;base64,...
-
-
-
-静态方法
-defineTheme(name, config)
-
-v0.2.23+
-
-定义新主题。
-name:新主题名称
-config:主题数据
-simple-mind-map内置了众多主题,另外你也可以注册新主题,建议在实例化之前进行注册,这样在实例化时可以直接使用新注册的主题,使用示例:
-import MindMap from 'simple-mind-map'
+
+ 如果你要添加自定义的字段,可以添加到data、children同级,如果你要添加到data对象里,那么请使用_开头来命名你的自定义字段,内部会通过这个来判断是否是自定义字段。
+
+ 水印配置
+
+
+
+ 字段名称
+ 类型
+ 默认值
+ 描述
+
+
+
+
+ text
+ String
+ ''
+ 水印文字,如果为空字符串则不显示水印
+
+
+ lineSpacing
+ Number
+ 100
+ 水印每行之间的间距
+
+
+ textSpacing
+ Number
+ 100
+ 同一行水印之间的间距
+
+
+ angle
+ Number
+ 30
+ 水印的倾斜角度,范围:[0, 90]
+
+
+ textStyle
+ Object
+ {color: '#999', opacity: 0.5, fontSize: 14}
+ 水印文字样式
+
+
+
+ 图标配置
+
+
+
+ 字段名称
+ 类型
+ 默认值
+ 描述
+
+
+
+
+ name
+ String
+
+ 图标分组的名称
+
+
+ type
+ String
+
+ 图标分组的值
+
+
+ list
+ Array
+
+
+ 分组下的图标列表,数组的每一项为一个对象,{ name: '', icon: '' },name代表图标的名称,icon代表图标,可以是svg图标,比如<svg ...><path></path></svg>,也可以是图片url,或者是base64图标,比如data:image/png;base64,...
+
+
+
+
+ 静态方法
+ defineTheme(name, config)
+
+ v0.2.23+
+
+ 定义新主题。
+ name:新主题名称
+ config:主题数据
+ simple-mind-map内置了众多主题,另外你也可以注册新主题,建议在实例化之前进行注册,这样在实例化时可以直接使用新注册的主题,使用示例:
+ import MindMap from 'simple-mind-map'
// 注册新主题
MindMap.defineTheme('主题名称', {})
@@ -616,41 +643,43 @@ MindMap.defineTheme('主题名称', {
// 2.动态切换新主题
mindMap.setTheme('主题名称')
-主题的所有配置可以参考默认主题。defineTheme方法会把你传入的配置和默认配置做合并。大部分主题其实需要自定义的部分不是很多,一个典型的自定义主题配置可以参考blueSky。
-usePlugin(plugin, opt = {})
-
-v0.3.0+
-
-
-opt:v0.4.0+,插件参数。如果某个插件支持自定义选项的话可以通过这个参数传入。
-
-注册插件,如果需要使用非核心的一些功能,比如小地图、水印等,可以通过该方法进行注册。可链式调用。
-注意:插件需要在实例化MindMap前注册。
-hasPlugin(plugin)
-
-v0.4.0+
-
-获取是否注册了某个插件,返回的是插件在注册插件列表里的索引,为-1则代表插件没有注册。
-静态属性
-pluginList
-
-v0.3.0+
-
-当前注册的所有插件列表。
-实例方法
-destroy()
-
-v0.6.0+
-
-销毁思维导图。会移除注册的插件、移除监听的事件、删除画布的所有节点。
-getSvgData({ paddingX = 0, paddingY = 0 })
-
-v0.3.0+
-
-paddingX:水平内边距
-paddingY:垂直内边距
-获取svg数据,返回一个对象,详细结构如下:
-{
+ 主题的所有配置可以参考默认主题。defineTheme方法会把你传入的配置和默认配置做合并。大部分主题其实需要自定义的部分不是很多,一个典型的自定义主题配置可以参考blueSky。
+ usePlugin(plugin, opt = {})
+
+ v0.3.0+
+
+
+ opt:v0.4.0+,插件参数。如果某个插件支持自定义选项的话可以通过这个参数传入。
+
+ 注册插件,如果需要使用非核心的一些功能,比如小地图、水印等,可以通过该方法进行注册。可链式调用。
+ 注意:插件需要在实例化MindMap前注册。
+ hasPlugin(plugin)
+
+ v0.4.0+
+
+ 获取是否注册了某个插件,返回的是插件在注册插件列表里的索引,为-1则代表插件没有注册。
+ 静态属性
+ pluginList
+
+ v0.3.0+
+
+ 当前注册的所有插件列表。
+ 实例方法
+ destroy()
+
+ v0.6.0+
+
+ 销毁思维导图。会移除注册的插件、移除监听的事件、删除画布的所有节点。
+ getSvgData({ paddingX = 0, paddingY = 0 })
+
+ v0.3.0+
+
+ paddingX:水平内边距
+ paddingY:垂直内边距
+ 获取svg数据,返回一个对象,详细结构如下:
+ {
svg, // Element,思维导图图形的整体svg元素,包括:svg(画布容器)、g(实际的思维导图组)
svgHTML, // String,svg字符串,即html字符串,可以直接渲染到你准备的小地图容器内
rect: // Object,思维导图图形未缩放时的位置尺寸等信息
@@ -660,489 +689,511 @@ mindMap.setTheme('主题名称')
scaleY, // Number,思维导图图形的垂直缩放值
}
-render(callback)
-
-callback:v0.3.2+,Function,当重新渲染完成时调用
-
-触发整体渲染,会进行节点复用,性能较reRender会更好一点,如果只是节点位置变化了可以调用该方法进行渲染
-reRender(callback)
-
-callback:v0.3.2+,Function,当重新渲染完成时调用
-
-整体重新渲染,会清空画布,节点也会重新创建,性能不好,慎重使用
-resize()
-容器尺寸变化后,需要调用该方法进行适应
-setMode(mode)
-
-v0.1.7+
-
-切换模式为只读或编辑。
-mode:readonly、edit
-on(event, fn)
-监听事件,事件列表:
-
-
-
-事件名称
-描述
-回调参数
-
-
-
-
-data_change
-渲染树数据变化,可以监听该方法获取最新数据
-data(当前渲染树数据)
-
-
-view_data_change(v0.1.1+)
-视图变化数据,比如拖动或缩放时会触发
-data(当前视图状态数据)
-
-
-back_forward
-前进或回退
-activeHistoryIndex(当前在历史数据数组里的索引)、length(当前历史数据数组的长度)
-
-
-draw_click
-画布的单击事件
-e(事件对象)
-
-
-svg_mousedown
-svg画布的鼠标按下事件
-e(事件对象)
-
-
-mousedown
-el元素的鼠标按下事件
-e(事件对象)、this(Event事件类实例)
-
-
-mousemove
-el元素的鼠标移动事件
-e(事件对象)、this(Event事件类实例)
-
-
-drag
-如果是按住左键拖动的话会触发拖动事件
-e(事件对象)、this(Event事件类实例)
-
-
-mouseup
-el元素的鼠标松开事件
-e(事件对象)、this(Event事件类实例)
-
-
-mousewheel
-鼠标滚动事件
-e(事件对象)、dir(向上up还是向下down滚动)、this(Event事件类实例)、isTouchPad(v0.6.1+,是否是触控板触发的事件)
-
-
-contextmenu
-svg画布的鼠标右键菜单事件
-e(事件对象)
-
-
-node_click
-节点的单击事件
-this(节点实例)、e(事件对象)
-
-
-node_mousedown
-节点的鼠标按下事件
-this(节点实例)、e(事件对象)
-
-
-node_mouseup
-节点的鼠标松开事件
-this(节点实例)、e(事件对象)
-
-
-node_dblclick
-节点的双击事件
-this(节点实例)、e(事件对象)
-
-
-node_contextmenu
-节点的右键菜单事件
-e(事件对象)、this(节点实例)
-
-
-node_mouseenter(v0.4.1+)
-节点的鼠标移入事件
-this(节点实例)、e(事件对象)
-
-
-node_mouseleave(v0.4.1+)
-节点的鼠标移出事件
-this(节点实例)、e(事件对象)
-
-
-before_node_active
-节点激活前事件
-this(节点实例)、activeNodeList(当前激活的所有节点列表)
-
-
-node_active
-节点激活事件
-this(节点实例)、activeNodeList(当前激活的所有节点列表)
-
-
-expand_btn_click
-节点展开或收缩事件
-this(节点实例)
-
-
-before_show_text_edit
-节点文本编辑框即将打开事件
-
-
-
-hide_text_edit
-节点文本编辑框关闭事件
-textEditNode(文本编辑框DOM节点)、activeNodeList(当前激活的所有节点列表)
-
-
-scale
-放大缩小事件
-scale(缩放比例)
-
-
-node_img_dblclick(v0.2.15+)
-节点内图片的双击事件
-this(节点实例)、e(事件对象)
-
-
-node_img_mouseenter(v0.6.5+)
-节点内图片的鼠标移入事件
-this(节点实例)、imgNode(图片节点)、e(事件对象)
-
-
-node_img_mouseleave(v0.6.5+)
-节点内图片的鼠标移出事件
-this(节点实例)、imgNode(图片节点)、e(事件对象)
-
-
-node_img_mousemove(v0.6.5+)
-节点内图片的鼠标移动事件
-this(节点实例)、imgNode(图片节点)、e(事件对象)
-
-
-node_tree_render_end(v0.2.16+)
-节点树渲染完毕事件
-
-
-
-rich_text_selection_change(v0.4.0+)
-当注册了RichText插件时可用。当节点编辑时,文本选区发生改变时触发
-hasRange(是否存在选区)、rectInfo(选区的尺寸和位置信息)、formatInfo(选区的文本格式化信息)
-
-
-transforming-dom-to-images(v0.4.0+)
-当注册了RichText插件时可用。当svg中存在DOM节点时,导出为图片时会将DOM节点转换为图片,转换过程中会触发该事件,可用通过该事件给用户提示,告知目前转换到的节点
-index(当前转换到的节点索引)、len(一共需要转换的节点数量)
-
-
-node_dragging(v0.4.5+)
-当某个节点被拖拽时触发
-node(当前被拖拽的节点)
-
-
-node_dragend(v0.4.5+)
-节点被拖拽结束时触发
-{ overlapNodeUid, prevNodeUid, nextNodeUid }(v0.6.12+,本次节点移动到的节点uid,比如本次移动到了节点A上,那么overlapNodeUid就是节点A的uid,如果移动到了B节点的前面,那么nextNodeUid就是节点B的uid,你可以通过mindMap.renderer.findNodeByUid(uid)方法来获取节点实例)
-
-
-associative_line_click(v0.4.5+)
-点击某条关联线时触发
-path(连接线节点)、clickPath(不可见的点击线节点)、node(起始节点)、toNode(目标节点)
-
-
-svg_mouseenter(v0.5.1+)
-鼠标移入svg画布时触发
-e(事件对象)
-
-
-svg_mouseleave(v0.5.1+)
-鼠标移出svg画布时触发
-e(事件对象)
-
-
-node_icon_click(v0.6.10+)
-点击节点内的图标时触发
-this(节点实例)、item(点击的图标名称)、e(事件对象)
-
-
-view_theme_change(v0.6.12+)
-调用了setTheme方法设置主题后触发
-theme(设置的新主题名称)
-
-
-
-emit(event, ...args)
-触发事件,可以是上面表格里的事件,也可以是自定义事件
-off(event, fn)
-解绑事件
-setTheme(theme)
-切换主题,可选主题见上面的选项表格
-getTheme()
-获取当前主题
-setThemeConfig(config)
-设置主题配置,config同上面选项表格里的选项themeConfig
-getCustomThemeConfig()
-获取自定义主题配置
-getThemeConfig(prop)
-获取某个主题配置属性值
-getConfig(prop)
-
-0.2.24+
-
-prop:获取指定配置的值,不传则返回整个配置
-获取配置,即new MindMap(opt)的opt
-updateConfig(opt = {})
-
-0.2.24+
-
-opt:要更新的配置
-更新配置,即更新new MindMap(opt)的opt,可以只更新部分数据,比如:
-mindMap.updateConfig({
+ render(callback)
+
+ callback:v0.3.2+,Function,当重新渲染完成时调用
+
+ 触发整体渲染,会进行节点复用,性能较reRender会更好一点,如果只是节点位置变化了可以调用该方法进行渲染
+ reRender(callback)
+
+ callback:v0.3.2+,Function,当重新渲染完成时调用
+
+ 整体重新渲染,会清空画布,节点也会重新创建,性能不好,慎重使用
+ resize()
+ 容器尺寸变化后,需要调用该方法进行适应
+ setMode(mode)
+
+ v0.1.7+
+
+ 切换模式为只读或编辑。
+ mode:readonly、edit
+ on(event, fn)
+ 监听事件,事件列表:
+
+
+
+ 事件名称
+ 描述
+ 回调参数
+
+
+
+
+ data_change
+ 渲染树数据变化,可以监听该方法获取最新数据
+ data(当前渲染树数据)
+
+
+ view_data_change(v0.1.1+)
+ 视图变化数据,比如拖动或缩放时会触发
+ data(当前视图状态数据)
+
+
+ back_forward
+ 前进或回退
+ activeHistoryIndex(当前在历史数据数组里的索引)、length(当前历史数据数组的长度)
+
+
+ draw_click
+ 画布的单击事件
+ e(事件对象)
+
+
+ svg_mousedown
+ svg画布的鼠标按下事件
+ e(事件对象)
+
+
+ mousedown
+ el元素的鼠标按下事件
+ e(事件对象)、this(Event事件类实例)
+
+
+ mousemove
+ el元素的鼠标移动事件
+ e(事件对象)、this(Event事件类实例)
+
+
+ drag
+ 如果是按住左键拖动的话会触发拖动事件
+ e(事件对象)、this(Event事件类实例)
+
+
+ mouseup
+ el元素的鼠标松开事件
+ e(事件对象)、this(Event事件类实例)
+
+
+ mousewheel
+ 鼠标滚动事件
+ e(事件对象)、dir(向上up还是向下down滚动)、this(Event事件类实例)、isTouchPad(v0.6.1+,是否是触控板触发的事件)
+
+
+ contextmenu
+ svg画布的鼠标右键菜单事件
+ e(事件对象)
+
+
+ node_click
+ 节点的单击事件
+ this(节点实例)、e(事件对象)
+
+
+ node_mousedown
+ 节点的鼠标按下事件
+ this(节点实例)、e(事件对象)
+
+
+ node_mouseup
+ 节点的鼠标松开事件
+ this(节点实例)、e(事件对象)
+
+
+ node_dblclick
+ 节点的双击事件
+ this(节点实例)、e(事件对象)
+
+
+ node_contextmenu
+ 节点的右键菜单事件
+ e(事件对象)、this(节点实例)
+
+
+ node_mouseenter(v0.4.1+)
+ 节点的鼠标移入事件
+ this(节点实例)、e(事件对象)
+
+
+ node_mouseleave(v0.4.1+)
+ 节点的鼠标移出事件
+ this(节点实例)、e(事件对象)
+
+
+ before_node_active
+ 节点激活前事件
+ this(节点实例)、activeNodeList(当前激活的所有节点列表)
+
+
+ node_active
+ 节点激活事件
+ this(节点实例)、activeNodeList(当前激活的所有节点列表)
+
+
+ expand_btn_click
+ 节点展开或收缩事件
+ this(节点实例)
+
+
+ before_show_text_edit
+ 节点文本编辑框即将打开事件
+
+
+
+ hide_text_edit
+ 节点文本编辑框关闭事件
+ textEditNode(文本编辑框DOM节点)、activeNodeList(当前激活的所有节点列表)
+
+
+ scale
+ 放大缩小事件
+ scale(缩放比例)
+
+
+ node_img_dblclick(v0.2.15+)
+ 节点内图片的双击事件
+ this(节点实例)、e(事件对象)
+
+
+ node_img_mouseenter(v0.6.5+)
+ 节点内图片的鼠标移入事件
+ this(节点实例)、imgNode(图片节点)、e(事件对象)
+
+
+ node_img_mouseleave(v0.6.5+)
+ 节点内图片的鼠标移出事件
+ this(节点实例)、imgNode(图片节点)、e(事件对象)
+
+
+ node_img_mousemove(v0.6.5+)
+ 节点内图片的鼠标移动事件
+ this(节点实例)、imgNode(图片节点)、e(事件对象)
+
+
+ node_tree_render_end(v0.2.16+)
+ 节点树渲染完毕事件
+
+
+
+ rich_text_selection_change(v0.4.0+)
+ 当注册了RichText插件时可用。当节点编辑时,文本选区发生改变时触发
+ hasRange(是否存在选区)、rectInfo(选区的尺寸和位置信息)、formatInfo(选区的文本格式化信息)
+
+
+ transforming-dom-to-images(v0.4.0+)
+
+ 当注册了RichText插件时可用。当svg中存在DOM节点时,导出为图片时会将DOM节点转换为图片,转换过程中会触发该事件,可用通过该事件给用户提示,告知目前转换到的节点
+
+ index(当前转换到的节点索引)、len(一共需要转换的节点数量)
+
+
+ node_dragging(v0.4.5+)
+ 当某个节点被拖拽时触发
+ node(当前被拖拽的节点)
+
+
+ node_dragend(v0.4.5+)
+ 节点被拖拽结束时触发
+ { overlapNodeUid, prevNodeUid, nextNodeUid
+ }(v0.6.12+,本次节点移动到的节点uid,比如本次移动到了节点A上,那么overlapNodeUid就是节点A的uid,如果移动到了B节点的前面,那么nextNodeUid就是节点B的uid,你可以通过mindMap.renderer.findNodeByUid(uid)方法来获取节点实例)
+
+
+
+ associative_line_click(v0.4.5+)
+ 点击某条关联线时触发
+ path(连接线节点)、clickPath(不可见的点击线节点)、node(起始节点)、toNode(目标节点)
+
+
+ svg_mouseenter(v0.5.1+)
+ 鼠标移入svg画布时触发
+ e(事件对象)
+
+
+ svg_mouseleave(v0.5.1+)
+ 鼠标移出svg画布时触发
+ e(事件对象)
+
+
+ node_icon_click(v0.6.10+)
+ 点击节点内的图标时触发
+ this(节点实例)、item(点击的图标名称)、e(事件对象)
+
+
+ view_theme_change(v0.6.12+)
+ 调用了setTheme方法设置主题后触发
+ theme(设置的新主题名称)
+
+
+
+ emit(event, ...args)
+ 触发事件,可以是上面表格里的事件,也可以是自定义事件
+ off(event, fn)
+ 解绑事件
+ setTheme(theme)
+ 切换主题,可选主题见上面的选项表格
+ getTheme()
+ 获取当前主题
+ setThemeConfig(config)
+ 设置主题配置,config同上面选项表格里的选项themeConfig
+ getCustomThemeConfig()
+ 获取自定义主题配置
+ getThemeConfig(prop)
+ 获取某个主题配置属性值
+ getConfig(prop)
+
+ 0.2.24+
+
+ prop:获取指定配置的值,不传则返回整个配置
+ 获取配置,即new MindMap(opt)的opt
+ updateConfig(opt = {})
+
+ 0.2.24+
+
+ opt:要更新的配置
+ 更新配置,即更新new MindMap(opt)的opt,可以只更新部分数据,比如:
+ mindMap.updateConfig({
enableFreeDrag: true// 开启节点自由拖拽
})
-该方法只做更新配置的事情,没有其他副作用,比如触发画布重新渲染之类的
-getLayout()
-获取当前的布局结构
-setLayout(layout)
-设置布局结构,可选值见上面选项表格的layout字段
-execCommand(name, ...args)
-执行命令,每执行一个命令就会在历史堆栈里添加一条记录用于回退或前进。所有命令如下:
-
-
-
-命令名称
-描述
-参数
-
-
-
-
-SELECT_ALL
-全选
-
-
-
-BACK
-回退指定的步数
-step(要回退的步数,默认为1)
-
-
-FORWARD
-前进指定的步数
-step(要前进的步数,默认为1)
-
-
-INSERT_NODE
-插入同级节点,操作节点为当前激活的节点或指定节点,如果有多个激活节点,只会对第一个有效
-openEdit(v0.4.6+,是否激活新插入的节点并进入编辑模式,默认为true)、 appointNodes(v0.4.7+,可选,指定节点,指定多个节点可以传一个数组)、 appointData(可选,指定新创建节点的数据,比如{text: 'xxx', ...},详细结构可以参考exampleData.js)、 appointChildren(v0.6.14+,可选,指定新创建节点的子节点,数组类型)
-
-
-INSERT_CHILD_NODE
-插入子节点,操作节点为当前激活的节点或指定节点
-openEdit(v0.4.6+,是否激活新插入的节点并进入编辑模式,默认为true)、 appointNodes(v0.4.7+,可选,指定节点,指定多个节点可以传一个数组)、 appointData(可选,指定新创建节点的数据,比如{text: 'xxx', ...},详细结构可以参考exampleData.js)、 appointChildren(v0.6.14+,可选,指定新创建节点的子节点,数组类型)
-
-
-UP_NODE
-上移节点,操作节点为当前激活的节点,如果有多个激活节点,只会对第一个有效,对根节点或在列表里的第一个节点使用无效
-
-
-
-DOWN_NODE
-操作节点为当前激活的节点,如果有多个激活节点,只会对第一个有效,对根节点或在列表里的最后一个节点使用无效
-
-
-
-REMOVE_NODE
-删除节点,操作节点为当前激活的节点或指定节点
-appointNodes(v0.4.7+,可选,指定节点,指定多个节点可以传一个数组)
-
-
-PASTE_NODE
-粘贴节点到节点,操作节点为当前激活的节点
-data(要粘贴的节点数据,一般通过renderer.copyNode()方法和renderer.cutNode()方法获取)
-
-
-CUT_NODE
-剪切节点,操作节点为当前激活的节点,如果有多个激活节点,只会对第一个有效,对根节点使用无效
-callback(回调函数,剪切的节点数据会通过调用该函数并通过参数返回)
-
-
-SET_NODE_STYLE
-修改节点单个样式
-node(要设置样式的节点)、style(样式属性)、value(样式属性值)、isActive(v0.7.0+已废弃,布尔值,是否设置的是激活状态的样式)
-
-
-SET_NODE_STYLEs(v0.6.12+)
-修改节点多个样式
-node(要设置样式的节点)、style(样式对象,key为样式属性,value为样式值)、isActive(v0.7.0+已废弃,布尔值,是否设置的是激活状态的样式)
-
-
-SET_NODE_ACTIVE
-设置节点是否激活
-node(要设置的节点)、active(布尔值,是否激活)
-
-
-CLEAR_ACTIVE_NODE
-清除当前已激活节点的激活状态,操作节点为当前激活的节点
-
-
-
-SET_NODE_EXPAND
-设置节点是否展开
-node(要设置的节点)、expand(布尔值,是否展开)
-
-
-EXPAND_ALL
-展开所有节点
-
-
-
-UNEXPAND_ALL
-收起所有节点
-
-
-
-UNEXPAND_TO_LEVEL(v0.2.8+)
-展开到指定层级
-level(要展开到的层级,1、2、3...)
-
-
-SET_NODE_DATA
-更新节点数据,即更新节点数据对象里data对象的数据
-node(要设置的节点)、data(对象,要更新的数据,如{expand: true})
-
-
-SET_NODE_TEXT
-设置节点文本
-node(要设置的节点)、text(要设置的文本字符串,换行可以使用\n)、richText(v0.4.0+,如果要设置的是富文本字符,需要设为true)、resetRichText(v0.6.10+是否要复位富文本,默认为false,如果传true那么会重置富文本节点的样式)
-
-
-SET_NODE_IMAGE
-设置节点图片
-node(要设置的节点)、imgData(对象,图片信息,结构为:{url, title, width, height},图片的宽高必须要传)
-
-
-SET_NODE_ICON
-设置节点图标
-node(要设置的节点)、icons(数组,预定义的图片名称组成的数组,可用图标可在icons.js文件里的nodeIconList列表里获取到,图标名称为type_name,如['priority_1'])
-
-
-SET_NODE_HYPERLINK
-设置节点超链接
-node(要设置的节点)、link(超链接地址)、title(超链接名称,可选)
-
-
-SET_NODE_NOTE
-设置节点备注
-node(要设置的节点)、note(备注文字)
-
-
-SET_NODE_TAG
-设置节点标签
-node(要设置的节点)、tag(字符串数组,内置颜色信息可在constant.js里获取到)
-
-
-INSERT_AFTER(v0.1.5+)
-将节点移动到另一个节点的后面
-node(要移动的节点)、 exist(目标节点)
-
-
-INSERT_BEFORE(v0.1.5+)
-将节点移动到另一个节点的前面
-node(要移动的节点)、 exist(目标节点)
-
-
-MOVE_NODE_TO(v0.1.5+)
-移动一个节点作为另一个节点的子节点
-node(要移动的节点)、 toNode(目标节点)
-
-
-ADD_GENERALIZATION(v0.2.0+)
-添加节点概要
-data(概要的数据,对象格式,节点的数字段都支持,默认为{text: '概要'})
-
-
-REMOVE_GENERALIZATION(v0.2.0+)
-删除节点概要
-
-
-
-SET_NODE_CUSTOM_POSITION(v0.2.0+)
-设置节点自定义位置
-node(要设置的节点)、 left(自定义的x坐标,默认为undefined)、 top(自定义的y坐标,默认为undefined)
-
-
-RESET_LAYOUT(v0.2.0+)
-一键整理布局
-
-
-
-SET_NODE_SHAPE(v0.2.4+)
-设置节点形状
-node(要设置的节点)、shape(形状,全部形状:Shape.js)
-
-
-GO_TARGET_NODE(v0.6.7+)
-定位到某个节点,如果该节点被收起,那么会自动展开到该节点
-node(要定位到的节点实例或节点uid)、callback(v0.6.9+,定位完成后的回调函数)
-
-
-
-setData(data)
-动态设置思维导图数据,纯节点数据
-data:思维导图结构数据
-setFullData(data)
-
-v0.2.7+
-
-动态设置思维导图数据,包括节点数据、布局、主题、视图
-data:完整数据,结构可参考exportFullData
-getData(withConfig)
-
-v0.2.9+
-
-获取思维导图数据
-withConfig:Boolean,默认为false,即获取的数据只包括节点树,如果传true则会包含主题、布局、视图等数据
-export(type, isDownload, fileName)
-
-需要先注册Export插件
-
-导出
-type:要导出的类型,可选值:png、svg、json、pdf(v0.2.1+)、smm(本质也是json)
-isDownload:是否需要直接触发下载,布尔值,默认为false
-fileName:(v0.1.6+)导出文件的名称,默认为思维导图
-如果是导出为png,那么可以传递第四个参数:
-transparent:v0.5.7+, Boolean,默认为false,指定导出图片的背景是否是透明的
-如果是导出为svg,那么可以传递第四个参数:
-plusCssText:附加的css样式,如果svg中存在dom节点,想要设置一些针对节点的样式可以通过这个参数传入
-如果是导出为json或smm,那么可以传递第四个参数:
-withConfig:Boolean,默认为true,指定导出的数据中是否包含配置数据,否则只导出纯节点树数据
-toPos(x, y)
-
-v0.1.5+
-
-将浏览器可视窗口的坐标转换成相对于画布的坐标
-addPlugin(plugin, opt)
-
-v0.4.0+
-
-注册插件,使用MindMap.usePlugin注册插件只能在实例化之前,实例化后注册的插件是不会生效的,所以如果想在实例化后注册插件可以使用实例的addPlugin方法。
-removePlugin(plugin)
-
-v0.4.0+
-
-移除注册的插件,无论是通过usePlugin还是addPlugin方法注册的插件都可以移除。
+ 该方法只做更新配置的事情,没有其他副作用,比如触发画布重新渲染之类的
+ getLayout()
+ 获取当前的布局结构
+ setLayout(layout)
+ 设置布局结构,可选值见上面选项表格的layout字段
+ execCommand(name, ...args)
+ 执行命令,每执行一个命令就会在历史堆栈里添加一条记录用于回退或前进。所有命令如下:
+
+
+
+ 命令名称
+ 描述
+ 参数
+
+
+
+
+ SELECT_ALL
+ 全选
+
+
+
+ BACK
+ 回退指定的步数
+ step(要回退的步数,默认为1)
+
+
+ FORWARD
+ 前进指定的步数
+ step(要前进的步数,默认为1)
+
+
+ INSERT_NODE
+ 插入同级节点,操作节点为当前激活的节点或指定节点,如果有多个激活节点,只会对第一个有效
+ openEdit(v0.4.6+,是否激活新插入的节点并进入编辑模式,默认为true)、 appointNodes(v0.4.7+,可选,指定节点,指定多个节点可以传一个数组)、
+ appointData(可选,指定新创建节点的数据,比如{text: 'xxx', ...},详细结构可以参考exampleData.js)、
+ appointChildren(v0.6.14+,可选,指定新创建节点的子节点,数组类型)
+
+
+ INSERT_CHILD_NODE
+ 插入子节点,操作节点为当前激活的节点或指定节点
+ openEdit(v0.4.6+,是否激活新插入的节点并进入编辑模式,默认为true)、 appointNodes(v0.4.7+,可选,指定节点,指定多个节点可以传一个数组)、
+ appointData(可选,指定新创建节点的数据,比如{text: 'xxx', ...},详细结构可以参考exampleData.js)、
+ appointChildren(v0.6.14+,可选,指定新创建节点的子节点,数组类型)
+
+
+ UP_NODE
+ 上移节点,操作节点为当前激活的节点,如果有多个激活节点,只会对第一个有效,对根节点或在列表里的第一个节点使用无效
+
+
+
+ DOWN_NODE
+ 操作节点为当前激活的节点,如果有多个激活节点,只会对第一个有效,对根节点或在列表里的最后一个节点使用无效
+
+
+
+ REMOVE_NODE
+ 删除节点,操作节点为当前激活的节点或指定节点
+ appointNodes(v0.4.7+,可选,指定节点,指定多个节点可以传一个数组)
+
+
+ PASTE_NODE
+ 粘贴节点到节点,操作节点为当前激活的节点
+ data(要粘贴的节点数据,一般通过renderer.copyNode()方法和renderer.cutNode()方法获取)
+
+
+ CUT_NODE
+ 剪切节点,操作节点为当前激活的节点,如果有多个激活节点,只会对第一个有效,对根节点使用无效
+ callback(回调函数,剪切的节点数据会通过调用该函数并通过参数返回)
+
+
+ SET_NODE_STYLE
+ 修改节点单个样式
+ node(要设置样式的节点)、style(样式属性)、value(样式属性值)、isActive(v0.7.0+已废弃,布尔值,是否设置的是激活状态的样式)
+
+
+ SET_NODE_STYLEs(v0.6.12+)
+ 修改节点多个样式
+ node(要设置样式的节点)、style(样式对象,key为样式属性,value为样式值)、isActive(v0.7.0+已废弃,布尔值,是否设置的是激活状态的样式)
+
+
+ SET_NODE_ACTIVE
+ 设置节点是否激活
+ node(要设置的节点)、active(布尔值,是否激活)
+
+
+ CLEAR_ACTIVE_NODE
+ 清除当前已激活节点的激活状态,操作节点为当前激活的节点
+
+
+
+ SET_NODE_EXPAND
+ 设置节点是否展开
+ node(要设置的节点)、expand(布尔值,是否展开)
+
+
+ EXPAND_ALL
+ 展开所有节点
+
+
+
+ UNEXPAND_ALL
+ 收起所有节点
+
+
+
+ UNEXPAND_TO_LEVEL(v0.2.8+)
+ 展开到指定层级
+ level(要展开到的层级,1、2、3...)
+
+
+ SET_NODE_DATA
+ 更新节点数据,即更新节点数据对象里data对象的数据
+ node(要设置的节点)、data(对象,要更新的数据,如{expand: true})
+
+
+ SET_NODE_TEXT
+ 设置节点文本
+
+ node(要设置的节点)、text(要设置的文本字符串,换行可以使用\n)、richText(v0.4.0+,如果要设置的是富文本字符,需要设为true)、resetRichText(v0.6.10+是否要复位富文本,默认为false,如果传true那么会重置富文本节点的样式)
+
+
+
+ SET_NODE_IMAGE
+ 设置节点图片
+ node(要设置的节点)、imgData(对象,图片信息,结构为:{url, title, width, height},图片的宽高必须要传)
+
+
+ SET_NODE_ICON
+ 设置节点图标
+ node(要设置的节点)、icons(数组,预定义的图片名称组成的数组,可用图标可在icons.js文件里的nodeIconList列表里获取到,图标名称为type_name,如['priority_1'])
+
+
+
+ SET_NODE_HYPERLINK
+ 设置节点超链接
+ node(要设置的节点)、link(超链接地址)、title(超链接名称,可选)
+
+
+ SET_NODE_NOTE
+ 设置节点备注
+ node(要设置的节点)、note(备注文字)
+
+
+ SET_NODE_TAG
+ 设置节点标签
+ node(要设置的节点)、tag(字符串数组,内置颜色信息可在constant.js里获取到)
+
+
+
+ INSERT_AFTER(v0.1.5+)
+ 将节点移动到另一个节点的后面
+ node(要移动的节点)、 exist(目标节点)
+
+
+ INSERT_BEFORE(v0.1.5+)
+ 将节点移动到另一个节点的前面
+ node(要移动的节点)、 exist(目标节点)
+
+
+ MOVE_NODE_TO(v0.1.5+)
+ 移动一个节点作为另一个节点的子节点
+ node(要移动的节点)、 toNode(目标节点)
+
+
+ ADD_GENERALIZATION(v0.2.0+)
+ 添加节点概要
+ data(概要的数据,对象格式,节点的数字段都支持,默认为{text: '概要'})
+
+
+ REMOVE_GENERALIZATION(v0.2.0+)
+ 删除节点概要
+
+
+
+ SET_NODE_CUSTOM_POSITION(v0.2.0+)
+ 设置节点自定义位置
+ node(要设置的节点)、 left(自定义的x坐标,默认为undefined)、 top(自定义的y坐标,默认为undefined)
+
+
+ RESET_LAYOUT(v0.2.0+)
+ 一键整理布局
+
+
+
+ SET_NODE_SHAPE(v0.2.4+)
+ 设置节点形状
+ node(要设置的节点)、shape(形状,全部形状:Shape.js)
+
+
+
+ GO_TARGET_NODE(v0.6.7+)
+ 定位到某个节点,如果该节点被收起,那么会自动展开到该节点
+ node(要定位到的节点实例或节点uid)、callback(v0.6.9+,定位完成后的回调函数)
+
+
+
+ setData(data)
+ 动态设置思维导图数据,纯节点数据
+ data:思维导图结构数据
+ setFullData(data)
+
+ v0.2.7+
+
+ 动态设置思维导图数据,包括节点数据、布局、主题、视图
+ data:完整数据,结构可参考exportFullData
+
+ getData(withConfig)
+
+ v0.2.9+
+
+ 获取思维导图数据
+ withConfig:Boolean,默认为false,即获取的数据只包括节点树,如果传true则会包含主题、布局、视图等数据
+
+ export(type, isDownload, fileName)
+
+ 需要先注册Export插件
+
+ 导出
+ type:要导出的类型,可选值:png、svg、json、pdf(v0.2.1+)、smm(本质也是json)
+ isDownload:是否需要直接触发下载,布尔值,默认为false
+ fileName:(v0.1.6+)导出文件的名称,默认为思维导图
+ 如果是导出为png,那么可以传递第四个参数:
+ transparent:v0.5.7+, Boolean,默认为false,指定导出图片的背景是否是透明的
+ 如果是导出为svg,那么可以传递第四个参数:
+ plusCssText:附加的css样式,如果svg中存在dom节点,想要设置一些针对节点的样式可以通过这个参数传入
+ 如果是导出为json或smm,那么可以传递第四个参数:
+ withConfig:Boolean,默认为true,指定导出的数据中是否包含配置数据,否则只导出纯节点树数据
+ toPos(x, y)
+
+ v0.1.5+
+
+ 将浏览器可视窗口的坐标转换成相对于画布的坐标
+ addPlugin(plugin, opt)
+
+ v0.4.0+
+
+ 注册插件,使用MindMap.usePlugin注册插件只能在实例化之前,实例化后注册的插件是不会生效的,所以如果想在实例化后注册插件可以使用实例的addPlugin方法。
+
+ removePlugin(plugin)
+
+ v0.4.0+
+
+ 移除注册的插件,无论是通过usePlugin还是addPlugin方法注册的插件都可以移除。