@electerm/electerm-react 2.3.114 → 2.3.126

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.
@@ -167,6 +167,16 @@ class ShortcutControl extends React.PureComponent {
167
167
  window.store.onNewSsh()
168
168
  }, 500)
169
169
 
170
+ toggleAddBtnShortcut = throttle((e) => {
171
+ e.stopPropagation()
172
+ const { currentLayoutBatch } = window.store
173
+ // Find the add button for the active layout (batch)
174
+ const addBtnElement = document.querySelector(`.v${currentLayoutBatch + 1} .tabs-add-btn`)
175
+ if (addBtnElement) {
176
+ addBtnElement.click()
177
+ }
178
+ }, 500)
179
+
170
180
  togglefullscreenShortcut = throttle((e) => {
171
181
  e.stopPropagation()
172
182
  const x = document.querySelector('.term-fullscreen-control') ||
@@ -31,6 +31,11 @@ export default () => {
31
31
  shortcut: 'ctrl+n',
32
32
  shortcutMac: 'meta+n'
33
33
  },
34
+ {
35
+ name: 'app_toggleAddBtn',
36
+ shortcut: 'alt+n',
37
+ shortcutMac: 'alt+n'
38
+ },
34
39
  {
35
40
  name: 'app_togglefullscreen',
36
41
  shortcut: 'alt+f',
@@ -57,8 +57,6 @@ export default function AddBtnMenu ({
57
57
  left: menuPosition === 'right'
58
58
  }
59
59
 
60
- console.log('render add btn menu', dragProps)
61
-
62
60
  return (
63
61
  <div
64
62
  ref={menuRef}
@@ -46,6 +46,10 @@ export default class AddBtn extends Component {
46
46
  document.body.removeChild(this.portalContainer)
47
47
  this.portalContainer = null
48
48
  }
49
+ // Clear focus timeout
50
+ if (this.çƒ) {
51
+ clearTimeout(this.focusTimeout)
52
+ }
49
53
  }
50
54
 
51
55
  componentDidUpdate (prevProps, prevState) {
@@ -111,6 +115,17 @@ export default class AddBtn extends Component {
111
115
  )
112
116
  }
113
117
 
118
+ focusSearchInput = () => {
119
+ // Focus the search input after the menu renders
120
+ this.focusTimeout = setTimeout(() => {
121
+ const searchInput = this.menuRef.current?.querySelector('.ant-input')
122
+ if (searchInput) {
123
+ searchInput.focus()
124
+ searchInput.select()
125
+ }
126
+ }, 500)
127
+ }
128
+
114
129
  handleAddBtnClick = () => {
115
130
  if (this.state.open) {
116
131
  this.setState({ open: false })
@@ -157,7 +172,7 @@ export default class AddBtn extends Component {
157
172
  menuPosition,
158
173
  menuTop,
159
174
  menuLeft
160
- })
175
+ }, this.focusSearchInput)
161
176
 
162
177
  window.openTabBatch = this.props.batch
163
178
  }
@@ -120,9 +120,9 @@ export default class TerminalCmdSuggestions extends Component {
120
120
 
121
121
  // Use bottom position if close to bottom edge
122
122
  if (reverse) {
123
- position.bottom = h - top + cellHeight
123
+ position.bottom = h - top + cellHeight * 1.5
124
124
  } else {
125
- position.top = top
125
+ position.top = top + cellHeight
126
126
  }
127
127
  this.setState({
128
128
  showSuggestions: true,
@@ -7,6 +7,7 @@ import {
7
7
  CopyOutlined
8
8
  } from '@ant-design/icons'
9
9
  import { copy } from '../../common/clipboard'
10
+ import { escapeRegExp } from 'lodash-es'
10
11
 
11
12
  export default function SimpleEditor (props) {
12
13
  const [searchKeyword, setSearchKeyword] = useState('')
@@ -72,7 +73,8 @@ export default function SimpleEditor (props) {
72
73
 
73
74
  const matches = []
74
75
  const text = props.value || ''
75
- const regex = new RegExp(searchKeyword, 'gi')
76
+ const escapedKeyword = escapeRegExp(searchKeyword)
77
+ const regex = new RegExp(escapedKeyword, 'gi')
76
78
  let match
77
79
 
78
80
  while ((match = regex.exec(text)) !== null) {
@@ -83,7 +83,6 @@ export default class VncSession extends RdpSession {
83
83
  username,
84
84
  password
85
85
  } = tab
86
- console.log('vnc tab', tab)
87
86
  const opts = clone({
88
87
  term: terminalType || config.terminalType,
89
88
  tabId: id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "2.3.114",
3
+ "version": "2.3.126",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",