File tree Expand file tree Collapse file tree 3 files changed +14
-10
lines changed
dashboard/Data/Playground Expand file tree Collapse file tree 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;
1313export const demos = [
1414 {
1515 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" /> ,
1717 } ,
1818] ;
Original file line number Diff line number Diff line change @@ -18,19 +18,21 @@ export default class CodeEditor extends React.Component {
1818 constructor ( props ) {
1919 super ( props ) ;
2020
21- this . state = { code : '' } ;
21+ this . state = {
22+ code : this . props . defaultValue || '' ,
23+ } ;
2224 }
2325
2426 get value ( ) {
25- return this . state . code || this . props . placeHolder ;
27+ return this . state . code ;
2628 }
2729
2830 set value ( code ) {
2931 this . setState ( { code } ) ;
3032 }
3133
3234 render ( ) {
33- const { placeHolder , fontSize = 18 } = this . props ;
35+ const { fontSize = 18 } = this . props ;
3436 const { code } = this . state ;
3537
3638 return (
@@ -43,7 +45,7 @@ export default class CodeEditor extends React.Component {
4345 showGutter = { true }
4446 highlightActiveLine = { true }
4547 width = "100%"
46- value = { code || placeHolder }
48+ value = { code }
4749 enableBasicAutocompletion = { true }
4850 enableLiveAutocompletion = { true }
4951 enableSnippets = { false }
@@ -56,5 +58,5 @@ export default class CodeEditor extends React.Component {
5658
5759CodeEditor . propTypes = {
5860 fontSize : PropTypes . number . describe ( 'Font size of the editor' ) ,
59- placeHolder : PropTypes . string . describe ( 'Code place holder ' ) ,
61+ defaultValue : PropTypes . string . describe ( 'Default Code ' ) ,
6062} ;
Original file line number Diff line number Diff line change @@ -10,6 +10,11 @@ import { CurrentApp } from 'context/currentApp';
1010
1111import styles from './Playground.scss' ;
1212
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+
1318export default class Playground extends Component {
1419 static contextType = CurrentApp ;
1520 constructor ( ) {
@@ -141,10 +146,7 @@ export default class Playground extends Component {
141146 < Toolbar section = { this . section } subsection = { this . subsection } />
142147 < div style = { { minHeight : '25vh' } } >
143148 < 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 }
148150 ref = { editor => ( this . editor = editor ) }
149151 />
150152 < div className = { styles [ 'console-ctn' ] } >
You can’t perform that action at this time.
0 commit comments