diff --git a/simple-mind-map/src/constants/defaultOptions.js b/simple-mind-map/src/constants/defaultOptions.js index 5f09a779..a830cdfb 100644 --- a/simple-mind-map/src/constants/defaultOptions.js +++ b/simple-mind-map/src/constants/defaultOptions.js @@ -245,6 +245,8 @@ export const defaultOpt = { emptyTextMeasureHeightText: 'abc123我和你', // 是否在进行节点文本编辑时实时更新节点大小和节点位置,开启后当节点数量比较多时可能会造成卡顿 openRealtimeRenderOnNodeTextEdit: false, + // 默认会给容器元素el绑定mousedown事件,并且会阻止其默认事件,这会带来一定问题,比如你聚焦在思维导图外的其他输入框,点击画布就不会触发其失焦,可以通过该选项关闭阻止。关闭后也会带来一定问题,比如鼠标框选节点时可能会选中节点文字,看你如何取舍 + mousedownEventPreventDefault: true, // 【Select插件】 // 多选节点时鼠标移动到边缘时的画布移动偏移量 diff --git a/simple-mind-map/src/core/view/View.js b/simple-mind-map/src/core/view/View.js index 94980e59..3c6ef130 100644 --- a/simple-mind-map/src/core/view/View.js +++ b/simple-mind-map/src/core/view/View.js @@ -30,8 +30,11 @@ class View { }) // 拖动视图 this.mindMap.event.on('mousedown', e => { - if (this.mindMap.opt.isDisableDrag) return - e.preventDefault() + const { isDisableDrag, mousedownEventPreventDefault } = this.mindMap.opt + if (isDisableDrag) return + if (mousedownEventPreventDefault) { + e.preventDefault() + } this.sx = this.x this.sy = this.y }) diff --git a/simple-mind-map/src/plugins/Select.js b/simple-mind-map/src/plugins/Select.js index d80865f6..eaf93f9b 100644 --- a/simple-mind-map/src/plugins/Select.js +++ b/simple-mind-map/src/plugins/Select.js @@ -41,7 +41,8 @@ class Select { // 鼠标按下 onMousedown(e) { - if (this.mindMap.opt.readonly) { + const { readonly, mousedownEventPreventDefault } = this.mindMap.opt + if (readonly) { return } let { useLeftKeySelectionRightKeyDrag } = this.mindMap.opt @@ -51,7 +52,9 @@ class Select { ) { return } - e.preventDefault() + if (mousedownEventPreventDefault) { + e.preventDefault() + } this.isMousedown = true this.cacheActiveList = [...this.mindMap.renderer.activeNodeList] let { x, y } = this.mindMap.toPos(e.clientX, e.clientY)