Skip to content

Commit

Permalink
Feat:支持按住Command键和Win键多选节点
Browse files Browse the repository at this point in the history
  • Loading branch information
wanglin2 committed Apr 13, 2024
1 parent d73225f commit c1217f1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
9 changes: 6 additions & 3 deletions simple-mind-map/src/core/render/node/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ class Node {
// 附件
if (this._attachmentData) {
textContentWidth += this._attachmentData.width
textContentHeight = Math.max(textContentHeight, this._attachmentData.height)
textContentHeight = Math.max(
textContentHeight,
this._attachmentData.height
)
}
// 文字内容部分的尺寸
this._rectInfo.textContentWidth = textContentWidth
Expand Down Expand Up @@ -466,7 +469,7 @@ class Node {
}
}
// 多选和取消多选
if (e.ctrlKey && enableCtrlKeyNodeSelection) {
if ((e.ctrlKey || e.metaKey) && enableCtrlKeyNodeSelection) {
this.isMultipleChoice = true
let isActive = this.getData('isActive')
if (!isActive)
Expand Down Expand Up @@ -510,7 +513,7 @@ class Node {
// 双击事件
this.group.on('dblclick', e => {
const { readonly, onlyOneEnableActiveNodeOnCooperate } = this.mindMap.opt
if (readonly || e.ctrlKey) {
if (readonly || e.ctrlKey || e.metaKey) {
return
}
e.stopPropagation()
Expand Down
8 changes: 6 additions & 2 deletions simple-mind-map/src/core/view/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class View {
this.mindMap.event.on('drag', (e, event) => {
// 按住ctrl键拖动为多选
// 禁用拖拽
if (e.ctrlKey || this.mindMap.opt.isDisableDrag) {
if (e.ctrlKey || e.metaKey || this.mindMap.opt.isDisableDrag) {
return
}
if (this.firstDrag) {
Expand Down Expand Up @@ -72,7 +72,11 @@ class View {
return customHandleMousewheel(e)
}
// 1.鼠标滚轮事件控制缩放
if (mousewheelAction === CONSTANTS.MOUSE_WHEEL_ACTION.ZOOM || e.ctrlKey) {
if (
mousewheelAction === CONSTANTS.MOUSE_WHEEL_ACTION.ZOOM ||
e.ctrlKey ||
e.metaKey
) {
if (disableMouseWheelZoom) return
const { x: clientX, y: clientY } = this.mindMap.toPos(
e.clientX,
Expand Down
2 changes: 1 addition & 1 deletion simple-mind-map/src/plugins/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Select {
}
let { useLeftKeySelectionRightKeyDrag } = this.mindMap.opt
if (
!e.ctrlKey &&
!(e.ctrlKey || e.metaKey) &&
(useLeftKeySelectionRightKeyDrag ? e.which !== 1 : e.which !== 3)
) {
return
Expand Down

0 comments on commit c1217f1

Please sign in to comment.