diff --git a/README.md b/README.md
index dd269b3a..04935180 100644
--- a/README.md
+++ b/README.md
@@ -169,4 +169,8 @@ const mindMap = new MindMap({
布林
+
+
+ 南风
+
Breaking change: Removed the section of node activation style in the theme file, Setting the activation style of nodes is no longer supported, and the activation effect has been changed to a unified node outer border style, while also supporting the mouse hover effect.
+Fix:
+++1.Fix rendering anomalies when the node border size is relatively large.
+2.Fixed an issue where the node style of the associated line will not be updated when switching themes.
+3.Fix that selecting all did not trigger node_ The issue with active events.
+
新增:
+++1.When folding nodes, displays the number of collapsed nodes.
+2.Support the position of the endpoint of the associated line to follow mouse drag changes.
+3.Add a scrollbar plugin.
+4.Support opening specified online files through fileURL query parameters in URLs.
+5.The fishbone diagram supports setting node margins.
+6.By default, double-click to reset the canvas.
+7.Modify the parameters of the export image method, and when exporting PDF, if the size of the mind map is smaller than A4 paper, do not rotate the direction.
+8.Improve the clarity of exported images and PDFs on high-definition screens.
+9.Add a pre destruction lifecycle function to the plugin to address the issue of some side effects that were not cleared during the destruction of the mind map.
+10.Optimize the settings of the basic style and do not trigger full rendering when modifying theme attributes that do not affect size.
+11.Prohibit triggering node right-click menu events when multiple node selections are completed, to avoid triggering the right-click menu display.
+12.Optimize the Select plugin so that if multiple selected nodes do not change, the activation event is not triggered.
+13.The activation node list thrown by event node_active no longer directly references the internal activation list.
+14.Optimize the logic of mouse button down node events, and support dragging the canvas by holding down the root node with the right mouse button in the right-click drag and drop canvas mode.
+
Demo:
++1.Do not directly reference the internal activation node list to optimize performance.
+2.Support configuring whether to display scrollbars.
+3.Delete the active node configuration in the sidebar node style configuration section.
+
Fix:
diff --git a/web/src/pages/Doc/en/constructor/index.md b/web/src/pages/Doc/en/constructor/index.md index 837f3268..4bf81074 100644 --- a/web/src/pages/Doc/en/constructor/index.md +++ b/web/src/pages/Doc/en/constructor/index.md @@ -48,8 +48,10 @@ const mindMap = new MindMap({ | 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' } | Expand the color of the stow button | | +| 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 | | @@ -80,7 +82,11 @@ const mindMap = new MindMap({ | 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 | Turn on the mouse and double-click to reset the position and zoom of the mind map | | +| 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 | | ### Watermark config @@ -337,8 +343,8 @@ redo. All commands are as follows: | 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 (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(boolean, whether the style being set is for the active state) | +| 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) | diff --git a/web/src/pages/Doc/en/constructor/index.vue b/web/src/pages/Doc/en/constructor/index.vue index 3df147c2..85fadc3a 100644 --- a/web/src/pages/Doc/en/constructor/index.vue +++ b/web/src/pages/Doc/en/constructor/index.vue @@ -1,1069 +1,6 @@-diff --git a/web/src/pages/Doc/en/doExport/index.md b/web/src/pages/Doc/en/doExport/index.md index 4a2f2c21..a3e37e12 100644 --- a/web/src/pages/Doc/en/doExport/index.md +++ b/web/src/pages/Doc/en/doExport/index.md @@ -38,13 +38,17 @@ a.download = 'xxx' a.click() ``` -### png(name, transparent = false, rotateWhenWidthLongerThenHeight) +### png(name, transparent = false, checkRotate) + +> Versions below v0.7.0 are: png(name, transparent = false, rotateWhenWidthLongerThenHeight) - `name`: Name, optional - `transparent`: v0.5.7+, Specify whether the background of the exported image is transparent -- `rotateWhenWidthLongerThenHeight`: v0.6.15+,Boolean, false, Automatically rotate 90 degrees when the image has a width to height ratio +- `rotateWhenWidthLongerThenHeight`: v0.6.15+, V0.7.0+abandoned, Boolean, false, Automatically rotate 90 degrees when the image has a width to height ratio + +- `checkRotate`: v0.7.0+, Function, You can pass a function that takes two parameters, the width and height of the image, and returns true or false. True represents that the image needs to be rotated by 90 degrees. Exports as `png`. diff --git a/web/src/pages/Doc/en/doExport/index.vue b/web/src/pages/Doc/en/doExport/index.vue index ee0db902..b087ccf8 100644 --- a/web/src/pages/Doc/en/doExport/index.vue +++ b/web/src/pages/Doc/en/doExport/index.vue @@ -27,7 +27,10 @@ a.href = 'xxx.png''xxx' a.click() -Constructor
-Basic use
--<div id="mindMapContainer"></div> --import MindMap from "simple-mind-map"; - -const mindMap = new MindMap({ - el: document.getElementById("mindMapContainer"), - data: { - "data": { - "text": "Root Node" - }, - "children": [] - } -}); -Instantiation options
-- -
-- - - -Field Name -Type -Default Value -Description -Required -- -el -Element -- Container element, must be a DOM element -Yes -- -data -Object -{} -Mind map data, refer to: exampleData.js -- - -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). IfcustomHandleMousewheelpasses a custom function, this property will not take effect- - -mousewheelMoveStep(v0.4.3+) -Number -100 -When the -mousewheelActionis set tomove, you can use this attribute to control the step length of the view movement when the mouse scrolls. The unit ispx- - -mousewheelZoomActionReverse(v0.6.5+) -Boolean -false -When -mousewheelActionis set tozoom, 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' } -Expand the color of the stow button -- - -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 -- - -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 tocenter, keywords can also be set toleft,top,right, andbottom, 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 at40%of the canvas width, and a vertical position at60%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 -isUseCustomNodeContentis set totrue, then this option needs to be used to pass in a method that receives the node instancenodeas a parameter (if you want to obtain data for that node, you can usenode.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 returnnull- - -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 -Turn on the mouse and double-click to reset the position and zoom of the mind map -- 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 ansvgicon, such as<svg ...><path></path></svg>, also can be a imageurl, orbase64icon, such asdata:image/png;base64,...Static methods
-defineTheme(name, config)
---v0.2.23+
-Define new theme.
--
name:New theme name-
config:New theme config-
Simple-mind-mapBuilt-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', {}) - -// 1.实例化时使用新注册的主题 -const mindMap = new MindMap({ - theme: '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 yGet the
-svgdata 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 - origWidth, // Number, canvas width - origHeight, // Number, canvas height - scaleX, // Number, horizontal zoom value of mind map graphics - scaleY, // Number, vertical zoom value of mind map graphics -} -render(callback)
--
-- -
callback:v0.3.2+,Function, Called when the re-rendering is completeTriggers 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 completePerforms 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、editon(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 -RichTextplugin is registered. Triggered when the text selection area changes when the node is editedhasRange(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 -RichTextplugin is registered. When there is aDOMnode insvg, theDOMnode 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 convertingindex(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.
-configis the same as thethemeConfigoption -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 passedGet config, That is,
-optofnew MindMap (opt)updateConfig(opt = {})
---0.2.24+
--
opt:Configuration to updateUpdate config,That is update
-optofnew 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
-layoutfield -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 (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(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 datasetFullData(data)
---v0.2.7+
-Dynamic setting of mind map data, including node data, layout, theme, view
--
data: complete data, structure can refer to -exportFullDatagetData(withConfig)
---v0.2.9+
-Gets mind map data
--
withConfig:Boolean, default isfalse, that is, the obtained data only -includes the node tree, iftrueis passed, it will also include theme, layout, -view, etc. dataexport(type, isDownload, fileName)
---You need to register the
-Exportplugin firstExport
--
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 isfalse, Specify whether the background of the exported image is transparentIf it is exported as
-svg, the fourth parameter can be passed:-
plusCssText: AdditionalCSSstyle. If there is adomnode insvg, you can pass in some styles specific to the node through this parameterIf it is exported as
-jsonorsmm, the fourth parameter can be passed:-
withConfig:Boolean, default istrue, Specify whether the exported data includes configuration data, otherwise only pure node tree data will be exportedtoPos(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.usePluginto 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 theaddPluginmethod of the instance.removePlugin(plugin)
---v0.4.0+
-Remove registered plugin, Plugins registered through the
- +usePluginoraddPluginmethods can be removed.png(name, transparent = false, rotateWhenWidthLongerThenHeight)
+png(name, transparent = false, checkRotate)
++Versions below v0.7.0 are: png(name, transparent = false, rotateWhenWidthLongerThenHeight)
+
@@ -36,7 +39,10 @@ a.click()
name: Name, optional
transparent: v0.5.7+, Specify whether the background of the exported image is transparent- -
++
rotateWhenWidthLongerThenHeight: v0.6.15+,Boolean, false, Automatically rotate 90 degrees when the image has a width to height ratio+
rotateWhenWidthLongerThenHeight: v0.6.15+, V0.7.0+abandoned, Boolean, false, Automatically rotate 90 degrees when the image has a width to height ratio- +
checkRotate: v0.7.0+, Function, You can pass a function that takes two parameters, the width and height of the image, and returns true or false. True represents that the image needs to be rotated by 90 degrees.Exports as
diff --git a/web/src/pages/Doc/en/introduction/index.md b/web/src/pages/Doc/en/introduction/index.md index 47970b2b..1f856d9e 100644 --- a/web/src/pages/Doc/en/introduction/index.md +++ b/web/src/pages/Doc/en/introduction/index.md @@ -188,4 +188,8 @@ Open source is not easy. If this project is helpful to you, you can invite the apng.![]()
布林
南风
+布林
+南风
+Get the final style value applied to this node
prop: the style property to get
root: whether it is the root node, default false
isActive: whether the value being fetched is the active state style value,
+
isActive: v0.7.0+has been abandoned, whether the value being fetched is the active state style value,
default false
isActive: v0.7.0+has been abandonedModify a style of the node, a shortcut method for the SET_NODE_STYLE command
+v0.6.12+
isActive: v0.7.0+has been abandonedModify multiple styles of nodes, a shortcut method for the SET_NODE_STYLES command
Get the specified value in the v0.7.0+ This plugin is used to help develop the functionality of horizontal and vertical scrollbar. After registration and instantiation of Triggered when the scrollbar data changes, you can listen to this event to update the position and size of the scrollbar. Set the size of the scroll bar container, which is the width of the container for horizontal scrollbars and the height of the container for vertical scrollbars. When your scrollbar container size changes, you need to call this method again. You need to first call the setScrollBarWrapSize method to set the width and height of the scroll bar container element. Generally, it is necessary to monitor scrollbar_change event, and then call it to update the scroll bar. Return value: Obtain the size and position of the scroll bar, and you can set it to the scroll bar element based on the return value to achieve the effect of rendering and caring about the scroll bar. This method needs to be called when the mouse press event of the scrollbar element occurs.data object of the node's real data nodeData,
diff --git a/web/src/pages/Doc/en/scrollbar/index.md b/web/src/pages/Doc/en/scrollbar/index.md
new file mode 100644
index 00000000..10974f51
--- /dev/null
+++ b/web/src/pages/Doc/en/scrollbar/index.md
@@ -0,0 +1,64 @@
+# Scrollbar plugin
+
+> v0.7.0+
+
+This plugin is used to help develop the functionality of horizontal and vertical scrollbar.
+
+## Register
+
+```js
+import MindMap from 'simple-mind-map'
+import Scrollbar from 'simple-mind-map/src/plugins/Scrollbar.js'
+MindMap.usePlugin(Scrollbar)
+```
+
+After registration and instantiation of `MindMap`, the instance can be obtained through `mindMap.scrollbar`.
+
+## Event
+
+#### scrollbar_change
+
+Triggered when the scrollbar data changes, you can listen to this event to update the position and size of the scrollbar.
+
+## Method
+
+### setScrollBarWrapSize(width, height)
+
+- `width`: Number, The width of your scrollbar container element.
+
+- `height`: Number, The height of your scrollbar container element.
+
+Set the size of the scroll bar container, which is the width of the container for horizontal scrollbars and the height of the container for vertical scrollbars. When your scrollbar container size changes, you need to call this method again.
+
+### calculationScrollbar()
+
+> You need to first call the setScrollBarWrapSize method to set the width and height of the scroll bar container element.
+>
+> Generally, it is necessary to monitor scrollbar_change event, and then call it to update the scroll bar.
+
+Return value:
+
+```js
+{
+ // Vertical scrollbar
+ vertical: {
+ top,
+ height
+ },
+ // Horizontal scrollbar
+ horizontal: {
+ left,
+ width
+ }
+}
+```
+
+Obtain the size and position of the scroll bar, and you can set it to the scroll bar element based on the return value to achieve the effect of rendering and caring about the scroll bar.
+
+### onMousedown(e, type)
+
+- `e`: The event object for the mouse down event.
+
+- `type`: The type of scroll bar pressed, vertical(Vertical scrollbar)、horizontal(Horizontal scrollbar)。
+
+This method needs to be called when the mouse press event of the scrollbar element occurs.
\ No newline at end of file
diff --git a/web/src/pages/Doc/en/scrollbar/index.vue b/web/src/pages/Doc/en/scrollbar/index.vue
new file mode 100644
index 00000000..d5851f33
--- /dev/null
+++ b/web/src/pages/Doc/en/scrollbar/index.vue
@@ -0,0 +1,70 @@
+
+ Scrollbar plugin
+
+
+Register
+
+import MindMap from 'simple-mind-map'
+import Scrollbar from 'simple-mind-map/src/plugins/Scrollbar.js'
+MindMap.usePlugin(Scrollbar)
+MindMap, the instance can be obtained through mindMap.scrollbar.Event
+scrollbar_change
+Method
+setScrollBarWrapSize(width, height)
+
+
+width: Number, The width of your scrollbar container element.height: Number, The height of your scrollbar container element.calculationScrollbar()
+
+
+
+{
+ // Vertical scrollbar
+ vertical: {
+ top,
+ height
+ },
+ // Horizontal scrollbar
+ horizontal: {
+ left,
+ width
+ }
+}
+onMousedown(e, type)
+
+
+e: The event object for the mouse down event.type: The type of scroll bar pressed, vertical(Vertical scrollbar)、horizontal(Horizontal scrollbar)。
After registration and instantiation of MindMap, the instance can be obtained through mindMap.Search.
After registration and instantiation of MindMap, the instance can be obtained through mindMap.search.
You can listen to 'search_info_change' event to get the number of current search results and the index currently located.
diff --git a/web/src/pages/Doc/routerList.js b/web/src/pages/Doc/routerList.js index 578b9aa2..88f8964b 100644 --- a/web/src/pages/Doc/routerList.js +++ b/web/src/pages/Doc/routerList.js @@ -29,6 +29,8 @@ export default [ { path: 'course20', title: '如何自定义节点内容' }, { path: 'course21', title: '如何复制、剪切、粘贴' }, { path: 'course22', title: '如何实现搜索、替换' }, + { path: 'course23', title: '如何渲染滚动条' }, + { path: 'course24', title: '如何开发一个插件' }, { path: 'doExport', title: 'Export 插件' }, { path: 'drag', title: 'Drag插件' }, { path: 'introduction', title: '简介' }, @@ -52,7 +54,8 @@ export default [ { path: 'nodeImgAdjust', title: 'NodeImgAdjust插件' }, { path: 'search', title: 'Search插件' }, { path: 'painter', title: 'Painter插件' }, - { path: 'help1', title: '概要/关联线' }, + { path: 'painter', title: 'Painter插件' }, + { path: 'scrollbar', title: 'Scrollbar插件' }, { path: 'help2', title: '客户端' } ] }, @@ -85,7 +88,8 @@ export default [ { path: 'touchEvent', title: 'TouchEvent plugin' }, { path: 'nodeImgAdjust', title: 'NodeImgAdjust plugin' }, { path: 'search', title: 'Search plugin' }, - { path: 'painter', title: 'Painter plugin' } + { path: 'painter', title: 'Painter plugin' }, + { path: 'scrollbar', title: 'Scrollbar plugin' } ] } ] diff --git a/web/src/pages/Doc/zh/changelog/index.md b/web/src/pages/Doc/zh/changelog/index.md index 213a6609..32722852 100644 --- a/web/src/pages/Doc/zh/changelog/index.md +++ b/web/src/pages/Doc/zh/changelog/index.md @@ -1,5 +1,55 @@ # Changelog +## 0.7.0 + +破坏性更新:删除了主题文件中节点激活样式的部分,不再支持设置节点的激活样式,激活效果改为统一的节点外边框样式,同时支持鼠标hover效果。 + +修复: + +> 1.修复节点边框尺寸比较大的情况下的的渲染异常问题。 +> +> 2.修复切换主题时存在关联线的节点样式不会更新的问题。 +> +> 3.修复全选没有触发node_active事件的问题。 + +新增: + +> 1.收起节点时,显示折叠的节点数量。 +> +> 2.支持关联线端点的位置跟随鼠标拖拽变化。 +> +> 3.新增滚动条插件。 +> +> 4.支持在url中通过fileURL查询参数打开指定的在线文件。 +> +> 5.鱼骨图支持设置节点margin。 +> +> 6.默认关闭双击复位画布。 +> +> 7.修改导出图片方法的参数,导出pdf时如果思维导图尺寸小于a4纸那么不旋转方向。 +> +> 8.提升导出的图片和pdf在高清屏的清晰度。 +> +> 9.插件新增销毁前生命周期函数,解决销毁思维导图时插件的一些副作用没有清除的问题。 +> +> 10.优化基础样式的设置,修改不影响大小的主题属性时不触发全量渲染。 +> +> 11.右键多选节点结束时禁止触发节点右键菜单事件,避免触发右键菜单显示。 +> +> 12.优化Select插件,如果多选节点没有变化,那么不触发激活激活事件。 +> +> 13.node_active事件抛出的激活节点列表不再直接引用内部激活列表。 +> +> 14.优化鼠标按下节点事件逻辑,在右键拖拽画布模式下支持右键按住根节点拖拽画布。 + +Demo: + +> 1.不直接引用内部激活节点列表,优化性能。 +> +> 2.支持配置是否显示滚动条。 +> +> 3.删除侧边栏节点样式配置部分的激活节点配置。 + ## 0.6.17 修复: diff --git a/web/src/pages/Doc/zh/changelog/index.vue b/web/src/pages/Doc/zh/changelog/index.vue index a98e89cd..73cfeb0f 100644 --- a/web/src/pages/Doc/zh/changelog/index.vue +++ b/web/src/pages/Doc/zh/changelog/index.vue @@ -1,6 +1,37 @@破坏性更新:删除了主题文件中节点激活样式的部分,不再支持设置节点的激活样式,激活效果改为统一的节点外边框样式,同时支持鼠标hover效果。
+修复:
+++1.修复节点边框尺寸比较大的情况下的的渲染异常问题。
+2.修复切换主题时存在关联线的节点样式不会更新的问题。
+3.修复全选没有触发node_active事件的问题。
+
新增:
+++1.收起节点时,显示折叠的节点数量。
+2.支持关联线端点的位置跟随鼠标拖拽变化。
+3.新增滚动条插件。
+4.支持在url中通过fileURL查询参数打开指定的在线文件。
+5.鱼骨图支持设置节点margin。
+6.默认关闭双击复位画布。
+7.修改导出图片方法的参数,导出pdf时如果思维导图尺寸小于a4纸那么不旋转方向。
+8.提升导出的图片和pdf在高清屏的清晰度。
+9.插件新增销毁前生命周期函数,解决销毁思维导图时插件的一些副作用没有清除的问题。
+10.优化基础样式的设置,修改不影响大小的主题属性时不触发全量渲染。
+11.右键多选节点结束时禁止触发节点右键菜单事件,避免触发右键菜单显示。
+12.优化Select插件,如果多选节点没有变化,那么不触发激活激活事件。
+13.node_active事件抛出的激活节点列表不再直接引用内部激活列表。
+14.优化鼠标按下节点事件逻辑,在右键拖拽画布模式下支持右键按住根节点拖拽画布。
+
Demo:
++1.不直接引用内部激活节点列表,优化性能。
+2.支持配置是否显示滚动条。
+3.删除侧边栏节点样式配置部分的激活节点配置。
+
修复:
diff --git a/web/src/pages/Doc/zh/constructor/index.md b/web/src/pages/Doc/zh/constructor/index.md index 177545f9..25bf7083 100644 --- a/web/src/pages/Doc/zh/constructor/index.md +++ b/web/src/pages/Doc/zh/constructor/index.md @@ -48,8 +48,10 @@ const mindMap = new MindMap({ | 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' } | 展开收起按钮的颜色 | | +| 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 | | @@ -80,7 +82,11 @@ const mindMap = new MindMap({ | 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 | 开启鼠标双击复位思维导图位置及缩放 | | +| 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 | 双击节点进入节点文本编辑时是否默认选中文本,默认只在创建新节点时会选中 | | ### 水印配置 @@ -330,8 +336,8 @@ mindMap.updateConfig({ | REMOVE_NODE | 删除节点,操作节点为当前激活的节点或指定节点 | appointNodes(v0.4.7+,可选,指定节点,指定多个节点可以传一个数组) | | PASTE_NODE | 粘贴节点到节点,操作节点为当前激活的节点 | data(要粘贴的节点数据,一般通过`renderer.copyNode()`方法和`renderer.cutNode()`方法获取) | | CUT_NODE | 剪切节点,操作节点为当前激活的节点,如果有多个激活节点,只会对第一个有效,对根节点使用无效 | callback(回调函数,剪切的节点数据会通过调用该函数并通过参数返回) | -| SET_NODE_STYLE | 修改节点单个样式 | node(要设置样式的节点)、style(样式属性)、value(样式属性值)、isActive(布尔值,是否设置的是激活状态的样式) | -| SET_NODE_STYLEs(v0.6.12+) | 修改节点多个样式 | node(要设置样式的节点)、style(样式对象,key为样式属性,value为样式值)、isActive(布尔值,是否设置的是激活状态的样式) | +| 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(布尔值,是否展开) | diff --git a/web/src/pages/Doc/zh/constructor/index.vue b/web/src/pages/Doc/zh/constructor/index.vue index 675b575e..6e34e391 100644 --- a/web/src/pages/Doc/zh/constructor/index.vue +++ b/web/src/pages/Doc/zh/constructor/index.vue @@ -199,8 +199,8 @@expandBtnStyle(v0.5.0+) Object -{ color: '#808080', fill: '#fff' } -展开收起按钮的颜色 +{ color: '#808080', fill: '#fff', fontSize: 13, strokeColor: '#333333' } +展开收起按钮的颜色,(fontSize及strokeColor字段为0.7.0+版本新增的,用于设置收起时显示节点数量的文字样式) @@ -211,6 +211,20 @@ + +expandBtnNumHandler(v0.7.0+) +Function ++ 用于自定义收起时显示节点数量的内容,接收一个参数,代表收起的节点实例,需要返回一个数字或字符串,代表最终显示的内容,比如你可以当数量大于99时,显示99+ ++ + +isShowExpandNum(v0.7.0+) +Boolean +true +节点收起时是否显示收起的数量 ++ enableShortcutOnlyWhenMouseInSvg(v0.5.1+) Boolean true @@ -423,10 +437,38 @@+ enableDblclickReset(v0.6.17+) Boolean -true +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 +双击节点进入节点文本编辑时是否默认选中文本,默认只在创建新节点时会选中 ++ 水印配置
@@ -888,12 +930,12 @@ mindMap.setTheme('主题名称')SET_NODE_STYLE 修改节点单个样式 -node(要设置样式的节点)、style(样式属性)、value(样式属性值)、isActive(布尔值,是否设置的是激活状态的样式) +node(要设置样式的节点)、style(样式属性)、value(样式属性值)、isActive(v0.7.0+已废弃,布尔值,是否设置的是激活状态的样式) SET_NODE_STYLEs(v0.6.12+) 修改节点多个样式 -node(要设置样式的节点)、style(样式对象,key为样式属性,value为样式值)、isActive(布尔值,是否设置的是激活状态的样式) +node(要设置样式的节点)、style(样式对象,key为样式属性,value为样式值)、isActive(v0.7.0+已废弃,布尔值,是否设置的是激活状态的样式) SET_NODE_ACTIVE diff --git a/web/src/pages/Doc/zh/course23/index.md b/web/src/pages/Doc/zh/course23/index.md new file mode 100644 index 00000000..ca16355c --- /dev/null +++ b/web/src/pages/Doc/zh/course23/index.md @@ -0,0 +1,116 @@ +# 如何渲染滚动条 + +> 需要先注册 Scrollbar 插件 + +滚动条分为水平和垂直滚动条,所以你需要创建如下模板: + +```html + + + + + +``` + +外层元素为滚动条容器元素,内层为滚动条元素。 + +内层滚动条元素一般需要设置成绝对定位,样式示例如下: + +```css +.scrollbar { + position: relative; + background-color: #f5f5f5; + border-radius: 10px; + overflow: hidden; + + &.verticalScrollbar { + width: 10px; + height: 500px; + + .scrollbarInner { + width: 10px; + left: 0; + } + } + + &.horizontalScrollbar { + width: 500px; + height: 10px; + + .scrollbarInner { + height: 10px; + top: 0; + } + } + + .scrollbarInner { + position: absolute; + background-color: #ccc; + border-radius: 10px; + } +} +``` + +垂直滚动条的`top`和`height`、水平滚动条的`left`和`width`值需要调用插件的方法获取。 + +首先你需要调用`setScrollBarWrapSize`方法传递你的滚动条容器的宽和高: + +```js +// 水平滚动条容器的宽度 +const { width } = this.$refs.horizontalScrollbarRef.getBoundingClientRect() +// 垂直滚动条容器的高度 +const { height } = this.$refs.verticalScrollbarRef.getBoundingClientRect() +mindMap.scrollbar.setScrollBarWrapSize(width, height) +``` + +如果容器大小发生了改变需要再次调用该方法传递改变后的大小。 + +然后你需要监听`scrollbar_change`方法来获取滚动条大小和位置数据: + +```js +mindMap.('scrollbar_change', this.updateScrollbar) + +// 调用插件方法更新滚动条位置和大小 +{ + updateScrollbar() { + const { + vertical, + horizontal + } = mindMap.scrollbar.calculationScrollbar() + this.verticalScrollbarStyle = { + top: vertical.top + '%', + height: vertical.height + '%' + } + this.horizontalScrollbarStyle = { + left: horizontal.left + '%', + width: horizontal.width + '%' + } + } +} +``` + +调用插件的`calculationScrollbar`方法来获取滚动条元素的位置和大小,返回的是百分比数值,所以需要添加`%`。 + +最后,需要给滚动条元素绑定`mousedown`事件,并且调用插件的`onMousedown`方法: + +```js +// 垂直滚动条元素 +mindMap.scrollbar.onMousedown(e, 'vertical') + +// 水平滚动条元素 +mindMap.scrollbar.onMousedown(e, 'horizontal') +``` + +以上就是实现滚动条渲染的全部步骤。 \ No newline at end of file diff --git a/web/src/pages/Doc/zh/course23/index.vue b/web/src/pages/Doc/zh/course23/index.vue new file mode 100644 index 00000000..f2839237 --- /dev/null +++ b/web/src/pages/Doc/zh/course23/index.vue @@ -0,0 +1,112 @@ + +++ + + + + \ No newline at end of file diff --git a/web/src/pages/Doc/zh/course24/index.md b/web/src/pages/Doc/zh/course24/index.md new file mode 100644 index 00000000..414b6465 --- /dev/null +++ b/web/src/pages/Doc/zh/course24/index.md @@ -0,0 +1,65 @@ +# 如何开发一个插件 + +库本身提供了一些插件,如果满足不了你的需求,你也可以自己开发一个新插件。 + +想要开发一个插件,你肯定需要对库的实现原理、模块划分、目录结构等等有一定了解,简而言之,需要你对库的源码有一定程度的熟悉,所以如果还没看过,现在就可以先去阅读一下,好消息是,本库的源码并不复杂,相信你一定能看懂。 + +在你决定动手之前,最好先看一下内部插件是如何实现的。 + +一个插件就是一个类: + +```js +class YourPlugin { + constructor({ mindMap }) { + this.mindMap = mindMap + } + + // 插件被移除前做的事情 + beforePluginRemove() { + + } + + // 插件被卸载前做的事情 + beforePluginDestroy() { + + } +} + +Scrollbar.instanceName = 'yourPlugin' +``` + +实例化插件时会传入思维导图实例,你可以保存起来,后续可以通过它来监听方法或调用实例的方法,甚至是其他插件的方法。 + +需要给插件类添加一个静态属性`instanceName`,会将你的插件实例通过该属性保存到思维导图实例上,外部或其他插件想要获取你的插件实例时都需要通过该属性: + +```js +mindMap.yourPlugin.xxx +``` + +插件存在两个生命周期函数: + +`beforePluginRemove`生命周期会在思维导图实例调用`removePlugin`方法时调用,代表思维导图实例并没有销毁,只是移除该插件。 + +`beforePluginDestroy`生命周期会在销毁思维导图时调用,此时思维导图实例也会被销毁。 + +```js +mindMap.removePlugin(YourPlugin) +``` + +你也可以继承内部的一些插件: + +```js +import ScrollbarPlugin from 'simple-mind-map/src/plugins/Scrollbar.js' + +class YourPlugin extends ScrollbarPlugin { + constructor(opt) { + super(opt) + } +} + +Scrollbar.instanceName = 'yourPlugin' +``` + +插件的原理无非是监听一些你需要的事件,然后调用一些你需要的方法来完成一些功能,其实没啥好多说的,建议看一下内部插件的实现。 + +当你完成了一个插件后,你可以考虑发布到`npm`,提供给其他开发者使用。 \ No newline at end of file diff --git a/web/src/pages/Doc/zh/course24/index.vue b/web/src/pages/Doc/zh/course24/index.vue new file mode 100644 index 00000000..fc72aea2 --- /dev/null +++ b/web/src/pages/Doc/zh/course24/index.vue @@ -0,0 +1,60 @@ + +如何渲染滚动条
+++需要先注册 Scrollbar 插件
+滚动条分为水平和垂直滚动条,所以你需要创建如下模板:
++<!-- 垂直 --> +<div class="scrollbar verticalScrollbar" ref="verticalScrollbarRef"> + <div + class="scrollbarInner" + :style="verticalScrollbarStyle" + @mousedown="onVerticalScrollbarMousedown" + ></div> +</div> + +<!-- 水平 --> +<div class="scrollbar horizontalScrollbar" ref="horizontalScrollbarRef"> + <div + class="scrollbarInner" + :style="horizontalScrollbarStyle" + @mousedown="onHorizontalScrollbarMousedown" + ></div> +</div> +外层元素为滚动条容器元素,内层为滚动条元素。
+内层滚动条元素一般需要设置成绝对定位,样式示例如下:
++.scrollbar { + position: relative; + background-color: #f5f5f5; + border-radius: 10px; + overflow: hidden; + + &.verticalScrollbar { + width: 10px; + height: 500px; + + .scrollbarInner { + width: 10px; + left: 0; + } + } + + &.horizontalScrollbar { + width: 500px; + height: 10px; + + .scrollbarInner { + height: 10px; + top: 0; + } + } + + .scrollbarInner { + position: absolute; + background-color: #ccc; + border-radius: 10px; + } +} +垂直滚动条的
+top和height、水平滚动条的left和width值需要调用插件的方法获取。首先你需要调用
+setScrollBarWrapSize方法传递你的滚动条容器的宽和高:+// 水平滚动条容器的宽度 +const { width } = this.$refs.horizontalScrollbarRef.getBoundingClientRect() +// 垂直滚动条容器的高度 +const { height } = this.$refs.verticalScrollbarRef.getBoundingClientRect() +mindMap.scrollbar.setScrollBarWrapSize(width, height) +如果容器大小发生了改变需要再次调用该方法传递改变后的大小。
+然后你需要监听
+scrollbar_change方法来获取滚动条大小和位置数据:+mindMap.('scrollbar_change', this.updateScrollbar) + +// 调用插件方法更新滚动条位置和大小 +{ + updateScrollbar() { + const { + vertical, + horizontal + } = mindMap.scrollbar.calculationScrollbar() + this.verticalScrollbarStyle = { + top: vertical.top + '%', + height: vertical.height + '%' + } + this.horizontalScrollbarStyle = { + left: horizontal.left + '%', + width: horizontal.width + '%' + } + } +} +调用插件的
+calculationScrollbar方法来获取滚动条元素的位置和大小,返回的是百分比数值,所以需要添加%。最后,需要给滚动条元素绑定
+mousedown事件,并且调用插件的onMousedown方法:+// 垂直滚动条元素 +mindMap.scrollbar.onMousedown(e, 'vertical') + +// 水平滚动条元素 +mindMap.scrollbar.onMousedown(e, 'horizontal') +以上就是实现滚动条渲染的全部步骤。
+ +++ + + + + \ No newline at end of file diff --git a/web/src/pages/Doc/zh/course3/index.md b/web/src/pages/Doc/zh/course3/index.md index 60b214d2..2a662381 100644 --- a/web/src/pages/Doc/zh/course3/index.md +++ b/web/src/pages/Doc/zh/course3/index.md @@ -14,6 +14,28 @@ mindMap.execCommand('INSERT_CHILD_NODE') `INSERT_CHILD_NODE`命令还支持传入几个参数,详细详细请阅读【API】-【构造函数】-【execCommand方法】。 +如果你想获取插入节点的实例,可以这样操作: + +1.需要指定新插入节点的`id`,比如: + +```js +import { createUid } from 'simple-mind-map/src/utils' + +let uid = createUid() +mindMap.execCommand('INSERT_CHILD_NODE', false, [], { + uid +}) +``` + +2.然后在`node_tree_render_end`事件里通过该`id`来获取实例: + +```js +mindMap.on('node_tree_render_end', () => { + // 调用renderer实例的findNodeByUid方法获取到节点的实例对象 + const node = mindMap.renderer.findNodeByUid(uid) +}) +``` + ## 插入兄弟节点 插入兄弟节点和插入子节点方式完全一致: diff --git a/web/src/pages/Doc/zh/course3/index.vue b/web/src/pages/Doc/zh/course3/index.vue index b502c9cf..d2e3d874 100644 --- a/web/src/pages/Doc/zh/course3/index.vue +++ b/web/src/pages/Doc/zh/course3/index.vue @@ -8,6 +8,21 @@如何开发一个插件
+库本身提供了一些插件,如果满足不了你的需求,你也可以自己开发一个新插件。
+想要开发一个插件,你肯定需要对库的实现原理、模块划分、目录结构等等有一定了解,简而言之,需要你对库的源码有一定程度的熟悉,所以如果还没看过,现在就可以先去阅读一下,好消息是,本库的源码并不复杂,相信你一定能看懂。
+在你决定动手之前,最好先看一下内部插件是如何实现的。
+一个插件就是一个类:
++class YourPlugin { + constructor({ mindMap }) { + this.mindMap = mindMap + } + + // 插件被移除前做的事情 + beforePluginRemove() { + + } + + // 插件被卸载前做的事情 + beforePluginDestroy() { + + } +} + +Scrollbar.instanceName = 'yourPlugin' +实例化插件时会传入思维导图实例,你可以保存起来,后续可以通过它来监听方法或调用实例的方法,甚至是其他插件的方法。
+需要给插件类添加一个静态属性
+instanceName,会将你的插件实例通过该属性保存到思维导图实例上,外部或其他插件想要获取你的插件实例时都需要通过该属性:+mindMap.yourPlugin.xxx +插件存在两个生命周期函数:
++
beforePluginRemove生命周期会在思维导图实例调用removePlugin方法时调用,代表思维导图实例并没有销毁,只是移除该插件。+
beforePluginDestroy生命周期会在销毁思维导图时调用,此时思维导图实例也会被销毁。+mindMap.removePlugin(YourPlugin) +你也可以继承内部的一些插件:
++import ScrollbarPlugin from 'simple-mind-map/src/plugins/Scrollbar.js' + +class YourPlugin extends ScrollbarPlugin { + constructor(opt) { + super(opt) + } +} + +Scrollbar.instanceName = 'yourPlugin' +插件的原理无非是监听一些你需要的事件,然后调用一些你需要的方法来完成一些功能,其实没啥好多说的,建议看一下内部插件的实现。
+当你完成了一个插件后,你可以考虑发布到
+ +npm,提供给其他开发者使用。这样就会在当前激活节点(如果存在多个激活节点,默认会操作第一个激活节点)下添加一个子节点。
+
INSERT_CHILD_NODE命令还支持传入几个参数,详细详细请阅读【API】-【构造函数】-【execCommand方法】。如果你想获取插入节点的实例,可以这样操作:
+1.需要指定新插入节点的
+id,比如:+import { createUid } from 'simple-mind-map/src/utils' + +let uid = createUid() +mindMap.execCommand('INSERT_CHILD_NODE', false, [], { + uid +}) +2.然后在
+node_tree_render_end事件里通过该id来获取实例:mindMap.on('node_tree_render_end', () => { + // 调用renderer实例的findNodeByUid方法获取到节点的实例对象 + const node = mindMap.renderer.findNodeByUid(uid) +}) +插入兄弟节点
插入兄弟节点和插入子节点方式完全一致:
-mindMap.execCommand('INSERT_NODE') diff --git a/web/src/pages/Doc/zh/doExport/index.md b/web/src/pages/Doc/zh/doExport/index.md index aa8904e9..3ff4f23e 100644 --- a/web/src/pages/Doc/zh/doExport/index.md +++ b/web/src/pages/Doc/zh/doExport/index.md @@ -38,13 +38,17 @@ a.download = 'xxx' a.click() ``` -### png(name, transparent = false, rotateWhenWidthLongerThenHeight) +### png(name, transparent = false, checkRotate) + +> v0.7.0以下版本为: png(name, transparent = false, rotateWhenWidthLongerThenHeight) - `name`:名称,可不传 - `transparent`:v0.5.7+,指定导出图片的背景是否是透明的 -- `rotateWhenWidthLongerThenHeight`: v0.6.15+,Boolean, false, 是否在图片宽比高长时自动旋转90度 +- `rotateWhenWidthLongerThenHeight`: v0.6.15+,v0.7.0+已废弃,Boolean, false, 是否在图片宽比高长时自动旋转90度 + +- `checkRotate`:v0.7.0+,Function,可以传递一个函数,接收图片的宽度和高度两个参数,返回true或false,true代表图片需要旋转90度。 导出为`png`。 diff --git a/web/src/pages/Doc/zh/doExport/index.vue b/web/src/pages/Doc/zh/doExport/index.vue index ecc32688..58f05daf 100644 --- a/web/src/pages/Doc/zh/doExport/index.vue +++ b/web/src/pages/Doc/zh/doExport/index.vue @@ -27,7 +27,10 @@ a.href = 'xxx.png''xxx' a.click()png(name, transparent = false, rotateWhenWidthLongerThenHeight)
+png(name, transparent = false, checkRotate)
++v0.7.0以下版本为: png(name, transparent = false, rotateWhenWidthLongerThenHeight)
+
@@ -36,7 +39,10 @@ a.click()
name:名称,可不传
transparent:v0.5.7+,指定导出图片的背景是否是透明的- -
++
rotateWhenWidthLongerThenHeight: v0.6.15+,Boolean, false, 是否在图片宽比高长时自动旋转90度+
rotateWhenWidthLongerThenHeight: v0.6.15+,v0.7.0+已废弃,Boolean, false, 是否在图片宽比高长时自动旋转90度- +
checkRotate:v0.7.0+,Function,可以传递一个函数,接收图片的宽度和高度两个参数,返回true或false,true代表图片需要旋转90度。导出为
diff --git a/web/src/pages/Doc/zh/introduction/index.md b/web/src/pages/Doc/zh/introduction/index.md index 17bf4a93..f901afa0 100644 --- a/web/src/pages/Doc/zh/introduction/index.md +++ b/web/src/pages/Doc/zh/introduction/index.md @@ -181,4 +181,8 @@png。![]()
布林
++\ No newline at end of file diff --git a/web/src/pages/Doc/zh/introduction/index.vue b/web/src/pages/Doc/zh/introduction/index.vue index 24a656ec..9420382d 100644 --- a/web/src/pages/Doc/zh/introduction/index.vue +++ b/web/src/pages/Doc/zh/introduction/index.vue @@ -141,6 +141,10 @@+
南风
+![]()
布林
++diff --git a/web/src/pages/Doc/zh/node/index.md b/web/src/pages/Doc/zh/node/index.md index dd7ea6a9..67706eb7 100644 --- a/web/src/pages/Doc/zh/node/index.md +++ b/web/src/pages/Doc/zh/node/index.md @@ -110,16 +110,20 @@ `root`:是否是根节点,默认`false` -`isActive`:获取的是否是激活状态的样式值,默认`false` +`isActive`:v0.7.0+已废弃,获取的是否是激活状态的样式值,默认`false` ### setStyle(prop, value, isActive) +`isActive`:v0.7.0+已废弃 + 修改节点的某个样式,`SET_NODE_STYLE`命令的快捷方法 ### setStyles(style, isActive) > v0.6.12+ +`isActive`:v0.7.0+已废弃 + 修改节点多个样式,`SET_NODE_STYLES`命令的快捷方法 ### getData(key) diff --git a/web/src/pages/Doc/zh/node/index.vue b/web/src/pages/Doc/zh/node/index.vue index ffc2a5cc..8642a410 100644 --- a/web/src/pages/Doc/zh/node/index.vue +++ b/web/src/pages/Doc/zh/node/index.vue @@ -64,13 +64,15 @@+
南风
+获取某个最终应用到该节点的样式值
prop:要获取的样式属性-
root:是否是根节点,默认false+
isActive:获取的是否是激活状态的样式值,默认false
isActive:v0.7.0+已废弃,获取的是否是激活状态的样式值,默认falsesetStyle(prop, value, isActive)
+
isActive:v0.7.0+已废弃修改节点的某个样式,
SET_NODE_STYLE命令的快捷方法setStyles(style, isActive)
+v0.6.12+
isActive:v0.7.0+已废弃修改节点多个样式,
SET_NODE_STYLES命令的快捷方法getData(key)
获取该节点真实数据
diff --git a/web/src/pages/Doc/zh/scrollbar/index.md b/web/src/pages/Doc/zh/scrollbar/index.md new file mode 100644 index 00000000..49a20d1e --- /dev/null +++ b/web/src/pages/Doc/zh/scrollbar/index.md @@ -0,0 +1,64 @@ +# Scrollbar 插件 + +> v0.7.0+ + +该插件用于帮助开发水平和垂直滚动条的功能。 + +## 注册 + +```js +import MindMap from 'simple-mind-map' +import Scrollbar from 'simple-mind-map/src/plugins/Scrollbar.js' +MindMap.usePlugin(Scrollbar) +``` + +注册完且实例化`MindMap`后可通过`mindMap.scrollbar`获取到该实例。 + +## 事件 + +#### scrollbar_change + +当滚动条数据发生改变时触发,你可以监听该事件来更新滚动条位置和大小。 + +## 方法 + +### setScrollBarWrapSize(width, height) + +- `width`:Number,你的滚动条容器元素的宽度。 + +- `height`: Number,你的滚动条容器元素的高度。 + +设置滚动条容器的大小,对于水平滚动条,即容器的宽度,对于垂直滚动条,即容器的高度。当你的滚动条容器尺寸改变时需要再次调用该方法。 + +### calculationScrollbar() + +> 需要先调用setScrollBarWrapSize方法设置滚动条容器元素的宽高。 +> +> 一般需要监听scrollbar_change事件,然后调用该方法更新滚动条。 + +返回值: + +```js +{ + // 垂直滚动条 + vertical: { + top, + height + }, + // 水平滚动条 + horizontal: { + left, + width + } +} +``` + +获取滚动条大小和位置,你可以根据返回值来设置到滚动条元素上,达到渲染和关心滚动条的效果。 + +### onMousedown(e, type) + +- `e`:鼠标按下事件的事件对象。 + +- `type`:按下的滚动条类型,vertical(垂直滚动条)、horizontal(水平滚动条)。 + +滚动条元素的鼠标按下事件时需要调用该方法。 \ No newline at end of file diff --git a/web/src/pages/Doc/zh/scrollbar/index.vue b/web/src/pages/Doc/zh/scrollbar/index.vue new file mode 100644 index 00000000..fc06ba0f --- /dev/null +++ b/web/src/pages/Doc/zh/scrollbar/index.vue @@ -0,0 +1,70 @@ + +nodeData的data对象里的指定值,key不传返回这个data对象++ + + + + \ No newline at end of fileScrollbar 插件
+++v0.7.0+
+该插件用于帮助开发水平和垂直滚动条的功能。
+注册
++import MindMap from 'simple-mind-map' +import Scrollbar from 'simple-mind-map/src/plugins/Scrollbar.js' +MindMap.usePlugin(Scrollbar) +注册完且实例化
+MindMap后可通过mindMap.scrollbar获取到该实例。事件
+scrollbar_change
+当滚动条数据发生改变时触发,你可以监听该事件来更新滚动条位置和大小。
+方法
+setScrollBarWrapSize(width, height)
++
+- +
++
width:Number,你的滚动条容器元素的宽度。- +
++
height: Number,你的滚动条容器元素的高度。设置滚动条容器的大小,对于水平滚动条,即容器的宽度,对于垂直滚动条,即容器的高度。当你的滚动条容器尺寸改变时需要再次调用该方法。
+calculationScrollbar()
+++需要先调用setScrollBarWrapSize方法设置滚动条容器元素的宽高。
+一般需要监听scrollbar_change事件,然后调用该方法更新滚动条。
+返回值:
++{ + // 垂直滚动条 + vertical: { + top, + height + }, + // 水平滚动条 + horizontal: { + left, + width + } +} +获取滚动条大小和位置,你可以根据返回值来设置到滚动条元素上,达到渲染和关心滚动条的效果。
+onMousedown(e, type)
++
+- +
++
e:鼠标按下事件的事件对象。- +
++
type:按下的滚动条类型,vertical(垂直滚动条)、horizontal(水平滚动条)。滚动条元素的鼠标按下事件时需要调用该方法。
+ +