File tree 6 files changed +25
-7
lines changed
6 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -72,15 +72,20 @@ Mine is configured only to respond to requests for domains I control.
72
72
73
73
Then, in one terminal
74
74
75
- ```
75
+ ``` bash
76
76
REACT_APP_OAUTH_HELPER_URL=< url-to-your-auth-helper> npm start
77
77
```
78
78
79
79
and in another.
80
80
81
- ```
82
- ngron http --subdomain=somedomain 3000
81
+ ``` bash
82
+ ngrok http --subdomain=somedomain 3000
83
83
```
84
84
85
85
Then go to ` https://somedomain.ngrok.io ` . Note that at the moment the preview won't
86
86
work but you can test authenticating, etc...
87
+
88
+ # Switching editors
89
+
90
+ By default Monaco is used on desktop, CodeMirror on mobile.
91
+ To test CodeMirror on desktop add ` codeMirror=true ` as a query parameter.
Original file line number Diff line number Diff line change @@ -702,6 +702,10 @@ hr {
702
702
resize : vertical;
703
703
overflow : auto;
704
704
}
705
+ .new-comment .new-comment-write {
706
+ min-height : 10em ;
707
+ height : 10em ;
708
+ }
705
709
.new-comment .new-comment-preview {
706
710
min-height : 10em ;
707
711
padding : 0.5em ;
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import ServiceContext from '../ServiceContext.js';
18
18
import Settings from './Settings.js' ;
19
19
import UserManager from '../libs/UserManager.js' ;
20
20
import * as winMsgMgr from '../libs/WindowMessageManager' ;
21
+ import query from '../libs/start-query.js' ;
21
22
22
23
import './App.css' ;
23
24
@@ -90,7 +91,6 @@ class App extends React.Component {
90
91
this . setState ( { dark : darkMatcher . matches } ) ;
91
92
} ) ;
92
93
93
- const query = Object . fromEntries ( new URLSearchParams ( window . location . search ) . entries ( ) ) ;
94
94
if ( query . newGist ) {
95
95
window . history . pushState ( { } , '' , `${ window . location . origin } ` ) ;
96
96
window . opener . postMessage ( { type : 'gimmeDaCodez' } , '*' ) ;
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import CodeCodeMirror from './CodeCodeMirror' ;
3
3
import CodeMonaco from './CodeMonaco' ;
4
+ import query from '../libs/start-query.js' ;
4
5
5
6
// TODO: Make Monaco lazy load
6
7
7
8
// This sucks but Monaco doesn't work on mobile
8
- const canMonaco = ! ( / w e b O S | i P h o n e | i P a d | A n d r o i d / . test ( navigator . userAgent ) ) ;
9
+ const canMonaco = ! query . codeMirror && ! ( / w e b O S | i P h o n e | i P a d | A n d r o i d / . test ( navigator . userAgent ) ) ;
9
10
10
11
export default function Code ( props ) {
11
12
return (
Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ const darkMatcher = window.matchMedia
8
8
9
9
const noop = ( ) => { } ;
10
10
11
+ function codeMirrorModeToLanguage ( editor ) {
12
+ const language = ( editor ?. mode || 'javascript' ) . split ( '/' ) . pop ( ) ;
13
+ return language === 'gfm' ? 'markdown' : language ;
14
+ }
15
+
11
16
export default class CodeMonaco extends React . Component {
12
17
constructor ( props ) {
13
18
super ( props ) ;
@@ -22,6 +27,7 @@ export default class CodeMonaco extends React.Component {
22
27
}
23
28
handleEditorDidMount = ( editor , monaco ) => {
24
29
this . editor = editor ;
30
+ editor . getModel ( ) . updateOptions ( { tabSize : 2 } ) ;
25
31
const { registerAPI} = this . props ;
26
32
if ( registerAPI ) {
27
33
registerAPI ( {
@@ -50,7 +56,7 @@ export default class CodeMonaco extends React.Component {
50
56
// https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.IEditorConstructionOptions.html
51
57
52
58
// we pass in mime-type (eg. 'text/css' but monaco wants just 'css')
53
- const language = ( options . editor ?. mode || 'javascript' ) . split ( '/' ) . pop ( ) ;
59
+ const language = codeMirrorModeToLanguage ( options . editor ) . split ( '/' ) . pop ( ) ;
54
60
return (
55
61
< Editor
56
62
theme = { isDarkMode ? "vs-dark" : "light" }
@@ -60,7 +66,7 @@ export default class CodeMonaco extends React.Component {
60
66
onMount = { this . handleEditorDidMount }
61
67
options = { {
62
68
minimap : { enabled : false } ,
63
- lineNumbers : "off" ,
69
+ // lineNumbers: "off",
64
70
glyphMargin : false ,
65
71
folding : false ,
66
72
} }
Original file line number Diff line number Diff line change
1
+ const query = Object . fromEntries ( new URLSearchParams ( window . location . search ) . entries ( ) ) ;
2
+ export default query ;
You can’t perform that action at this time.
0 commit comments