@electerm/electerm-react 2.3.176 → 2.3.190
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/components/bookmark-form/common/fields.jsx +1 -1
- package/client/components/bookmark-form/common/ssh-auth-selector.jsx +36 -32
- package/client/components/bookmark-form/common/ssh-auth-type-selector.jsx +4 -1
- package/client/components/bookmark-form/config/common-fields.js +29 -24
- package/client/components/bookmark-form/config/ftp.js +5 -5
- package/client/components/bookmark-form/config/local.js +9 -9
- package/client/components/bookmark-form/config/rdp.js +3 -3
- package/client/components/bookmark-form/config/serial.js +4 -4
- package/client/components/bookmark-form/config/ssh.js +3 -2
- package/client/components/bookmark-form/config/telnet.js +2 -2
- package/client/components/bookmark-form/config/vnc.js +5 -5
- package/client/components/bookmark-form/config/web.js +3 -3
- package/client/components/bookmark-form/tree-delete.jsx +100 -42
- package/client/components/quick-commands/quick-commands-form-elem.jsx +9 -39
- package/client/components/setting-panel/hotkey.jsx +132 -0
- package/client/components/setting-panel/setting-common.jsx +8 -62
- package/client/components/shortcuts/get-key-char.js +1 -1
- package/client/components/shortcuts/shortcut-control.jsx +5 -0
- package/client/components/shortcuts/shortcut-editor.jsx +3 -0
- package/client/components/shortcuts/shortcut-handler.js +8 -0
- package/client/components/shortcuts/shortcut-utils.js +49 -0
- package/client/components/shortcuts/shortcuts-defaults.js +5 -0
- package/client/components/shortcuts/shortcuts.jsx +4 -40
- package/client/components/sidebar/index.jsx +3 -0
- package/client/components/tabs/tab.jsx +11 -0
- package/client/components/widgets/widget-form.jsx +7 -1
- package/client/store/tab.js +11 -0
- package/package.json +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import StartSessionSelect from '../setting-panel/start-session-select'
|
|
2
1
|
import {
|
|
3
2
|
Tree,
|
|
4
3
|
Button,
|
|
@@ -6,67 +5,126 @@ import {
|
|
|
6
5
|
} from 'antd'
|
|
7
6
|
import { defaultBookmarkGroupId, settingMap } from '../../common/constants'
|
|
8
7
|
import deepCopy from 'json-deep-copy'
|
|
8
|
+
import { createTitleWithTag } from '../../common/create-title'
|
|
9
9
|
|
|
10
10
|
const e = window.translate
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
function buildData (bookmarks, bookmarkGroups) {
|
|
13
|
+
const cats = bookmarkGroups
|
|
14
|
+
const tree = bookmarks
|
|
15
|
+
.reduce((p, k) => {
|
|
16
|
+
return {
|
|
17
|
+
...p,
|
|
18
|
+
[k.id]: k
|
|
19
|
+
}
|
|
20
|
+
}, {})
|
|
21
|
+
const btree = cats
|
|
22
|
+
.reduce((p, k) => {
|
|
23
|
+
return {
|
|
24
|
+
...p,
|
|
25
|
+
[k.id]: k
|
|
26
|
+
}
|
|
27
|
+
}, {})
|
|
28
|
+
function buildSubCats (id) {
|
|
29
|
+
const x = btree[id]
|
|
30
|
+
if (!x) {
|
|
31
|
+
return ''
|
|
32
|
+
}
|
|
33
|
+
const y = {
|
|
34
|
+
key: x.id,
|
|
35
|
+
value: x.id,
|
|
36
|
+
title: x.title
|
|
37
|
+
}
|
|
38
|
+
y.children = [
|
|
39
|
+
...(x.bookmarkGroupIds || []).map(buildSubCats),
|
|
40
|
+
...(x.bookmarkIds || []).map(buildLeaf)
|
|
41
|
+
].filter(d => d)
|
|
42
|
+
if (y.children && !y.children.length) {
|
|
43
|
+
delete y.children
|
|
44
|
+
}
|
|
45
|
+
return y
|
|
46
|
+
}
|
|
47
|
+
function buildLeaf (id) {
|
|
48
|
+
const x = tree[id]
|
|
49
|
+
if (!x) {
|
|
50
|
+
return ''
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
value: x.id,
|
|
54
|
+
key: x.id,
|
|
55
|
+
title: createTitleWithTag(x)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const level1 = cats.filter(d => d.level !== 2)
|
|
59
|
+
.map(d => {
|
|
60
|
+
const r = {
|
|
61
|
+
title: d.title,
|
|
62
|
+
value: d.id,
|
|
63
|
+
key: d.id,
|
|
64
|
+
children: [
|
|
65
|
+
...(d.bookmarkGroupIds || []).map(buildSubCats),
|
|
66
|
+
...(d.bookmarkIds || []).map(buildLeaf)
|
|
67
|
+
].filter(d => d)
|
|
68
|
+
}
|
|
69
|
+
return r
|
|
70
|
+
}).filter(d => d)
|
|
71
|
+
return level1
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default function BookmarkTreeDelete (props) {
|
|
75
|
+
const { expandedKeys, checkedKeys, bookmarks, bookmarkGroups } = props
|
|
76
|
+
|
|
77
|
+
const onExpand = (expandedKeys) => {
|
|
14
78
|
window.store.expandedKeys = deepCopy(expandedKeys)
|
|
15
79
|
}
|
|
16
80
|
|
|
17
|
-
onCheck = (checkedKeys) => {
|
|
81
|
+
const onCheck = (checkedKeys) => {
|
|
18
82
|
window.store.checkedKeys = deepCopy(checkedKeys)
|
|
19
83
|
}
|
|
20
84
|
|
|
21
|
-
handleDel = () => {
|
|
85
|
+
const handleDel = () => {
|
|
22
86
|
const { store } = window
|
|
23
|
-
const {
|
|
24
|
-
checkedKeys
|
|
25
|
-
} = this.props
|
|
26
87
|
const arr = checkedKeys.filter(d => d !== defaultBookmarkGroupId)
|
|
27
88
|
store.delItems(arr, settingMap.bookmarks)
|
|
28
89
|
store.delItems(arr, settingMap.bookmarkGroups)
|
|
29
90
|
store.checkedKeys = []
|
|
30
91
|
}
|
|
31
92
|
|
|
32
|
-
handleCancel = () => {
|
|
93
|
+
const handleCancel = () => {
|
|
33
94
|
const { store } = window
|
|
34
95
|
store.bookmarkSelectMode = false
|
|
35
96
|
store.checkedKeys = []
|
|
36
97
|
}
|
|
37
98
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
onExpand: this.onExpand,
|
|
47
|
-
treeData: this.buildData()
|
|
48
|
-
}
|
|
49
|
-
const len = checkedKeys.length
|
|
50
|
-
return (
|
|
51
|
-
<div>
|
|
52
|
-
<div className='pd2'>
|
|
53
|
-
<Space.Compact>
|
|
54
|
-
<Button
|
|
55
|
-
type='primary'
|
|
56
|
-
disabled={!len}
|
|
57
|
-
onClick={this.handleDel}
|
|
58
|
-
>
|
|
59
|
-
{e('delSelected')} ({len})
|
|
60
|
-
</Button>
|
|
61
|
-
<Button
|
|
62
|
-
onClick={this.handleCancel}
|
|
63
|
-
>
|
|
64
|
-
{e('cancel')}
|
|
65
|
-
</Button>
|
|
66
|
-
</Space.Compact>
|
|
67
|
-
<Tree {...rProps} />
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
)
|
|
99
|
+
const rProps = {
|
|
100
|
+
checkable: true,
|
|
101
|
+
autoExpandParent: true,
|
|
102
|
+
onCheck,
|
|
103
|
+
expandedKeys,
|
|
104
|
+
checkedKeys,
|
|
105
|
+
onExpand,
|
|
106
|
+
treeData: buildData(bookmarks, bookmarkGroups)
|
|
71
107
|
}
|
|
108
|
+
const len = checkedKeys.length
|
|
109
|
+
return (
|
|
110
|
+
<div>
|
|
111
|
+
<div className='pd2'>
|
|
112
|
+
<Space.Compact>
|
|
113
|
+
<Button
|
|
114
|
+
type='primary'
|
|
115
|
+
disabled={!len}
|
|
116
|
+
onClick={handleDel}
|
|
117
|
+
>
|
|
118
|
+
{e('delSelected')} ({len})
|
|
119
|
+
</Button>
|
|
120
|
+
<Button
|
|
121
|
+
onClick={handleCancel}
|
|
122
|
+
>
|
|
123
|
+
{e('cancel')}
|
|
124
|
+
</Button>
|
|
125
|
+
</Space.Compact>
|
|
126
|
+
<Tree {...rProps} />
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
)
|
|
72
130
|
}
|
|
@@ -11,18 +11,14 @@ import generate from '../../common/uid'
|
|
|
11
11
|
import InputAutoFocus from '../common/input-auto-focus'
|
|
12
12
|
import renderQm from './quick-commands-list-form'
|
|
13
13
|
import ShortcutEdit from '../shortcuts/shortcut-editor'
|
|
14
|
-
import
|
|
14
|
+
import { getKeysTakenData } from '../shortcuts/shortcut-utils'
|
|
15
15
|
import deepCopy from 'json-deep-copy'
|
|
16
|
-
import {
|
|
17
|
-
isMacJs as isMac
|
|
18
|
-
} from '../../common/constants.js'
|
|
19
16
|
import templates from './templates'
|
|
20
17
|
import HelpIcon from '../common/help-icon'
|
|
21
18
|
|
|
22
19
|
const FormItem = Form.Item
|
|
23
20
|
const { Option } = Select
|
|
24
21
|
const e = window.translate
|
|
25
|
-
const shortcutsDefaults = shortcutsDefaultsGen()
|
|
26
22
|
|
|
27
23
|
export default function QuickCommandForm (props) {
|
|
28
24
|
const [form] = Form.useForm()
|
|
@@ -42,41 +38,15 @@ export default function QuickCommandForm (props) {
|
|
|
42
38
|
})
|
|
43
39
|
setShortcut('')
|
|
44
40
|
}
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const { quickCommands = [] } = store
|
|
48
|
-
|
|
49
|
-
// Gather system shortcuts
|
|
50
|
-
const systemShortcuts = shortcutsDefaults.reduce((p, k) => {
|
|
51
|
-
const propName = isMac ? 'shortcutMac' : 'shortcut'
|
|
52
|
-
const name = k.name + '_' + propName
|
|
53
|
-
const vv = k.readonly ? k[propName] : (shortcuts[name] || k[propName])
|
|
54
|
-
const v = vv
|
|
55
|
-
.split(',')
|
|
56
|
-
.map(f => f.trim())
|
|
57
|
-
.reduce((p, k) => ({
|
|
58
|
-
...p,
|
|
59
|
-
[k]: true
|
|
60
|
-
}), {})
|
|
61
|
-
return {
|
|
62
|
-
...p,
|
|
63
|
-
...v
|
|
64
|
-
}
|
|
65
|
-
}, {})
|
|
41
|
+
const getKeysTaken = () => {
|
|
42
|
+
const keysTaken = getKeysTakenData()
|
|
66
43
|
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
acc[command.shortcut] = true
|
|
71
|
-
}
|
|
72
|
-
return acc
|
|
73
|
-
}, {})
|
|
74
|
-
|
|
75
|
-
// Combine system shortcuts and quick command shortcuts
|
|
76
|
-
return {
|
|
77
|
-
...systemShortcuts,
|
|
78
|
-
...quickCommandShortcuts
|
|
44
|
+
// Exclude current shortcut if editing existing command
|
|
45
|
+
if (formData.shortcut) {
|
|
46
|
+
delete keysTaken[formData.shortcut]
|
|
79
47
|
}
|
|
48
|
+
|
|
49
|
+
return keysTaken
|
|
80
50
|
}
|
|
81
51
|
|
|
82
52
|
async function handleSubmit (res) {
|
|
@@ -126,7 +96,7 @@ export default function QuickCommandForm (props) {
|
|
|
126
96
|
name: uid,
|
|
127
97
|
shortcut
|
|
128
98
|
},
|
|
129
|
-
keysTaken:
|
|
99
|
+
keysTaken: getKeysTaken(),
|
|
130
100
|
store,
|
|
131
101
|
updateConfig,
|
|
132
102
|
handleClear,
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import React, { Component } from 'react'
|
|
2
|
+
import ShortcutEdit from '../shortcuts/shortcut-editor'
|
|
3
|
+
import { getKeysTakenData } from '../shortcuts/shortcut-utils'
|
|
4
|
+
import './setting.styl'
|
|
5
|
+
|
|
6
|
+
const e = window.translate
|
|
7
|
+
|
|
8
|
+
// Bidirectional maps for key conversions
|
|
9
|
+
const MODIFIER_MAP = {
|
|
10
|
+
// Display format -> Electron format
|
|
11
|
+
ctrl: 'CommandOrControl',
|
|
12
|
+
meta: 'CommandOrControl',
|
|
13
|
+
alt: 'Alt',
|
|
14
|
+
shift: 'Shift',
|
|
15
|
+
// Electron format -> Display format
|
|
16
|
+
CommandOrControl: 'ctrl',
|
|
17
|
+
Command: 'meta',
|
|
18
|
+
Control: 'ctrl',
|
|
19
|
+
Alt: 'alt',
|
|
20
|
+
Shift: 'shift',
|
|
21
|
+
Super: 'meta',
|
|
22
|
+
Meta: 'meta'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const KEY_MAP = {
|
|
26
|
+
// Display format -> Electron format
|
|
27
|
+
'←': 'Left',
|
|
28
|
+
'↑': 'Up',
|
|
29
|
+
'→': 'Right',
|
|
30
|
+
'↓': 'Down',
|
|
31
|
+
'▲': 'mouseWheelUp',
|
|
32
|
+
'▼': 'mouseWheelDown',
|
|
33
|
+
enter: 'Return',
|
|
34
|
+
// Electron format -> Display format
|
|
35
|
+
Left: '←',
|
|
36
|
+
Up: '↑',
|
|
37
|
+
Right: '→',
|
|
38
|
+
Down: '↓',
|
|
39
|
+
Return: 'enter',
|
|
40
|
+
Enter: 'enter',
|
|
41
|
+
mouseWheelUp: '▲',
|
|
42
|
+
mouseWheelDown: '▼'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default class HotkeySetting extends Component {
|
|
46
|
+
onChangeHotkey = (name, shortcut) => {
|
|
47
|
+
// Convert shortcut from ShortcutEdit format to Electron accelerator format
|
|
48
|
+
const electronShortcut = this.convertToElectronAccelerator(shortcut)
|
|
49
|
+
return this.props.onSaveConfig({
|
|
50
|
+
[name]: electronShortcut
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
convertToElectronAccelerator = (shortcut) => {
|
|
55
|
+
if (!shortcut) return shortcut
|
|
56
|
+
|
|
57
|
+
// Split the shortcut into parts
|
|
58
|
+
const parts = shortcut.split('+')
|
|
59
|
+
const modifiers = []
|
|
60
|
+
let key = ''
|
|
61
|
+
|
|
62
|
+
// Process each part
|
|
63
|
+
for (const part of parts) {
|
|
64
|
+
const lowerPart = part.toLowerCase()
|
|
65
|
+
if (MODIFIER_MAP[lowerPart]) {
|
|
66
|
+
modifiers.push(MODIFIER_MAP[lowerPart])
|
|
67
|
+
} else {
|
|
68
|
+
// Handle special key mappings
|
|
69
|
+
key = KEY_MAP[part] || part.toUpperCase()
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Combine modifiers and key
|
|
74
|
+
return [...modifiers, key].join('+')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
convertFromElectronAccelerator = (electronShortcut) => {
|
|
78
|
+
if (!electronShortcut) return electronShortcut
|
|
79
|
+
|
|
80
|
+
// Split the shortcut into parts
|
|
81
|
+
const parts = electronShortcut.split('+')
|
|
82
|
+
const modifiers = []
|
|
83
|
+
let key = ''
|
|
84
|
+
|
|
85
|
+
// Process each part
|
|
86
|
+
for (const part of parts) {
|
|
87
|
+
if (MODIFIER_MAP[part]) {
|
|
88
|
+
modifiers.push(MODIFIER_MAP[part])
|
|
89
|
+
} else {
|
|
90
|
+
// Handle special key mappings
|
|
91
|
+
key = KEY_MAP[part] || part.toLowerCase()
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Combine modifiers and key
|
|
96
|
+
return [...modifiers, key].join('+')
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
getKeysTaken = (currentHotkey) => {
|
|
100
|
+
const keysTaken = getKeysTakenData()
|
|
101
|
+
|
|
102
|
+
// Convert current hotkey to display format for comparison
|
|
103
|
+
const currentShortcutDisplay = this.convertFromElectronAccelerator(currentHotkey)
|
|
104
|
+
|
|
105
|
+
// Remove current hotkey from taken keys (allow re-setting the same hotkey)
|
|
106
|
+
delete keysTaken[currentShortcutDisplay]
|
|
107
|
+
|
|
108
|
+
return keysTaken
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
render () {
|
|
112
|
+
const { hotkey } = this.props
|
|
113
|
+
const shortcutProps = {
|
|
114
|
+
data: {
|
|
115
|
+
name: 'hotkey',
|
|
116
|
+
shortcut: this.convertFromElectronAccelerator(hotkey),
|
|
117
|
+
index: 0
|
|
118
|
+
},
|
|
119
|
+
updateConfig: this.onChangeHotkey,
|
|
120
|
+
keysTaken: this.getKeysTaken(hotkey)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<div className='pd2b'>
|
|
125
|
+
<div className='pd1b'>{e('hotkeyDesc')}</div>
|
|
126
|
+
<ShortcutEdit
|
|
127
|
+
{...shortcutProps}
|
|
128
|
+
/>
|
|
129
|
+
</div>
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -32,24 +32,12 @@ import HelpIcon from '../common/help-icon'
|
|
|
32
32
|
import delay from '../../common/wait.js'
|
|
33
33
|
import isColorDark from '../../common/is-color-dark'
|
|
34
34
|
import DeepLinkControl from './deep-link-control'
|
|
35
|
+
import HotkeySetting from './hotkey'
|
|
35
36
|
import './setting.styl'
|
|
36
37
|
|
|
37
38
|
const { Option } = Select
|
|
38
39
|
const e = window.translate
|
|
39
40
|
|
|
40
|
-
const modifiers = [
|
|
41
|
-
'Command',
|
|
42
|
-
'Control',
|
|
43
|
-
'Alt',
|
|
44
|
-
'Shift'
|
|
45
|
-
]
|
|
46
|
-
const keys = [
|
|
47
|
-
...'0123456789~ABCDEFGHIJKLMNOPQRTSUVWXYZ'.split(''),
|
|
48
|
-
...new Array(12).fill(0).map((m, i) => {
|
|
49
|
-
return 'F' + (i + 1)
|
|
50
|
-
})
|
|
51
|
-
]
|
|
52
|
-
|
|
53
41
|
export default class SettingCommon extends Component {
|
|
54
42
|
state = {
|
|
55
43
|
ready: false,
|
|
@@ -142,28 +130,12 @@ export default class SettingCommon extends Component {
|
|
|
142
130
|
)
|
|
143
131
|
}
|
|
144
132
|
|
|
145
|
-
handleChangeModifier = modifier => {
|
|
146
|
-
const { hotkey } = this.props.config
|
|
147
|
-
const key = hotkey.split('+')[1]
|
|
148
|
-
return this.saveConfig({
|
|
149
|
-
hotkey: `${modifier}+${key}`
|
|
150
|
-
})
|
|
151
|
-
}
|
|
152
|
-
|
|
153
133
|
onChangeTimeout = sshReadyTimeout => {
|
|
154
134
|
return this.saveConfig({
|
|
155
135
|
sshReadyTimeout
|
|
156
136
|
})
|
|
157
137
|
}
|
|
158
138
|
|
|
159
|
-
handleChangeKey = key => {
|
|
160
|
-
const { hotkey } = this.props.config
|
|
161
|
-
const modifier = hotkey.split('+')[0]
|
|
162
|
-
return this.saveConfig({
|
|
163
|
-
hotkey: `${modifier}+${key}`
|
|
164
|
-
})
|
|
165
|
-
}
|
|
166
|
-
|
|
167
139
|
handleChangeLang = language => {
|
|
168
140
|
this.setState({
|
|
169
141
|
languageChanged: true
|
|
@@ -211,12 +183,6 @@ export default class SettingCommon extends Component {
|
|
|
211
183
|
this.props.store.setConfig(ext)
|
|
212
184
|
}
|
|
213
185
|
|
|
214
|
-
renderOption = (m, i) => {
|
|
215
|
-
return (
|
|
216
|
-
<Option value={m} key={m + 'opt' + i}>{m}</Option>
|
|
217
|
-
)
|
|
218
|
-
}
|
|
219
|
-
|
|
220
186
|
renderToggle = (name, extra = null) => {
|
|
221
187
|
const checked = !!this.props.config[name]
|
|
222
188
|
return (
|
|
@@ -513,7 +479,6 @@ export default class SettingCommon extends Component {
|
|
|
513
479
|
langs = []
|
|
514
480
|
} = window.et
|
|
515
481
|
const terminalThemes = props.store.getSidebarList(settingMap.terminalThemes)
|
|
516
|
-
const [modifier, key] = hotkey.split('+')
|
|
517
482
|
const pops = {
|
|
518
483
|
onStartSessions: props.config.onStartSessions,
|
|
519
484
|
bookmarks: props.bookmarks,
|
|
@@ -521,35 +486,16 @@ export default class SettingCommon extends Component {
|
|
|
521
486
|
workspaces: props.store.workspaces,
|
|
522
487
|
onChangeStartSessions: this.onChangeStartSessions
|
|
523
488
|
}
|
|
489
|
+
const hotkeyProps = {
|
|
490
|
+
hotkey,
|
|
491
|
+
onSaveConfig: this.saveConfig
|
|
492
|
+
}
|
|
524
493
|
return (
|
|
525
494
|
<div className='form-wrap pd1y pd2x'>
|
|
526
495
|
<h2>{e('settings')}</h2>
|
|
527
|
-
<
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
value={modifier}
|
|
531
|
-
onChange={this.handleChangeModifier}
|
|
532
|
-
className='width100'
|
|
533
|
-
popupMatchSelectWidth={false}
|
|
534
|
-
showSearch
|
|
535
|
-
>
|
|
536
|
-
{
|
|
537
|
-
modifiers.map(this.renderOption)
|
|
538
|
-
}
|
|
539
|
-
</Select>
|
|
540
|
-
<span className='mg1x'>+</span>
|
|
541
|
-
<Select
|
|
542
|
-
value={key}
|
|
543
|
-
className='width100'
|
|
544
|
-
onChange={this.handleChangeKey}
|
|
545
|
-
popupMatchSelectWidth={false}
|
|
546
|
-
showSearch
|
|
547
|
-
>
|
|
548
|
-
{
|
|
549
|
-
keys.map(this.renderOption)
|
|
550
|
-
}
|
|
551
|
-
</Select>
|
|
552
|
-
</div>
|
|
496
|
+
<HotkeySetting
|
|
497
|
+
{...hotkeyProps}
|
|
498
|
+
/>
|
|
553
499
|
<div className='pd1b'>{e('onStartBookmarks')}</div>
|
|
554
500
|
<div className='pd2b'>
|
|
555
501
|
<StartSession
|
|
@@ -37,7 +37,7 @@ export function getKeyCharacter (code = '') {
|
|
|
37
37
|
}
|
|
38
38
|
if (code.startsWith('Key') && code.length === 4) {
|
|
39
39
|
return code[3].toLowerCase()
|
|
40
|
-
} else if (code.startsWith('Digit') && code.length ===
|
|
40
|
+
} else if (code.startsWith('Digit') && code.length === 6) {
|
|
41
41
|
return code[5]
|
|
42
42
|
} else {
|
|
43
43
|
return mapping[code] || code
|
|
@@ -139,6 +139,11 @@ class ShortcutControl extends React.PureComponent {
|
|
|
139
139
|
window.store.reloadTab()
|
|
140
140
|
}, 500)
|
|
141
141
|
|
|
142
|
+
reloadAllShortcut = throttle((e) => {
|
|
143
|
+
e.stopPropagation()
|
|
144
|
+
window.store.reloadAllTabs()
|
|
145
|
+
}, 500)
|
|
146
|
+
|
|
142
147
|
cloneToNextLayoutShortcut = throttle((e) => {
|
|
143
148
|
e.stopPropagation()
|
|
144
149
|
window.store.cloneToNextLayout()
|
|
@@ -106,6 +106,8 @@ export default class ShortcutEdit extends PureComponent {
|
|
|
106
106
|
altKey,
|
|
107
107
|
wheelDeltaY
|
|
108
108
|
} = e
|
|
109
|
+
e.preventDefault()
|
|
110
|
+
e.stopPropagation()
|
|
109
111
|
const codeName = e instanceof window.WheelEvent
|
|
110
112
|
? (wheelDeltaY > 0 ? 'mouseWheelUp' : 'mouseWheelDown')
|
|
111
113
|
: code
|
|
@@ -201,6 +203,7 @@ export default class ShortcutEdit extends PureComponent {
|
|
|
201
203
|
<Input
|
|
202
204
|
addonAfter={this.renderAfter()}
|
|
203
205
|
value={shortcut}
|
|
206
|
+
className='shortcut-input'
|
|
204
207
|
/>
|
|
205
208
|
</div>
|
|
206
209
|
)
|
|
@@ -44,6 +44,11 @@ function buildConfigForSearch (config) {
|
|
|
44
44
|
}, {})
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
function isInAntdInput () {
|
|
48
|
+
const activeElement = document.activeElement
|
|
49
|
+
return activeElement && activeElement.classList.contains('shortcut-input')
|
|
50
|
+
}
|
|
51
|
+
|
|
47
52
|
export function shortcutExtend (Cls) {
|
|
48
53
|
Cls.prototype.handleKeyboardEvent = function (event) {
|
|
49
54
|
const {
|
|
@@ -57,6 +62,9 @@ export function shortcutExtend (Cls) {
|
|
|
57
62
|
type,
|
|
58
63
|
key
|
|
59
64
|
} = event
|
|
65
|
+
if (isInAntdInput()) {
|
|
66
|
+
return
|
|
67
|
+
}
|
|
60
68
|
if (this.cmdAddon) {
|
|
61
69
|
this.cmdAddon.handleKey(event)
|
|
62
70
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { isMacJs as isMac } from '../../common/constants.js'
|
|
2
|
+
import shortcutsDefaultsGen from './shortcuts-defaults'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get keys taken data for shortcut conflict checking
|
|
6
|
+
* @returns {object} Object with shortcut strings as keys and true as values
|
|
7
|
+
*/
|
|
8
|
+
export function getKeysTakenData () {
|
|
9
|
+
const { store } = window
|
|
10
|
+
const { config, quickCommands } = store
|
|
11
|
+
const { shortcuts = {} } = config
|
|
12
|
+
|
|
13
|
+
// Get shortcuts defaults
|
|
14
|
+
const shortcutsDefaults = shortcutsDefaultsGen()
|
|
15
|
+
|
|
16
|
+
// Gather system shortcuts
|
|
17
|
+
const systemShortcuts = shortcutsDefaults.reduce((p, k) => {
|
|
18
|
+
const propName = isMac ? 'shortcutMac' : 'shortcut'
|
|
19
|
+
const name = k.name + '_' + propName
|
|
20
|
+
const vv = k.readonly ? k[propName] : (shortcuts[name] || k[propName])
|
|
21
|
+
if (!vv) return p
|
|
22
|
+
|
|
23
|
+
const v = vv
|
|
24
|
+
.split(',')
|
|
25
|
+
.map(f => f.trim())
|
|
26
|
+
.reduce((p, k) => ({
|
|
27
|
+
...p,
|
|
28
|
+
[k]: true
|
|
29
|
+
}), {})
|
|
30
|
+
return {
|
|
31
|
+
...p,
|
|
32
|
+
...v
|
|
33
|
+
}
|
|
34
|
+
}, {})
|
|
35
|
+
|
|
36
|
+
// Gather quick command shortcuts
|
|
37
|
+
const quickCommandShortcuts = quickCommands.reduce((acc, command) => {
|
|
38
|
+
if (command.shortcut) {
|
|
39
|
+
acc[command.shortcut] = true
|
|
40
|
+
}
|
|
41
|
+
return acc
|
|
42
|
+
}, {})
|
|
43
|
+
|
|
44
|
+
// Combine system shortcuts and quick command shortcuts
|
|
45
|
+
return {
|
|
46
|
+
...systemShortcuts,
|
|
47
|
+
...quickCommandShortcuts
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -6,9 +6,10 @@ import {
|
|
|
6
6
|
Table,
|
|
7
7
|
Button
|
|
8
8
|
} from 'antd'
|
|
9
|
+
import { isMacJs as isMac } from '../../common/constants.js'
|
|
9
10
|
import {
|
|
10
|
-
|
|
11
|
-
} from '
|
|
11
|
+
getKeysTakenData
|
|
12
|
+
} from './shortcut-utils.js'
|
|
12
13
|
|
|
13
14
|
const e = window.translate
|
|
14
15
|
const shortcutsDefaults = shortcutsDefaultsGen()
|
|
@@ -45,43 +46,6 @@ export default class Shortcuts extends PureComponent {
|
|
|
45
46
|
})
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
getKeysTakenData = () => {
|
|
49
|
-
const { config, quickCommands = [] } = this.props
|
|
50
|
-
const { shortcuts = {} } = config
|
|
51
|
-
|
|
52
|
-
// Gather system shortcuts
|
|
53
|
-
const systemShortcuts = shortcutsDefaults.reduce((p, k) => {
|
|
54
|
-
const propName = isMac ? 'shortcutMac' : 'shortcut'
|
|
55
|
-
const name = k.name + '_' + propName
|
|
56
|
-
const vv = k.readonly ? k[propName] : (shortcuts[name] || k[propName])
|
|
57
|
-
const v = vv
|
|
58
|
-
.split(',')
|
|
59
|
-
.map(f => f.trim())
|
|
60
|
-
.reduce((p, k) => ({
|
|
61
|
-
...p,
|
|
62
|
-
[k]: true
|
|
63
|
-
}), {})
|
|
64
|
-
return {
|
|
65
|
-
...p,
|
|
66
|
-
...v
|
|
67
|
-
}
|
|
68
|
-
}, {})
|
|
69
|
-
|
|
70
|
-
// Gather quick command shortcuts
|
|
71
|
-
const quickCommandShortcuts = quickCommands.reduce((acc, command) => {
|
|
72
|
-
if (command.shortcut) {
|
|
73
|
-
acc[command.shortcut] = true
|
|
74
|
-
}
|
|
75
|
-
return acc
|
|
76
|
-
}, {})
|
|
77
|
-
|
|
78
|
-
// Combine system shortcuts and quick command shortcuts
|
|
79
|
-
return {
|
|
80
|
-
...systemShortcuts,
|
|
81
|
-
...quickCommandShortcuts
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
49
|
render () {
|
|
86
50
|
const columns = [
|
|
87
51
|
{
|
|
@@ -124,7 +88,7 @@ export default class Shortcuts extends PureComponent {
|
|
|
124
88
|
return (
|
|
125
89
|
<ShortcutEdit
|
|
126
90
|
data={inst}
|
|
127
|
-
keysTaken={
|
|
91
|
+
keysTaken={getKeysTakenData()}
|
|
128
92
|
updateConfig={this.updateConfig}
|
|
129
93
|
/>
|
|
130
94
|
)
|