From 5737bcaec6e51b5ca6837dac28cfe8f49e7ae656 Mon Sep 17 00:00:00 2001 From: MohammadAli Karimi Date: Mon, 13 May 2024 13:27:13 +0400 Subject: [PATCH 1/3] fix: use default value props instead placeholder in the code editor --- src/components/CodeEditor/CodeEditor.react.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/CodeEditor/CodeEditor.react.js b/src/components/CodeEditor/CodeEditor.react.js index bf865041a9..e8554fe7e3 100644 --- a/src/components/CodeEditor/CodeEditor.react.js +++ b/src/components/CodeEditor/CodeEditor.react.js @@ -18,11 +18,13 @@ export default class CodeEditor extends React.Component { constructor(props) { super(props); - this.state = { code: '' }; + this.state = { + code: this.props.defaultValue || '', + }; } get value() { - return this.state.code || this.props.placeHolder; + return this.state.code; } set value(code) { @@ -30,7 +32,7 @@ export default class CodeEditor extends React.Component { } render() { - const { placeHolder, fontSize = 18 } = this.props; + const { fontSize = 18 } = this.props; const { code } = this.state; return ( @@ -43,7 +45,7 @@ export default class CodeEditor extends React.Component { showGutter={true} highlightActiveLine={true} width="100%" - value={code || placeHolder} + value={code} enableBasicAutocompletion={true} enableLiveAutocompletion={true} enableSnippets={false} @@ -56,5 +58,5 @@ export default class CodeEditor extends React.Component { CodeEditor.propTypes = { fontSize: PropTypes.number.describe('Font size of the editor'), - placeHolder: PropTypes.string.describe('Code place holder'), + defaultValue: PropTypes.string.describe('Default Code'), }; From d756a0af7f042485c119a2ece2e55b782f1032ee Mon Sep 17 00:00:00 2001 From: MohammadAli Karimi Date: Mon, 13 May 2024 13:28:02 +0400 Subject: [PATCH 2/3] chore: add default value for dashboard playground --- src/dashboard/Data/Playground/Playground.react.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dashboard/Data/Playground/Playground.react.js b/src/dashboard/Data/Playground/Playground.react.js index 08e830246a..b741d2dd7a 100644 --- a/src/dashboard/Data/Playground/Playground.react.js +++ b/src/dashboard/Data/Playground/Playground.react.js @@ -10,6 +10,11 @@ import { CurrentApp } from 'context/currentApp'; import styles from './Playground.scss'; +const DEFAULT_CODE_EDITOR_VALUE = `const myObj = new Parse.Object('MyClass'); +myObj.set('myField', 'Hello World!') +await myObj.save(); +console.log(myObj);`; + export default class Playground extends Component { static contextType = CurrentApp; constructor() { @@ -141,10 +146,7 @@ export default class Playground extends Component {
(this.editor = editor)} />
From 282e2108f84c0a16e7fd2a8235acec66fe5ce91d Mon Sep 17 00:00:00 2001 From: MohammadAli Karimi Date: Mon, 13 May 2024 13:28:29 +0400 Subject: [PATCH 3/3] chore: use default value for code editor example --- src/components/CodeEditor/CodeEditor.example.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/CodeEditor/CodeEditor.example.js b/src/components/CodeEditor/CodeEditor.example.js index 4b9cb25b4b..5e86534be9 100644 --- a/src/components/CodeEditor/CodeEditor.example.js +++ b/src/components/CodeEditor/CodeEditor.example.js @@ -13,6 +13,6 @@ export const component = CodeEditor; export const demos = [ { name: 'Simple code editor (only JS support)', - render: () => , + render: () => , }, ];