Skip to content
This repository has been archived by the owner on Oct 8, 2022. It is now read-only.

Commit

Permalink
Use fullscreen api wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmota committed Jul 12, 2020
1 parent d04f6b2 commit 4df4bb8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"react-dropzone": "10.0.4",
"react-router-dom": "5.0.0",
"react-scripts": "2.1.8",
"screenfull": "5.0.2",
"string-to-arraybuffer": "1.0.2",
"styled-components": "4.1.3",
"typescript": "3.9.5",
Expand Down
13 changes: 10 additions & 3 deletions src/components/functional/Terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ArrowCollapse from 'mdi-material-ui/ArrowCollapse'
import FullscreenExit from 'mdi-material-ui/FullscreenExit'
import HelpTooltip from 'src/components/functional/HelpTooltip'
import str2ab from 'string-to-arraybuffer'
import screenfull from 'screenfull'
import { Terminal } from 'xterm'
import * as fit from 'xterm/lib/addons/fit/fit'
import * as termFullscreen from 'xterm/lib/addons/fullscreen/fullscreen'
Expand Down Expand Up @@ -471,7 +472,11 @@ class TerminalComponent extends Component<Props, State> {
const lastHeight = container.clientHeight

let terminal = this.terminalRef.current
await terminal.requestFullscreen()
if (!screenfull.isEnabled) {
throw new Error('Not supported')
}

screenfull.request(terminal)
this.focusTerminal()

this.setState({
Expand All @@ -497,9 +502,11 @@ class TerminalComponent extends Component<Props, State> {
}

exitFullscreen () {
if (document.exitFullscreen) {
document.exitFullscreen()
if (!screenfull.isEnabled) {
throw new Error('Not supported')
}

screenfull.exit()
}

showExpandedView () {
Expand Down
3 changes: 2 additions & 1 deletion src/components/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const UI = {
display: inline-block;
width: auto;
float: left;
min-width: 220px;
}
`,
ShareUrlInput: styled.input`
Expand Down Expand Up @@ -192,7 +193,7 @@ const UI = {
`,
Settings: styled.div`
@media (max-width: 500px) {
float: left;
float: right;
}
`,
Notice: styled.div`
Expand Down

0 comments on commit 4df4bb8

Please sign in to comment.