diff --git a/index.html b/index.html index 0ba7857e..ffed24e8 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -一个简单的web思维导图实现
\ No newline at end of file +一个简单的web思维导图实现
\ No newline at end of file diff --git a/simple-mind-map/package.json b/simple-mind-map/package.json index fe2faea2..9c15737f 100644 --- a/simple-mind-map/package.json +++ b/simple-mind-map/package.json @@ -1,6 +1,6 @@ { "name": "simple-mind-map", - "version": "0.6.1", + "version": "0.6.2", "description": "一个简单的web在线思维导图", "authors": [ { diff --git a/simple-mind-map/src/constants/constant.js b/simple-mind-map/src/constants/constant.js index 6505b71d..a441e99d 100644 --- a/simple-mind-map/src/constants/constant.js +++ b/simple-mind-map/src/constants/constant.js @@ -259,4 +259,24 @@ export const layoutValueList = [ CONSTANTS.LAYOUT.TIMELINE, CONSTANTS.LAYOUT.TIMELINE2, CONSTANTS.LAYOUT.FISHBONE +] + +// 节点数据中非样式的字段 +export const nodeDataNoStylePropList = [ + 'text', + 'image', + 'imageTitle', + 'imageSize', + 'icon', + 'tag', + 'hyperlink', + 'hyperlinkTitle', + 'note', + 'expand', + 'isActive', + 'generalization', + 'richText', + 'resetRichText', + 'uid', + 'activeStyle' ] \ No newline at end of file diff --git a/simple-mind-map/src/core/render/node/Node.js b/simple-mind-map/src/core/render/node/Node.js index d92c9f72..3d2bab6f 100644 --- a/simple-mind-map/src/core/render/node/Node.js +++ b/simple-mind-map/src/core/render/node/Node.js @@ -798,6 +798,11 @@ class Node { getData(key) { return key ? this.nodeData.data[key] || '' : this.nodeData.data } + + // 是否存在自定义样式 + hasCustomStyle() { + return this.style.hasCustomStyle() + } } export default Node diff --git a/simple-mind-map/src/core/render/node/Style.js b/simple-mind-map/src/core/render/node/Style.js index f6816580..99e7def9 100644 --- a/simple-mind-map/src/core/render/node/Style.js +++ b/simple-mind-map/src/core/render/node/Style.js @@ -1,4 +1,4 @@ -import { tagColorList } from '../../../constants/constant' +import { tagColorList, nodeDataNoStylePropList } from '../../../constants/constant' const rootProp = ['paddingX', 'paddingY'] const backgroundStyleProps = ['backgroundColor', 'backgroundImage', 'backgroundRepeat', 'backgroundPosition', 'backgroundSize'] @@ -209,6 +209,17 @@ class Style { node2.fill({ color: color }) fillNode.fill({ color: fill }) } + + // 是否设置了自定义的样式 + hasCustomStyle() { + let res = false + Object.keys(this.ctx.nodeData.data).forEach((item) => { + if (!nodeDataNoStylePropList.includes(item)) { + res = true + } + }) + return res + } } Style.cacheStyle = null diff --git a/simple-mind-map/src/core/render/node/nodeCreateContents.js b/simple-mind-map/src/core/render/node/nodeCreateContents.js index c5231e71..e175455f 100644 --- a/simple-mind-map/src/core/render/node/nodeCreateContents.js +++ b/simple-mind-map/src/core/render/node/nodeCreateContents.js @@ -64,8 +64,18 @@ function createIconNode() { function createRichTextNode() { let g = new G() // 重新设置富文本节点内容 - if (this.nodeData.data.resetRichText || [CONSTANTS.CHANGE_THEME].includes(this.mindMap.renderer.renderSource)) { + let recoverText = false + if (this.nodeData.data.resetRichText) { delete this.nodeData.data.resetRichText + recoverText = true + } + if ([CONSTANTS.CHANGE_THEME].includes(this.mindMap.renderer.renderSource)) { + // 如果自定义过样式则不允许覆盖 + if (!this.hasCustomStyle()) { + recoverText = true + } + } + if (recoverText) { let text = getTextFromHtml(this.nodeData.data.text) this.nodeData.data.text = `

${text}

` } diff --git a/simple-mind-map/src/plugins/RichText.js b/simple-mind-map/src/plugins/RichText.js index ab5eca67..47cc9ecd 100644 --- a/simple-mind-map/src/plugins/RichText.js +++ b/simple-mind-map/src/plugins/RichText.js @@ -219,7 +219,7 @@ class RichText { underline: node.style.merge('textDecoration') === 'underline', strike: node.style.merge('textDecoration') === 'line-through' } - this.formatAllText(style) + this.pureFormatAllText(style) } // 获取当前正在编辑的内容 @@ -325,7 +325,7 @@ class RichText { // 中文输入结束 onCompositionEnd() { - if (!this.showTextEdit) { + if (!this.showTextEdit || !this.lostStyle) { return } this.isCompositing = false @@ -372,6 +372,11 @@ class RichText { // 格式化所有文本 formatAllText(config = {}) { this.syncFormatToNodeConfig(config) + this.pureFormatAllText(config) + } + + // 纯粹的格式化所有文本 + pureFormatAllText(config = {}) { this.quill.formatText(0, this.quill.getLength(), config) } diff --git a/web/src/pages/Doc/en/changelog/index.md b/web/src/pages/Doc/en/changelog/index.md index 714becd0..b2ec82a8 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.6.2 + +Fix: 1.Fixed the problem that the new node does not change with the theme in rich Text mode. + ## 0.6.1 Fix: 1.Fixed the issue of high movement sensitivity when using the touchpad when changing mouse scrolling to moving the canvas behavior. diff --git a/web/src/pages/Doc/en/changelog/index.vue b/web/src/pages/Doc/en/changelog/index.vue index ce71b82a..f75ec873 100644 --- a/web/src/pages/Doc/en/changelog/index.vue +++ b/web/src/pages/Doc/en/changelog/index.vue @@ -1,6 +1,8 @@