@electerm/electerm-react 1.34.63 → 1.35.0

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.
Files changed (46) hide show
  1. package/client/common/constants.js +3 -1
  2. package/client/common/key-pressed.js +1 -1
  3. package/client/common/rand-hex-color.js +28 -0
  4. package/client/common/shortcuts-defaults.js +51 -0
  5. package/client/components/batch-op/batch-op.jsx +6 -2
  6. package/client/components/bookmark-form/color-picker-item.jsx +14 -0
  7. package/client/components/bookmark-form/color-picker.jsx +90 -0
  8. package/client/components/bookmark-form/color-picker.styl +20 -0
  9. package/client/components/bookmark-form/form-ssh-common.jsx +4 -0
  10. package/client/components/bookmark-form/hex-input.jsx +39 -0
  11. package/client/components/bookmark-form/local-form-ui.jsx +1 -0
  12. package/client/components/bookmark-form/serial-form-ui.jsx +12 -8
  13. package/client/components/bookmark-form/ssh-form-ui.jsx +3 -0
  14. package/client/components/bookmark-form/telnet-form-ui.jsx +1 -0
  15. package/client/components/bookmark-form/use-ui.jsx +11 -1
  16. package/client/components/context-menu/context-menu.styl +1 -1
  17. package/client/components/context-menu/menu-btn.jsx +6 -3
  18. package/client/components/main/custom-css.jsx +28 -0
  19. package/client/components/main/main.jsx +5 -2
  20. package/client/components/session/session.jsx +11 -35
  21. package/client/components/session/sessions.jsx +15 -15
  22. package/client/components/setting-panel/setting.jsx +20 -32
  23. package/client/components/setting-panel/tab-settings.jsx +13 -10
  24. package/client/components/sftp/transfer-tag.jsx +2 -2
  25. package/client/components/sftp/transport-action.jsx +1 -0
  26. package/client/components/shortcuts/get-key-char.js +45 -0
  27. package/client/components/shortcuts/shortcut-control.jsx +63 -0
  28. package/client/components/shortcuts/shortcut-editor.jsx +194 -0
  29. package/client/components/shortcuts/shortcut-handler.js +76 -0
  30. package/client/components/shortcuts/shortcut.styl +0 -0
  31. package/client/components/shortcuts/shortcuts-defaults.js +87 -0
  32. package/client/components/shortcuts/shortcuts.jsx +166 -0
  33. package/client/components/sidebar/index.jsx +1 -1
  34. package/client/components/sidebar/transfer-history-modal.jsx +14 -2
  35. package/client/components/tabs/index.jsx +0 -25
  36. package/client/components/tabs/tab.jsx +6 -5
  37. package/client/components/terminal/index.jsx +93 -110
  38. package/client/components/terminal/term-search.jsx +9 -21
  39. package/client/components/terminal-theme/index.jsx +4 -3
  40. package/client/store/index.js +17 -2
  41. package/client/store/init-state.js +1 -8
  42. package/client/store/item.js +3 -0
  43. package/client/store/session.js +0 -22
  44. package/client/store/watch.js +3 -1
  45. package/client/views/index.pug +2 -0
  46. package/package.json +1 -1
@@ -8,22 +8,20 @@ import {
8
8
  ArrowRightOutlined,
9
9
  CloseCircleOutlined
10
10
  } from '@ant-design/icons'
11
- import { paneMap, terminalActions, isMac } from '../../common/constants'
11
+ import { paneMap, terminalActions } from '../../common/constants'
12
12
  import postMessage from '../../common/post-msg'
13
13
  import { MatchCaseIcon } from '../icons/match-case'
14
14
  import { MatchWholWordIcon } from '../icons/match-whole-word'
15
15
  import { RegularExpIcon } from '../icons/regular-exp'
16
16
  import classNames from 'classnames'
17
17
  import copy from 'json-deep-copy'
18
- import keyShiftPressed from '../../common/key-shift-pressed'
19
- import keyControlPressed from '../../common/key-control-pressed'
20
- import keyPressed from '../../common/key-pressed'
18
+ import { shortcutExtend } from '../shortcuts/shortcut-handler.js'
21
19
  import './term-search.styl'
22
20
 
23
21
  const { prefix } = window
24
22
  const s = prefix('ssh')
25
23
 
