1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/* eslint new-cap: ["error", {"newIsCapExceptionPattern": "^mx"}] */
import 'mxgraph/javascript/src/css/common.css'
import mxGraphFactory from 'mxgraph'
import {
editorRedo,
editorUndo,
editorZoomAct,
editorZoomIn,
editorZoomOut
} from './ToolbarTools'
const {
mxKeyHandler,
mxEvent,
mxClient
} = new mxGraphFactory()
export default function keyboardShortcuts (graph) {
const keyHandler = new mxKeyHandler(graph)
keyHandler.getFunction = function (evt) {
if (evt != null) {
return (mxEvent.isControlDown(evt) || (mxClient.IS_MAC && evt.metaKey)) ? this.controlKeys[evt.keyCode] : this.normalKeys[evt.keyCode]
}
return null
}
// Delete - Del
// keyHandler.bindKey(46, function (evt) {
// if (graph.isEnabled()) {
// graph.removeCells()
// }
// })
// Undo - Ctrl + Z
keyHandler.bindControlKey(90, function () {
if (graph.isEnabled()) {
editorUndo()
}
})
// Redo - Ctrl + A
keyHandler.bindControlKey(65, function () {
if (graph.isEnabled()) {
editorRedo()
}
})
// Zoom In - Ctrl + I
keyHandler.bindControlKey(73, function () {
if (graph.isEnabled()) {
editorZoomIn()
}
})
// Zoom Out - Ctrl + O
keyHandler.bindControlKey(79, function () {
if (graph.isEnabled()) {
editorZoomOut()
}
})
// Zoom Out - Ctrl + Y
keyHandler.bindControlKey(89, function () {
if (graph.isEnabled()) {
editorZoomAct()
}
})
}
|