Feat:支持按住Command键和Win键多选节点

This commit is contained in:
wanglin2 2024-04-13 15:28:56 +08:00
parent d73225f787
commit c1217f1532
3 changed files with 13 additions and 6 deletions

View File

@ -272,7 +272,10 @@ class Node {
// 附件 // 附件
if (this._attachmentData) { if (this._attachmentData) {
textContentWidth += this._attachmentData.width textContentWidth += this._attachmentData.width
textContentHeight = Math.max(textContentHeight, this._attachmentData.height) textContentHeight = Math.max(
textContentHeight,
this._attachmentData.height
)
} }
// 文字内容部分的尺寸 // 文字内容部分的尺寸
this._rectInfo.textContentWidth = textContentWidth this._rectInfo.textContentWidth = textContentWidth
@ -466,7 +469,7 @@ class Node {
} }
} }
// 多选和取消多选 // 多选和取消多选
if (e.ctrlKey && enableCtrlKeyNodeSelection) { if ((e.ctrlKey || e.metaKey) && enableCtrlKeyNodeSelection) {
this.isMultipleChoice = true this.isMultipleChoice = true
let isActive = this.getData('isActive') let isActive = this.getData('isActive')
if (!isActive) if (!isActive)
@ -510,7 +513,7 @@ class Node {
// 双击事件 // 双击事件
this.group.on('dblclick', e => { this.group.on('dblclick', e => {
const { readonly, onlyOneEnableActiveNodeOnCooperate } = this.mindMap.opt const { readonly, onlyOneEnableActiveNodeOnCooperate } = this.mindMap.opt
if (readonly || e.ctrlKey) { if (readonly || e.ctrlKey || e.metaKey) {
return return
} }
e.stopPropagation() e.stopPropagation()

View File

@ -37,7 +37,7 @@ class View {
this.mindMap.event.on('drag', (e, event) => { this.mindMap.event.on('drag', (e, event) => {
// 按住ctrl键拖动为多选 // 按住ctrl键拖动为多选
// 禁用拖拽 // 禁用拖拽
if (e.ctrlKey || this.mindMap.opt.isDisableDrag) { if (e.ctrlKey || e.metaKey || this.mindMap.opt.isDisableDrag) {
return return
} }
if (this.firstDrag) { if (this.firstDrag) {
@ -72,7 +72,11 @@ class View {
return customHandleMousewheel(e) return customHandleMousewheel(e)
} }
// 1.鼠标滚轮事件控制缩放 // 1.鼠标滚轮事件控制缩放
if (mousewheelAction === CONSTANTS.MOUSE_WHEEL_ACTION.ZOOM || e.ctrlKey) { if (
mousewheelAction === CONSTANTS.MOUSE_WHEEL_ACTION.ZOOM ||
e.ctrlKey ||
e.metaKey
) {
if (disableMouseWheelZoom) return if (disableMouseWheelZoom) return
const { x: clientX, y: clientY } = this.mindMap.toPos( const { x: clientX, y: clientY } = this.mindMap.toPos(
e.clientX, e.clientX,

View File

@ -44,7 +44,7 @@ class Select {
} }
let { useLeftKeySelectionRightKeyDrag } = this.mindMap.opt let { useLeftKeySelectionRightKeyDrag } = this.mindMap.opt
if ( if (
!e.ctrlKey && !(e.ctrlKey || e.metaKey) &&
(useLeftKeySelectionRightKeyDrag ? e.which !== 1 : e.which !== 3) (useLeftKeySelectionRightKeyDrag ? e.which !== 1 : e.which !== 3)
) { ) {
return return