diff --git a/simple-mind-map/src/constants/defaultOptions.js b/simple-mind-map/src/constants/defaultOptions.js index 8892f628..8725c108 100644 --- a/simple-mind-map/src/constants/defaultOptions.js +++ b/simple-mind-map/src/constants/defaultOptions.js @@ -2,6 +2,11 @@ import { CONSTANTS } from './constant' // 默认选项配置 export const defaultOpt = { + // 【基本】 + // 容器元素,必传,必须为DOM元素 + el: null, + // 思维导图回显数据 + data: null, // 是否只读 readonly: false, // 布局 @@ -24,10 +29,6 @@ export const defaultOpt = { imgTextMargin: 5, // 节点里各种文字信息的间距,如图标和文字的间距 textContentMargin: 2, - // 多选节点时鼠标移动到边缘时的画布移动偏移量 - selectTranslateStep: 3, - // 多选节点时鼠标移动距边缘多少距离时开始偏移 - selectTranslateLimit: 20, // 自定义节点备注内容显示 customNoteContentShow: null, /* @@ -36,22 +37,6 @@ export const defaultOpt = { hide(){} } */ - // 是否开启节点自由拖拽 - enableFreeDrag: false, - // 水印配置 - watermarkConfig: { - onlyExport: false, // 是否仅在导出时添加水印 - text: '', - lineSpacing: 100, - textSpacing: 100, - angle: 30, - textStyle: { - color: '#999', - opacity: 0.5, - fontSize: 14 - }, - belowNode: false - }, // 达到该宽度文本自动换行 textAutoWrapWidth: 500, // 自定义鼠标滚轮事件处理 @@ -89,9 +74,6 @@ export const defaultOpt = { enableShortcutOnlyWhenMouseInSvg: true, // 初始根节点的位置 initRootNodePosition: null, - // 导出png、svg、pdf时的图形内边距,注意是单侧内边距 - exportPaddingX: 10, - exportPaddingY: 10, // 节点文本编辑框的z-index nodeTextEditZIndex: 3000, // 节点备注浮层的z-index @@ -117,8 +99,6 @@ export const defaultOpt = { ], // 节点最大缓存数量 maxNodeCacheCount: 1000, - // 关联线默认文字 - defaultAssociativeLineText: '关联', // 思维导图适应画布大小时的内边距 fitPadding: 50, // 是否开启按住ctrl键多选节点功能 @@ -133,14 +113,9 @@ export const defaultOpt = { customCreateNodeContent: null, // 指定内部一些元素(节点文本编辑元素、节点备注显示元素、关联线文本编辑元素、节点图片调整按钮元素)添加到的位置,默认添加到document.body下 customInnerElsAppendTo: null, - // 拖拽元素时,指示元素新位置的块的最大高度 - nodeDragPlaceholderMaxSize: 20, // 是否在存在一个激活节点时,当按下中文、英文、数字按键时自动进入文本编辑模式 // 开启该特性后,需要给你的输入框绑定keydown事件,并禁止冒泡 enableAutoEnterTextEditWhenKeydown: false, - // 设置富文本节点编辑框和节点大小一致,形成伪原地编辑的效果 - // 需要注意的是,只有当节点内只有文本、且形状是矩形才会有比较好的效果 - richTextEditFakeInPlace: false, // 自定义对剪贴板文本的处理。当按ctrl+v粘贴时会读取用户剪贴板中的文本和图片,默认只会判断文本是否是普通文本和simple-mind-map格式的节点数据,如果你想处理其他思维导图的数据,比如processon、zhixi等,那么可以传递一个函数,接受当前剪贴板中的文本为参数,返回处理后的数据,可以返回两种类型: /* 1.返回一个纯文本,那么会直接以该文本创建一个子节点 @@ -162,26 +137,12 @@ export const defaultOpt = { customHandleClipboardText: null, // 禁止鼠标滚轮缩放,你仍旧可以使用api进行缩放 disableMouseWheelZoom: false, - // 禁止双指缩放,你仍旧可以使用api进行缩放 - // 需要注册TouchEvent插件后生效 - disableTouchZoom: false, // 错误处理函数 errorHandler: (code, error) => { console.error(code, error) }, - // 设置导出图片和svg时,针对富文本节点内容,也就是嵌入到svg中的html节点的默认样式覆盖 - // 如果不覆盖,会发生偏移问题 - resetCss: ` - * { - margin: 0; - padding: 0; - box-sizing: border-box; - } - `, // 是否在鼠标双击时回到根节点,也就是让根节点居中显示 enableDblclickBackToRootNode: false, - // 导出图片时canvas的缩放倍数,该配置会和window.devicePixelRatio值取最大值 - minExportImgCanvasScale: 2, // 节点鼠标hover和激活时显示的矩形边框的颜色 hoverRectColor: 'rgb(94, 200, 248)', // 节点鼠标hover和激活时显示的矩形边框距节点内容的距离 @@ -190,28 +151,8 @@ export const defaultOpt = { selectTextOnEnterEditText: false, // 删除节点后激活相邻节点 deleteNodeActive: true, - // 拖拽节点时鼠标移动到画布边缘是否开启画布自动移动 - autoMoveWhenMouseInEdgeOnDrag: true, // 是否首次加载fit view fit: false, - // 拖拽多个节点时随鼠标移动的示意矩形的样式配置 - dragMultiNodeRectConfig: { - width: 40, - height: 20, - fill: 'rgb(94, 200, 248)' // 填充颜色 - }, - // 节点拖拽时新位置的示意矩形的填充颜色 - dragPlaceholderRectFill: 'rgb(94, 200, 248)', - // 节点拖拽时新位置的示意连线的样式配置 - dragPlaceholderLineConfig: { - color: 'rgb(94, 200, 248)', - width: 2 - }, - // 节点拖拽时的透明度配置 - dragOpacityConfig: { - cloneNodeOpacity: 0.5, // 跟随鼠标移动的克隆节点或矩形的透明度 - beingDragNodeOpacity: 0.3 // 被拖拽节点的透明度 - }, // 自定义标签的颜色 // {pass: 'green, unpass: 'red'} tagsColorMap: {}, @@ -220,9 +161,8 @@ export const defaultOpt = { avatarSize: 22, // 头像大小 fontSize: 12 // 如果是文字头像,那么文字的大小 }, - // 关联线是否始终显示在节点上层 - // false:即创建关联线和激活关联线时处于最顶层,其他情况下处于节点下方 - associativeLineIsAlwaysAboveNode: true, + // 协同编辑时,同一个节点不能同时被多人选中 + onlyOneEnableActiveNodeOnCooperate: false, // 插入概要的默认文本 defaultGeneralizationText: '概要', // 粘贴文本的方式创建新节点时,控制是否按换行自动分割节点,即如果存在换行,那么会根据换行创建多个节点,否则只会创建一个节点 @@ -249,8 +189,6 @@ export const defaultOpt = { // 是否将思维导图限制在画布内 // 比如向右拖动时,思维导图图形的最左侧到达画布中心时将无法继续向右拖动,其他同理 isLimitMindMapInCanvas: false, - // 当注册了滚动条插件(Scrollbar)时,是否将思维导图限制在画布内,isLimitMindMapInCanvas不再起作用 - isLimitMindMapInCanvasWhenHasScrollbar: true, // 在节点上粘贴剪贴板中的图片的处理方法,默认是转换为data:url数据插入到节点中,你可以通过该方法来将图片数据上传到服务器,实现保存图片的url // 可以传递一个异步方法,接收Blob类型的图片数据,需要返回如下结构: /* @@ -263,15 +201,6 @@ export const defaultOpt = { } */ handleNodePasteImg: null, - // 默认情况下,新创建的关联线两个端点的位置是根据两个节点中心点的相对位置来计算的,如果你想固定位置,可以通过这个属性来配置 - // from和to都不传,则都自动计算,如果只传一个,另一个则会自动计算 - associativeLineInitPointsPosition: { - // from和to可选值:left、top、bottom、right - from: '', // 关联线起始节点上端点的位置 - to: '' // 关联线目标节点上端点的位置 - }, - // 是否允许调整关联线两个端点的位置 - enableAdjustAssociativeLinePoints: true, // 自定义创建节点形状的方法,可以传一个函数,均接收一个参数 // 矩形、圆角矩形、椭圆、圆等形状会调用该方法 // 接收svg path字符串,返回svg节点 @@ -282,10 +211,119 @@ export const defaultOpt = { // 自定义转换节点连线路径的方法 // 接收svg path字符串,返回转换后的svg path字符串 customTransformNodeLinePath: null, + // 快捷键操作即将执行前的生命周期函数,返回true可以阻止操作执行 + // 函数接收两个参数:key(快捷键)、activeNodeList(当前激活的节点列表) + beforeShortcutRun: null, + // 移动节点到画布中心、回到根节点等操作时是否将缩放层级复位为100% + resetScaleOnMoveNodeToCenter: false, + // 添加附加的节点前置内容,前置内容指和文本同一行的区域中的前置内容,不包括节点图片部分 + createNodePrefixContent: null, + // 添加附加的节点后置内容,后置内容指和文本同一行的区域中的后置内容,不包括节点图片部分 + createNodePostfixContent: null, + + // 【Select插件】 + // 多选节点时鼠标移动到边缘时的画布移动偏移量 + selectTranslateStep: 3, + // 多选节点时鼠标移动距边缘多少距离时开始偏移 + selectTranslateLimit: 20, + + // 【Drag插件】 + // 是否开启节点自由拖拽 + enableFreeDrag: false, + // 拖拽节点时鼠标移动到画布边缘是否开启画布自动移动 + autoMoveWhenMouseInEdgeOnDrag: true, + // 拖拽多个节点时随鼠标移动的示意矩形的样式配置 + dragMultiNodeRectConfig: { + width: 40, + height: 20, + fill: 'rgb(94, 200, 248)' // 填充颜色 + }, + // 节点拖拽时新位置的示意矩形的填充颜色 + dragPlaceholderRectFill: 'rgb(94, 200, 248)', + // 节点拖拽时新位置的示意连线的样式配置 + dragPlaceholderLineConfig: { + color: 'rgb(94, 200, 248)', + width: 2 + }, + // 节点拖拽时的透明度配置 + dragOpacityConfig: { + cloneNodeOpacity: 0.5, // 跟随鼠标移动的克隆节点或矩形的透明度 + beingDragNodeOpacity: 0.3 // 被拖拽节点的透明度 + }, + + // 【Watermark插件】 + // 水印配置 + watermarkConfig: { + onlyExport: false, // 是否仅在导出时添加水印 + text: '', + lineSpacing: 100, + textSpacing: 100, + angle: 30, + textStyle: { + color: '#999', + opacity: 0.5, + fontSize: 14 + }, + belowNode: false + }, + + // 【Export插件】 + // 导出png、svg、pdf时的图形内边距,注意是单侧内边距 + exportPaddingX: 10, + exportPaddingY: 10, + // 设置导出图片和svg时,针对富文本节点内容,也就是嵌入到svg中的html节点的默认样式覆盖 + // 如果不覆盖,会发生偏移问题 + resetCss: ` + * { + margin: 0; + padding: 0; + box-sizing: border-box; + } + `, + // 导出图片时canvas的缩放倍数,该配置会和window.devicePixelRatio值取最大值 + minExportImgCanvasScale: 2, + // 导出png、svg、pdf时在头部和尾部添加自定义内容 + // 可传递一个函数,这个函数可以返回null代表不添加内容,也可以返回如下数据: + /* + { + el,// 要追加的自定义DOM节点,样式可内联 + cssText,// 可选,如果样式不想内联,可以传递该值,一个css字符串 + height: 50// 返回的DOM节点的高度,必须传递 + } + */ + addContentToHeader: null, + addContentToFooter: null, + + // 【AssociativeLine插件】 + // 关联线默认文字 + defaultAssociativeLineText: '关联', + // 关联线是否始终显示在节点上层 + // false:即创建关联线和激活关联线时处于最顶层,其他情况下处于节点下方 + associativeLineIsAlwaysAboveNode: true, + // 默认情况下,新创建的关联线两个端点的位置是根据两个节点中心点的相对位置来计算的,如果你想固定位置,可以通过这个属性来配置 + // from和to都不传,则都自动计算,如果只传一个,另一个则会自动计算 + associativeLineInitPointsPosition: { + // from和to可选值:left、top、bottom、right + from: '', // 关联线起始节点上端点的位置 + to: '' // 关联线目标节点上端点的位置 + }, + // 是否允许调整关联线两个端点的位置 + enableAdjustAssociativeLinePoints: true, + + // 【TouchEvent插件】 + // 禁止双指缩放,你仍旧可以使用api进行缩放 + // 需要注册TouchEvent插件后生效 + disableTouchZoom: false, + + // 【Scrollbar插件】 + // 当注册了滚动条插件(Scrollbar)时,是否将思维导图限制在画布内,isLimitMindMapInCanvas不再起作用 + isLimitMindMapInCanvasWhenHasScrollbar: true, + + // 【Search插件】 // 是否仅搜索当前渲染的节点,被收起的节点不会被搜索到 isOnlySearchCurrentRenderNodes: false, - // 协同编辑时,同一个节点不能同时被多人选中 - onlyOneEnableActiveNodeOnCooperate: false, + + // 【Cooperate插件】 // 协同编辑时,节点操作即将更新到其他客户端前的生命周期函数 // 函数接收一个对象作为参数: /* @@ -295,9 +333,8 @@ export const defaultOpt = { } */ beforeCooperateUpdate: null, - // 快捷键操作即将执行前的生命周期函数,返回true可以阻止操作执行 - // 函数接收两个参数:key(快捷键)、activeNodeList(当前激活的节点列表) - beforeShortcutRun: null, + + // 【RainbowLines插件】 // 彩虹线条配置,需要先注册RainbowLines插件 rainbowLinesConfig: { open: false, // 是否开启彩虹线条 @@ -314,29 +351,21 @@ export const defaultOpt = { ] */ }, - // 导出png、svg、pdf时在头部和尾部添加自定义内容 - // 可传递一个函数,这个函数可以返回null代表不添加内容,也可以返回如下数据: - /* - { - el,// 要追加的自定义DOM节点,样式可内联 - cssText,// 可选,如果样式不想内联,可以传递该值,一个css字符串 - height: 50// 返回的DOM节点的高度,必须传递 - } - */ - addContentToHeader: null, - addContentToFooter: null, + + // 【Demonstrate插件】 // 演示插件配置 demonstrateConfig: null, - // 移动节点到画布中心、回到根节点等操作时是否将缩放层级复位为100% - resetScaleOnMoveNodeToCenter: false, - // 添加附加的节点前置内容,前置内容指和文本同一行的区域中的前置内容,不包括节点图片部分 - createNodePrefixContent: null, - // 添加附加的节点后置内容,后置内容指和文本同一行的区域中的后置内容,不包括节点图片部分 - createNodePostfixContent: null, + + // 【Formula插件】 // 是否开启在富文本编辑框中直接编辑数学公式 enableEditFormulaInRichTextEdit: true, + + // 【RichText插件】 // 转换富文本内容,当进入富文本编辑时,可以通过该参数传递一个函数,函数接收文本内容,需要返回你处理后的文本内容 transformRichTextOnEnterEdit: null, // 可以传递一个函数,即将结束富文本编辑前会执行该函数,函数接收richText实例,所以你可以在此时机更新quill文档数据 - beforeHideRichTextEdit: null + beforeHideRichTextEdit: null, + // 设置富文本节点编辑框和节点大小一致,形成伪原地编辑的效果 + // 需要注意的是,只有当节点内只有文本、且形状是矩形才会有比较好的效果 + richTextEditFakeInPlace: false, } diff --git a/web/src/pages/Doc/en/constructor/index.md b/web/src/pages/Doc/en/constructor/index.md index 0770e8b6..ed628779 100644 --- a/web/src/pages/Doc/en/constructor/index.md +++ b/web/src/pages/Doc/en/constructor/index.md @@ -22,8 +22,10 @@ const mindMap = new MindMap({ ## Instantiation options -| Field Name | Type | Default Value | Description | Required | -| -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | -------- | +### 1.Base + +| Field Name | Type | Default Value | Description | Required | +| -------------------------------- | ------- | ---------------- | ------------------------------------------- | -------- | | el | Element | | Container element, must be a DOM element(When the position of container elements on the page has changed but the size has not changed, the 'getElRectInfo()' method must be called to update the relevant information inside the library; When the size also changes, the 'resize()' method must be called, otherwise it will cause some functional exceptions) | Yes | | data | Object 、null | | Mind map data, Please refer to the introduction of 【Data structure】 below. V0.9.9+supports passing empty objects or null, and the canvas will display blank space | | | 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) | | @@ -32,15 +34,10 @@ const mindMap = new MindMap({ | themeConfig | Object | {} | Theme configuration, will be merged with the selected theme, available fields refer to: [default.js](https://github.com/wanglin2/mind-map/blob/main/simple-mind-map/src/themes/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, node) => {// your display node note logic. node is a new parameter added in v0.8.1+ version, representing node instances }, 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(Free drag means that nodes can be dragged to any position on the canvas. Please note that it is not a function of dragging nodes to become siblings of other nodes. The connection of free drag may have certain problems, so it is best not to use this feature) 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(v0.9.1+ default is move) | 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 | | @@ -56,8 +53,6 @@ const mindMap = new MindMap({ | 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 | | @@ -65,7 +60,6 @@ const mindMap = new MindMap({ | 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. | | @@ -74,56 +68,36 @@ const mindMap = new MindMap({ | 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+)(v0.8.0+this attribute has been deleted) | 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 | | | enableDblclickBackToRootNode(v0.8.0+) | Boolean | false | Whether to return to the root node when double clicking with the mouse, that is, to center the display of the root node | | -| 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(v0.7.1-fix.2+) | Boolean | false | Is the first rendering scaled to fit the canvas size | | -| dragMultiNodeRectConfig(v0.7.2+) | Object | { width: 40, height: 20, fill: '' } | The style configuration of the schematic rectangle that moves with the mouse when dragging multiple nodes, passing an object, and the field meanings are the width, height, and fill color of the rectangle | | -| dragPlaceholderRectFill(v0.7.2+) | String | | The filling color of the schematic rectangle for the new position when dragging nodes. If not transmitted, the default color for the connected line is used | | -| dragOpacityConfig(v0.7.2+) | Object | { cloneNodeOpacity: 0.5, beingDragNodeOpacity: 0.3 } | The transparency configuration during node dragging, passing an object, and the field meanings are: the transparency of the cloned node or rectangle that follows the mouse movement, and the transparency of the dragged node | | | tagsColorMap(v0.7.2+) | Object | {} | The color of a custom node label can be transferred to an object, where key is the label content to be assigned a color, and value is the color of the label content. If not transferred internally, a corresponding color will be generated based on the label content | | | cooperateStyle(v0.7.3+) | Object | { avatarSize: 22, fontSize: 12 } | The configuration of personnel avatar style during node collaboration editing, with field meanings as follows: avatar size, and if it is a text avatar, the size of the text | | -| associativeLineIsAlwaysAboveNode(v0.8.0+) | Boolean | true | Is the associated line always displayed above the node? If set to false, it will be at the top level when creating and activating the associated line, and in other cases, it will be below the node | | +| onlyOneEnableActiveNodeOnCooperate(v0.9.8+) | Boolean | false | During collaborative editing, the same node cannot be selected by multiple people at the same time | | | defaultGeneralizationText(v0.8.0+) | String | 概要 | Insert default text for summary | | | handleIsSplitByWrapOnPasteCreateNewNode(v0.8.0+) | Function / null | null | When creating a new node by pasting text, control whether to automatically split the nodes based on line breaks. If there is a line break, multiple nodes will be created based on the line break. Otherwise, only one node will be created, and a function can be passed to return promise. resolve represents splitting based on line breaks, and reject represents ignoring line breaks | | | addHistoryTime(v0.8.0+) | Number | 100 | Only one historical record can be added within the specified time to avoid adding unnecessary intermediate states. Unit: ms | | | isDisableDrag(v0.8.1+) | Boolean | false | Is disable dragging the canvas | | -| disableTouchZoom(v0.8.1+) | Boolean | false | Prohibit double finger scaling, you can still use the API for scaling, which takes effect on the TouchEvent plugin | | | highlightNodeBoxStyle(v0.9.0+) | Object | { stroke: 'rgb(94, 200, 248)', fill: 'transparent' } | Highlight box style when the mouse moves into the summary to highlight the node it belongs to | | | createNewNodeBehavior(v0.9.1+) | String | default | Behavior when creating a new node. default(By default, newly created nodes will be activated and enter editing mode. If multiple new nodes are created simultaneously, they will only be activated and will not enter editing mode)、notActive(Do not activate newly created nodes)、activeOnly(Only activate newly created nodes and do not enter editing mode) | | | defaultNodeImage(v0.9.1-fix.2+) | String | | Image address, the default image displayed when node image loading fails | | | handleNodePasteImg(v0.9.2+) | null or Function | null | The processing method for pasting images from the clipboard on a node is to convert them into data:URL data and insert them into the node by default. You can use this method to upload image data to the server and save the URL of the image. An asynchronous method can be passed to receive image data of Blob type, and the specified structure needs to be returned: { url, size: {width, height} } | | | isLimitMindMapInCanvas(v0.9.2+) | Boolean | false | Whether to limit the mind map within the canvas. For example, when dragging to the right, the leftmost part of the mind map graphic will not be able to continue dragging to the right when it reaches the center of the canvas, and the same applies to other things | | -| isLimitMindMapInCanvasWhenHasScrollbar(v0.9.2+) | Boolean | true | When registering the Scrollbar plugin, will the mind map be limited to the canvas and the isLimitMindMapInCanvas configuration no longer work | | -| associativeLineInitPointsPosition(v0.9.5+) | null / { from, to } | { from: '', to: '' } | By default, the position of the two endpoints of a newly created association line is calculated based on the relative position of the center points of the two nodes. If you want to fix the position, you can configure it through this option. If neither from nor to is transmitted, they will be automatically calculated. If only one is transmitted, the other will be automatically calculated. from and to optional values -:left、top、bottom、right | | -| enableAdjustAssociativeLinePoints(v0.9.5+) | Boolean | true | Is it allowed to adjust the position of the two endpoints of the associated line | | -| isOnlySearchCurrentRenderNodes(v0.9.8+) | Boolean | false | Is it necessary to only search for the current rendered node, and nodes that have been collapsed will not be searched for | | -| onlyOneEnableActiveNodeOnCooperate(v0.9.8+) | Boolean | false | During collaborative editing, the same node cannot be selected by multiple people at the same time | | -| beforeCooperateUpdate(v0.9.8+) | Function、null | null | During collaborative editing, node operations are about to be updated to the lifecycle functions of other clients. The function takes an object as a parameter:{ type: 【createOrUpdate(Create or update nodes)、delete(Delete node)】, list: 【Array type, 1.When type=createOrUpdate, it represents the node data that has been created or updated, which will be synchronized to other clients, so you can modify the data; 2.When type=delete, represents the deleted node data】 } | | | beforeShortcutRun(v0.9.9+) | Function、null | null | The lifecycle function before the shortcut operation is about to be executed, returning true can prevent the operation from executing. The function takes two parameters: key(Shortcut key)、activeNodeList(List of currently activated nodes) | | -| rainbowLinesConfig(v0.9.9+) | Object | { open: false, colorsList: [] } | Rainbow line configuration requires registering the RainbowLines plugin first. Object type, Structure: { open: false【Is turn on rainbow lines】, colorsList: []【Customize the color list for rainbow lines. If not set, the default color list will be used】 } | | -| addContentToHeader(v0.9.9+) | Function、null | null | Add custom content to the header when exporting PNG, SVG, and PDF. Can pass a function that can return null to indicate no content is added, or it can return an object, For a detailed introduction, please refer to section 【How to add custom content when exporting】 below | | -| addContentToFooter(v0.9.9+) | Function、null | null | The basic definition is the same as addContentToHeader, adding custom content at the end | | -| demonstrateConfig(v0.9.11+) | Object、null | null | Demonstration plugin configuration. If not transmitted, the default configuration will be used. An object can be transmitted. If only a certain property is configured, only that property can be set. Other properties that have not been set will also use the default configuration. For complete configuration, please refer to the 【Demonstration Plugin Configuration】 section below | | | resetScaleOnMoveNodeToCenter(v0.9.12+) | Boolean | false | Whether to reset the scaling level to 100% when moving nodes to the canvas center, returning to the root node, and other operations(The underlying impact is on the moveNodeToCenter method of the render class) | | | createNodePrefixContent(v0.9.12+) | Function、null | null | Add additional node pre content.Pre content refers to the pre content in the area of the same line as the text, excluding the node image section.You can pass a function that takes the parameters of a node instance, Can return objects in {el, width, height} format, el is a DOM node object, width and height represent the width, height, and numerical type of the content. If custom content is not required, null can also be returned | | | createNodePostfixContent(v0.9.12+) | Function、null | null | Add additional node post content.Post content refers to the post content in the area of the same line as the text, excluding the node image section. The usage is the same as createNodePrefixContent | | -### Data structure +### 1.1Data structure The basic data structure is as follows: @@ -166,18 +140,7 @@ The basic data structure is as follows: 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 | -| onlyExport(v0.9.2+) | Boolean | false | Is only add watermarks during export | - -### Icon Configuration +### 1.2Icon Configuration | Field Name | Type | Default Value | Description | | ----------- | ------ | ------------------------------------------- | ------------------------------------------------------------ | @@ -185,7 +148,19 @@ If you want to add custom fields, you can add them to the same level as 'data' a | 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: '' }`,`name`represents the name of the icon, `icon`represents the icon, Can be an `svg` icon, such as ``, also can be a image `url`, or `base64` icon, such as `data:image/png;base64,...` | -### How to add custom content when exporting +### 2.Export plugin + +| Field Name | Type | Default Value | Description | Required | +| -------------------------------- | ------- | ---------------- | ------------------------------------------- | -------- | +| exportPadding | Number | 20 | The padding for exporting images | | +| 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 | | +| 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 | | +| 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 | | +| addContentToHeader(v0.9.9+) | Function、null | null | Add custom content to the header when exporting PNG, SVG, and PDF. Can pass a function that can return null to indicate no content is added, or it can return an object, For a detailed introduction, please refer to section 【How to add custom content when exporting】 below | | +| addContentToFooter(v0.9.9+) | Function、null | null | The basic definition is the same as addContentToHeader, adding custom content at the end | | + +#### 2.1How to add custom content when exporting The two instantiation options `addContentToHeader` and `addContentToFooter` can be used to add custom content at the beginning and end when exporting `png`、`svg`、`pdf`, The default value is `null`, which means no configuration. A function can be passed and can return `null`, which means no content will be added. If you want to add content, you need to return the following structure: @@ -220,7 +195,94 @@ new MindMap({ }) ``` -### Demonstration Plugin Configuration +### 3.Select plugin + +| Field Name | Type | Default Value | Description | Required | +| -------------------------------- | ------- | ---------------- | ------------------------------------------- | -------- | +| 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 | | + +### 4.Drag plugin + +| Field Name | Type | Default Value | Description | Required | +| -------------------------------- | ------- | ---------------- | ------------------------------------------- | -------- | +| enableFreeDrag(v0.2.4+) | Boolean | false | Enable node free(Free drag means that nodes can be dragged to any position on the canvas. Please note that it is not a function of dragging nodes to become siblings of other nodes. The connection of free drag may have certain problems, so it is best not to use this feature) drag | | +| nodeDragPlaceholderMaxSize(v0.6.12+)(v0.10.0+ has been abolished) | Number | 20 | When dragging an element, the maximum height of the block indicating the new position of the element | | +| 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 | | +| dragMultiNodeRectConfig(v0.7.2+) | Object | { width: 40, height: 20, fill: '' } | The style configuration of the schematic rectangle that moves with the mouse when dragging multiple nodes, passing an object, and the field meanings are the width, height, and fill color of the rectangle | | +| dragPlaceholderRectFill(v0.7.2+) | String | | The filling color of the schematic rectangle for the new position when dragging nodes. If not transmitted, the default color for the connected line is used | | +| dragOpacityConfig(v0.7.2+) | Object | { cloneNodeOpacity: 0.5, beingDragNodeOpacity: 0.3 } | The transparency configuration during node dragging, passing an object, and the field meanings are: the transparency of the cloned node or rectangle that follows the mouse movement, and the transparency of the dragged node | | + +### 5.Watermark plugin + +| Field Name | Type | Default Value | Description | Required | +| -------------------------------- | ------- | ---------------- | ------------------------------------------- | -------- | +| watermarkConfig(v0.2.4+) | Object | | Watermark config, Please refer to the table 【Watermark config】 below for detailed configuration | | + +#### 5.1Watermark 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 | +| onlyExport(v0.9.2+) | Boolean | false | Is only add watermarks during export | + +### 6.AssociativeLine plugin + +| Field Name | Type | Default Value | Description | Required | +| -------------------------------- | ------- | ---------------- | ------------------------------------------- | -------- | +| defaultAssociativeLineText(v0.5.11+) | String | 关联 | Association Line Default Text | | +| associativeLineIsAlwaysAboveNode(v0.8.0+) | Boolean | true | Is the associated line always displayed above the node? If set to false, it will be at the top level when creating and activating the associated line, and in other cases, it will be below the node | | +| associativeLineInitPointsPosition(v0.9.5+) | null / { from, to } | { from: '', to: '' } | By default, the position of the two endpoints of a newly created association line is calculated based on the relative position of the center points of the two nodes. If you want to fix the position, you can configure it through this option. If neither from nor to is transmitted, they will be automatically calculated. If only one is transmitted, the other will be automatically calculated. from and to optional values +:left、top、bottom、right | | +| enableAdjustAssociativeLinePoints(v0.9.5+) | Boolean | true | Is it allowed to adjust the position of the two endpoints of the associated line | | + +### 7.RichText plugin + +| Field Name | Type | Default Value | Description | Required | +| -------------------------------- | ------- | ---------------- | ------------------------------------------- | -------- | +| 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 | | + +### 8.TouchEvent plugin + +| Field Name | Type | Default Value | Description | Required | +| -------------------------------- | ------- | ---------------- | ------------------------------------------- | -------- | +| disableTouchZoom(v0.8.1+) | Boolean | false | Prohibit double finger scaling, you can still use the API for scaling, which takes effect on the TouchEvent plugin | | + +### 9.Scrollbar plugin + +| Field Name | Type | Default Value | Description | Required | +| -------------------------------- | ------- | ---------------- | ------------------------------------------- | -------- | +| isLimitMindMapInCanvasWhenHasScrollbar(v0.9.2+) | Boolean | true | When registering the Scrollbar plugin, will the mind map be limited to the canvas and the isLimitMindMapInCanvas configuration no longer work | | + +### 10.Search plugin + +| Field Name | Type | Default Value | Description | Required | +| -------------------------------- | ------- | ---------------- | ------------------------------------------- | -------- | +| isOnlySearchCurrentRenderNodes(v0.9.8+) | Boolean | false | Is it necessary to only search for the current rendered node, and nodes that have been collapsed will not be searched for | | + +### 11.Cooperate plugin + +| Field Name | Type | Default Value | Description | Required | +| -------------------------------- | ------- | ---------------- | ------------------------------------------- | -------- | +| beforeCooperateUpdate(v0.9.8+) | Function、null | null | During collaborative editing, node operations are about to be updated to the lifecycle functions of other clients. The function takes an object as a parameter:{ type: 【createOrUpdate(Create or update nodes)、delete(Delete node)】, list: 【Array type, 1.When type=createOrUpdate, it represents the node data that has been created or updated, which will be synchronized to other clients, so you can modify the data; 2.When type=delete, represents the deleted node data】 } | | + +### 12.RainbowLines plugin + +| Field Name | Type | Default Value | Description | Required | +| -------------------------------- | ------- | ---------------- | ------------------------------------------- | -------- | +| rainbowLinesConfig(v0.9.9+) | Object | { open: false, colorsList: [] } | Rainbow line configuration requires registering the RainbowLines plugin first. Object type, Structure: { open: false【Is turn on rainbow lines】, colorsList: []【Customize the color list for rainbow lines. If not set, the default color list will be used】 } | | + +### 13.Demonstrate plugin + +| Field Name | Type | Default Value | Description | Required | +| -------------------------------- | ------- | ---------------- | ------------------------------------------- | -------- | +| demonstrateConfig(v0.9.11+) | Object、null | null | Demonstration plugin configuration. If not transmitted, the default configuration will be used. An object can be transmitted. If only a certain property is configured, only that property can be set. Other properties that have not been set will also use the default configuration. For complete configuration, please refer to the 【Demonstration Plugin Configuration】 section below | | + +#### 13.1Demonstration Plugin Configuration | Field Name | Type | Default Value | Description | | ----------- | ------ | ------------------------------------------- | ------------------------------------ | diff --git a/web/src/pages/Doc/en/constructor/index.vue b/web/src/pages/Doc/en/constructor/index.vue index 39f8c0b4..201bd207 100644 --- a/web/src/pages/Doc/en/constructor/index.vue +++ b/web/src/pages/Doc/en/constructor/index.vue @@ -17,6 +17,7 @@ });

