Feat:支持设置水印显示在节点下方

This commit is contained in:
街角小林 2024-05-27 19:13:29 +08:00
parent 1f8fad8fc5
commit dccd1c9459
2 changed files with 19 additions and 4 deletions

View File

@ -49,7 +49,8 @@ export const defaultOpt = {
color: '#999', color: '#999',
opacity: 0.5, opacity: 0.5,
fontSize: 14 fontSize: 14
} },
belowNode: false
}, },
// 达到该宽度文本自动换行 // 达到该宽度文本自动换行
textAutoWrapWidth: 500, textAutoWrapWidth: 500,
@ -326,5 +327,5 @@ export const defaultOpt = {
// 添加附加的节点前置内容,前置内容指和文本同一行的区域中的前置内容,不包括节点图片部分 // 添加附加的节点前置内容,前置内容指和文本同一行的区域中的前置内容,不包括节点图片部分
createNodePrefixContent: null, createNodePrefixContent: null,
// 添加附加的节点后置内容,后置内容指和文本同一行的区域中的后置内容,不包括节点图片部分 // 添加附加的节点后置内容,后置内容指和文本同一行的区域中的后置内容,不包括节点图片部分
createNodePostfixContent: null createNodePostfixContent: null,
} }

View File

@ -41,10 +41,21 @@ class Watermark {
// 创建水印容器 // 创建水印容器
createContainer() { createContainer() {
if (this.watermarkDraw) return if (this.watermarkDraw) return
this.watermarkDraw = this.mindMap.svg this.watermarkDraw = new G()
.group()
.css({ 'pointer-events': 'none', 'user-select': 'none' }) .css({ 'pointer-events': 'none', 'user-select': 'none' })
.addClass('smm-water-mark-container') .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, this.mindMap.opt.watermarkConfig,
config config
) )
this.updateLayer()
this.handleConfig(config) this.handleConfig(config)
this.draw() this.draw()
} }
@ -167,11 +179,13 @@ class Watermark {
// 插件被移除前做的事情 // 插件被移除前做的事情
beforePluginRemove() { beforePluginRemove() {
this.unBindEvent() this.unBindEvent()
this.removeContainer()
} }
// 插件被卸载前做的事情 // 插件被卸载前做的事情
beforePluginDestroy() { beforePluginDestroy() {
this.unBindEvent() this.unBindEvent()
this.removeContainer()
} }
} }