Skip to content

Commit

Permalink
format code, fix some lints
Browse files Browse the repository at this point in the history
  • Loading branch information
SillyFreak committed Jun 24, 2020
1 parent 757f7a0 commit cc35dea
Showing 1 changed file with 71 additions and 68 deletions.
139 changes: 71 additions & 68 deletions src/routes/webrtc/WebRTC.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ import 'ace-builds/src-noconflict/theme-github';

import s from './WebRTC.scss';

const peerOptions = __DEV__ ? {
host: 'localhost',
port: 3010,
path: '/peerjs',
} : {
host: '/',
path: '/peerjs',
};
const peerOptions = __DEV__
? {
host: 'localhost',
port: 3010,
path: '/peerjs',
}
: {
host: '/',
path: '/peerjs',
};

type Message = {|
type: 'IN' | 'OUT',
Expand Down Expand Up @@ -82,7 +84,7 @@ function Chat({ connection, sendText }: ChatProps) {

type EditorProps = {||};

function Editor(_props: Props) {
function Editor(_props: EditorProps) {
const [content, setContent] = React.useState<string | null>(null);

React.useEffect(() => {
Expand All @@ -97,65 +99,66 @@ function Editor(_props: Props) {
return `(${positionToString(start)}, ${positionToString(end)})`;
}

return content !== null && (
<AceEditor
mode="javascript"
theme="github"
name="editor"
width={'800px'}
height={'600px'}
// onLoad={onLoad}
onChange={(value, event) => {
console.log(event);
setContent(value);
}}
fontSize={16}
onSelectionChange={(selection, _event) => {
const ranges = selection.getAllRanges();
console.log(ranges.map(rangeToString).join(', '));
}}
onCursorChange={(selection, _event) => {
const cursor = selection.getCursor();
console.log(positionToString(cursor));
}}
markers={[
{
startRow: 0,
startCol: 1,
endRow: 0,
endCol: 3,
className: s['remote-selection'],
type: 'text',
},
{
startRow: 0,
startCol: 3,
endRow: 0,
endCol: 4,
className: s['remote-cursor'],
type: 'text',
},
]}
// onValidate={onValidate}
value={content}
showGutter
highlightActiveLine
autoScrollEditorIntoView
style={{
position: 'absolute',
}}
editorProps={{
// $blockScrolling: Infinity,
}}
setOptions={{
// useWorker: false,
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
// enableSnippets: enableSnippets,
showLineNumbers: true,
tabSize: 2,
}}
/>
return (
content !== null && (
<AceEditor
mode="javascript"
theme="github"
name="editor"
width="800px"
height="600px"
// onLoad={onLoad}
onChange={(value, event) => {
// eslint-disable-next-line no-console
console.log(event);
setContent(value);
}}
fontSize={16}
onSelectionChange={(selection, _event) => {
const ranges = selection.getAllRanges();
// eslint-disable-next-line no-console
console.log(ranges.map(rangeToString).join(', '));
}}
onCursorChange={(selection, _event) => {
const cursor = selection.getCursor();
// eslint-disable-next-line no-console
console.log(positionToString(cursor));
}}
markers={[
{
startRow: 0,
startCol: 1,
endRow: 0,
endCol: 3,
className: s['remote-selection'],
type: 'text',
},
{
startRow: 0,
startCol: 3,
endRow: 0,
endCol: 4,
className: s['remote-cursor'],
type: 'text',
},
]}
// onValidate={onValidate}
value={content}
showGutter
highlightActiveLine
autoScrollEditorIntoView
style={{
position: 'absolute',
}}
setOptions={{
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
// enableSnippets: enableSnippets,
showLineNumbers: true,
tabSize: 2,
}}
/>
)
);
}

Expand Down

0 comments on commit cc35dea

Please sign in to comment.