26
- export default class TermSearch extends Component {
24
+ class TermSearch extends Component {
27
25
  searchControls = [{
28
26
  id: 'matchCase',
29
27
  icon: MatchCaseIcon,
@@ -53,11 +51,7 @@ export default class TermSearch extends Component {
53
51
  }]
54
52
 
55
53
  componentDidMount () {
56
- window.addEventListener('keydown', this.handleEvent)
57
- }
58
-
59
- componentWillUnmount () {
60
- window.removeEventListener('keydown', this.handleEvent)
54
+ window.addEventListener('keydown', this.handleKeyboardEvent.bind(this))
61
55
  }
62
56
 
63
57
  toggleSearch = () => {
@@ -65,17 +59,9 @@ export default class TermSearch extends Component {
65
59
  setTimeout(window.store.focus, 100)
66
60
  }
67
61
 
68
- handleEvent = (e) => {
69
- if (
70
- keyPressed(e, 'f') && keyControlPressed(e) &&
71
- (
72
- isMac ||
73
- (!isMac && keyShiftPressed(e))
74
- )
75
- ) {
76
- e.stopPropagation()
77
- this.toggleSearch()
78
- }
62
+ searchShortcut = (e) => {
63
+ e.stopPropagation()
64
+ this.toggleSearch()
79
65
  }
80
66
 
81
67
  prev = () => {
@@ -222,3 +208,5 @@ export default class TermSearch extends Component {
222
208
  )
223
209
  }
224
210
  }
211
+
212
+ export default shortcutExtend(TermSearch)
@@ -164,7 +164,7 @@ export default function ThemeForm (props) {
164
164
  }
165
165
 
166
166
  const {
167
- readOnly,
167
+ readonly,
168
168
  id,
169
169
  type,
170
170
  name: themeName
@@ -175,7 +175,7 @@ export default function ThemeForm (props) {
175
175
  }
176
176
  const { autofocustrigger } = props.store
177
177
  const isDefaultTheme = id === defaultTheme.id || id === defaultThemeLight.id
178
- const disabled = readOnly || isDefaultTheme
178
+ const disabled = readonly || isDefaultTheme
179
179
  return (
180
180
  <Form
181
181
  onFinish={handleSubmit}
@@ -226,7 +226,8 @@ export default function ThemeForm (props) {
226
226
  rules={[{
227
227
  max: 1000, message: '1000 chars max'
228
228
  }, {
229
- required: true, message: 'theme Config required'
229
+ required: true,
230
+ message: 'theme config required'
230
231
  }, {
231
232
  validator: validateInput
232
233
  }]}
@@ -33,13 +33,19 @@ import {
33
33
  settingMap,
34
34
  sidebarWidth,
35
35
  sidebarPanelWidth,
36
- paneMap
36
+ paneMap,
37
+ settingSyncId,
38
+ settingShortcutsId
37
39
  } from '../common/constants'
38
40
  import getInitItem from '../common/init-setting-item'
39
41
  import {
40
42
  theme
41
43
  } from 'antd'
42
44
 
45
+ const { prefix } = window
46
+ const ss = prefix('settingSync')
47
+ const s = prefix('setting')
48
+
43
49
  function getReverseColor (hex) {
44
50
  // Check if the input is a valid hex color code
45
51
  if (!/^#[0-9a-fA-F]{6}$/.test(hex)) {
@@ -240,7 +246,16 @@ class Store {
240
246
  }
241
247
 
242
248
  get setting () {
243
- return JSON.parse(window.store._setting || '[]')
249
+ return [
250
+ {
251
+ id: settingSyncId,
252
+ title: ss('settingSync')
253
+ },
254
+ {
255
+ id: settingShortcutsId,
256
+ title: s('settingShortcuts')
257
+ }
258
+ ]
244
259
  }
245
260
 
246
261
  get config () {
@@ -8,7 +8,6 @@ import {
8
8
  newBookmarkIdPrefix,
9
9
  fileOperationsMap,
10
10
  syncTypes,
11
- settingSyncId,
12
11
  infoTabs,
13
12
  openedSidebarKey,
14
13
  sidebarPinnedKey,
@@ -26,7 +25,6 @@ const t = prefix('terminalThemes')
26
25
  const e = prefix('control')
27
26
  const newQuickCommand = 'newQuickCommand'
28
27
  const q = prefix('quickCommands')
29
- const ss = prefix('settingSync')
30
28
 
31
29
  function getDefaultBookmarkGroups (bookmarks) {
32
30
  return [
@@ -104,12 +102,7 @@ export default {
104
102
  }),
105
103
 
106
104
  // for settings related
107
- _setting: JSON.stringify([
108
- {
109
- id: settingSyncId,
110
- title: ss('settingSync')
111
- }
112
- ]),
105
+ _setting: '',
113
106
  _settingItem: JSON.stringify(getInitItem([], settingMap.bookmarks)),
114
107
  settingTab: settingMap.bookmarks, // setting tab
115
108
  autofocustrigger: Date.now(),
@@ -111,6 +111,9 @@ export default Store => {
111
111
  }
112
112
 
113
113
  Store.prototype.getItems = function (type) {
114
+ if (type === 'setting') {
115
+ return window.store.setting
116
+ }
114
117
  return JSON.parse(this['_' + type] || [])
115
118
  }
116
119
 
@@ -22,28 +22,6 @@ export default Store => {
22
22
  }
23
23
  }
24
24
 
25
- Store.prototype.onKeyDown = function (event) {
26
- if (
27
- event.key === '=' &&
28
- (
29
- (isMac && event.metaKey) ||
30
- (!isMac && event.ctrlKey)
31
- )
32
- ) {
33
- event.stopPropagation()
34
- window.store.zoom(0.25, true)
35
- } else if (
36
- event.key === '-' &&
37
- (
38
- (isMac && event.metaKey) ||
39
- (!isMac && event.ctrlKey)
40
- )
41
- ) {
42
- event.stopPropagation()
43
- window.store.zoom(-0.25, true)
44
- }
45
- }
46
-
47
25
  Store.prototype.zoomTerminal = debounce(function (delta) {
48
26
  postMsg({
49
27
  action: terminalActions.zoom,
@@ -65,7 +65,9 @@ export default store => {
65
65
  }).start()
66
66
 
67
67
  autoRun(store, () => {
68
- window.pre.runGlobalAsync('saveUserConfig', store.config)
68
+ if (store.config) {
69
+ window.pre.runGlobalAsync('saveUserConfig', store.config)
70
+ }
69
71
  return store._config
70
72
  }, func => debounce(func, 100)).start()
71
73
 
@@ -29,9 +29,11 @@ html
29
29
  link(rel='stylesheet', href='css/' + version + '-basic.css')
30
30
  link(rel='stylesheet', href='css/' + version + '-index.css')
31
31
  style(id='theme-css').
32
+ style(id='custom-css').
32
33
  body
33
34
  - if (isDev)
34
35
  style(id='theme-css').
36
+ style(id='custom-css').
35
37
  #container
36
38
  #content-loading
37
39
  .morph-shape.iblock.pd3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "1.34.63",
3
+ "version": "1.35.0",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",