Instantiation options

+

1.Base

@@ -85,13 +86,6 @@ - - - - - - - @@ -106,20 +100,6 @@ - - - - - - - - - - - - - - @@ -134,20 +114,6 @@ - - - - - - - - - - - - - - @@ -253,20 +219,6 @@ - - - - - - - - - - - - - - @@ -316,13 +268,6 @@ - - - - - - - @@ -379,13 +324,6 @@ - - - - - - - @@ -400,13 +338,6 @@ - - - - - - - @@ -428,13 +359,6 @@ - - - - - - - @@ -449,13 +373,6 @@ - - - - - - - @@ -484,13 +401,6 @@ - - - - - - - @@ -498,27 +408,6 @@ - - - - - - - - - - - - - - - - - - - - - @@ -533,10 +422,10 @@ - + - - + + @@ -568,13 +457,6 @@ - - - - - - - @@ -610,55 +492,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -666,34 +499,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -716,7 +521,7 @@
exportPaddingNumber20The padding for exporting images
imgTextMargin Number 5
selectTranslateStepNumber3The canvas offset when mouse moves to the edge during multi-select node
selectTranslateLimitNumber20The distance from the edge when the canvas begins to offset during multi-select node
customNoteContentShow(v0.1.6+) Object null
enableFreeDrag(v0.2.4+)BooleanfalseEnable node free(Free drag means that nodes can be dragged to any position on the canvas. Please note that it is not a function of dragging nodes to become siblings of other nodes. The connection of free drag may have certain problems, so it is best not to use this feature) drag
watermarkConfig(v0.2.4+)ObjectWatermark config, Please refer to the table 【Watermark config】 below for detailed configuration
textAutoWrapWidth(v0.3.4+) Number 500
exportPaddingX(v0.5.5+)Number10Horizontal padding of graphics when exporting PNG, SVG, and PDF
exportPaddingY(v0.5.5+)Number10Vertical padding of graphics when exporting PNG, SVG, and PDF
nodeTextEditZIndex(v0.5.5+) Number 3000
defaultAssociativeLineText(v0.5.11+)String关联Association Line Default Text
fitPadding(v0.6.0+) Number 50
nodeDragPlaceholderMaxSize(v0.6.12+)Number20When 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
richTextEditFakeInPlace(v0.6.13+)BooleanfalseSet 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
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+)(v0.8.0+this attribute has been deleted) Boolean true(v0.7.0+changed to false)
minExportImgCanvasScale(v0.7.0+)Number2The 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)
autoMoveWhenMouseInEdgeOnDrag(v0.7.1+)BooleantrueWhether to enable automatic canvas movement when the mouse moves to the edge of the canvas while dragging nodes
fit(v0.7.1-fix.2+) Boolean false
dragMultiNodeRectConfig(v0.7.2+)Object{ width: 40, height: 20, fill: '' }The style configuration of the schematic rectangle that moves with the mouse when dragging multiple nodes, passing an object, and the field meanings are the width, height, and fill color of the rectangle
dragPlaceholderRectFill(v0.7.2+)StringThe filling color of the schematic rectangle for the new position when dragging nodes. If not transmitted, the default color for the connected line is used
dragOpacityConfig(v0.7.2+)Object{ cloneNodeOpacity: 0.5, beingDragNodeOpacity: 0.3 }The transparency configuration during node dragging, passing an object, and the field meanings are: the transparency of the cloned node or rectangle that follows the mouse movement, and the transparency of the dragged node
tagsColorMap(v0.7.2+) Object {}
associativeLineIsAlwaysAboveNode(v0.8.0+)onlyOneEnableActiveNodeOnCooperate(v0.9.8+) BooleantrueIs the associated line always displayed above the node? If set to false, it will be at the top level when creating and activating the associated line, and in other cases, it will be below the nodefalseDuring collaborative editing, the same node cannot be selected by multiple people at the same time
disableTouchZoom(v0.8.1+)BooleanfalseProhibit double finger scaling, you can still use the API for scaling, which takes effect on the TouchEvent plugin
highlightNodeBoxStyle(v0.9.0+) Object { stroke: 'rgb(94, 200, 248)', fill: 'transparent' }
isLimitMindMapInCanvasWhenHasScrollbar(v0.9.2+)BooleantrueWhen registering the Scrollbar plugin, will the mind map be limited to the canvas and the isLimitMindMapInCanvas configuration no longer work
associativeLineInitPointsPosition(v0.9.5+)null / { from, to }{ from: '', to: '' }By default, the position of the two endpoints of a newly created association line is calculated based on the relative position of the center points of the two nodes. If you want to fix the position, you can configure it through this option. If neither from nor to is transmitted, they will be automatically calculated. If only one is transmitted, the other will be automatically calculated. from and to optional values
:left、top、bottom、right
enableAdjustAssociativeLinePoints(v0.9.5+)BooleantrueIs it allowed to adjust the position of the two endpoints of the associated line
isOnlySearchCurrentRenderNodes(v0.9.8+)BooleanfalseIs it necessary to only search for the current rendered node, and nodes that have been collapsed will not be searched for
onlyOneEnableActiveNodeOnCooperate(v0.9.8+)BooleanfalseDuring collaborative editing, the same node cannot be selected by multiple people at the same time
beforeCooperateUpdate(v0.9.8+)Function、nullnullDuring collaborative editing, node operations are about to be updated to the lifecycle functions of other clients. The function takes an object as a parameter:{ type: 【createOrUpdate(Create or update nodes)、delete(Delete node)】, list: 【Array type, 1.When type=createOrUpdate, it represents the node data that has been created or updated, which will be synchronized to other clients, so you can modify the data; 2.When type=delete, represents the deleted node data】 }
beforeShortcutRun(v0.9.9+) Function、null null
rainbowLinesConfig(v0.9.9+)Object{ open: false, colorsList: [] }Rainbow line configuration requires registering the RainbowLines plugin first. Object type, Structure: { open: false【Is turn on rainbow lines】, colorsList: []【Customize the color list for rainbow lines. If not set, the default color list will be used】 }
addContentToHeader(v0.9.9+)Function、nullnullAdd custom content to the header when exporting PNG, SVG, and PDF. Can pass a function that can return null to indicate no content is added, or it can return an object, For a detailed introduction, please refer to section 【How to add custom content when exporting】 below
addContentToFooter(v0.9.9+)Function、nullnullThe basic definition is the same as addContentToHeader, adding custom content at the end
demonstrateConfig(v0.9.11+)Object、nullnullDemonstration plugin configuration. If not transmitted, the default configuration will be used. An object can be transmitted. If only a certain property is configured, only that property can be set. Other properties that have not been set will also use the default configuration. For complete configuration, please refer to the 【Demonstration Plugin Configuration】 section below
resetScaleOnMoveNodeToCenter(v0.9.12+) Boolean false
-

