diff --git a/simple-mind-map/src/constants/defaultOptions.js b/simple-mind-map/src/constants/defaultOptions.js index ee9417ce..ea801d67 100644 --- a/simple-mind-map/src/constants/defaultOptions.js +++ b/simple-mind-map/src/constants/defaultOptions.js @@ -49,7 +49,8 @@ export const defaultOpt = { color: '#999', opacity: 0.5, fontSize: 14 - } + }, + belowNode: false }, // 达到该宽度文本自动换行 textAutoWrapWidth: 500, @@ -326,5 +327,5 @@ export const defaultOpt = { // 添加附加的节点前置内容,前置内容指和文本同一行的区域中的前置内容,不包括节点图片部分 createNodePrefixContent: null, // 添加附加的节点后置内容,后置内容指和文本同一行的区域中的后置内容,不包括节点图片部分 - createNodePostfixContent: null + createNodePostfixContent: null, } diff --git a/simple-mind-map/src/plugins/Watermark.js b/simple-mind-map/src/plugins/Watermark.js index fe40fe96..6042f56b 100644 --- a/simple-mind-map/src/plugins/Watermark.js +++ b/simple-mind-map/src/plugins/Watermark.js @@ -41,10 +41,21 @@ class Watermark { // 创建水印容器 createContainer() { if (this.watermarkDraw) return - this.watermarkDraw = this.mindMap.svg - .group() + this.watermarkDraw = new G() .css({ 'pointer-events': 'none', 'user-select': 'none' }) .addClass('smm-water-mark-container') + this.updateLayer() + } + + // 更新水印容器层级 + updateLayer() { + if (!this.watermarkDraw) return + const { belowNode } = this.mindMap.opt.watermarkConfig + if (belowNode) { + this.watermarkDraw.insertBefore(this.mindMap.draw) + } else { + this.mindMap.svg.add(this.watermarkDraw) + } } // 删除水印容器 @@ -160,6 +171,7 @@ class Watermark { this.mindMap.opt.watermarkConfig, config ) + this.updateLayer() this.handleConfig(config) this.draw() } @@ -167,11 +179,13 @@ class Watermark { // 插件被移除前做的事情 beforePluginRemove() { this.unBindEvent() + this.removeContainer() } // 插件被卸载前做的事情 beforePluginDestroy() { this.unBindEvent() + this.removeContainer() } }