Feat:新增拦截删除节点图片的实例化选项
This commit is contained in:
parent
007a5f2815
commit
ef526fe302
@ -410,5 +410,9 @@ export const defaultOpt = {
|
|||||||
|
|
||||||
// 【Painter】插件
|
// 【Painter】插件
|
||||||
// 是否只格式刷节点手动设置的样式,不考虑节点通过主题的应用的样式
|
// 是否只格式刷节点手动设置的样式,不考虑节点通过主题的应用的样式
|
||||||
onlyPainterNodeCustomStyles: false
|
onlyPainterNodeCustomStyles: false,
|
||||||
|
|
||||||
|
// 【NodeImgAdjust】插件
|
||||||
|
// 拦截节点图片的删除,点击节点图片上的删除按钮删除图片前会调用该函数,如果函数返回true则取消删除
|
||||||
|
beforeDeleteNodeImg: null
|
||||||
}
|
}
|
||||||
|
|||||||
@ -192,8 +192,14 @@ class NodeImgAdjust {
|
|||||||
if (this.isMousedown) return
|
if (this.isMousedown) return
|
||||||
this.hideHandleEl()
|
this.hideHandleEl()
|
||||||
})
|
})
|
||||||
btnRemove.addEventListener('click', e => {
|
btnRemove.addEventListener('click', async e => {
|
||||||
this.mindMap.execCommand('SET_NODE_IMAGE', this.node, { url: null })
|
let stop = false
|
||||||
|
if (typeof this.mindMap.opt.beforeDeleteNodeImg === 'function') {
|
||||||
|
stop = await this.mindMap.opt.beforeDeleteNodeImg(this.node)
|
||||||
|
}
|
||||||
|
if (!stop) {
|
||||||
|
this.mindMap.execCommand('SET_NODE_IMAGE', this.node, { url: null })
|
||||||
|
}
|
||||||
})
|
})
|
||||||
// 添加元素到页面
|
// 添加元素到页面
|
||||||
const targetNode = this.mindMap.opt.customInnerElsAppendTo || document.body
|
const targetNode = this.mindMap.opt.customInnerElsAppendTo || document.body
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user