diff --git a/simple-mind-map/index.js b/simple-mind-map/index.js index 7ebbc2e4..7ae5592a 100644 --- a/simple-mind-map/index.js +++ b/simple-mind-map/index.js @@ -92,7 +92,10 @@ const defaultOpt = { // 如果开启节点动画过渡,可以通过该属性设置过渡的时间,单位ms nodeTransitionMoveDuration: 300, // 初始根节点的位置 - initRootNodePosition: null + initRootNodePosition: null, + // 导出png、svg、pdf时的图形内边距 + exportPaddingX: 10, + exportPaddingY: 10 } // 思维导图 @@ -359,7 +362,7 @@ class MindMap { } // 获取svg数据 - getSvgData() { + getSvgData({ paddingX = 0, paddingY = 0 }) { const svg = this.svg const draw = this.draw // 保存原始信息 @@ -371,6 +374,10 @@ class MindMap { draw.scale(1 / origTransform.scaleX, 1 / origTransform.scaleY) // 获取变换后的位置尺寸信息,其实是getBoundingClientRect方法的包装方法 const rect = draw.rbox() + // 内边距 + rect.width += paddingX + rect.height += paddingY + draw.translate(paddingX / 2, paddingY / 2) // 将svg设置为实际内容的宽高 svg.size(rect.width, rect.height) // 把实际内容变换 diff --git a/simple-mind-map/package.json b/simple-mind-map/package.json index 6403a28d..783d8696 100644 --- a/simple-mind-map/package.json +++ b/simple-mind-map/package.json @@ -1,6 +1,6 @@ { "name": "simple-mind-map", - "version": "0.5.4-fix.1", + "version": "0.5.5", "description": "一个简单的web在线思维导图", "authors": [ { diff --git a/simple-mind-map/src/Export.js b/simple-mind-map/src/Export.js index 27fd84b7..aab5b1dc 100644 --- a/simple-mind-map/src/Export.js +++ b/simple-mind-map/src/Export.js @@ -28,7 +28,11 @@ class Export { // 获取svg数据 async getSvgData(domToImage) { - let { svg, svgHTML } = this.mindMap.getSvgData() + let { exportPaddingX, exportPaddingY } = this.mindMap.opt + let { svg, svgHTML } = this.mindMap.getSvgData({ + paddingX: exportPaddingX, + paddingY: exportPaddingY + }) // 把图片的url转换成data:url类型,否则导出会丢失图片 let imageList = svg.find('image') let task = imageList.map(async item => { diff --git a/web/src/lang/en_us.js b/web/src/lang/en_us.js index 9df10eae..0d1d1c6d 100644 --- a/web/src/lang/en_us.js +++ b/web/src/lang/en_us.js @@ -95,7 +95,9 @@ export default { svgTips: 'tips: Exporting pictures in rich text mode is time-consuming', transformingDomToImages: 'Converting nodes: ', notifyTitle: 'Info', - notifyMessage: 'If the download is not triggered, check whether it is blocked by the browser' + notifyMessage: 'If the download is not triggered, check whether it is blocked by the browser', + paddingX: 'Padding x', + paddingY: 'Padding y' }, fullscreen: { fullscreenShow: 'Full screen show', diff --git a/web/src/lang/zh_cn.js b/web/src/lang/zh_cn.js index 09f00b2f..74477611 100644 --- a/web/src/lang/zh_cn.js +++ b/web/src/lang/zh_cn.js @@ -95,7 +95,9 @@ export default { svgTips: 'tips:富文本模式导出图片非常耗时', transformingDomToImages: '正在转换节点:', notifyTitle: '消息', - notifyMessage: '如果没有触发下载,请检查是否被浏览器拦截了' + notifyMessage: '如果没有触发下载,请检查是否被浏览器拦截了', + paddingX: '水平内边距', + paddingY: '垂直内边距' }, fullscreen: { fullscreenShow: '全屏查看', diff --git a/web/src/pages/Doc/en/changelog/index.md b/web/src/pages/Doc/en/changelog/index.md index 651e9fb7..e81b51e4 100644 --- a/web/src/pages/Doc/en/changelog/index.md +++ b/web/src/pages/Doc/en/changelog/index.md @@ -1,5 +1,9 @@ # Changelog +## 0.5.5 + +New: 1.Supports configuring the padding when exporting to PNG, SVG, or PDF. + ## 0.5.4 New: 1.Add new themes. 2.Added timeline and fishbone structure. @@ -8,6 +12,10 @@ Fix: 1.Fix the conflict issue between node right-click and canvas right-click. 2 optimization: 1.Optimize the layout of organizational chart. 2.Optimize the layout of the directory organization chart. +## 0.5.4-fix.1 + +optimization: 1.Optimize fishbone layout. + ## 0.5.3 Fix: 1.Fixed the issue of setting the text style when multiple nodes were selected in rich text mode, which would change the text of all selected nodes to the text of the last selected node. diff --git a/web/src/pages/Doc/en/changelog/index.vue b/web/src/pages/Doc/en/changelog/index.vue index 83b64dad..5418d29c 100644 --- a/web/src/pages/Doc/en/changelog/index.vue +++ b/web/src/pages/Doc/en/changelog/index.vue @@ -1,10 +1,14 @@