mirror of
https://github.com/ritz078/transform.git
synced 2026-11-22 17:11:32 +03:00
allow JS object instead of JSON
This commit is contained in:
1 parent
c8ae576c14
commit
c93caa6765
3 files changed
+19
-14
No files matched your search
@@ -185,7 +185,7 @@ export default class ConversionPanel extends PureComponent {
|
||||
};
|
||||
|
||||
onChange = async (newValue, leftSplitValue) => {
|
||||
const { prettifyRightPanel, rightMode } = this.props;
|
||||
const { prettifyRightPanel, rightMode, leftMode } = this.props;
|
||||
|
||||
const nValue = newValue || this.state.value;
|
||||
const splitValue =
|
||||
@@ -194,7 +194,12 @@ export default class ConversionPanel extends PureComponent {
|
||||
: this.state.splitValue;
|
||||
|
||||
try {
|
||||
let code = await this.props.getTransformedValue(nValue, splitValue);
|
||||
// Convert JS to JSON
|
||||
const json =
|
||||
leftMode === "json"
|
||||
? JSON.stringify(eval("(" + nValue + ")", null, 2))
|
||||
: nValue;
|
||||
let code = await this.props.getTransformedValue(json, splitValue);
|
||||
code = code.prettyCode || code;
|
||||
if (prettifyRightPanel) {
|
||||
this.passCodeToWorker(code, rightMode, "resultValue");
|
||||
|
||||
Reference in new issue
Block a user