@electerm/electerm-react 1.37.88 → 1.37.92

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.
@@ -42,7 +42,7 @@ export const maxHistory = 50
42
42
  export const maxTransport = 5
43
43
  export const maxSftpHistory = 20
44
44
  export const maxZoom = 8
45
- export const minZoom = 0.25
45
+ export const minZoom = 0.5
46
46
  export const extraTabWidth = 113
47
47
  // export const maxTabs = 20
48
48
 
@@ -340,6 +340,8 @@ class Sessions extends Component {
340
340
  currentTabId,
341
341
  tab: toSimpleObj(tab),
342
342
  ...pick(store, [
343
+ 'fileOperation',
344
+ 'file',
343
345
  'height',
344
346
  'width',
345
347
  'activeTerminalId',
@@ -382,7 +384,6 @@ class Sessions extends Component {
382
384
  currentTabId,
383
385
  config,
384
386
  ...pick(store, [
385
- 'fileOperation',
386
387
  'height',
387
388
  'width',
388
389
  'activeTerminalId',
@@ -320,23 +320,16 @@ export default class SettingCommon extends Component {
320
320
  const defaultValue = defaultSettings[name]
321
321
  const onChange = (e) => this.onChangeValue(e.target.value, name)
322
322
  const onChangeArgs = (v) => this.onChangeValue(v, agrsProp)
323
- const style = {
324
- style: {
325
- width: '40%'
326
- }
327
- }
328
323
  const styleArg = {
329
324
  style: {
330
- width: '40%',
331
- marginLeft: '3px'
325
+ width: '40%'
332
326
  }
333
327
  }
334
328
  return (
335
329
  <div className='pd2b'>
336
- <Space.Compact>
330
+ <Space.Compact block>
337
331
  <Input
338
332
  value={value}
339
- {...style}
340
333
  onChange={onChange}
341
334
  placeholder={defaultValue}
342
335
  />
@@ -5,6 +5,7 @@
5
5
 
6
6
  import React from 'react'
7
7
  import { shortcutExtend } from './shortcut-handler.js'
8
+ import { throttle } from 'lodash-es'
8
9
 
9
10
  class ShortcutControl extends React.PureComponent {
10
11
  componentDidMount () {
@@ -40,33 +41,33 @@ class ShortcutControl extends React.PureComponent {
40
41
  x && x.click()
41
42
  }
42
43
 
43
- zoominShortcut = (e) => {
44
+ zoominShortcut = throttle((e) => {
44
45
  e.stopPropagation()
45
46
  window.store.zoom(0.25, true)
46
- }
47
+ }, 1000)
47
48
 
48
- zoomoutShortcut = (e) => {
49
+ zoomoutShortcut = throttle((e) => {
49
50
  e.stopPropagation()
50
51
  window.store.zoom(-0.25, true)
51
- }
52
+ }, 1000)
52
53
 
53
- zoominTerminalShortcut = (event) => {
54
+ zoominTerminalShortcut = throttle((event) => {
54
55
  if (window.store.inActiveTerminal) {
55
56
  window.store.zoomTerminal(event.wheelDeltaY || 120)
56
57
  } else {
57
58
  const plus = 0.2
58
59
  window.store.zoom(plus, true)
59
60
  }
60
- }
61
+ }, 1000)
61
62
 
62
- zoomoutTerminalShortcut = (event) => {
63
+ zoomoutTerminalShortcut = throttle((event) => {
63
64
  if (window.store.inActiveTerminal) {
64
65
  window.store.zoomTerminal(event.wheelDeltaY || -120)
65
66
  } else {
66
67
  const plus = -0.2
67
68
  window.store.zoom(plus, true)
68
69
  }
69
- }
70
+ }, 1000)
70
71
 
71
72
  render () {
72
73
  return null
@@ -58,12 +58,22 @@ export function shortcutExtend (Cls) {
58
58
  key
59
59
  } = event
60
60
  if (key === 'Backspace' && this.isTerm && type === 'keydown') {
61
+ const now = Date.now()
62
+ if (!this.lastTimePressDel) {
63
+ this.lastTimePressDel = now
64
+ }
65
+ const timer = now - this.lastTimePressDel
66
+ const count = Math.ceil(timer / 800)
67
+ let char = String.fromCharCode(
68
+ shiftKey ? 127 : 8
69
+ )
70
+ char = new Array(count).fill(char).join('')
61
71
  this.socket.send(
62
- String.fromCharCode(
63
- shiftKey ? 127 : 8
64
- )
72
+ char
65
73
  )
66
74
  return false
75
+ } else if (key === 'Backspace' && this.isTerm && type === 'keyup') {
76
+ delete this.lastTimePressDel
67
77
  }
68
78
  const codeName = event instanceof window.WheelEvent
69
79
  ? (wheelDeltaY > 0 ? 'mouseWheelUp' : 'mouseWheelDown')
@@ -1,3 +1,5 @@
1
+ import { useEffect } from 'react'
2
+
1
3
  export default function AppDrag (props) {
2
4
  function canOperate (e) {
3
5
  const {
@@ -37,6 +39,10 @@ export default function AppDrag (props) {
37
39
  window.pre.runGlobalAsync('maximize')
38
40
  }
39
41
  }
42
+
43
+ useEffect(() => {
44
+ window.addEventListener('contextmenu', onMouseUp)
45
+ }, [])
40
46
  return (
41
47
  <div
42
48
  className='app-drag'
@@ -219,7 +219,19 @@ export default class Tabs extends React.Component {
219
219
  )
220
220
  }
221
221
 
222
- render () {
222
+ renderContent () {
223
+ const { config } = this.props
224
+ if (config.useSystemTitleBar) {
225
+ return this.renderContentInner()
226
+ }
227
+ return (
228
+ <AppDrag>
229
+ {this.renderContentInner()}
230
+ </AppDrag>
231
+ )
232
+ }
233
+
234
+ renderContentInner () {
223
235
  const { tabs = [], width } = this.props
224
236
  const len = tabs.length
225
237
  const tabsWidthAll = tabMargin * len + 10 + this.tabsWidth()
@@ -230,46 +242,51 @@ export default class Tabs extends React.Component {
230
242
  const style = {
231
243
  width: width - windowControlWidth - 86
232
244
  }
245
+ return (
246
+ <div
247
+ className='tabs-inner'
248
+ style={style}
249
+ >
250
+ <div
251
+ style={{
252
+ left
253
+ }}
254
+ />
255
+ <div
256
+ className='tabs-wrapper relative'
257
+ style={{
258
+ width: tabsWidthAll + extraTabWidth + 10
259
+ }}
260
+ onDoubleClick={this.handleAdd}
261
+ >
262
+ {
263
+ tabs.map((tab, i) => {
264
+ const isLast = i === len - 1
265
+ return (
266
+ <Tab
267
+ {...this.props}
268
+ tab={tab}
269
+ isLast={isLast}
270
+ key={tab.id}
271
+ />
272
+ )
273
+ })
274
+ }
275
+ {
276
+ !overflow
277
+ ? this.renderAddBtn()
278
+ : null
279
+ }
280
+ </div>
281
+ </div>
282
+ )
283
+ }
284
+
285
+ render () {
286
+ const overflow = this.isOverflow()
233
287
  return (
234
288
  <div className='tabs' ref={this.tabsRef}>
235
- <AppDrag>
236
- <div
237
- className='tabs-inner'
238
- style={style}
239
- >
240
- <div
241
- style={{
242
- left
243
- }}
244
- />
245
- <div
246
- className='tabs-wrapper relative'
247
- style={{
248
- width: tabsWidthAll + extraTabWidth + 10
249
- }}
250
- onDoubleClick={this.handleAdd}
251
- >
252
- {
253
- tabs.map((tab, i) => {
254
- const isLast = i === len - 1
255
- return (
256
- <Tab
257
- {...this.props}
258
- tab={tab}
259
- isLast={isLast}
260
- key={tab.id}
261
- />
262
- )
263
- })
264
- }
265
- {
266
- !overflow
267
- ? this.renderAddBtn()
268
- : null
269
- }
270
- </div>
271
- </div>
272
- </AppDrag>
289
+ {this.renderContent()}
273
290
  <WindowControl
274
291
  store={window.store}
275
292
  />
@@ -26,7 +26,8 @@ import {
26
26
  terminalActions,
27
27
  commonActions,
28
28
  rendererTypes,
29
- cwdId
29
+ cwdId,
30
+ isMac
30
31
  } from '../../common/constants'
31
32
  import deepCopy from 'json-deep-copy'
32
33
  import { readClipboardAsync, copy } from '../../common/clipboard'
@@ -242,6 +243,19 @@ class Term extends Component {
242
243
  this.tryInsertSelected()
243
244
  }
244
245
 
246
+ pasteShortcut = (e) => {
247
+ if (isMac) {
248
+ return true
249
+ }
250
+ if (!this.isRemote()) {
251
+ return true
252
+ }
253
+ if (this.term.buffer.active.type !== 'alternate') {
254
+ return false
255
+ }
256
+ return true
257
+ }
258
+
245
259
  showNormalBufferShortcut = (e) => {
246
260
  e.stopPropagation()
247
261
  this.openNormalBuffer()
@@ -48,6 +48,7 @@ export default Store => {
48
48
 
49
49
  Store.prototype.onBlur = function () {
50
50
  window.focused = false
51
+ window.pre.runSync('windowMove', false)
51
52
  }
52
53
 
53
54
  Store.prototype.selectall = function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "1.37.88",
3
+ "version": "1.37.92",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",