@electerm/electerm-react 1.37.16 → 1.37.18
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.
|
@@ -8,6 +8,27 @@ import { throttle } from 'lodash-es'
|
|
|
8
8
|
function buildConfig (config, filter = d => d) {
|
|
9
9
|
const defs = shortcutsDefaultsGen().filter(filter)
|
|
10
10
|
const { shortcuts = {} } = config
|
|
11
|
+
return defs.reduce((p, c) => {
|
|
12
|
+
const propName = isMacJs ? 'shortcutMac' : 'shortcut'
|
|
13
|
+
if (isMacJs && c.skipMac) {
|
|
14
|
+
return p
|
|
15
|
+
}
|
|
16
|
+
const name = c.name + '_' + propName
|
|
17
|
+
const [type, func] = c.name.split('_')
|
|
18
|
+
return {
|
|
19
|
+
...p,
|
|
20
|
+
[name]: {
|
|
21
|
+
shortcut: c.readonly ? c[propName] : (shortcuts[name] || c[propName]),
|
|
22
|
+
type,
|
|
23
|
+
func
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}, {})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function buildConfigForSearch (config) {
|
|
30
|
+
const defs = shortcutsDefaultsGen()
|
|
31
|
+
const { shortcuts = {} } = config
|
|
11
32
|
return defs.reduce((p, c) => {
|
|
12
33
|
const propName = isMacJs ? 'shortcutMac' : 'shortcut'
|
|
13
34
|
const name = c.name + '_' + propName
|
|
@@ -46,7 +67,7 @@ export function shortcutExtend (Cls) {
|
|
|
46
67
|
(shiftKey ? 'shift+' : '') +
|
|
47
68
|
(altKey ? 'alt+' : '') +
|
|
48
69
|
codeK.toLowerCase()
|
|
49
|
-
const shortcutsConfig = buildConfig(this.props.config, d => !d.
|
|
70
|
+
const shortcutsConfig = buildConfig(this.props.config, d => !d.hidden)
|
|
50
71
|
const keys = Object.keys(shortcutsConfig)
|
|
51
72
|
const len = keys.length
|
|
52
73
|
for (let i = 0; i < len; i++) {
|
|
@@ -55,9 +76,9 @@ export function shortcutExtend (Cls) {
|
|
|
55
76
|
const funcName = conf.func + 'Shortcut'
|
|
56
77
|
if (conf.shortcut.split(',').includes(r)) {
|
|
57
78
|
if (this[funcName]) {
|
|
58
|
-
this[funcName](event)
|
|
59
|
-
} else {
|
|
60
|
-
return
|
|
79
|
+
return this[funcName](event)
|
|
80
|
+
} else if (this.isTerm) {
|
|
81
|
+
return true
|
|
61
82
|
}
|
|
62
83
|
}
|
|
63
84
|
}
|
|
@@ -67,7 +88,7 @@ export function shortcutExtend (Cls) {
|
|
|
67
88
|
|
|
68
89
|
export function shortcutDescExtend (Cls) {
|
|
69
90
|
Cls.prototype.getShortcut = function (name) {
|
|
70
|
-
const shortcutsConfig =
|
|
91
|
+
const shortcutsConfig = buildConfigForSearch(this.props.config)
|
|
71
92
|
const propName = isMacJs ? 'shortcutMac' : 'shortcut'
|
|
72
93
|
const n = `${name}_${propName}`
|
|
73
94
|
return shortcutsConfig[n].shortcut
|
|
@@ -49,18 +49,21 @@ export default () => {
|
|
|
49
49
|
name: 'terminal_selectAll',
|
|
50
50
|
shortcut: 'ctrl+a,ctrl+shift+a',
|
|
51
51
|
shortcutMac: 'meta+a',
|
|
52
|
+
skipMac: true,
|
|
52
53
|
readonly: true
|
|
53
54
|
},
|
|
54
55
|
{
|
|
55
56
|
name: 'terminal_copy',
|
|
56
57
|
shortcut: 'ctrl+c,ctrl+shift+c',
|
|
57
58
|
shortcutMac: 'meta+c',
|
|
59
|
+
skipMac: true,
|
|
58
60
|
readonly: true
|
|
59
61
|
},
|
|
60
62
|
{
|
|
61
63
|
name: 'terminal_paste',
|
|
62
64
|
shortcut: 'ctrl+v,ctrl+shift+v',
|
|
63
65
|
shortcutMac: 'meta+v',
|
|
66
|
+
hidden: true,
|
|
64
67
|
readonly: true
|
|
65
68
|
},
|
|
66
69
|
{
|
|
@@ -87,6 +87,8 @@ class Term extends Component {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
isTerm = true
|
|
91
|
+
|
|
90
92
|
dataCache = ''
|
|
91
93
|
|
|
92
94
|
componentDidMount () {
|
|
@@ -234,15 +236,14 @@ class Term extends Component {
|
|
|
234
236
|
this.term.selectAll()
|
|
235
237
|
}
|
|
236
238
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
// }
|
|
239
|
+
copyShortcut = (e) => {
|
|
240
|
+
const sel = this.term.getSelection()
|
|
241
|
+
if (sel) {
|
|
242
|
+
e.stopPropagation()
|
|
243
|
+
this.copySelectionToClipboard()
|
|
244
|
+
return false
|
|
245
|
+
}
|
|
246
|
+
}
|
|
246
247
|
|
|
247
248
|
searchShortcut = (e) => {
|
|
248
249
|
e.stopPropagation()
|