mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-24 10:28:26 +08:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a64094f14 | ||
|
|
95fdb35f7b | ||
|
|
497c2606df | ||
|
|
d735be1204 | ||
|
|
45d2da1337 | ||
|
|
194571d5fe | ||
|
|
418b24b039 | ||
|
|
b32a8b5a85 | ||
|
|
2dee415a64 | ||
|
|
4e7d59b328 | ||
|
|
9bde9ffaf3 |
@@ -431,4 +431,12 @@ const mindMap = new MindMap({
|
||||
<img src="./web/src/assets/avatar/晴空.jpg" style="width: 50px;height: 50px;" />
|
||||
<span>晴空</span>
|
||||
</span>
|
||||
<span>
|
||||
<img src="./web/src/assets/avatar/default.png" style="width: 50px;height: 50px;" />
|
||||
<span>黄泳</span>
|
||||
</span>
|
||||
<span>
|
||||
<img src="./web/src/assets/avatar/ccccs.jpg" style="width: 50px;height: 50px;" />
|
||||
<span>ccccs</span>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
File diff suppressed because one or more lines are too long
BIN
dist/img/ccccs.jpg
vendored
Normal file
BIN
dist/img/ccccs.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
2
dist/js/app.js
vendored
2
dist/js/app.js
vendored
File diff suppressed because one or more lines are too long
1
dist/js/chunk-2c6ccfd7.js
vendored
1
dist/js/chunk-2c6ccfd7.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/chunk-2d0c0a44.js
vendored
2
dist/js/chunk-2d0c0a44.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/chunk-2d0d9fbc.js
vendored
2
dist/js/chunk-2d0d9fbc.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/chunk-2d0dad5f.js
vendored
2
dist/js/chunk-2d0dad5f.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/chunk-2d0f026c.js
vendored
2
dist/js/chunk-2d0f026c.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/chunk-2d208ffa.js
vendored
2
dist/js/chunk-2d208ffa.js
vendored
File diff suppressed because one or more lines are too long
1
dist/js/chunk-2d20f68f.js
vendored
1
dist/js/chunk-2d20f68f.js
vendored
@@ -1 +0,0 @@
|
||||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d20f68f"],{b407:function(n,u,t){"use strict";t.r(u);var c=function(){var n=this,u=n._self._c;return u("div")},e=[],l={},s=l,i=t("2877"),o=Object(i["a"])(s,c,e,!1,null,null,null);u["default"]=o.exports}}]);
|
||||
2
dist/js/chunk-2d216004.js
vendored
2
dist/js/chunk-2d216004.js
vendored
File diff suppressed because one or more lines are too long
1
dist/js/chunk-583efa32.js
vendored
Normal file
1
dist/js/chunk-583efa32.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
dist/js/chunk-68de956c.js
vendored
2
dist/js/chunk-68de956c.js
vendored
File diff suppressed because one or more lines are too long
1
dist/js/chunk-6f12c8fe.js
vendored
Normal file
1
dist/js/chunk-6f12c8fe.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -9,7 +9,7 @@
|
||||
})
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}</script><link href="dist/css/chunk-vendors.css?dca8675d85e0a079cc96" rel="stylesheet"><link href="dist/css/app.css?dca8675d85e0a079cc96" rel="stylesheet"></head><body><noscript><strong>We're sorry but thoughts doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script>const getDataFromBackend = () => {
|
||||
}</script><link href="dist/css/chunk-vendors.css?4d8e2833c3860a9a5265" rel="stylesheet"><link href="dist/css/app.css?4d8e2833c3860a9a5265" rel="stylesheet"></head><body><noscript><strong>We're sorry but thoughts doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script>const getDataFromBackend = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve({
|
||||
@@ -74,4 +74,4 @@
|
||||
// 可以通过window.$bus.$on()来监听应用的一些事件
|
||||
// 实例化页面
|
||||
window.initApp()
|
||||
}</script><script src="dist/js/chunk-vendors.js?dca8675d85e0a079cc96"></script><script src="dist/js/app.js?dca8675d85e0a079cc96"></script></body></html>
|
||||
}</script><script src="dist/js/chunk-vendors.js?4d8e2833c3860a9a5265"></script><script src="dist/js/app.js?4d8e2833c3860a9a5265"></script></body></html>
|
||||
@@ -31,7 +31,7 @@ MindMap.iconList = icons.nodeIconList
|
||||
MindMap.constants = constants
|
||||
MindMap.themes = themes
|
||||
MindMap.defaultTheme = defaultTheme
|
||||
MindMap.version = '0.10.3'
|
||||
MindMap.version = '0.10.4'
|
||||
|
||||
MindMap.usePlugin(MiniMap)
|
||||
.usePlugin(Watermark)
|
||||
|
||||
@@ -194,7 +194,7 @@ class MindMap {
|
||||
this.renderer.reRender = true // 标记为重新渲染
|
||||
this.renderer.clearCache() // 清空节点缓存池
|
||||
this.clearDraw() // 清空画布
|
||||
this.render(callback, (source = ''))
|
||||
this.render(callback, source)
|
||||
}
|
||||
|
||||
// 获取或更新容器尺寸位置信息
|
||||
@@ -288,7 +288,9 @@ class MindMap {
|
||||
|
||||
// 更新配置
|
||||
updateConfig(opt = {}) {
|
||||
this.emit('before_update_config', this.opt)
|
||||
this.opt = this.handleOpt(merge.all([defaultOpt, this.opt, opt]))
|
||||
this.emit('after_update_config', this.opt)
|
||||
}
|
||||
|
||||
// 获取当前布局结构
|
||||
@@ -379,6 +381,9 @@ class MindMap {
|
||||
// 导出
|
||||
async export(...args) {
|
||||
try {
|
||||
if (!this.doExport) {
|
||||
throw new Error('请注册Export插件!')
|
||||
}
|
||||
let result = await this.doExport.export(...args)
|
||||
return result
|
||||
} catch (error) {
|
||||
@@ -416,6 +421,11 @@ class MindMap {
|
||||
addContentToFooter,
|
||||
node
|
||||
} = {}) {
|
||||
const { watermarkConfig, openPerformance } = this.opt
|
||||
// 如果开启了性能模式,那么需要先渲染所有节点
|
||||
if (openPerformance) {
|
||||
this.renderer.forceLoadNode(node)
|
||||
}
|
||||
const { cssTextList, header, headerHeight, footer, footerHeight } =
|
||||
handleGetSvgDataExtraContent({
|
||||
addContentToHeader,
|
||||
@@ -459,7 +469,7 @@ class MindMap {
|
||||
if (!ignoreWatermark && hasWatermark) {
|
||||
this.watermark.isInExport = true
|
||||
// 是否是仅导出时需要水印
|
||||
const { onlyExport } = this.opt.watermarkConfig
|
||||
const { onlyExport } = watermarkConfig
|
||||
// 是否需要重新绘制水印
|
||||
const needReDrawWatermark =
|
||||
rect.width > origWidth || rect.height > origHeight
|
||||
|
||||
6
simple-mind-map/package-lock.json
generated
6
simple-mind-map/package-lock.json
generated
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "simple-mind-map",
|
||||
"version": "0.10.0-fix.1",
|
||||
"version": "0.10.4",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"version": "0.10.0-fix.1",
|
||||
"version": "0.10.4",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@svgdotjs/svg.js": "^3.0.16",
|
||||
"@svgdotjs/svg.js": "^3.2.0",
|
||||
"deepmerge": "^1.5.2",
|
||||
"eventemitter3": "^4.0.7",
|
||||
"jszip": "^3.10.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "simple-mind-map",
|
||||
"version": "0.10.3",
|
||||
"version": "0.10.4",
|
||||
"description": "一个简单的web在线思维导图",
|
||||
"authors": [
|
||||
{
|
||||
@@ -28,7 +28,7 @@
|
||||
"module": "index.js",
|
||||
"main": "./dist/simpleMindMap.umd.min.js",
|
||||
"dependencies": {
|
||||
"@svgdotjs/svg.js": "^3.0.16",
|
||||
"@svgdotjs/svg.js": "^3.2.0",
|
||||
"deepmerge": "^1.5.2",
|
||||
"eventemitter3": "^4.0.7",
|
||||
"jszip": "^3.10.1",
|
||||
|
||||
@@ -228,6 +228,14 @@ export const defaultOpt = {
|
||||
// 自定义超链接的跳转
|
||||
// 如果不传,默认会以新窗口的方式打开超链接,可以传递一个函数,函数接收两个参数:link(超链接的url)、node(所属节点实例),只要传递了函数,就会阻止默认的跳转
|
||||
customHyperlinkJump: null,
|
||||
// 是否开启性能模式,默认情况下所有节点都会直接渲染,无论是否处于画布可视区域,这样当节点数量比较多时(1000+)会比较卡,如果你的数据量比较大,那么可以通过该配置开启性能模式,即只渲染画布可视区域内的节点,超出的节点不渲染,这样会大幅提高渲染速度,当然同时也会带来一些其他问题,比如:1.当拖动或是缩放画布时会实时计算并渲染未节点的节点,所以会带来一定卡顿;2.导出图片、svg、pdf时需要先渲染全部节点,所以会比较慢;3.其他目前未发现的问题
|
||||
openPerformance: false,
|
||||
// 性能优化模式配置
|
||||
performanceConfig: {
|
||||
time: 250,// 当视图改变后多久刷新一次节点,单位:ms,
|
||||
padding: 100,// 超出画布四周指定范围内依旧渲染节点
|
||||
removeNodeWhenOutCanvas: true,// 节点移除画布可视区域后从画布删除
|
||||
},
|
||||
|
||||
// 【Select插件】
|
||||
// 多选节点时鼠标移动到边缘时的画布移动偏移量
|
||||
|
||||
@@ -32,7 +32,8 @@ import {
|
||||
checkIsNodeStyleDataKey,
|
||||
removeRichTextStyes,
|
||||
formatGetNodeGeneralization,
|
||||
sortNodeList
|
||||
sortNodeList,
|
||||
throttle
|
||||
} from '../../utils'
|
||||
import { shapeList } from './node/Shape'
|
||||
import { lineStyleProps } from '../../themes/default'
|
||||
@@ -144,13 +145,54 @@ class Render {
|
||||
if (!this.mindMap.opt.enableDblclickBackToRootNode) return
|
||||
this.setRootNodeCenter()
|
||||
})
|
||||
// let timer = null
|
||||
// this.mindMap.on('view_data_change', () => {
|
||||
// clearTimeout(timer)
|
||||
// timer = setTimeout(() => {
|
||||
// this.render()
|
||||
// }, 300)
|
||||
// })
|
||||
// 性能模式
|
||||
this.performanceMode()
|
||||
}
|
||||
|
||||
// 性能模式,懒加载节点
|
||||
performanceMode() {
|
||||
const { openPerformance, performanceConfig } = this.mindMap.opt
|
||||
const onViewDataChange = throttle(() => {
|
||||
if (this.root) {
|
||||
this.mindMap.emit('node_tree_render_start')
|
||||
this.root.render(
|
||||
() => {
|
||||
this.mindMap.emit('node_tree_render_end')
|
||||
},
|
||||
false,
|
||||
true
|
||||
)
|
||||
}
|
||||
}, performanceConfig.time)
|
||||
let lastOpen = false
|
||||
this.mindMap.on('before_update_config', opt => {
|
||||
lastOpen = opt.openPerformance
|
||||
})
|
||||
this.mindMap.on('after_update_config', opt => {
|
||||
if (opt.openPerformance && !lastOpen) {
|
||||
// 动态开启性能模式
|
||||
this.mindMap.on('view_data_change', onViewDataChange)
|
||||
this.forceLoadNode()
|
||||
}
|
||||
if (!opt.openPerformance && lastOpen) {
|
||||
// 动态关闭性能模式
|
||||
this.mindMap.off('view_data_change', onViewDataChange)
|
||||
this.forceLoadNode()
|
||||
}
|
||||
})
|
||||
if (!openPerformance) return
|
||||
this.mindMap.on('view_data_change', onViewDataChange)
|
||||
}
|
||||
|
||||
// 强制渲染节点,不考虑是否在画布可视区域内
|
||||
forceLoadNode(node) {
|
||||
node = node || this.root
|
||||
if (node) {
|
||||
this.mindMap.emit('node_tree_render_start')
|
||||
node.render(() => {
|
||||
this.mindMap.emit('node_tree_render_end')
|
||||
}, true)
|
||||
}
|
||||
}
|
||||
|
||||
// 注册命令
|
||||
@@ -453,6 +495,7 @@ class Render {
|
||||
}
|
||||
this.mindMap.emit('node_tree_render_start')
|
||||
// 计算布局
|
||||
this.root = null
|
||||
this.layout.doLayout(root => {
|
||||
// 删除本次渲染时不再需要的节点
|
||||
Object.keys(this.lastNodeCache).forEach(uid => {
|
||||
|
||||
@@ -528,6 +528,7 @@ class Node {
|
||||
textContentNested.add(foreignObject)
|
||||
textContentOffsetX += this._postfixData.width
|
||||
}
|
||||
this.group.add(textContentNested)
|
||||
// 文字内容整体
|
||||
textContentNested.translate(
|
||||
width / 2 - textContentNested.bbox().width / 2,
|
||||
@@ -535,7 +536,6 @@ class Node {
|
||||
imgHeight + // 图片高度
|
||||
(imgHeight > 0 && textContentHeight > 0 ? this.blockContentMargin : 0) // 和图片的间距
|
||||
)
|
||||
this.group.add(textContentNested)
|
||||
addHoverNode()
|
||||
this.mindMap.emit('node_layout_end', this)
|
||||
}
|
||||
@@ -683,7 +683,7 @@ class Node {
|
||||
}
|
||||
|
||||
// 更新节点
|
||||
update() {
|
||||
update(forceRender) {
|
||||
if (!this.group) {
|
||||
return
|
||||
}
|
||||
@@ -710,36 +710,11 @@ class Node {
|
||||
}
|
||||
}
|
||||
// 更新概要
|
||||
this.renderGeneralization()
|
||||
this.renderGeneralization(forceRender)
|
||||
// 更新协同头像
|
||||
if (this.updateUserListNode) this.updateUserListNode()
|
||||
// 更新节点位置
|
||||
let t = this.group.transform()
|
||||
// // 如果上次不在可视区内,且本次也不在,那么直接返回
|
||||
// let { left: ox, top: oy } = this.getNodePosInClient(
|
||||
// t.translateX,
|
||||
// t.translateY
|
||||
// )
|
||||
// let oldIsInClient =
|
||||
// ox > 0 && oy > 0 && ox < this.mindMap.width && oy < this.mindMap.height
|
||||
// let { left: nx, top: ny } = this.getNodePosInClient(this.left, this.top)
|
||||
// let newIsNotInClient =
|
||||
// nx + this.width < 0 ||
|
||||
// ny + this.height < 0 ||
|
||||
// nx > this.mindMap.width ||
|
||||
// ny > this.mindMap.height
|
||||
// if (!oldIsInClient && newIsNotInClient) {
|
||||
// if (!this.isHide) {
|
||||
// this.isHide = true
|
||||
// this.group.hide()
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
// // 如果当前是隐藏状态,那么先显示
|
||||
// if (this.isHide) {
|
||||
// this.isHide = false
|
||||
// this.group.show()
|
||||
// }
|
||||
// 如果节点位置没有变化,则返回
|
||||
if (this.left === t.translateX && this.top === t.translateY) return
|
||||
this.group.translate(this.left - t.translateX, this.top - t.translateY)
|
||||
@@ -757,6 +732,17 @@ class Node {
|
||||
}
|
||||
}
|
||||
|
||||
// 判断节点是否可见
|
||||
checkIsInClient(padding = 0) {
|
||||
const { left: nx, top: ny } = this.getNodePosInClient(this.left, this.top)
|
||||
return (
|
||||
nx + this.width > 0 - padding &&
|
||||
ny + this.height > 0 - padding &&
|
||||
nx < this.mindMap.width + padding &&
|
||||
ny < this.mindMap.height + padding
|
||||
)
|
||||
}
|
||||
|
||||
// 重新渲染节点,即重新创建节点内容、计算节点大小、计算节点内容布局、更新展开收起按钮,概要及位置
|
||||
reRender() {
|
||||
let sizeChange = this.getSize()
|
||||
@@ -785,32 +771,44 @@ class Node {
|
||||
}
|
||||
}
|
||||
|
||||
// 递归渲染
|
||||
render(callback = () => {}) {
|
||||
// 递归渲染
|
||||
// forceRender:强制渲染,无论是否处于画布可视区域
|
||||
// async:异步渲染
|
||||
render(callback = () => {}, forceRender = false, async = false) {
|
||||
// 节点
|
||||
// 重新渲染连线
|
||||
this.renderLine()
|
||||
if (!this.group) {
|
||||
// 创建组
|
||||
this.group = new G()
|
||||
this.group.addClass('smm-node')
|
||||
this.group.css({
|
||||
cursor: 'default'
|
||||
})
|
||||
this.bindGroupEvent()
|
||||
this.nodeDraw.add(this.group)
|
||||
this.layout()
|
||||
this.update()
|
||||
} else {
|
||||
if (!this.nodeDraw.has(this.group)) {
|
||||
const { openPerformance, performanceConfig } = this.mindMap.opt
|
||||
// 强制渲染、或没有开启性能模式、或不在画布可视区域内不渲染节点内容
|
||||
if (
|
||||
forceRender ||
|
||||
!openPerformance ||
|
||||
this.checkIsInClient(performanceConfig.padding)
|
||||
) {
|
||||
if (!this.group) {
|
||||
// 创建组
|
||||
this.group = new G()
|
||||
this.group.addClass('smm-node')
|
||||
this.group.css({
|
||||
cursor: 'default'
|
||||
})
|
||||
this.bindGroupEvent()
|
||||
this.nodeDraw.add(this.group)
|
||||
}
|
||||
if (this.needLayout) {
|
||||
this.needLayout = false
|
||||
this.layout()
|
||||
this.update(forceRender)
|
||||
} else {
|
||||
if (!this.nodeDraw.has(this.group)) {
|
||||
this.nodeDraw.add(this.group)
|
||||
}
|
||||
if (this.needLayout) {
|
||||
this.needLayout = false
|
||||
this.layout()
|
||||
}
|
||||
this.updateExpandBtnPlaceholderRect()
|
||||
this.update(forceRender)
|
||||
}
|
||||
this.updateExpandBtnPlaceholderRect()
|
||||
this.update()
|
||||
} else if (openPerformance && performanceConfig.removeNodeWhenOutCanvas) {
|
||||
this.removeSelf()
|
||||
}
|
||||
// 子节点
|
||||
if (
|
||||
@@ -820,12 +818,23 @@ class Node {
|
||||
) {
|
||||
let index = 0
|
||||
this.children.forEach(item => {
|
||||
item.render(() => {
|
||||
index++
|
||||
if (index >= this.children.length) {
|
||||
callback()
|
||||
}
|
||||
})
|
||||
const renderChild = () => {
|
||||
item.render(
|
||||
() => {
|
||||
index++
|
||||
if (index >= this.children.length) {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
forceRender,
|
||||
async
|
||||
)
|
||||
}
|
||||
if (async) {
|
||||
setTimeout(renderChild, 0)
|
||||
} else {
|
||||
renderChild()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
callback()
|
||||
@@ -840,6 +849,13 @@ class Node {
|
||||
}
|
||||
}
|
||||
|
||||
// 删除自身,只是从画布删除,节点容器还在,后续还可以重新插回画布
|
||||
removeSelf() {
|
||||
if (!this.group) return
|
||||
this.group.remove()
|
||||
this.removeGeneralization()
|
||||
}
|
||||
|
||||
// 递归删除,只是从画布删除,节点容器还在,后续还可以重新插回画布
|
||||
remove() {
|
||||
if (!this.group) return
|
||||
@@ -856,6 +872,10 @@ class Node {
|
||||
|
||||
// 销毁节点,不但会从画布删除,而且原节点直接置空,后续无法再插回画布
|
||||
destroy() {
|
||||
this.removeLine()
|
||||
if (this.parent) {
|
||||
this.parent.removeLine()
|
||||
}
|
||||
if (!this.group) return
|
||||
if (this.emptyUser) {
|
||||
this.emptyUser()
|
||||
@@ -863,11 +883,7 @@ class Node {
|
||||
this.resetWhenDelete()
|
||||
this.group.remove()
|
||||
this.removeGeneralization()
|
||||
this.removeLine()
|
||||
this.group = null
|
||||
if (this.parent) {
|
||||
this.parent.removeLine()
|
||||
}
|
||||
this.style.onRemove()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import btnsSvg from '../../../svg/btns'
|
||||
import { SVG, Circle, G } from '@svgdotjs/svg.js'
|
||||
import { SVG, Circle, G, Text } from '@svgdotjs/svg.js'
|
||||
|
||||
// 创建展开收起按钮的内容节点
|
||||
function createExpandNodeContent() {
|
||||
@@ -10,9 +10,7 @@ function createExpandNodeContent() {
|
||||
// 根据配置判断是否显示数量按钮
|
||||
if (this.mindMap.opt.isShowExpandNum) {
|
||||
// 展开的节点
|
||||
this._openExpandNode = SVG()
|
||||
.text()
|
||||
.size(this.expandBtnSize, this.expandBtnSize)
|
||||
this._openExpandNode = new Text()
|
||||
// 文本垂直居中
|
||||
this._openExpandNode.attr({
|
||||
'text-anchor': 'middle',
|
||||
@@ -81,7 +79,7 @@ function updateExpandBtnNode() {
|
||||
// 计算子节点数量
|
||||
let count = this.sumNode(this.nodeData.children)
|
||||
count = expandBtnNumHandler(count)
|
||||
node.text(count)
|
||||
node.text(String(count))
|
||||
} else {
|
||||
this._fillExpandNode.stroke('none')
|
||||
}
|
||||
@@ -126,11 +124,7 @@ function renderExpandBtn() {
|
||||
this._expandBtn.on('click', e => {
|
||||
e.stopPropagation()
|
||||
// 展开收缩
|
||||
this.mindMap.execCommand(
|
||||
'SET_NODE_EXPAND',
|
||||
this,
|
||||
!this.getData('expand')
|
||||
)
|
||||
this.mindMap.execCommand('SET_NODE_EXPAND', this, !this.getData('expand'))
|
||||
this.mindMap.emit('expand_btn_click', this)
|
||||
})
|
||||
this._expandBtn.on('dblclick', e => {
|
||||
|
||||
@@ -85,7 +85,7 @@ function updateGeneralization() {
|
||||
}
|
||||
|
||||
// 渲染概要节点
|
||||
function renderGeneralization() {
|
||||
function renderGeneralization(forceRender) {
|
||||
if (this.isGeneralization) return
|
||||
this.updateGeneralizationData()
|
||||
const list = this.formatGetGeneralization()
|
||||
@@ -100,7 +100,7 @@ function renderGeneralization() {
|
||||
this.renderer.layout.renderGeneralization(this._generalizationList)
|
||||
this._generalizationList.forEach(item => {
|
||||
this.style.generalizationLine(item.generalizationLine)
|
||||
item.generalizationNode.render()
|
||||
item.generalizationNode.render(() => {}, forceRender)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -297,6 +297,13 @@ class OuterFrame {
|
||||
if (range[0] === -1 || range[1] === -1) return
|
||||
const { left, top, width, height } =
|
||||
getNodeListBoundingRect(nodeList)
|
||||
if (
|
||||
!Number.isFinite(left) ||
|
||||
!Number.isFinite(top) ||
|
||||
!Number.isFinite(width) ||
|
||||
!Number.isFinite(height)
|
||||
)
|
||||
return
|
||||
const el = this.createOuterFrameEl(
|
||||
(left -
|
||||
outerFramePaddingX -
|
||||
|
||||
@@ -1382,22 +1382,24 @@ export const getNodeTreeBoundingRect = (
|
||||
let minY = Infinity
|
||||
let maxY = -Infinity
|
||||
const walk = (root, isRoot) => {
|
||||
if (!(isRoot && excludeSelf)) {
|
||||
const { x, y, width, height } = root.group
|
||||
.findOne('.smm-node-shape')
|
||||
.rbox()
|
||||
if (x < minX) {
|
||||
minX = x
|
||||
}
|
||||
if (x + width > maxX) {
|
||||
maxX = x + width
|
||||
}
|
||||
if (y < minY) {
|
||||
minY = y
|
||||
}
|
||||
if (y + height > maxY) {
|
||||
maxY = y + height
|
||||
}
|
||||
if (!(isRoot && excludeSelf) && root.group) {
|
||||
try {
|
||||
const { x, y, width, height } = root.group
|
||||
.findOne('.smm-node-shape')
|
||||
.rbox()
|
||||
if (x < minX) {
|
||||
minX = x
|
||||
}
|
||||
if (x + width > maxX) {
|
||||
maxX = x + width
|
||||
}
|
||||
if (y < minY) {
|
||||
minY = y
|
||||
}
|
||||
if (y + height > maxY) {
|
||||
maxY = y + height
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
if (!excludeGeneralization && root._generalizationList.length > 0) {
|
||||
root._generalizationList.forEach(item => {
|
||||
|
||||
BIN
web/src/assets/avatar/ccccs.jpg
Normal file
BIN
web/src/assets/avatar/ccccs.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
@@ -26,7 +26,8 @@ export default {
|
||||
nodeBorderType: 'Node border style',
|
||||
nodeUseLineStyle: 'Use only has bottom border style',
|
||||
otherConfig: 'Other config',
|
||||
enableFreeDrag: 'Enable node free drag',
|
||||
enableFreeDrag: 'Enable node free drag(Beta)',
|
||||
openPerformance: 'Enable performance mode',
|
||||
watermark: 'Watermark',
|
||||
showWatermark: 'Is show watermark',
|
||||
onlyExport: 'Only export',
|
||||
|
||||
@@ -27,6 +27,7 @@ export default {
|
||||
nodeUseLineStyle: '是否使用只有底边框的风格',
|
||||
otherConfig: '其他配置',
|
||||
enableFreeDrag: '是否开启节点自由拖拽',
|
||||
openPerformance: '开启性能模式(Beta)',
|
||||
watermark: '水印',
|
||||
showWatermark: '是否显示水印',
|
||||
watermarkDefaultText: '水印文字',
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# Changelog
|
||||
|
||||
## 0.10.4
|
||||
|
||||
> 2024.7.25
|
||||
|
||||
This update mainly adds a performance mode. When enabled, only nodes within the visible area of the canvas will be rendered, and nodes outside the area will be deleted from the canvas, improving usability in the case of large data volumes (1000+nodes). The first rendering time for 2000 nodes has been reduced from 5s+to 0.5s. However, this also brings some problems, such as a slight lag when dragging the animation canvas, as nodes will be rendered in real time, and exporting images will be slower because all nodes need to be rendered first, as well as other temporarily undiscovered issues.
|
||||
|
||||
Fix:
|
||||
|
||||
> 1.Delete useless code and fix the issue where the mouse hover node reports an error and does not display the expand and collapse buttons;
|
||||
|
||||
## 0.10.3
|
||||
|
||||
> 2024.7.19
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>Changelog</h1>
|
||||
<h2>0.10.4</h2>
|
||||
<blockquote>
|
||||
<p>2024.7.25</p>
|
||||
</blockquote>
|
||||
<p>This update mainly adds a performance mode. When enabled, only nodes within the visible area of the canvas will be rendered, and nodes outside the area will be deleted from the canvas, improving usability in the case of large data volumes (1000+nodes). The first rendering time for 2000 nodes has been reduced from 5s+to 0.5s. However, this also brings some problems, such as a slight lag when dragging the animation canvas, as nodes will be rendered in real time, and exporting images will be slower because all nodes need to be rendered first, as well as other temporarily undiscovered issues.</p>
|
||||
<p>Fix:</p>
|
||||
<blockquote>
|
||||
<p>1.Delete useless code and fix the issue where the mouse hover node reports an error and does not display the expand and collapse buttons;</p>
|
||||
</blockquote>
|
||||
<h2>0.10.3</h2>
|
||||
<blockquote>
|
||||
<p>2024.7.19</p>
|
||||
|
||||
@@ -99,6 +99,8 @@ const mindMap = new MindMap({
|
||||
| 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 | |
|
||||
| disabledClipboard(v0.10.2+) | Boolean | false | Is prohibit pasting data from the user's clipboard and writing copied node data to the user's clipboard. At this time, only node data from the canvas can be copied and pasted | |
|
||||
| customHyperlinkJump(v0.10.2+) | null、Function | false | Customize the jump of hyperlinks. If not passed, the hyperlink will be opened as a new window by default, and a function can be passed, The function takes two parameters: link(The URL of the hyperlink)、node(Node instance to which it belongs), As long as a function is passed, it will block the default jump | |
|
||||
| openPerformance(v0.10.4+) | Boolean | false | Whether to enable performance mode or not, by default, all nodes will be rendered directly, regardless of whether they are in the visible area of the canvas. This will cause a lag when there are a large number of nodes (1000+). If your data volume is large, you can enable performance mode through this configuration, that is, only rendering nodes within the visible area of the canvas, and not rendering nodes beyond it. This will greatly improve rendering speed, but of course, it will also bring some other problems, such as: 1. When dragging or scaling the canvas, real-time calculation and rendering of nodes without nodes will be performed, which will bring some lag; When exporting images, SVG, and PDF, all nodes need to be rendered first, so it may be slower; 3. Other currently undiscovered issues | |
|
||||
| performanceConfig(v0.10.4+) | Object | { time: 250, padding: 100, removeNodeWhenOutCanvas: true } | Performance optimization mode configuration. time(How often do nodes refresh after a view change. Unit:ms)、padding(Still rendering nodes beyond the specified range around the canvas)、removeNodeWhenOutCanvas(Is the node deleted from the canvas after being moved out of the visible area of the canvas) | |
|
||||
|
||||
### 1.1Data structure
|
||||
|
||||
@@ -618,6 +620,8 @@ Listen to an event. Event list:
|
||||
| node_layout_end(v0.10.1+) | Event where the content layout of a single node is completed | this(Current node instance) |
|
||||
| node_attachmentClick(v0.9.10+) | Click event for node attachment icon | this(Current node instance)、e(Event Object)、node(Icon node) |
|
||||
| node_attachmentContextmenu(v0.9.10+) | Right click event on node attachment icon | this(Current node instance)、e(Event Object)、node(Icon node) |
|
||||
| before_update_config(v0.10.4+) | Triggered before updating the configuration, that is, when the 'mindMap.updateConfig' method is called to update the configuration | opt(The configuration object before updating refers to an object, not a copy, so when the after_uupdate_comfig event is triggered, the object will also change synchronously. Therefore, it is necessary to cache a certain configuration field that you need) |
|
||||
| after_update_config(v0.10.4+) | Triggered after updating configuration | opt(Updated configuration object) |
|
||||
|
||||
### emit(event, ...args)
|
||||
|
||||
|
||||
@@ -540,6 +540,20 @@
|
||||
<td>Customize the jump of hyperlinks. If not passed, the hyperlink will be opened as a new window by default, and a function can be passed, The function takes two parameters: link(The URL of the hyperlink)、node(Node instance to which it belongs), As long as a function is passed, it will block the default jump</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>openPerformance(v0.10.4+)</td>
|
||||
<td>Boolean</td>
|
||||
<td>false</td>
|
||||
<td>Whether to enable performance mode or not, by default, all nodes will be rendered directly, regardless of whether they are in the visible area of the canvas. This will cause a lag when there are a large number of nodes (1000+). If your data volume is large, you can enable performance mode through this configuration, that is, only rendering nodes within the visible area of the canvas, and not rendering nodes beyond it. This will greatly improve rendering speed, but of course, it will also bring some other problems, such as: 1. When dragging or scaling the canvas, real-time calculation and rendering of nodes without nodes will be performed, which will bring some lag; When exporting images, SVG, and PDF, all nodes need to be rendered first, so it may be slower; 3. Other currently undiscovered issues</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>performanceConfig(v0.10.4+)</td>
|
||||
<td>Object</td>
|
||||
<td>{ time: 250, padding: 100, removeNodeWhenOutCanvas: true }</td>
|
||||
<td>Performance optimization mode configuration. time(How often do nodes refresh after a view change. Unit:ms)、padding(Still rendering nodes beyond the specified range around the canvas)、removeNodeWhenOutCanvas(Is the node deleted from the canvas after being moved out of the visible area of the canvas)</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3>1.1Data structure</h3>
|
||||
@@ -1698,6 +1712,16 @@ poor performance and should be used sparingly.</p>
|
||||
<td>Right click event on node attachment icon</td>
|
||||
<td>this(Current node instance)、e(Event Object)、node(Icon node)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>before_update_config(v0.10.4+)</td>
|
||||
<td>Triggered before updating the configuration, that is, when the 'mindMap.updateConfig' method is called to update the configuration</td>
|
||||
<td>opt(The configuration object before updating refers to an object, not a copy, so when the after_uupdate_comfig event is triggered, the object will also change synchronously. Therefore, it is necessary to cache a certain configuration field that you need)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>after_update_config(v0.10.4+)</td>
|
||||
<td>Triggered after updating configuration</td>
|
||||
<td>opt(Updated configuration object)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3>emit(event, ...args)</h3>
|
||||
|
||||
@@ -450,4 +450,12 @@ Open source is not easy. If this project is helpful to you, you can invite the a
|
||||
<img src="../../../../assets/avatar/晴空.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>晴空</p>
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
|
||||
<img src="../../../../assets/avatar/default.png" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>黄泳</p>
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
|
||||
<img src="../../../../assets/avatar/ccccs.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>ccccs</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -407,6 +407,14 @@ full screen, support mini map</li>
|
||||
<img src="../../../../assets/avatar/晴空.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>晴空</p>
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
|
||||
<img src="../../../../assets/avatar/default.png" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>黄泳</p>
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
|
||||
<img src="../../../../assets/avatar/ccccs.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>ccccs</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -56,6 +56,14 @@ Whether the node is currently being dragged
|
||||
|
||||
## Methods
|
||||
|
||||
### checkIsInClient(padding = 0)
|
||||
|
||||
> v0.10.4+
|
||||
|
||||
- `padding`: Number, The size of the area extending around the canvas
|
||||
|
||||
Determine whether the node is within the visible area of the canvas.
|
||||
|
||||
### deactivate()
|
||||
|
||||
> 0.9.11+
|
||||
|
||||
@@ -31,6 +31,14 @@
|
||||
</blockquote>
|
||||
<p>Whether the node is currently being dragged</p>
|
||||
<h2>Methods</h2>
|
||||
<h3>checkIsInClient(padding = 0)</h3>
|
||||
<blockquote>
|
||||
<p>v0.10.4+</p>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li><code>padding</code>: Number, The size of the area extending around the canvas</li>
|
||||
</ul>
|
||||
<p>Determine whether the node is within the visible area of the canvas.</p>
|
||||
<h3>deactivate()</h3>
|
||||
<blockquote>
|
||||
<p>0.9.11+</p>
|
||||
|
||||
@@ -78,16 +78,25 @@ import('simple-mind-map/src/plugins/Export.js').then(res => {
|
||||
})
|
||||
```
|
||||
|
||||
If you need a file in the format of `umd` module, such as `CDN` in the browser, Then you can find the `simpleMindMap.umd.min.js` file and `simpleMindMap.css` file in the `/simple-mind-map/dist/` directory, copy it to your project, and then import it into the page:
|
||||
If you need a file in the format of `umd` module, such as `CDN` in the browser, So you can first install `npm i simple-mind-map` through npm,, Then you can find the `simpleMindMap.umd.min.js` file and `simpleMindMap.esm.min.css` file in the `node_modules/simple-mind-map/dist/` directory, copy it to your project, and then import it into the page:
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="simpleMindMap.css">
|
||||
<link rel="stylesheet" href="simpleMindMap.esm.min.css">
|
||||
<script scr="simpleMindMap.umd.min.js"></script>
|
||||
```
|
||||
|
||||
A global variable `window.simpleMindMap` will be created. you can get `MindMap` constructor by `window.simpleMindMap.default`, for more detail info you can log `window.simpleMindMap`.
|
||||
A global variable `window.simpleMindMap` will be created. you can get `MindMap` constructor by `window.simpleMindMap.default`, Then it can be instantiated normally, for more detail info you can log `window.simpleMindMap`.
|
||||
|
||||
The disadvantage of this method is that it will contain all the content, including the plugins you have not registered, so the overall volume will be relatively large.
|
||||
If it is inconvenient to install using 'npm', you can also obtain these two files through some online 'CDN' services, such as:
|
||||
|
||||
```
|
||||
https://unpkg.com/simple-mind-map@0.10.2/dist/simpleMindMap.esm.css
|
||||
https://unpkg.com/simple-mind-map@0.10.2/dist/simpleMindMap.umd.min.js
|
||||
```
|
||||
|
||||
You can replace the version number in it.
|
||||
|
||||
The disadvantage of this method is that it will contain all the content, including the plugins you have not registered(You can find it here [full.js](https://github.com/wanglin2/mind-map/blob/main/simple-mind-map/full.js#L36) View plugins packaged into files by default), so the overall volume will be relatively large. If you only want to package the specified plugin, you can modify the file and repackage it. If necessary, you can also contact the developer.
|
||||
|
||||
(v0.5.4+)If you want to use the `ES` module directly on the browser side, you can find the `simpleMindMap.esm.js` and `simpleMindMap.esm.css` files in the `/simple-mind-map/dist/` directory.
|
||||
|
||||
@@ -216,7 +225,7 @@ The browser uses API [window.showOpenFilePicker](https://developer.mozilla.org/z
|
||||
|
||||
This is because your build environment does not support this JavaScript syntax, which comes from the '@svgdotjs/svg.js' library. The solution is as follows:
|
||||
|
||||
1.Manually reduce the version of the '@svgdotjs/svg.js' library. You can manually install the lower version in your project, such as: `npm i @svgdotjs/svg.js@3.0.16`
|
||||
1.Manually reduce the version of the '@svgdotjs/svg.js' library. You can manually install the lower version in your project, such as: `npm i @svgdotjs/svg.js@3.2.0`
|
||||
|
||||
2.If you don't reduce the version, you can modify the relevant configuration of your build tool, modify the configuration of 'babel', and have it compile the 'simple-mind-map' library in 'node.modules' or the '@svgdotjs/svg.js' library. If you are using 'vue-cli' or 'vite', they also provide the relevant configuration directly. In addition, it is necessary to install the 'babel' plugin that compiles this syntax and configure it in the 'babel' configuration file:
|
||||
|
||||
|
||||
@@ -1,6 +1,157 @@
|
||||
<template>
|
||||
<div>
|
||||
|
||||
<h1>Start</h1>
|
||||
<h2>Installation</h2>
|
||||
<blockquote>
|
||||
<p>Things to note before version 0.2.0:</p>
|
||||
</blockquote>
|
||||
<pre class="hljs"><code>npm i simple-mind-map
|
||||
</code></pre>
|
||||
<p><code>0.2.0</code> Notes for previous versions:</p>
|
||||
<blockquote>
|
||||
<p>Note: This project is directly published in source code form and has not been
|
||||
packaged. If compilation fails, a Vue CLI-created project can add the
|
||||
following configuration to the vue.config.js file to allow babel-loader to
|
||||
compile this dependency:</p>
|
||||
<pre class="hljs"><code><span class="hljs-built_in">module</span>.exports = {
|
||||
<span class="hljs-attr">transpileDependencies</span>: [<span class="hljs-string">"simple-mind-map"</span>],
|
||||
};
|
||||
</code></pre>
|
||||
<p>Other projects should modify the packaging configuration as needed.</p>
|
||||
</blockquote>
|
||||
<h2>Usage</h2>
|
||||
<blockquote>
|
||||
<p>The <code>web</code> directory of this repository provides a complete project based on <code>Vue2</code>. If you encounter any doubts about using it, you can refer to the implementation of this project.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p>To learn about its use in other frameworks, you can refer to the following unofficial implementations:</p>
|
||||
<p>1.<a href="https://github.com/huangyuanyin/hyy-vue3-mindMap">https://github.com/huangyuanyin/hyy-vue3-mindMap</a>: A mind map based on Vue3.2+ElementPlus.</p>
|
||||
</blockquote>
|
||||
<p>Firstly, provide a container element with a width and height not equal to 0:</p>
|
||||
<pre class="hljs"><code><span class="hljs-tag"><<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"mindMapContainer"</span>></span><span class="hljs-tag"></<span class="hljs-name">div</span>></span>
|
||||
</code></pre>
|
||||
<p>Also, set the <code>CSS</code> style again:</p>
|
||||
<pre class="hljs"><code><span class="hljs-selector-id">#mindMapContainer</span> * {
|
||||
<span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>;
|
||||
<span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>;
|
||||
}
|
||||
</code></pre>
|
||||
<p>Then introduce the <code>simple-mind-map</code> library and create an instance:</p>
|
||||
<pre class="hljs"><code><span class="hljs-keyword">import</span> MindMap <span class="hljs-keyword">from</span> <span class="hljs-string">"simple-mind-map"</span>;
|
||||
|
||||
<span class="hljs-keyword">const</span> mindMap = <span class="hljs-keyword">new</span> MindMap({
|
||||
<span class="hljs-attr">el</span>: <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'mindMapContainer'</span>),
|
||||
<span class="hljs-attr">data</span>: {
|
||||
<span class="hljs-string">"data"</span>: {
|
||||
<span class="hljs-string">"text"</span>: <span class="hljs-string">"Root Node"</span>
|
||||
},
|
||||
<span class="hljs-string">"children"</span>: []
|
||||
}
|
||||
});
|
||||
</code></pre>
|
||||
<p>This will result in a mind map.</p>
|
||||
<p>If you want to implement a complete mind map, you usually need to develop some UI interfaces to achieve more functions through the interfaces provided by the <code>simple-mind-map</code> library.</p>
|
||||
<p><code>simple-mind-map</code> supports rich configurations, events, commands, and some additional plugin extensions. Read the subsequent documentation to learn more.</p>
|
||||
<p>The non-packaged 'ES' module is introduced by default, and only contains core functions, not unregistered plugin content, which can effectively reduce the size. However, you need to configure the <code>babel</code> compilation <code>simple mind-map</code> in your project to prevent some newer <code>js</code> syntax some browsers not supporting it.</p>
|
||||
<p>If you don't want to load all plugins from the beginning and want to load and register plugins asynchronously after instantiation, you can do this:</p>
|
||||
<pre class="hljs"><code><span class="hljs-keyword">import</span>(<span class="hljs-string">'simple-mind-map/src/plugins/Export.js'</span>).then(<span class="hljs-function"><span class="hljs-params">res</span> =></span> {
|
||||
mindMap.addPlugin(res.default)
|
||||
})
|
||||
</code></pre>
|
||||
<p>If you need a file in the format of <code>umd</code> module, such as <code>CDN</code> in the browser, So you can first install <code>npm i simple-mind-map</code> through npm,, Then you can find the <code>simpleMindMap.umd.min.js</code> file and <code>simpleMindMap.esm.min.css</code> file in the <code>node_modules/simple-mind-map/dist/</code> directory, copy it to your project, and then import it into the page:</p>
|
||||
<pre class="hljs"><code><span class="hljs-tag"><<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">"stylesheet"</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"simpleMindMap.esm.min.css"</span>></span>
|
||||
<span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">scr</span>=<span class="hljs-string">"simpleMindMap.umd.min.js"</span>></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span>
|
||||
</code></pre>
|
||||
<p>A global variable <code>window.simpleMindMap</code> will be created. you can get <code>MindMap</code> constructor by <code>window.simpleMindMap.default</code>, Then it can be instantiated normally, for more detail info you can log <code>window.simpleMindMap</code>.</p>
|
||||
<p>If it is inconvenient to install using 'npm', you can also obtain these two files through some online 'CDN' services, such as:</p>
|
||||
<pre class="hljs"><code>https://unpkg.com/simple-mind-map@0.10.2/dist/simpleMindMap.esm.css
|
||||
https://unpkg.com/simple-mind-map@0.10.2/dist/simpleMindMap.umd.min.js
|
||||
</code></pre>
|
||||
<p>You can replace the version number in it.</p>
|
||||
<p>The disadvantage of this method is that it will contain all the content, including the plugins you have not registered(You can find it here <a href="https://github.com/wanglin2/mind-map/blob/main/simple-mind-map/full.js#L36">full.js</a> View plugins packaged into files by default), so the overall volume will be relatively large. If you only want to package the specified plugin, you can modify the file and repackage it. If necessary, you can also contact the developer.</p>
|
||||
<p>(v0.5.4+)If you want to use the <code>ES</code> module directly on the browser side, you can find the <code>simpleMindMap.esm.js</code> and <code>simpleMindMap.esm.css</code> files in the <code>/simple-mind-map/dist/</code> directory.</p>
|
||||
<p>Online CDN services can also be used, such as:</p>
|
||||
<pre class="hljs"><code>https://unpkg.com/browse/simple-mind-map@0.9.2/dist/
|
||||
</code></pre>
|
||||
<p>You can find all the packaged files for a certain version.</p>
|
||||
<h2>Development</h2>
|
||||
<p>If you only use library, you don't need to read this section.</p>
|
||||
<h3>Local Development</h3>
|
||||
<pre class="hljs"><code>git <span class="hljs-built_in">clone</span> https://github.com/wanglin2/mind-map.git
|
||||
<span class="hljs-built_in">cd</span> mind-map
|
||||
<span class="hljs-built_in">cd</span> simple-mind-map
|
||||
npm i
|
||||
npm link
|
||||
<span class="hljs-built_in">cd</span> ..
|
||||
<span class="hljs-built_in">cd</span> web
|
||||
npm i
|
||||
npm link simple-mind-map
|
||||
npm run serve
|
||||
</code></pre>
|
||||
<blockquote>
|
||||
<p>If there is an installation dependency error, you can try adjusting the node version. The author is using version 14. x.</p>
|
||||
</blockquote>
|
||||
<h3>Packaging the Library</h3>
|
||||
<p>Since version <code>0.2.0</code>, we have added support for packaging the core library
|
||||
simple-mind-map. This uses the same packaging tool as the sample project web.</p>
|
||||
<pre class="hljs"><code><span class="hljs-built_in">cd</span> web
|
||||
npm run buildLibrary
|
||||
</code></pre>
|
||||
<p>The packaging entry is <code>simple-mind-map/full.js</code>, which will introduce all plugins by default. If you don't need all plugins, you can modify the file to only introduce the plugins you need, which can reduce the size of the packaged file.</p>
|
||||
<p>The <code>package.json</code> file in the <code>simple-mind-map</code> library provides two export
|
||||
fields:</p>
|
||||
<pre class="hljs"><code>{
|
||||
<span class="hljs-attr">"module"</span>: <span class="hljs-string">"index.js"</span>,
|
||||
<span class="hljs-attr">"main"</span>: <span class="hljs-string">"./dist/simpleMindMap.umd.min.js"</span>
|
||||
}
|
||||
</code></pre>
|
||||
<p>Environments that support the <code>module</code> field will use <code>index.js</code> as the entry
|
||||
point, otherwise the packed <code>simpleMindMap.umd.min.js</code> will be used as the entry
|
||||
point.</p>
|
||||
<h4>Generate TypeScript type files</h4>
|
||||
<pre class="hljs"><code><span class="hljs-built_in">cd</span> simple-mind-map
|
||||
npm run types
|
||||
</code></pre>
|
||||
<p>You can obtain the type files in the 'simple-mind-map/types/' directory.</p>
|
||||
<h3>Compile the doc</h3>
|
||||
<pre class="hljs"><code><span class="hljs-built_in">cd</span> web
|
||||
npm run buildDoc
|
||||
</code></pre>
|
||||
<h3>Packaging the Demo</h3>
|
||||
<pre class="hljs"><code><span class="hljs-built_in">cd</span> web
|
||||
npm run build
|
||||
</code></pre>
|
||||
<p>The <code>index.html</code> file will be automatically moved to the root directory.</p>
|
||||
<h2>Problems</h2>
|
||||
<h3>Error when using in Vite, indicating xml-js dependency error</h3>
|
||||
<p>Solution: use the following import method:</p>
|
||||
<pre class="hljs"><code><span class="hljs-keyword">import</span> MindMap <span class="hljs-keyword">from</span> <span class="hljs-string">"simple-mind-map/dist/simpleMindMap.umd.min"</span>;
|
||||
</code></pre>
|
||||
<p>The <code>simple-mind-map</code> package provides the unpacked entry field <code>module</code>, and
|
||||
the <code>xml-js</code> package dependency needs to import the package in the <code>node</code>
|
||||
environment. Therefore, it cannot be obtained in <code>Vite</code> and an error will be
|
||||
reported. Therefore, specify the import of the packed entry, and all relevant
|
||||
packages are packed into the product, so there will be no error.</p>
|
||||
<p>If you need to do further development, that is, you must use the unpacked code,
|
||||
and if you do not need to parse the <code>xmind</code> file, you can remove the <code>xmind</code>
|
||||
module. If you need it, you can try using other libraries to parse <code>xml</code> to
|
||||
<code>json</code>.</p>
|
||||
<h3>Error <code>Getting bbox of element "text" is not possible: TypeError: Cannot read properties of undefined (reading 'apply')</code></h3>
|
||||
<p>The reason is that the installed version of <code>@svgdotjs/svg.js</code> is too high. You can manually reduce it to the version of <code>3.0.16</code>.</p>
|
||||
<h3>TypeError: Cannot read properties of undefined (reading 'prototype') at sax.js:222:46</h3>
|
||||
<p>The following configurations can be added to the packaging configuration file:</p>
|
||||
<pre class="hljs"><code>resolve: { <span class="hljs-attr">alias</span>: { <span class="hljs-attr">stream</span>: <span class="hljs-string">"stream-browserify"</span> } }
|
||||
</code></pre>
|
||||
<p>Different packaging tools may have different specific configurations, with the principle of excluding 'stream' dependencies.</p>
|
||||
<h3>When clicking the [New], [Open], or [Save As] buttons, it will prompt that the browser does not support it or is not using the HTTPS protocol.</h3>
|
||||
<p>The browser uses API <a href="https://developer.mozilla.org/zh-CN/docs/Web/API/Window/showOpenFilePicker">window.showOpenFilePicker</a> to operate local files on the computer. If it is not supported, either the browser does not support this API or the page is not using the HTTPS protocol, You can press F12, or open the browser console through the right-click menu on the page and enter 'window.showOpenFilePicker' in the 'Console' tab. If it returns 'undefined', it means it is not supported. If it does not return this message and the page still prompts that the browser does not support it or is not using the HTTPS protocol, you can submit an issue or contact the author.</p>
|
||||
<h3>5.Import simple-mind-map error message, the error message is as follows:</h3>
|
||||
<img src="../../../../assets/img/docs/错误.jpg" style="width: 850px" />
|
||||
<p>This is because your build environment does not support this JavaScript syntax, which comes from the '@svgdotjs/svg.js' library. The solution is as follows:</p>
|
||||
<p>1.Manually reduce the version of the '@svgdotjs/svg.js' library. You can manually install the lower version in your project, such as: <code>npm i @svgdotjs/svg.js@3.2.0</code></p>
|
||||
<p>2.If you don't reduce the version, you can modify the relevant configuration of your build tool, modify the configuration of 'babel', and have it compile the 'simple-mind-map' library in 'node.modules' or the '@svgdotjs/svg.js' library. If you are using 'vue-cli' or 'vite', they also provide the relevant configuration directly. In addition, it is necessary to install the 'babel' plugin that compiles this syntax and configure it in the 'babel' configuration file:</p>
|
||||
<p><code>@babel/plugin-proposal-nullish-coalescing-operator</code>、<code>@babel/plugin-proposal-optional-chaining</code>。</p>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# Changelog
|
||||
|
||||
## 0.10.4
|
||||
|
||||
> 2024.7.25
|
||||
|
||||
本次更新主要是增加了一个性能模式,开启后只会渲染画布可视区域内的节点,超出区域的节点会从画布删除,提升大数据量(1000+节点)情况下的可用性,2000节点首次渲染时间由5s+减少到0.5s,当然由此也会带来一些问题,比如拖动画布时会有一点卡顿,因为会实时渲染节点,导出图片等会变慢,因为需要先渲染所有节点,以及其他一些暂时未发现的问题。
|
||||
|
||||
修复:
|
||||
|
||||
> 1.删除无用代码,修复鼠标悬浮节点上报错不显示展开收起按钮的问题;
|
||||
|
||||
## 0.10.3
|
||||
|
||||
> 2024.7.19
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>Changelog</h1>
|
||||
<h2>0.10.4</h2>
|
||||
<blockquote>
|
||||
<p>2024.7.25</p>
|
||||
</blockquote>
|
||||
<p>本次更新主要是增加了一个性能模式,开启后只会渲染画布可视区域内的节点,超出区域的节点会从画布删除,提升大数据量(1000+节点)情况下的可用性,2000节点首次渲染时间由5s+减少到0.5s,当然由此也会带来一些问题,比如拖动画布时会有一点卡顿,因为会实时渲染节点,导出图片等会变慢,因为需要先渲染所有节点,以及其他一些暂时未发现的问题。</p>
|
||||
<p>修复:</p>
|
||||
<blockquote>
|
||||
<p>1.删除无用代码,修复鼠标悬浮节点上报错不显示展开收起按钮的问题;</p>
|
||||
</blockquote>
|
||||
<h2>0.10.3</h2>
|
||||
<blockquote>
|
||||
<p>2024.7.19</p>
|
||||
|
||||
@@ -99,6 +99,8 @@ const mindMap = new MindMap({
|
||||
| createNodePostfixContent(v0.9.12+) | Function、null | null | 添加附加的节点后置内容。后置内容指和文本同一行的区域中的后置内容,不包括节点图片部分。用法同createNodePrefixContent |
|
||||
| disabledClipboard(v0.10.2+) | Boolean | false | 是否禁止粘贴用户剪贴板中的数据,禁止将复制的节点数据写入用户的剪贴板中,此时只能复制和粘贴画布内的节点数据 |
|
||||
| customHyperlinkJump(v0.10.2+) | null、Function | false | 自定义超链接的跳转。如果不传,默认会以新窗口的方式打开超链接,可以传递一个函数,函数接收两个参数:link(超链接的url)、node(所属节点实例),只要传递了函数,就会阻止默认的跳转 |
|
||||
| openPerformance(v0.10.4+) | Boolean | false | 是否开启性能模式,默认情况下所有节点都会直接渲染,无论是否处于画布可视区域,这样当节点数量比较多时(1000+)会比较卡,如果你的数据量比较大,那么可以通过该配置开启性能模式,即只渲染画布可视区域内的节点,超出的节点不渲染,这样会大幅提高渲染速度,当然同时也会带来一些其他问题,比如:1.当拖动或是缩放画布时会实时计算并渲染未节点的节点,所以会带来一定卡顿;2.导出图片、svg、pdf时需要先渲染全部节点,所以会比较慢;3.其他目前未发现的问题 |
|
||||
| performanceConfig(v0.10.4+) | Object | { time: 250, padding: 100, removeNodeWhenOutCanvas: true } | 性能优化模式配置。time(当视图改变后多久刷新一次节点,单位:ms)、padding(超出画布四周指定范围内依旧渲染节点)、removeNodeWhenOutCanvas(节点移出画布可视区域后是否从画布删除) |
|
||||
|
||||
#### 1.1数据结构
|
||||
|
||||
@@ -617,6 +619,8 @@ mindMap.setTheme('主题名称')
|
||||
| node_layout_end(v0.10.1+) | 单个节点内容布局完成的事件 | this(当前节点实例) |
|
||||
| node_attachmentClick(v0.9.10+) | 节点附件图标的点击事件 | this(当前节点实例)、e(事件对象)、node(图标节点) |
|
||||
| node_attachmentContextmenu(v0.9.10+) | 节点附件图标的右键点击事件 | this(当前节点实例)、e(事件对象)、node(图标节点) |
|
||||
| before_update_config(v0.10.4+) | 更新配置前触发,即当调用了`mindMap.updateConfig`方法更新配置时触发 | opt(未更新前的配置对象,引用对象,而非拷贝,所以当after_update_config事件触发后,该对象也会同步变化,所以需要缓存你需要的某个配置字段) |
|
||||
| after_update_config(v0.10.4+) | 更新配置后触发 | opt(更新后的配置对象) |
|
||||
|
||||
### emit(event, ...args)
|
||||
|
||||
|
||||
@@ -466,6 +466,18 @@
|
||||
<td>false</td>
|
||||
<td>自定义超链接的跳转。如果不传,默认会以新窗口的方式打开超链接,可以传递一个函数,函数接收两个参数:link(超链接的url)、node(所属节点实例),只要传递了函数,就会阻止默认的跳转</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>openPerformance(v0.10.4+)</td>
|
||||
<td>Boolean</td>
|
||||
<td>false</td>
|
||||
<td>是否开启性能模式,默认情况下所有节点都会直接渲染,无论是否处于画布可视区域,这样当节点数量比较多时(1000+)会比较卡,如果你的数据量比较大,那么可以通过该配置开启性能模式,即只渲染画布可视区域内的节点,超出的节点不渲染,这样会大幅提高渲染速度,当然同时也会带来一些其他问题,比如:1.当拖动或是缩放画布时会实时计算并渲染未节点的节点,所以会带来一定卡顿;2.导出图片、svg、pdf时需要先渲染全部节点,所以会比较慢;3.其他目前未发现的问题</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>performanceConfig(v0.10.4+)</td>
|
||||
<td>Object</td>
|
||||
<td>{ time: 250, padding: 100, removeNodeWhenOutCanvas: true }</td>
|
||||
<td>性能优化模式配置。time(当视图改变后多久刷新一次节点,单位:ms)、padding(超出画布四周指定范围内依旧渲染节点)、removeNodeWhenOutCanvas(节点移出画布可视区域后是否从画布删除)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h4>1.1数据结构</h4>
|
||||
@@ -1609,6 +1621,16 @@ mindMap.setTheme(<span class="hljs-string">'主题名称'</span>)
|
||||
<td>节点附件图标的右键点击事件</td>
|
||||
<td>this(当前节点实例)、e(事件对象)、node(图标节点)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>before_update_config(v0.10.4+)</td>
|
||||
<td>更新配置前触发,即当调用了<code>mindMap.updateConfig</code>方法更新配置时触发</td>
|
||||
<td>opt(未更新前的配置对象,引用对象,而非拷贝,所以当after_update_config事件触发后,该对象也会同步变化,所以需要缓存你需要的某个配置字段)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>after_update_config(v0.10.4+)</td>
|
||||
<td>更新配置后触发</td>
|
||||
<td>opt(更新后的配置对象)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3>emit(event, ...args)</h3>
|
||||
|
||||
@@ -446,4 +446,12 @@
|
||||
<img src="../../../../assets/avatar/晴空.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>晴空</p>
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
|
||||
<img src="../../../../assets/avatar/default.png" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>黄泳</p>
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
|
||||
<img src="../../../../assets/avatar/ccccs.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>ccccs</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -400,6 +400,14 @@
|
||||
<img src="../../../../assets/avatar/晴空.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>晴空</p>
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
|
||||
<img src="../../../../assets/avatar/default.png" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>黄泳</p>
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
|
||||
<img src="../../../../assets/avatar/ccccs.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
|
||||
<p>ccccs</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -56,6 +56,14 @@
|
||||
|
||||
## 方法
|
||||
|
||||
### checkIsInClient(padding = 0)
|
||||
|
||||
> v0.10.4+
|
||||
|
||||
- `padding`: Number, 向画布四周延伸的区域大小
|
||||
|
||||
判断节点是否处于画布可视区域。
|
||||
|
||||
### deactivate()
|
||||
|
||||
> 0.9.11+
|
||||
|
||||
@@ -31,6 +31,14 @@
|
||||
</blockquote>
|
||||
<p>节点是否正在拖拽中</p>
|
||||
<h2>方法</h2>
|
||||
<h3>checkIsInClient(padding = 0)</h3>
|
||||
<blockquote>
|
||||
<p>v0.10.4+</p>
|
||||
</blockquote>
|
||||
<ul>
|
||||
<li><code>padding</code>: Number, 向画布四周延伸的区域大小</li>
|
||||
</ul>
|
||||
<p>判断节点是否处于画布可视区域。</p>
|
||||
<h3>deactivate()</h3>
|
||||
<blockquote>
|
||||
<p>0.9.11+</p>
|
||||
|
||||
@@ -73,16 +73,25 @@ import('simple-mind-map/src/plugins/Export.js').then(res => {
|
||||
})
|
||||
```
|
||||
|
||||
如果你需要`umd`模块格式的文件,比如以`CDN`的方式在浏览器上使用,那么你可以从`/simple-mind-map/dist/`目录中找到`simpleMindMap.umd.min.js`文件和`simpleMindMap.css`文件,复制到你的项目中,然后在页面中引入:
|
||||
如果你需要`umd`模块格式的文件,比如以`CDN`的方式在浏览器上使用,那么你可以先通过npm安装`npm i simple-mind-map`,然后在`node_modules/simple-mind-map/dist/`目录中找到`simpleMindMap.umd.min.js`文件和`simpleMindMap.esm.min.css`文件,复制到你的项目中,然后在页面中引入:
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="simpleMindMap.css">
|
||||
<link rel="stylesheet" href="simpleMindMap.esm.min.css">
|
||||
<script scr="simpleMindMap.umd.min.js"></script>
|
||||
```
|
||||
|
||||
会创建一个全局变量`window.simpleMindMap`,可以通过`window.simpleMindMap.default`获取到`MindMap`构造函数,详细信息可以把`window.simpleMindMap`打印出来看一下。
|
||||
库会创建一个全局变量`window.simpleMindMap`,可以通过`window.simpleMindMap.default`获取到`MindMap`构造函数,然后正常实例化即可,详细信息可以把`window.simpleMindMap`打印出来看一下。
|
||||
|
||||
这种方式的缺点是会包含所有的内容,包括你没有注册的插件,所以整体体积会比较大。
|
||||
如果不方便使用`npm`来安装,也可以通过一些在线`CDN`服务来获取到这两个文件,比如:
|
||||
|
||||
```
|
||||
https://unpkg.com/simple-mind-map@0.10.2/dist/simpleMindMap.esm.css
|
||||
https://unpkg.com/simple-mind-map@0.10.2/dist/simpleMindMap.umd.min.js
|
||||
```
|
||||
|
||||
你可以替换其中的版本号。
|
||||
|
||||
这种方式的缺点是会包含所有的内容,包括你没有注册的插件(可以在这里[full.js](https://github.com/wanglin2/mind-map/blob/main/simple-mind-map/full.js#L36)查看默认打包进文件的插件),所以整体体积会比较大,如果只想要打包指定的插件,你可以修改该文件,然后重新打包,如有需要也可以联系开发者。
|
||||
|
||||
(v0.5.4+)如果你想直接在浏览器端通过`ES`模块的方式来使用,你可以在`/simple-mind-map/dist/`目录中找到`simpleMindMap.esm.js`和`simpleMindMap.esm.css`文件。
|
||||
|
||||
@@ -200,7 +209,7 @@ resolve: { alias: { stream: "stream-browserify" } }
|
||||
|
||||
这是因为你的构建环境不支持该js语法,该语法出自`@svgdotjs/svg.js`库,解决方法如下:
|
||||
|
||||
1.手动降低`@svgdotjs/svg.js`库的版本,你可以在你的项目中手动安装低版本,比如:`npm i @svgdotjs/svg.js@3.0.16`
|
||||
1.手动降低`@svgdotjs/svg.js`库的版本,你可以在你的项目中手动安装低版本,比如:`npm i @svgdotjs/svg.js@3.2.0`
|
||||
|
||||
2.不降低版本的话,可以通过修改你的构建工具的相关配置,修改`babel`的配置,让它编译一下`node_modules`中的`simple-mind-map`库,或`@svgdotjs/svg.js`库,如果用的是`vue-cli`或`vite`,它们也直接提供了相关配置。另外需要安装编译该语法的`babel`插件,并且配置到`babel`的配置文件中:
|
||||
|
||||
|
||||
@@ -52,12 +52,17 @@
|
||||
mindMap.addPlugin(res.default)
|
||||
})
|
||||
</code></pre>
|
||||
<p>如果你需要<code>umd</code>模块格式的文件,比如以<code>CDN</code>的方式在浏览器上使用,那么你可以从<code>/simple-mind-map/dist/</code>目录中找到<code>simpleMindMap.umd.min.js</code>文件和<code>simpleMindMap.css</code>文件,复制到你的项目中,然后在页面中引入:</p>
|
||||
<pre class="hljs"><code><span class="hljs-tag"><<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">"stylesheet"</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"simpleMindMap.css"</span>></span>
|
||||
<p>如果你需要<code>umd</code>模块格式的文件,比如以<code>CDN</code>的方式在浏览器上使用,那么你可以先通过npm安装<code>npm i simple-mind-map</code>,然后在<code>node_modules/simple-mind-map/dist/</code>目录中找到<code>simpleMindMap.umd.min.js</code>文件和<code>simpleMindMap.esm.min.css</code>文件,复制到你的项目中,然后在页面中引入:</p>
|
||||
<pre class="hljs"><code><span class="hljs-tag"><<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">"stylesheet"</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"simpleMindMap.esm.min.css"</span>></span>
|
||||
<span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">scr</span>=<span class="hljs-string">"simpleMindMap.umd.min.js"</span>></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span>
|
||||
</code></pre>
|
||||
<p>会创建一个全局变量<code>window.simpleMindMap</code>,可以通过<code>window.simpleMindMap.default</code>获取到<code>MindMap</code>构造函数,详细信息可以把<code>window.simpleMindMap</code>打印出来看一下。</p>
|
||||
<p>这种方式的缺点是会包含所有的内容,包括你没有注册的插件,所以整体体积会比较大。</p>
|
||||
<p>库会创建一个全局变量<code>window.simpleMindMap</code>,可以通过<code>window.simpleMindMap.default</code>获取到<code>MindMap</code>构造函数,然后正常实例化即可,详细信息可以把<code>window.simpleMindMap</code>打印出来看一下。</p>
|
||||
<p>如果不方便使用<code>npm</code>来安装,也可以通过一些在线<code>CDN</code>服务来获取到这两个文件,比如:</p>
|
||||
<pre class="hljs"><code>https://unpkg.com/simple-mind-map@0.10.2/dist/simpleMindMap.esm.css
|
||||
https://unpkg.com/simple-mind-map@0.10.2/dist/simpleMindMap.umd.min.js
|
||||
</code></pre>
|
||||
<p>你可以替换其中的版本号。</p>
|
||||
<p>这种方式的缺点是会包含所有的内容,包括你没有注册的插件(可以在这里<a href="https://github.com/wanglin2/mind-map/blob/main/simple-mind-map/full.js#L36">full.js</a>查看默认打包进文件的插件),所以整体体积会比较大,如果只想要打包指定的插件,你可以修改该文件,然后重新打包,如有需要也可以联系开发者。</p>
|
||||
<p>(v0.5.4+)如果你想直接在浏览器端通过<code>ES</code>模块的方式来使用,你可以在<code>/simple-mind-map/dist/</code>目录中找到<code>simpleMindMap.esm.js</code>和<code>simpleMindMap.esm.css</code>文件。</p>
|
||||
<p>也可以使用在线cdn服务,比如:</p>
|
||||
<pre class="hljs"><code>https://unpkg.com/browse/simple-mind-map@0.9.2/dist/
|
||||
@@ -126,7 +131,7 @@ npm run build
|
||||
<h3>5.引入simple-mind-map报错,报错信息如下:</h3>
|
||||
<img src="../../../../assets/img/docs/错误.jpg" style="width: 850px" />
|
||||
<p>这是因为你的构建环境不支持该js语法,该语法出自<code>@svgdotjs/svg.js</code>库,解决方法如下:</p>
|
||||
<p>1.手动降低<code>@svgdotjs/svg.js</code>库的版本,你可以在你的项目中手动安装低版本,比如:<code>npm i @svgdotjs/svg.js@3.0.16</code></p>
|
||||
<p>1.手动降低<code>@svgdotjs/svg.js</code>库的版本,你可以在你的项目中手动安装低版本,比如:<code>npm i @svgdotjs/svg.js@3.2.0</code></p>
|
||||
<p>2.不降低版本的话,可以通过修改你的构建工具的相关配置,修改<code>babel</code>的配置,让它编译一下<code>node_modules</code>中的<code>simple-mind-map</code>库,或<code>@svgdotjs/svg.js</code>库,如果用的是<code>vue-cli</code>或<code>vite</code>,它们也直接提供了相关配置。另外需要安装编译该语法的<code>babel</code>插件,并且配置到<code>babel</code>的配置文件中:</p>
|
||||
<p><code>@babel/plugin-proposal-nullish-coalescing-operator</code>、<code>@babel/plugin-proposal-optional-chaining</code>。</p>
|
||||
|
||||
|
||||
@@ -845,6 +845,20 @@
|
||||
</div>
|
||||
<!-- 其他配置 -->
|
||||
<div class="title noTop">{{ $t('baseStyle.otherConfig') }}</div>
|
||||
<!-- 配置性能模式 -->
|
||||
<div class="row">
|
||||
<div class="rowItem">
|
||||
<el-checkbox
|
||||
v-model="config.openPerformance"
|
||||
@change="
|
||||
value => {
|
||||
updateOtherConfig('openPerformance', value)
|
||||
}
|
||||
"
|
||||
>{{ $t('baseStyle.openPerformance') }}</el-checkbox
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 配置开启自由拖拽 -->
|
||||
<div class="row">
|
||||
<div class="rowItem">
|
||||
@@ -1062,6 +1076,7 @@ export default {
|
||||
nodeUseLineStyle: false
|
||||
},
|
||||
config: {
|
||||
openPerformance: false,
|
||||
enableFreeDrag: false,
|
||||
mousewheelAction: 'zoom',
|
||||
mousewheelZoomActionReverse: false,
|
||||
@@ -1244,6 +1259,7 @@ export default {
|
||||
// 初始化其他配置
|
||||
initConfig() {
|
||||
;[
|
||||
'openPerformance',
|
||||
'enableFreeDrag',
|
||||
'mousewheelAction',
|
||||
'mousewheelZoomActionReverse',
|
||||
|
||||
Reference in New Issue
Block a user