diff --git a/frontend/src/components/ParsedAction.jsx b/frontend/src/components/ParsedAction.jsx index 3fdfd8a2..28958a5b 100644 --- a/frontend/src/components/ParsedAction.jsx +++ b/frontend/src/components/ParsedAction.jsx @@ -1245,6 +1245,7 @@ const ParsedAction = (props) => { const shufflecode = { //}} onClick={() => { console.log("CLICKED: ", innerdata); + console.log(innerdata.example) handleItemClick([innerdata]); }} > diff --git a/frontend/src/components/ShuffleCodeEditor.jsx b/frontend/src/components/ShuffleCodeEditor.jsx index bc6c9f69..c53fa29e 100644 --- a/frontend/src/components/ShuffleCodeEditor.jsx +++ b/frontend/src/components/ShuffleCodeEditor.jsx @@ -19,14 +19,47 @@ import 'codemirror/keymap/sublime'; import 'codemirror/theme/gruvbox-dark.css'; const CodeEditor = (props) => { - const {fieldCount, setFieldCount} = props - const {changeActionParameterCodeMirror} = props - const {expansionModalOpen, setExpansionModalOpen} = props - const {codedata, setcodedata} = props + const { fieldCount, setFieldCount, actionlist, changeActionParameterCodeMirror, expansionModalOpen, setExpansionModalOpen, codedata, setcodedata } = props const [localcodedata, setlocalcodedata] = React.useState(codedata === undefined || codedata === null || codedata.length === 0 ? "" : codedata); - // const {codelang, setcodelang} = props + // const {codelang, setcodelang} = props const theme = useTheme(); + const [expOutput, setexpOutput] = React.useState(" "); + 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); + // setexpOutput(JSON.stringify(JSON.parse(input), null, 4)) + // x.innerHTML = "" + JSON.stringify(input, null, 4) + "" + // x.appendChild(document.createTextNode(JSON.stringify(JSON.parse(input), null, 4))); + // setexpOutput(JSON.stringify(input, undefined, 4).replace('\ ', '\n')) + // setexpOutput("Hi there \n Hey there") + // Variables + Syntax highlighting + Validation + } + return ( { > Code Editor - {/* / Removed due to possible confusion between cancel, done and close buttons. -
- - { - setExpansionModalOpen(false) - }} - > - - - -
- */} { }} onChange={(value) => { setlocalcodedata(value.getValue()) + expectedOutput(value.getValue()) + // console.log(actionlist.slice(-1)) }} options={{ theme: 'gruvbox-dark', @@ -104,6 +110,38 @@ const CodeEditor = (props) => { }} /> + +
+ + + Output + + +

+ {expOutput} +

+
+
{ setExpansionModalOpen(false) }} > - CANCEL + Cancel
@@ -148,7 +186,7 @@ const CodeEditor = (props) => { setcodedata(localcodedata) }} > - DONE + Done