mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-17 22:08:25 +08:00
Feat:新增拦截删除节点图片的实例化选项
This commit is contained in:
@@ -410,5 +410,9 @@ export const defaultOpt = {
|
||||
|
||||
// 【Painter】插件
|
||||
// 是否只格式刷节点手动设置的样式,不考虑节点通过主题的应用的样式
|
||||
onlyPainterNodeCustomStyles: false
|
||||
onlyPainterNodeCustomStyles: false,
|
||||
|
||||
// 【NodeImgAdjust】插件
|
||||
// 拦截节点图片的删除,点击节点图片上的删除按钮删除图片前会调用该函数,如果函数返回true则取消删除
|
||||
beforeDeleteNodeImg: null
|
||||
}
|
||||
|
||||
@@ -192,8 +192,14 @@ class NodeImgAdjust {
|
||||
if (this.isMousedown) return
|
||||
this.hideHandleEl()
|
||||
})
|
||||
btnRemove.addEventListener('click', e => {
|
||||
this.mindMap.execCommand('SET_NODE_IMAGE', this.node, { url: null })
|
||||
btnRemove.addEventListener('click', async e => {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user