File tree 3 files changed +14
-10
lines changed
dashboard/Data/Playground
3 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,6 @@ export const component = CodeEditor;
13
13
export const demos = [
14
14
{
15
15
name : 'Simple code editor (only JS support)' ,
16
- render : ( ) => < CodeEditor placeHolder = { '//I am editable, try change me!' } id = "example1" /> ,
16
+ render : ( ) => < CodeEditor defaultValue = { '//I am editable, try change me!' } id = "example1" /> ,
17
17
} ,
18
18
] ;
Original file line number Diff line number Diff line change @@ -18,19 +18,21 @@ export default class CodeEditor extends React.Component {
18
18
constructor ( props ) {
19
19
super ( props ) ;
20
20
21
- this . state = { code : '' } ;
21
+ this . state = {
22
+ code : this . props . defaultValue || '' ,
23
+ } ;
22
24
}
23
25
24
26
get value ( ) {
25
- return this . state . code || this . props . placeHolder ;
27
+ return this . state . code ;
26
28
}
27
29
28
30
set value ( code ) {
29
31
this . setState ( { code } ) ;
30
32
}
31
33
32
34
render ( ) {
33
- const { placeHolder , fontSize = 18 } = this . props ;
35
+ const { fontSize = 18 } = this . props ;
34
36
const { code } = this . state ;
35
37
36
38
return (
@@ -43,7 +45,7 @@ export default class CodeEditor extends React.Component {
43
45
showGutter = { true }
44
46
highlightActiveLine = { true }
45
47
width = "100%"
46
- value = { code || placeHolder }
48
+ value = { code }
47
49
enableBasicAutocompletion = { true }
48
50
enableLiveAutocompletion = { true }
49
51
enableSnippets = { false }
@@ -56,5 +58,5 @@ export default class CodeEditor extends React.Component {
56
58
57
59
CodeEditor . propTypes = {
58
60
fontSize : PropTypes . number . describe ( 'Font size of the editor' ) ,
59
- placeHolder : PropTypes . string . describe ( 'Code place holder ' ) ,
61
+ defaultValue : PropTypes . string . describe ( 'Default Code ' ) ,
60
62
} ;
Original file line number Diff line number Diff line change @@ -10,6 +10,11 @@ import { CurrentApp } from 'context/currentApp';
10
10
11
11
import styles from './Playground.scss' ;
12
12
13
+ const DEFAULT_CODE_EDITOR_VALUE = `const myObj = new Parse.Object('MyClass');
14
+ myObj.set('myField', 'Hello World!')
15
+ await myObj.save();
16
+ console.log(myObj);` ;
17
+
13
18
export default class Playground extends Component {
14
19
static contextType = CurrentApp ;
15
20
constructor ( ) {
@@ -141,10 +146,7 @@ export default class Playground extends Component {
141
146
< Toolbar section = { this . section } subsection = { this . subsection } />
142
147
< div style = { { minHeight : '25vh' } } >
143
148
< CodeEditor
144
- placeHolder = { `const myObj = new Parse.Object('MyClass');
145
- myObj.set('myField', 'Hello World!')
146
- await myObj.save();
147
- console.log(myObj);` }
149
+ defaultValue = { DEFAULT_CODE_EDITOR_VALUE }
148
150
ref = { editor => ( this . editor = editor ) }
149
151
/>
150
152
< div className = { styles [ 'console-ctn' ] } >
You can’t perform that action at this time.
0 commit comments