Updated popup editor and added variable detection functionality
This commit is contained in:
@@ -1218,6 +1218,7 @@ const ParsedAction = (props) => {
|
|||||||
const shufflecode = <ShuffleCodeEditor
|
const shufflecode = <ShuffleCodeEditor
|
||||||
fieldCount = {fieldCount}
|
fieldCount = {fieldCount}
|
||||||
setFieldCount = {setFieldCount}
|
setFieldCount = {setFieldCount}
|
||||||
|
actionlist = {actionlist}
|
||||||
changeActionParameterCodeMirror = {changeActionParameterCodeMirror}
|
changeActionParameterCodeMirror = {changeActionParameterCodeMirror}
|
||||||
codedata={codedata}
|
codedata={codedata}
|
||||||
setcodedata={setcodedata}
|
setcodedata={setcodedata}
|
||||||
@@ -1738,6 +1739,7 @@ const ParsedAction = (props) => {
|
|||||||
//}}
|
//}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
console.log("CLICKED: ", innerdata);
|
console.log("CLICKED: ", innerdata);
|
||||||
|
console.log(innerdata.example)
|
||||||
handleItemClick([innerdata]);
|
handleItemClick([innerdata]);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import 'codemirror/theme/gruvbox-dark.css';
|
|||||||
|
|
||||||
const CodeEditor = (props) => {
|
const CodeEditor = (props) => {
|
||||||
const {fieldCount, setFieldCount} = props
|
const {fieldCount, setFieldCount} = props
|
||||||
|
const {actionlist} = props
|
||||||
const {changeActionParameterCodeMirror} = props
|
const {changeActionParameterCodeMirror} = props
|
||||||
const {expansionModalOpen, setExpansionModalOpen} = props
|
const {expansionModalOpen, setExpansionModalOpen} = props
|
||||||
const {codedata, setcodedata} = props
|
const {codedata, setcodedata} = props
|
||||||
@@ -29,14 +30,37 @@ const CodeEditor = (props) => {
|
|||||||
|
|
||||||
const [expOutput, setexpOutput] = React.useState(" ");
|
const [expOutput, setexpOutput] = React.useState(" ");
|
||||||
function expectedOutput(input) {
|
function expectedOutput(input) {
|
||||||
|
|
||||||
|
const found = input.match(/[$]{1}([a-zA-Z0-9_-]+\.?){1}([a-zA-Z0-9#_-]+\.?){0,}/g)
|
||||||
|
console.log(found)
|
||||||
|
|
||||||
|
for (var i = 0; i < found.length; i++) {
|
||||||
|
// console.log(found[i]);
|
||||||
|
|
||||||
|
for (var j = 0; j < actionlist.length; j++) {
|
||||||
|
if(found[i].slice(1,).toLowerCase() == actionlist[j].autocomplete.toLowerCase()){
|
||||||
|
input = input.replace(found[i], JSON.stringify(actionlist[j].example));
|
||||||
|
// console.log(input)
|
||||||
|
// console.log(actionlist[j].example)
|
||||||
|
}
|
||||||
|
// console.log(actionlist[j].autocomplete);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// var x = document.getElementById("expOutput");
|
||||||
|
// x.innerHTML = JSON.stringify(JSON.parse(input), null, 4)
|
||||||
|
setexpOutput(JSON.stringify(JSON.parse(input), null, 4))
|
||||||
|
} catch (e) {
|
||||||
|
setexpOutput(input)
|
||||||
|
}
|
||||||
|
|
||||||
// const obj = JSON.parse(input);
|
// const obj = JSON.parse(input);
|
||||||
// setexpOutput(JSON.stringify(JSON.parse(input), null, 4))
|
// setexpOutput(JSON.stringify(JSON.parse(input), null, 4))
|
||||||
var x = document.getElementById("expOutput");
|
// x.innerHTML = "<span style='font-size: 30px'>" + JSON.stringify(input, null, 4) + "</span>"
|
||||||
x.innerHTML = JSON.stringify(input, null, 4)
|
|
||||||
// x.innerHTML = JSON.stringify(JSON.parse(input), null, 4)
|
|
||||||
// x.appendChild(document.createTextNode(JSON.stringify(JSON.parse(input), null, 4)));
|
// x.appendChild(document.createTextNode(JSON.stringify(JSON.parse(input), null, 4)));
|
||||||
// setexpOutput(JSON.stringify(input, null, 4))
|
// setexpOutput(JSON.stringify(input, undefined, 4).replace('\ ', '\n'))
|
||||||
|
// setexpOutput("Hi there \n Hey there")
|
||||||
// Variables + Syntax highlighting + Validation
|
// Variables + Syntax highlighting + Validation
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +104,7 @@ const CodeEditor = (props) => {
|
|||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
setlocalcodedata(value.getValue())
|
setlocalcodedata(value.getValue())
|
||||||
expectedOutput(value.getValue())
|
expectedOutput(value.getValue())
|
||||||
|
// console.log(actionlist.slice(-1))
|
||||||
}}
|
}}
|
||||||
options={{
|
options={{
|
||||||
theme: 'gruvbox-dark',
|
theme: 'gruvbox-dark',
|
||||||
@@ -107,6 +132,7 @@ const CodeEditor = (props) => {
|
|||||||
<p
|
<p
|
||||||
id='expOutput'
|
id='expOutput'
|
||||||
style={{
|
style={{
|
||||||
|
whiteSpace: "pre-wrap",
|
||||||
color: "#f85a3e",
|
color: "#f85a3e",
|
||||||
fontFamily: "monospace",
|
fontFamily: "monospace",
|
||||||
backgroundColor: "#282828",
|
backgroundColor: "#282828",
|
||||||
@@ -116,7 +142,7 @@ const CodeEditor = (props) => {
|
|||||||
borderRadius: theme.palette.borderRadius,
|
borderRadius: theme.palette.borderRadius,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{/* {expOutput} */}
|
{expOutput}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user