From dccd1c945977b0adc22167f1c338d98378783f2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Mon, 27 May 2024 19:13:29 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9A=E6=94=AF=E6=8C=81=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=B0=B4=E5=8D=B0=E6=98=BE=E7=A4=BA=E5=9C=A8=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E4=B8=8B=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/constants/defaultOptions.js | 5 +++-- simple-mind-map/src/plugins/Watermark.js | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) 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() } }