diff --git a/index.html b/index.html index 25742be7..de5534fb 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -思绪思维导图
\ No newline at end of file +思绪思维导图
\ No newline at end of file diff --git a/simple-mind-map/package.json b/simple-mind-map/package.json index f42f03e4..ccc51ff0 100644 --- a/simple-mind-map/package.json +++ b/simple-mind-map/package.json @@ -1,6 +1,6 @@ { "name": "simple-mind-map", - "version": "0.6.10", + "version": "0.6.11", "description": "一个简单的web在线思维导图", "authors": [ { diff --git a/simple-mind-map/src/core/render/node/Node.js b/simple-mind-map/src/core/render/node/Node.js index 4dd66d84..4a5a6ac2 100644 --- a/simple-mind-map/src/core/render/node/Node.js +++ b/simple-mind-map/src/core/render/node/Node.js @@ -266,6 +266,7 @@ class Node { paddingY += this.shapePadding.paddingY // 节点形状 this.shapeNode = this.shapeInstance.createShape() + this.shapeNode.addClass('smm-node-shape') this.group.add(this.shapeNode) this.updateNodeShape() // 渲染一个隐藏的矩形区域,用来触发展开收起按钮的显示 @@ -531,6 +532,7 @@ class Node { isLayout = true // 创建组 this.group = new G() + this.group.addClass('smm-node') this.group.css({ cursor: 'default' }) diff --git a/simple-mind-map/src/plugins/MiniMap.js b/simple-mind-map/src/plugins/MiniMap.js index 78198685..ed4a99d3 100644 --- a/simple-mind-map/src/plugins/MiniMap.js +++ b/simple-mind-map/src/plugins/MiniMap.js @@ -1,3 +1,5 @@ +import { isWhite, isTransparent } from '../utils/index' + // 小地图插件 class MiniMap { // 构造函数 @@ -20,7 +22,7 @@ class MiniMap { * boxHeight:小地图容器的高度 */ calculationMiniMap(boxWidth, boxHeight) { - let { svgHTML, rect, origWidth, origHeight, scaleX, scaleY } = + let { svg, rect, origWidth, origHeight, scaleX, scaleY } = this.mindMap.getSvgData() // 计算数据 let boxRatio = boxWidth / boxHeight @@ -65,8 +67,10 @@ class MiniMap { Math.max(0, ((_rectY2 - origHeight) / _rectHeight) * actHeight) + miniMapBoxTop + 'px' + + this.removeNodeContent(svg) return { - svgHTML, // 小地图html + svgHTML: svg.svg(), // 小地图html viewBoxStyle, // 视图框的位置信息 miniMapBoxScale, // 视图框的缩放值 miniMapBoxLeft, // 视图框的left值 @@ -74,6 +78,38 @@ class MiniMap { } } + // 移除节点的内容 + removeNodeContent(svg) { + if (svg.hasClass('smm-node')) { + let shape = svg.findOne('.smm-node-shape') + let fill = shape.attr('fill') + if (isWhite(fill) || isTransparent(fill)) { + shape.attr('fill', this.getDefaultFill()) + } + svg.clear() + svg.add(shape) + return + } + let children = svg.children() + if (children && children.length > 0) { + children.forEach((node) => { + this.removeNodeContent(node) + }) + } + } + + // 计算默认的填充颜色 + getDefaultFill() { + let { lineColor, root, second, node } = this.mindMap.themeConfig + let list = [lineColor, root.fillColor, root.color, second.fillColor, second.color, node.fillColor, node.color, root.borderColor, second.borderColor, node.borderColor] + for(let i = 0; i < list.length; i++) { + let color = list[i] + if (!isTransparent(color) && !isWhite(color)) { + return color + } + } + } + // 小地图鼠标按下事件 onMousedown(e) { this.isMousedown = true diff --git a/simple-mind-map/src/utils/index.js b/simple-mind-map/src/utils/index.js index 5488e394..68cc323a 100644 --- a/simple-mind-map/src/utils/index.js +++ b/simple-mind-map/src/utils/index.js @@ -515,4 +515,16 @@ export const replaceHtmlText = (html, searchText, replaceText) => { } walk(replaceHtmlTextEl) return replaceHtmlTextEl.innerHTML +} + +// 判断一个颜色是否是白色 +export const isWhite = (color) => { + color = String(color).replaceAll(/\s+/g, '') + return ['#fff', '#ffffff', '#FFF', '#FFFFFF', 'rgb(255,255,255)'].includes(color) || /rgba\(255,255,255,[^)]+\)/.test(color) +} + +// 判断一个颜色是否是透明 +export const isTransparent = (color) => { + color = String(color).replaceAll(/\s+/g, '') + return ['', 'transparent'].includes(color) || /rgba\(\d+,\d+,\d+,0\)/.test(color) } \ No newline at end of file diff --git a/web/src/pages/Doc/en/changelog/index.md b/web/src/pages/Doc/en/changelog/index.md index 1439531e..849ba902 100644 --- a/web/src/pages/Doc/en/changelog/index.md +++ b/web/src/pages/Doc/en/changelog/index.md @@ -1,12 +1,18 @@ # Changelog +## 0.6.11 + +New: 1.Optimize the mini map, remove node content within the mini map, and optimize performance. + +Demo: 1.Add a new topic and add tab differentiation to the topic list. 2.Node image upload supports inputting network image addresses. 3.Node image upload supports inputting network images. + ## 0.6.10 Fix: 1.Fix the issue of deleting a node after searching for it and not updating the search results when searching again. 2.Fixed an issue where the button for adjusting image size did not update after node operation. 3.Fix the issue of incorrect internal data deep copy location. 4.Fix the issue of ineffective line wrapping in rich text nodes. 5. Fix the issue of node swapping and loss when switching themes and other scenarios. New: 1.Search supports searching for white space characters and replacing them with white space characters. -Demo: 1.Support calling up search through icon buttons. 2.Support for switching to dark mode through icon buttons. 3.Optimize search: The mouse is not in the search area and not focused, solving the problem of not being able to delete input text when the mouse is not in the search area. 4.Adjust the interface UI for adding node icons and add a series of node icons. 5.Add a sticker list. 6.Fixed the issue of missing focus in the input box after entering the search box. 7.Support clicking on the icon within the node to display an icon for quick replacement and deletion of the floating panel. +Demo: 1.Support calling up search through icon buttons. 2.Support for switching to dark mode through icon buttons. 3.Optimize search: The mouse is not in the search area and not focused, solving the problem of not being able to delete input text when the mouse is not in the search area. 4.Adjust the interface UI for adding node icons and add a series of node icons. 5.Add a sticker list. 6.Fixed the issue of missing focus in the input box after entering the search box. 7.Support clicking on the icon within the node to display an icon for quick replacement and deletion of the floating panel. ## 0.6.9-fix.1 diff --git a/web/src/pages/Doc/en/changelog/index.vue b/web/src/pages/Doc/en/changelog/index.vue index 85a9c3fd..c61d8f73 100644 --- a/web/src/pages/Doc/en/changelog/index.vue +++ b/web/src/pages/Doc/en/changelog/index.vue @@ -1,6 +1,9 @@