Data structure

+

1.1Data structure

The basic data structure is as follows:

{
   data: {
@@ -754,7 +559,234 @@
 }
 

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

+

1.2Icon Configuration

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Field NameTypeDefault ValueDescription
nameStringThe name of the icon group
typeStringValues for icon grouping
listArrayA 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,...
+

2.Export plugin

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Field NameTypeDefault ValueDescriptionRequired
exportPaddingNumber20The padding for exporting images
exportPaddingX(v0.5.5+)Number10Horizontal padding of graphics when exporting PNG, SVG, and PDF
exportPaddingY(v0.5.5+)Number10Vertical padding of graphics when exporting PNG, SVG, and PDF
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
minExportImgCanvasScale(v0.7.0+)Number2The scaling factor of canvas when exporting images and PDFs, which is set to the maximum value of window.devicePixelRatio to improve image clarity
addContentToHeader(v0.9.9+)Function、nullnullAdd custom content to the header when exporting PNG, SVG, and PDF. Can pass a function that can return null to indicate no content is added, or it can return an object, For a detailed introduction, please refer to section 【How to add custom content when exporting】 below
addContentToFooter(v0.9.9+)Function、nullnullThe basic definition is the same as addContentToHeader, adding custom content at the end
+

2.1How to add custom content when exporting

+

The two instantiation options addContentToHeader and addContentToFooter can be used to add custom content at the beginning and end when exporting pngsvgpdf, The default value is null, which means no configuration. A function can be passed and can return null, which means no content will be added. If you want to add content, you need to return the following structure:

+
{
+  el,// Custom DOM node to be added, styles can be inline
+  cssText,// Optional, if the style does not want to be inlined, you can pass this value as a CSS string
+  height: 50// The height of the returned DOM node must be passed
+}
+
+

A simple example:

+
new MindMap({
+  addContentToFooter: () => {
+    const el = document.createElement('div')
+    el.className = 'footer'
+    el.innerHTML = 'From: simple-mind-map'
+    const cssText = `
+      .footer {
+        width: 100%;
+        height: 30px;
+      }
+    `
+    return {
+      el,
+      cssText,
+      height: 30
+    }
+  }
+})
+
+

3.Select plugin

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Field NameTypeDefault ValueDescriptionRequired
selectTranslateStepNumber3The canvas offset when mouse moves to the edge during multi-select node
selectTranslateLimitNumber20The distance from the edge when the canvas begins to offset during multi-select node
+

4.Drag plugin

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Field NameTypeDefault ValueDescriptionRequired
enableFreeDrag(v0.2.4+)BooleanfalseEnable node free(Free drag means that nodes can be dragged to any position on the canvas. Please note that it is not a function of dragging nodes to become siblings of other nodes. The connection of free drag may have certain problems, so it is best not to use this feature) drag
nodeDragPlaceholderMaxSize(v0.6.12+)(v0.10.0+ has been abolished)Number20When dragging an element, the maximum height of the block indicating the new position of the element
autoMoveWhenMouseInEdgeOnDrag(v0.7.1+)BooleantrueWhether to enable automatic canvas movement when the mouse moves to the edge of the canvas while dragging nodes
dragMultiNodeRectConfig(v0.7.2+)Object{ width: 40, height: 20, fill: '' }The style configuration of the schematic rectangle that moves with the mouse when dragging multiple nodes, passing an object, and the field meanings are the width, height, and fill color of the rectangle
dragPlaceholderRectFill(v0.7.2+)StringThe filling color of the schematic rectangle for the new position when dragging nodes. If not transmitted, the default color for the connected line is used
dragOpacityConfig(v0.7.2+)Object{ cloneNodeOpacity: 0.5, beingDragNodeOpacity: 0.3 }The transparency configuration during node dragging, passing an object, and the field meanings are: the transparency of the cloned node or rectangle that follows the mouse movement, and the transparency of the dragged node
+

5.Watermark plugin

+ + + + + + + + + + + + + + + + + + + +
Field NameTypeDefault ValueDescriptionRequired
watermarkConfig(v0.2.4+)ObjectWatermark config, Please refer to the table 【Watermark config】 below for detailed configuration
+

5.1Watermark config

@@ -803,7 +835,7 @@
-

Icon Configuration

+

6.AssociativeLine plugin

@@ -811,58 +843,195 @@ + - + + + - - - + + + + - - - + + + + + + + + + + + + + + + + + + -
Type Default Value DescriptionRequired
namedefaultAssociativeLineText(v0.5.11+) String关联Association Line Default Text The name of the icon group
typeStringassociativeLineIsAlwaysAboveNode(v0.8.0+)BooleantrueIs the associated line always displayed above the node? If set to false, it will be at the top level when creating and activating the associated line, and in other cases, it will be below the node Values for icon grouping
listArrayassociativeLineInitPointsPosition(v0.9.5+)null / { from, to }{ from: '', to: '' }By default, the position of the two endpoints of a newly created association line is calculated based on the relative position of the center points of the two nodes. If you want to fix the position, you can configure it through this option. If neither from nor to is transmitted, they will be automatically calculated. If only one is transmitted, the other will be automatically calculated. from and to optional values
:left、top、bottom、right
enableAdjustAssociativeLinePoints(v0.9.5+)BooleantrueIs it allowed to adjust the position of the two endpoints of the associated line 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,...
-

How to add custom content when exporting

-

The two instantiation options addContentToHeader and addContentToFooter can be used to add custom content at the beginning and end when exporting pngsvgpdf, The default value is null, which means no configuration. A function can be passed and can return null, which means no content will be added. If you want to add content, you need to return the following structure:

-
{
-  el,// Custom DOM node to be added, styles can be inline
-  cssText,// Optional, if the style does not want to be inlined, you can pass this value as a CSS string
-  height: 50// The height of the returned DOM node must be passed
-}
-
-

A simple example:

-
new MindMap({
-  addContentToFooter: () => {
-    const el = document.createElement('div')
-    el.className = 'footer'
-    el.innerHTML = 'From: simple-mind-map'
-    const cssText = `
-      .footer {
-        width: 100%;
-        height: 30px;
-      }
-    `
-    return {
-      el,
-      cssText,
-      height: 30
-    }
-  }
-})
-
-

Demonstration Plugin Configuration

+

7.RichText plugin

+ + + + + + + + + + + + + + + + + + + +
Field NameTypeDefault ValueDescriptionRequired
richTextEditFakeInPlace(v0.6.13+)BooleanfalseSet 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
+

8.TouchEvent plugin

+ + + + + + + + + + + + + + + + + + + +
Field NameTypeDefault ValueDescriptionRequired
disableTouchZoom(v0.8.1+)BooleanfalseProhibit double finger scaling, you can still use the API for scaling, which takes effect on the TouchEvent plugin
+

9.Scrollbar plugin

+ + + + + + + + + + + + + + + + + + + +
Field NameTypeDefault ValueDescriptionRequired
isLimitMindMapInCanvasWhenHasScrollbar(v0.9.2+)BooleantrueWhen registering the Scrollbar plugin, will the mind map be limited to the canvas and the isLimitMindMapInCanvas configuration no longer work
+

10.Search plugin

+ + + + + + + + + + + + + + + + + + + +
Field NameTypeDefault ValueDescriptionRequired
isOnlySearchCurrentRenderNodes(v0.9.8+)BooleanfalseIs it necessary to only search for the current rendered node, and nodes that have been collapsed will not be searched for
+

11.Cooperate plugin

+ + + + + + + + + + + + + + + + + + + +
Field NameTypeDefault ValueDescriptionRequired
beforeCooperateUpdate(v0.9.8+)Function、nullnullDuring collaborative editing, node operations are about to be updated to the lifecycle functions of other clients. The function takes an object as a parameter:{ type: 【createOrUpdate(Create or update nodes)、delete(Delete node)】, list: 【Array type, 1.When type=createOrUpdate, it represents the node data that has been created or updated, which will be synchronized to other clients, so you can modify the data; 2.When type=delete, represents the deleted node data】 }
+

12.RainbowLines plugin

+ + + + + + + + + + + + + + + + + + + +
Field NameTypeDefault ValueDescriptionRequired
rainbowLinesConfig(v0.9.9+)Object{ open: false, colorsList: [] }Rainbow line configuration requires registering the RainbowLines plugin first. Object type, Structure: { open: false【Is turn on rainbow lines】, colorsList: []【Customize the color list for rainbow lines. If not set, the default color list will be used】 }
+

13.Demonstrate plugin

+ + + + + + + + + + + + + + + + + + + +
Field NameTypeDefault ValueDescriptionRequired
demonstrateConfig(v0.9.11+)Object、nullnullDemonstration plugin configuration. If not transmitted, the default configuration will be used. An object can be transmitted. If only a certain property is configured, only that property can be set. Other properties that have not been set will also use the default configuration. For complete configuration, please refer to the 【Demonstration Plugin Configuration】 section below
+

13.1Demonstration Plugin Configuration

diff --git a/web/src/pages/Doc/zh/constructor/index.md b/web/src/pages/Doc/zh/constructor/index.md index d15474a4..681b7a56 100644 --- a/web/src/pages/Doc/zh/constructor/index.md +++ b/web/src/pages/Doc/zh/constructor/index.md @@ -22,6 +22,8 @@ const mindMap = new MindMap({ ## 实例化选项 +### 1.基本 + | 字段名称 | 类型 | 默认值 | 描述 | | -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | | el | Element | | 容器元素,必传,必须为DOM元素(当容器元素在页面上的位置发生了改变,但大小没有改变的情况下必须调用`getElRectInfo()`方法更新库内部的相关信息;当大小也发生了改变后必须调用`resize()`方法,否则会造成一些功能异常) | @@ -32,15 +34,10 @@ const mindMap = new MindMap({ | themeConfig | Object | {} | 主题配置,会和所选择的主题进行合并,可用字段可参考:[default.js](https://github.com/wanglin2/mind-map/blob/main/simple-mind-map/src/themes/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, node) => {// 你的显示节点备注逻辑。node为v0.8.1+版本新增的回参,代表节点实例 }, 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(v0.9.1+默认改为move) | 鼠标滚轮的行为,`zoom`(放大缩小)、`move`(上下移动)。如果`customHandleMousewheel`传了自定义函数,这个属性不生效 | @@ -56,8 +53,6 @@ const mindMap = new MindMap({ | 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 | 是否在点击了画布外的区域时结束节点文本的编辑状态 | @@ -65,7 +60,6 @@ const mindMap = new MindMap({ | 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 | 设置为左键多选节点,右键拖动画布 | @@ -74,55 +68,36 @@ const mindMap = new MindMap({ | 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+)(v0.8.0+已删除该属性) | Boolean | true(v0.7.0+改为false) | 开启鼠标双击复位思维导图位置及缩放 | | enableDblclickBackToRootNode(v0.8.0+) | Boolean | 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(v0.7.1-fix.2+) | Boolean | false | 首次渲染时是否缩放至适应画布大小 | -| dragMultiNodeRectConfig(v0.7.2+) | Object | { width: 40, height: 20, fill: '' } | 拖拽多个节点时随鼠标移动的示意矩形的样式配置,传递一个对象,字段含义分别为矩形的宽、高、填充色 | -| dragPlaceholderRectFill(v0.7.2+) | String | | 节点拖拽时新位置的示意矩形的填充颜色,如果不传默认使用连线的颜色 | -| dragOpacityConfig(v0.7.2+) | Object | { cloneNodeOpacity: 0.5, beingDragNodeOpacity: 0.3 } | 节点拖拽时的透明度配置,传递一个对象,字段含义分别为:跟随鼠标移动的克隆节点或矩形的透明度、被拖拽节点的透明度 | | tagsColorMap(v0.7.2+) | Object | {} | 自定义节点标签的颜色,可传一个对象,key为要指定颜色的标签内容,value为该标签内容的颜色,如果不传内部会根据标签内容生成对应的颜色 | | cooperateStyle(v0.7.3+) | Object | { avatarSize: 22, fontSize: 12 } | 节点协作编辑时的人员头像样式配置,字段含义分别为:头像大小、如果是文字头像,那么文字的大小 | -| associativeLineIsAlwaysAboveNode(v0.8.0+) | Boolean | true | 关联线是否始终显示在节点上层,如果设为false,那么创建关联线和激活关联线时处于最顶层,其他情况下处于节点下方 | +| onlyOneEnableActiveNodeOnCooperate(v0.9.8+) | Boolean | false | 协同编辑时,同一个节点不能同时被多人选中 | | defaultGeneralizationText(v0.8.0+) | String | 概要 | 插入概要的默认文本 | | handleIsSplitByWrapOnPasteCreateNewNode(v0.8.0+) | Function / null | null | 粘贴文本的方式创建新节点时,控制是否按换行自动分割节点,即如果存在换行,那么会根据换行创建多个节点,否则只会创建一个节点,可以传递一个函数,返回promise,resolve代表根据换行分割,reject代表忽略换行 | | addHistoryTime(v0.8.0+) | Number | 100 | 指定时间内只允许添加一次历史记录,避免添加没有必要的中间状态,单位:ms | | isDisableDrag(v0.8.1+) | Boolean | false | 是否禁止拖动画布 | -| disableTouchZoom(v0.8.1+) | Boolean | false | 禁止双指缩放,你仍旧可以使用api进行缩放,对TouchEvent插件生效 | | highlightNodeBoxStyle(v0.9.0+) | Object | { stroke: 'rgb(94, 200, 248)', fill: 'transparent' } | 鼠标移入概要高亮所属节点时的高亮框样式 | | createNewNodeBehavior(v0.9.1+) | String | default | 创建新节点时的行为。default(默认会激活新创建的节点,并且进入编辑模式。如果同时创建了多个新节点,那么只会激活而不会进入编辑模式)、notActive(不激活新创建的节点)、activeOnly(只激活新创建的节点,不进入编辑模式) | | defaultNodeImage(v0.9.1-fix.2+) | String | | 图片地址,当节点图片加载失败时显示的默认图片 | | handleNodePasteImg(v0.9.2+) | null 或 Function | null | 在节点上粘贴剪贴板中的图片的处理方法,默认是转换为data:url数据插入到节点中,你可以通过该方法来将图片数据上传到服务器,实现保存图片的url。可以传递一个异步方法,接收Blob类型的图片数据,需要返回指定结构:{ url, size: {width, height} } | | isLimitMindMapInCanvas(v0.9.2+) | Boolean | false | 是否将思维导图限制在画布内。比如向右拖动时,思维导图图形的最左侧到达画布中心时将无法继续向右拖动,其他同理 | -| isLimitMindMapInCanvasWhenHasScrollbar(v0.9.2+) | Boolean | true | 当注册了滚动条插件(Scrollbar)时,是否将思维导图限制在画布内,isLimitMindMapInCanvas配置不再起作用 | -| associativeLineInitPointsPosition(v0.9.5+) | null / { from, to } | { from: '', to: '' } | 默认情况下,新创建的关联线两个端点的位置是根据两个节点中心点的相对位置来计算的,如果你想固定位置,可以通过这个选项来配置。from和to都不传,则都自动计算,如果只传一个,另一个则会自动计算。from和to可选值:left、top、bottom、right | -| enableAdjustAssociativeLinePoints(v0.9.5+) | Boolean | true | 是否允许调整关联线两个端点的位置 | -| isOnlySearchCurrentRenderNodes(v0.9.8+) | Boolean | false | 是否仅搜索当前渲染的节点,被收起的节点不会被搜索到 | -| onlyOneEnableActiveNodeOnCooperate(v0.9.8+) | Boolean | false | 协同编辑时,同一个节点不能同时被多人选中 | -| beforeCooperateUpdate(v0.9.8+) | Function、null | null | 协同编辑时,节点操作即将更新到其他客户端前的生命周期函数。函数接收一个对象作为参数:{ type: 【createOrUpdate(创建节点或更新节点)、delete(删除节点)】, list: 【数组类型,1.当type=createOrUpdate时,代表被创建或被更新的节点数据,即将同步到其他客户端,所以你可以修改该数据;2.当type=delete时,代表被删除的节点数据】 } | | beforeShortcutRun(v0.9.9+) | Function、null | null | 快捷键操作即将执行前的生命周期函数,返回true可以阻止操作执行。函数接收两个参数:key(快捷键)、activeNodeList(当前激活的节点列表) | -| rainbowLinesConfig(v0.9.9+) | Object | { open: false, colorsList: [] } | 彩虹线条配置,需要先注册RainbowLines插件。对象类型,结构:{ open: false【是否开启彩虹线条】, colorsList: []【自定义彩虹线条的颜色列表,如果不设置,会使用默认颜色列表】 } | -| addContentToHeader(v0.9.9+) | Function、null | null | 导出png、svg、pdf时在头部添加自定义内容。可传递一个函数,这个函数可以返回null代表不添加内容,也可以返回一个对象,详细介绍请参考下方【导出时如何添加自定义内容】 | -| addContentToFooter(v0.9.9+) | Function、null | null | 基本释义同addContentToHeader,在尾部添加自定义内容 | -| demonstrateConfig(v0.9.11+) | Object、null | null | 演示插件Demonstrate的配置。不传则使用默认配置,可传递一个对象,如果只配置某个属性,可以只设置该属性,其他没有设置的同样会使用默认配置,完整配置请参考下方【演示插件配置】小节 | | resetScaleOnMoveNodeToCenter(v0.9.12+) | Boolean | false | 移动节点到画布中心、回到根节点等操作时是否将缩放层级复位为100%(底层影响的是render类的moveNodeToCenter方法) | | createNodePrefixContent(v0.9.12+) | Function、null | null | 添加附加的节点前置内容。前置内容指和文本同一行的区域中的前置内容,不包括节点图片部分。可以传递一个函数,这个函数接收一个节点实例的参数,可以返回{el, width, height}格式的对象,el为DOM节点对象,width和height代表内容的宽高,数字类型,如果不需要自定义内容,也可以返回null | | createNodePostfixContent(v0.9.12+) | Function、null | null | 添加附加的节点后置内容。后置内容指和文本同一行的区域中的后置内容,不包括节点图片部分。用法同createNodePrefixContent | -### 数据结构 +#### 1.1数据结构 基本的数据结构如下: @@ -167,18 +142,7 @@ const mindMap = new MindMap({ 如果你要添加自定义的字段,可以添加到`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} | 水印文字样式 | -| onlyExport(v0.9.2+) | Boolean | false | 是否仅在导出时添加水印 | - -### 图标配置 +#### 1.2图标配置 | 字段名称 | 类型 | 默认值 | 描述 | | ----------- | ------ | ------------------------------------------- | ------------------------------------ | @@ -186,7 +150,20 @@ const mindMap = new MindMap({ | type | String | | 图标分组的值 | | list | Array | | 分组下的图标列表,数组的每一项为一个对象,`{ name: '', icon: '' }`,`name`代表图标的名称,`icon`代表图标,可以是`svg`图标,比如``,也可以是图片`url`,或者是`base64`图标,比如`data:image/png;base64,...` | -### 导出时如何添加自定义内容 + +### 2.Export插件 + +| 字段名称 | 类型 | 默认值 | 描述 | +| -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | +| exportPadding(已废除) | Number | 20 | 导出图片时的内边距 | +| exportPaddingX(v0.5.5+) | Number | 10 | 导出png、svg、pdf时的图形水平内边距 | +| exportPaddingY(v0.5.5+) | Number | 10 | 导出png、svg、pdf时的图形垂直内边距 | +| resetCss(v0.6.16+) | String | * { margin: 0; padding: 0; box-sizing: border-box; } | 设置导出图片和svg时,针对富文本节点内容,也就是嵌入到svg中的html节点的默认样式覆盖,如果不覆盖,节点内容会发生偏移 | +| minExportImgCanvasScale(v0.7.0+) | Number | 2 | 导出图片和pdf时canvas的缩放倍数,该配置会和window.devicePixelRatio值取最大值,用于提升图片清晰度 | +| addContentToHeader(v0.9.9+) | Function、null | null | 导出png、svg、pdf时在头部添加自定义内容。可传递一个函数,这个函数可以返回null代表不添加内容,也可以返回一个对象,详细介绍请参考下方【导出时如何添加自定义内容】 | +| addContentToFooter(v0.9.9+) | Function、null | null | 基本释义同addContentToHeader,在尾部添加自定义内容 | + +#### 2.1导出时如何添加自定义内容 `addContentToHeader`和`addContentToFooter`两个实例化选项可以用于在导出`png`、`svg`、`pdf`时在头部和尾部添加自定义的内容,默认为`null`,代表不配置,可以传递一个函数,函数可以返回`null`,代表不添加内容,如果要添加内容那么需要返回如下的结构: @@ -221,7 +198,93 @@ new MindMap({ }) ``` -### 演示插件配置 +### 3.Select插件 + +| 字段名称 | 类型 | 默认值 | 描述 | +| -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | +| selectTranslateStep | Number | 3 | 多选节点时鼠标移动到边缘时的画布移动偏移量 | +| selectTranslateLimit | Number | 20 | 多选节点时鼠标移动距边缘多少距离时开始偏移 | + +### 4.Drag插件 + +| 字段名称 | 类型 | 默认值 | 描述 | +| -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | +| enableFreeDrag(v0.2.4+) | Boolean | false | 是否开启节点自由拖拽(自由拖拽即可以把节点拖拽到画布的任意位置,注意不是拖拽节点成为其他节点的子节点兄弟节点的功能,自由拖拽的连线会存在一定问题,所以该特性最好不要使用) | +| nodeDragPlaceholderMaxSize(v0.6.12+)(v0.10.0+已废除) | Number | 20 | 拖拽元素时,指示元素新位置的块的最大高度 | +| autoMoveWhenMouseInEdgeOnDrag(v0.7.1+) | Boolean | true | 拖拽节点时鼠标移动到画布边缘是否开启画布自动移动 | +| dragMultiNodeRectConfig(v0.7.2+) | Object | { width: 40, height: 20, fill: '' } | 拖拽多个节点时随鼠标移动的示意矩形的样式配置,传递一个对象,字段含义分别为矩形的宽、高、填充色 | +| dragPlaceholderRectFill(v0.7.2+) | String | | 节点拖拽时新位置的示意矩形的填充颜色,如果不传默认使用连线的颜色 | +| dragOpacityConfig(v0.7.2+) | Object | { cloneNodeOpacity: 0.5, beingDragNodeOpacity: 0.3 } | 节点拖拽时的透明度配置,传递一个对象,字段含义分别为:跟随鼠标移动的克隆节点或矩形的透明度、被拖拽节点的透明度 | + +### 5.Watermark插件 + +| 字段名称 | 类型 | 默认值 | 描述 | +| -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | +| watermarkConfig(v0.2.4+) | Object | | 水印配置,详细配置请参考下方表格【水印配置】 | + +#### 5.1水印配置 + +| 字段名称 | 类型 | 默认值 | 描述 | +| ----------- | ------ | ------------------------------------------- | ------------------------------------ | +| text | String | '' | 水印文字,如果为空字符串则不显示水印 | +| lineSpacing | Number | 100 | 水印每行之间的间距 | +| textSpacing | Number | 100 | 同一行水印之间的间距 | +| angle | Number | 30 | 水印的倾斜角度,范围:[0, 90] | +| textStyle | Object | {color: '#999', opacity: 0.5, fontSize: 14} | 水印文字样式 | +| onlyExport(v0.9.2+) | Boolean | false | 是否仅在导出时添加水印 | + +### 6.AssociativeLine插件 + +| 字段名称 | 类型 | 默认值 | 描述 | +| -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | +| defaultAssociativeLineText(v0.5.11+) | String | 关联 | 关联线默认文字 | +| associativeLineIsAlwaysAboveNode(v0.8.0+) | Boolean | true | 关联线是否始终显示在节点上层,如果设为false,那么创建关联线和激活关联线时处于最顶层,其他情况下处于节点下方 | +| associativeLineInitPointsPosition(v0.9.5+) | null / { from, to } | { from: '', to: '' } | 默认情况下,新创建的关联线两个端点的位置是根据两个节点中心点的相对位置来计算的,如果你想固定位置,可以通过这个选项来配置。from和to都不传,则都自动计算,如果只传一个,另一个则会自动计算。from和to可选值:left、top、bottom、right | +| enableAdjustAssociativeLinePoints(v0.9.5+) | Boolean | true | 是否允许调整关联线两个端点的位置 | + +### 7.RichText插件 + +| 字段名称 | 类型 | 默认值 | 描述 | +| -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | +| richTextEditFakeInPlace(v0.6.13+) | Boolean | false | 设置富文本节点编辑框和节点大小一致,形成伪原地编辑的效果,需要注意的是,只有当节点内只有文本、且形状是矩形才会有比较好的效果 | + +### 8.TouchEvent插件 + +| 字段名称 | 类型 | 默认值 | 描述 | +| -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | +| disableTouchZoom(v0.8.1+) | Boolean | false | 禁止双指缩放,你仍旧可以使用api进行缩放,对TouchEvent插件生效 | + +### 9.Scrollbar插件 + +| 字段名称 | 类型 | 默认值 | 描述 | +| -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | +| isLimitMindMapInCanvasWhenHasScrollbar(v0.9.2+) | Boolean | true | 当注册了滚动条插件(Scrollbar)时,是否将思维导图限制在画布内,isLimitMindMapInCanvas配置不再起作用 | + +### 10.Search插件 + +| 字段名称 | 类型 | 默认值 | 描述 | +| -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | +| isOnlySearchCurrentRenderNodes(v0.9.8+) | Boolean | false | 是否仅搜索当前渲染的节点,被收起的节点不会被搜索到 | + +### 11.Cooperate插件 + +| 字段名称 | 类型 | 默认值 | 描述 | +| -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | +| beforeCooperateUpdate(v0.9.8+) | Function、null | null | 协同编辑时,节点操作即将更新到其他客户端前的生命周期函数。函数接收一个对象作为参数:{ type: 【createOrUpdate(创建节点或更新节点)、delete(删除节点)】, list: 【数组类型,1.当type=createOrUpdate时,代表被创建或被更新的节点数据,即将同步到其他客户端,所以你可以修改该数据;2.当type=delete时,代表被删除的节点数据】 } | + +### 12.RainbowLines插件 + +| 字段名称 | 类型 | 默认值 | 描述 | +| -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | +| rainbowLinesConfig(v0.9.9+) | Object | { open: false, colorsList: [] } | 彩虹线条配置,需要先注册RainbowLines插件。对象类型,结构:{ open: false【是否开启彩虹线条】, colorsList: []【自定义彩虹线条的颜色列表,如果不设置,会使用默认颜色列表】 } | + +### 13.Demonstrate插件 + +| 字段名称 | 类型 | 默认值 | 描述 | +| -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | +| demonstrateConfig(v0.9.11+) | Object、null | null | 演示插件Demonstrate的配置。不传则使用默认配置,可传递一个对象,如果只配置某个属性,可以只设置该属性,其他没有设置的同样会使用默认配置,完整配置请参考下方【演示插件配置】小节 | + +#### 13.1演示插件配置 | 字段名称 | 类型 | 默认值 | 描述 | | ----------- | ------ | ------------------------------------------- | ------------------------------------ | diff --git a/web/src/pages/Doc/zh/constructor/index.vue b/web/src/pages/Doc/zh/constructor/index.vue index 1098a4d3..d7fdbc35 100644 --- a/web/src/pages/Doc/zh/constructor/index.vue +++ b/web/src/pages/Doc/zh/constructor/index.vue @@ -17,6 +17,7 @@ });

实例化选项

+

1.基本

@@ -76,12 +77,6 @@ - - - - - - @@ -94,18 +89,6 @@ - - - - - - - - - - - - @@ -118,18 +101,6 @@ - - - - - - - - - - - - @@ -220,18 +191,6 @@ - - - - - - - - - - - - @@ -274,12 +233,6 @@ - - - - - - @@ -328,12 +281,6 @@ - - - - - - @@ -346,12 +293,6 @@ - - - - - - @@ -370,12 +311,6 @@ - - - - - - @@ -388,12 +323,6 @@ - - - - - - @@ -418,36 +347,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -460,10 +365,10 @@ - + - - + + @@ -490,12 +395,6 @@ - - - - - - @@ -526,72 +425,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -611,7 +450,7 @@
节点里最多显示的标签数量,多余的会被丢弃
exportPaddingNumber20导出图片时的内边距
imgTextMargin Number 5节点里各种文字信息的间距,如图标和文字的间距
selectTranslateStepNumber3多选节点时鼠标移动到边缘时的画布移动偏移量
selectTranslateLimitNumber20多选节点时鼠标移动距边缘多少距离时开始偏移
customNoteContentShow(v0.1.6+) Object null是否是只读模式
enableFreeDrag(v0.2.4+)Booleanfalse是否开启节点自由拖拽(自由拖拽即可以把节点拖拽到画布的任意位置,注意不是拖拽节点成为其他节点的子节点兄弟节点的功能,自由拖拽的连线会存在一定问题,所以该特性最好不要使用)
watermarkConfig(v0.2.4+)Object水印配置,详细配置请参考下方表格【水印配置】
textAutoWrapWidth(v0.3.4+) Number 500初始根节点的位置,可传一个数组,默认为['center', 'center'],代表根节点处于画布中心位置,除了center,关键词还可以设置lefttoprightbottom,除了可以传关键词,数组的每项还可以传递一个数字,代表具体的像素,可以传递一个百分比字符串,比如['40%', '60%'],代表水平位置在画布宽度的40%的位置,垂直位置在画布高度的60%的位置
exportPaddingX(v0.5.5+)Number10导出png、svg、pdf时的图形水平内边距
exportPaddingY(v0.5.5+)Number10导出png、svg、pdf时的图形垂直内边距
nodeTextEditZIndex(v0.5.5+) Number 3000节点最大缓存数量。为了优化性能,内部会维护一个节点缓存池,用来复用节点,通过该属性可以指定池的最大缓存数量
defaultAssociativeLineText(v0.5.11+)String关联关联线默认文字
fitPadding(v0.6.0+) Number 50指定内部一些元素(节点文本编辑元素、节点备注显示元素、关联线文本编辑元素、节点图片调整按钮元素)添加到的位置,默认添加到document.body下
nodeDragPlaceholderMaxSize(v0.6.12+)Number20拖拽元素时,指示元素新位置的块的最大高度
enableCreateHiddenInput(v0.6.13+)(v0.6.14+版本已去除该特性) Boolean true是否在存在一个激活节点时,当按下中文、英文、数字按键时自动进入文本编辑模式
richTextEditFakeInPlace(v0.6.13+)Booleanfalse设置富文本节点编辑框和节点大小一致,形成伪原地编辑的效果,需要注意的是,只有当节点内只有文本、且形状是矩形才会有比较好的效果
customHandleClipboardText(v0.6.14+) Function null禁止鼠标滚轮缩放,你仍旧可以使用api进行缩放
resetCss(v0.6.16+)String* { margin: 0; padding: 0; box-sizing: border-box; }设置导出图片和svg时,针对富文本节点内容,也就是嵌入到svg中的html节点的默认样式覆盖,如果不覆盖,节点内容会发生偏移
enableDblclickReset(v0.6.17+)(v0.8.0+已删除该属性) Boolean true(v0.7.0+改为false)是否在鼠标双击时回到根节点,也就是让根节点居中显示
minExportImgCanvasScale(v0.7.0+)Number2导出图片和pdf时canvas的缩放倍数,该配置会和window.devicePixelRatio值取最大值,用于提升图片清晰度
hoverRectColor(v0.7.0+) String rgb(94, 200, 248)是否开启删除节点后自动激活节点相邻节点或父节点的功能
autoMoveWhenMouseInEdgeOnDrag(v0.7.1+)Booleantrue拖拽节点时鼠标移动到画布边缘是否开启画布自动移动
fit(v0.7.1-fix.2+) Boolean false 首次渲染时是否缩放至适应画布大小
dragMultiNodeRectConfig(v0.7.2+)Object{ width: 40, height: 20, fill: '' }拖拽多个节点时随鼠标移动的示意矩形的样式配置,传递一个对象,字段含义分别为矩形的宽、高、填充色
dragPlaceholderRectFill(v0.7.2+)String节点拖拽时新位置的示意矩形的填充颜色,如果不传默认使用连线的颜色
dragOpacityConfig(v0.7.2+)Object{ cloneNodeOpacity: 0.5, beingDragNodeOpacity: 0.3 }节点拖拽时的透明度配置,传递一个对象,字段含义分别为:跟随鼠标移动的克隆节点或矩形的透明度、被拖拽节点的透明度
tagsColorMap(v0.7.2+) Object {}节点协作编辑时的人员头像样式配置,字段含义分别为:头像大小、如果是文字头像,那么文字的大小
associativeLineIsAlwaysAboveNode(v0.8.0+)onlyOneEnableActiveNodeOnCooperate(v0.9.8+) Booleantrue关联线是否始终显示在节点上层,如果设为false,那么创建关联线和激活关联线时处于最顶层,其他情况下处于节点下方false协同编辑时,同一个节点不能同时被多人选中
defaultGeneralizationText(v0.8.0+)是否禁止拖动画布
disableTouchZoom(v0.8.1+)Booleanfalse禁止双指缩放,你仍旧可以使用api进行缩放,对TouchEvent插件生效
highlightNodeBoxStyle(v0.9.0+) Object { stroke: 'rgb(94, 200, 248)', fill: 'transparent' }是否将思维导图限制在画布内。比如向右拖动时,思维导图图形的最左侧到达画布中心时将无法继续向右拖动,其他同理
isLimitMindMapInCanvasWhenHasScrollbar(v0.9.2+)Booleantrue当注册了滚动条插件(Scrollbar)时,是否将思维导图限制在画布内,isLimitMindMapInCanvas配置不再起作用
associativeLineInitPointsPosition(v0.9.5+)null / { from, to }{ from: '', to: '' }默认情况下,新创建的关联线两个端点的位置是根据两个节点中心点的相对位置来计算的,如果你想固定位置,可以通过这个选项来配置。from和to都不传,则都自动计算,如果只传一个,另一个则会自动计算。from和to可选值:left、top、bottom、right
enableAdjustAssociativeLinePoints(v0.9.5+)Booleantrue是否允许调整关联线两个端点的位置
isOnlySearchCurrentRenderNodes(v0.9.8+)Booleanfalse是否仅搜索当前渲染的节点,被收起的节点不会被搜索到
onlyOneEnableActiveNodeOnCooperate(v0.9.8+)Booleanfalse协同编辑时,同一个节点不能同时被多人选中
beforeCooperateUpdate(v0.9.8+)Function、nullnull协同编辑时,节点操作即将更新到其他客户端前的生命周期函数。函数接收一个对象作为参数:{ type: 【createOrUpdate(创建节点或更新节点)、delete(删除节点)】, list: 【数组类型,1.当type=createOrUpdate时,代表被创建或被更新的节点数据,即将同步到其他客户端,所以你可以修改该数据;2.当type=delete时,代表被删除的节点数据】 }
beforeShortcutRun(v0.9.9+) Function、null null 快捷键操作即将执行前的生命周期函数,返回true可以阻止操作执行。函数接收两个参数:key(快捷键)、activeNodeList(当前激活的节点列表)
rainbowLinesConfig(v0.9.9+)Object{ open: false, colorsList: [] }彩虹线条配置,需要先注册RainbowLines插件。对象类型,结构:{ open: false【是否开启彩虹线条】, colorsList: []【自定义彩虹线条的颜色列表,如果不设置,会使用默认颜色列表】 }
addContentToHeader(v0.9.9+)Function、nullnull导出png、svg、pdf时在头部添加自定义内容。可传递一个函数,这个函数可以返回null代表不添加内容,也可以返回一个对象,详细介绍请参考下方【导出时如何添加自定义内容】
addContentToFooter(v0.9.9+)Function、nullnull基本释义同addContentToHeader,在尾部添加自定义内容
demonstrateConfig(v0.9.11+)Object、nullnull演示插件Demonstrate的配置。不传则使用默认配置,可传递一个对象,如果只配置某个属性,可以只设置该属性,其他没有设置的同样会使用默认配置,完整配置请参考下方【演示插件配置】小节
resetScaleOnMoveNodeToCenter(v0.9.12+) Boolean false
-

数据结构

+

1.1数据结构

基本的数据结构如下:

{
   data: {
@@ -651,7 +490,214 @@
 }
 

如果你要添加自定义的字段,可以添加到datachildren同级,如果你要添加到data对象里,那么请使用_开头来命名你的自定义字段,内部会通过这个来判断是否是自定义字段。

-

水印配置

+

1.2图标配置

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
字段名称类型默认值描述
nameString图标分组的名称
typeString图标分组的值
listArray分组下的图标列表,数组的每一项为一个对象,{ name: '', icon: '' }name代表图标的名称,icon代表图标,可以是svg图标,比如<svg ...><path></path></svg>,也可以是图片url,或者是base64图标,比如data:image/png;base64,...
+

2.Export插件

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
字段名称类型默认值描述
exportPadding(已废除)Number20导出图片时的内边距
exportPaddingX(v0.5.5+)Number10导出png、svg、pdf时的图形水平内边距
exportPaddingY(v0.5.5+)Number10导出png、svg、pdf时的图形垂直内边距
resetCss(v0.6.16+)String* { margin: 0; padding: 0; box-sizing: border-box; }设置导出图片和svg时,针对富文本节点内容,也就是嵌入到svg中的html节点的默认样式覆盖,如果不覆盖,节点内容会发生偏移
minExportImgCanvasScale(v0.7.0+)Number2导出图片和pdf时canvas的缩放倍数,该配置会和window.devicePixelRatio值取最大值,用于提升图片清晰度
addContentToHeader(v0.9.9+)Function、nullnull导出png、svg、pdf时在头部添加自定义内容。可传递一个函数,这个函数可以返回null代表不添加内容,也可以返回一个对象,详细介绍请参考下方【导出时如何添加自定义内容】
addContentToFooter(v0.9.9+)Function、nullnull基本释义同addContentToHeader,在尾部添加自定义内容
+

2.1导出时如何添加自定义内容

+

addContentToHeaderaddContentToFooter两个实例化选项可以用于在导出pngsvgpdf时在头部和尾部添加自定义的内容,默认为null,代表不配置,可以传递一个函数,函数可以返回null,代表不添加内容,如果要添加内容那么需要返回如下的结构:

+
{
+  el,// 要追加的自定义DOM节点,样式可内联
+  cssText,// 可选,如果样式不想内联,可以传递该值,一个css字符串
+  height: 50// 返回的DOM节点的高度,必须传递
+}
+
+

一个简单的示例:

+
new MindMap({
+  addContentToFooter: () => {
+    const el = document.createElement('div')
+    el.className = 'footer'
+    el.innerHTML = '来自:simple-mind-map'
+    const cssText = `
+      .footer {
+        width: 100%;
+        height: 30px;
+      }
+    `
+    return {
+      el,
+      cssText,
+      height: 30
+    }
+  }
+})
+
+

3.Select插件

+ + + + + + + + + + + + + + + + + + + + + + + +
字段名称类型默认值描述
selectTranslateStepNumber3多选节点时鼠标移动到边缘时的画布移动偏移量
selectTranslateLimitNumber20多选节点时鼠标移动距边缘多少距离时开始偏移
+

4.Drag插件

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
字段名称类型默认值描述
enableFreeDrag(v0.2.4+)Booleanfalse是否开启节点自由拖拽(自由拖拽即可以把节点拖拽到画布的任意位置,注意不是拖拽节点成为其他节点的子节点兄弟节点的功能,自由拖拽的连线会存在一定问题,所以该特性最好不要使用)
nodeDragPlaceholderMaxSize(v0.6.12+)(v0.10.0+已废除)Number20拖拽元素时,指示元素新位置的块的最大高度
autoMoveWhenMouseInEdgeOnDrag(v0.7.1+)Booleantrue拖拽节点时鼠标移动到画布边缘是否开启画布自动移动
dragMultiNodeRectConfig(v0.7.2+)Object{ width: 40, height: 20, fill: '' }拖拽多个节点时随鼠标移动的示意矩形的样式配置,传递一个对象,字段含义分别为矩形的宽、高、填充色
dragPlaceholderRectFill(v0.7.2+)String节点拖拽时新位置的示意矩形的填充颜色,如果不传默认使用连线的颜色
dragOpacityConfig(v0.7.2+)Object{ cloneNodeOpacity: 0.5, beingDragNodeOpacity: 0.3 }节点拖拽时的透明度配置,传递一个对象,字段含义分别为:跟随鼠标移动的克隆节点或矩形的透明度、被拖拽节点的透明度
+

5.Watermark插件

+ + + + + + + + + + + + + + + + + +
字段名称类型默认值描述
watermarkConfig(v0.2.4+)Object水印配置,详细配置请参考下方表格【水印配置】
+

5.1水印配置

@@ -700,7 +746,7 @@
-

图标配置

+

6.AssociativeLine插件

@@ -712,54 +758,165 @@ - + - - + + - - - - + + + + - - - - + + + + + + + + + +
namedefaultAssociativeLineText(v0.5.11+) String图标分组的名称关联关联线默认文字
typeString图标分组的值associativeLineIsAlwaysAboveNode(v0.8.0+)Booleantrue关联线是否始终显示在节点上层,如果设为false,那么创建关联线和激活关联线时处于最顶层,其他情况下处于节点下方
listArray分组下的图标列表,数组的每一项为一个对象,{ name: '', icon: '' }name代表图标的名称,icon代表图标,可以是svg图标,比如<svg ...><path></path></svg>,也可以是图片url,或者是base64图标,比如data:image/png;base64,...associativeLineInitPointsPosition(v0.9.5+)null / { from, to }{ from: '', to: '' }默认情况下,新创建的关联线两个端点的位置是根据两个节点中心点的相对位置来计算的,如果你想固定位置,可以通过这个选项来配置。from和to都不传,则都自动计算,如果只传一个,另一个则会自动计算。from和to可选值:left、top、bottom、right
enableAdjustAssociativeLinePoints(v0.9.5+)Booleantrue是否允许调整关联线两个端点的位置
-

导出时如何添加自定义内容

-

addContentToHeaderaddContentToFooter两个实例化选项可以用于在导出pngsvgpdf时在头部和尾部添加自定义的内容,默认为null,代表不配置,可以传递一个函数,函数可以返回null,代表不添加内容,如果要添加内容那么需要返回如下的结构:

-
{
-  el,// 要追加的自定义DOM节点,样式可内联
-  cssText,// 可选,如果样式不想内联,可以传递该值,一个css字符串
-  height: 50// 返回的DOM节点的高度,必须传递
-}
-
-

一个简单的示例:

-
new MindMap({
-  addContentToFooter: () => {
-    const el = document.createElement('div')
-    el.className = 'footer'
-    el.innerHTML = '来自:simple-mind-map'
-    const cssText = `
-      .footer {
-        width: 100%;
-        height: 30px;
-      }
-    `
-    return {
-      el,
-      cssText,
-      height: 30
-    }
-  }
-})
-
-

演示插件配置

+

7.RichText插件

+ + + + + + + + + + + + + + + + + +
字段名称类型默认值描述
richTextEditFakeInPlace(v0.6.13+)Booleanfalse设置富文本节点编辑框和节点大小一致,形成伪原地编辑的效果,需要注意的是,只有当节点内只有文本、且形状是矩形才会有比较好的效果
+

8.TouchEvent插件

+ + + + + + + + + + + + + + + + + +
字段名称类型默认值描述
disableTouchZoom(v0.8.1+)Booleanfalse禁止双指缩放,你仍旧可以使用api进行缩放,对TouchEvent插件生效
+

9.Scrollbar插件

+ + + + + + + + + + + + + + + + + +
字段名称类型默认值描述
isLimitMindMapInCanvasWhenHasScrollbar(v0.9.2+)Booleantrue当注册了滚动条插件(Scrollbar)时,是否将思维导图限制在画布内,isLimitMindMapInCanvas配置不再起作用
+

10.Search插件

+ + + + + + + + + + + + + + + + + +
字段名称类型默认值描述
isOnlySearchCurrentRenderNodes(v0.9.8+)Booleanfalse是否仅搜索当前渲染的节点,被收起的节点不会被搜索到
+

11.Cooperate插件

+ + + + + + + + + + + + + + + + + +
字段名称类型默认值描述
beforeCooperateUpdate(v0.9.8+)Function、nullnull协同编辑时,节点操作即将更新到其他客户端前的生命周期函数。函数接收一个对象作为参数:{ type: 【createOrUpdate(创建节点或更新节点)、delete(删除节点)】, list: 【数组类型,1.当type=createOrUpdate时,代表被创建或被更新的节点数据,即将同步到其他客户端,所以你可以修改该数据;2.当type=delete时,代表被删除的节点数据】 }
+

12.RainbowLines插件

+ + + + + + + + + + + + + + + + + +
字段名称类型默认值描述
rainbowLinesConfig(v0.9.9+)Object{ open: false, colorsList: [] }彩虹线条配置,需要先注册RainbowLines插件。对象类型,结构:{ open: false【是否开启彩虹线条】, colorsList: []【自定义彩虹线条的颜色列表,如果不设置,会使用默认颜色列表】 }
+

13.Demonstrate插件

+ + + + + + + + + + + + + + + + + +
字段名称类型默认值描述
demonstrateConfig(v0.9.11+)Object、nullnull演示插件Demonstrate的配置。不传则使用默认配置,可传递一个对象,如果只配置某个属性,可以只设置该属性,其他没有设置的同样会使用默认配置,完整配置请参考下方【演示插件配置】小节
+

13.1演示插件配置