diff --git a/frontend/src/js/component/wb-json-editor.js b/frontend/src/js/component/wb-json-editor.js
index 0fe39b8..52f6011 100644
--- a/frontend/src/js/component/wb-json-editor.js
+++ b/frontend/src/js/component/wb-json-editor.js
@@ -3,6 +3,41 @@ import WBJsonViewer from 'wb-json-viewer';
import WBAccordion from 'wb-accordion';
import WBDialog from 'wb-dialog';
+class WbJsonEditorDialog extends Component {
+ constructor(...args) {
+ super(...args);
+ this.dialogRef = createRef();
+ }
+
+ render({ name, onChange }, { editValue, parseError }) {
+ return (
+ {
+ onChange(JSON.parse(editValue));
+ } }
+ canAccept={ () => {
+ try { JSON.parse(editValue) }
+ catch (exc) { this.setState({ parseError: exc.message }); return false; }
+ return true;
+ } }>
+
+
+ );
+ }
+
+ show() {
+ this.dialogRef.current.show();
+ }
+}
+
class WBJsonEditor extends Component {
constructor(...args) {
super(...args);
@@ -12,33 +47,16 @@ class WBJsonEditor extends Component {
render({ app, name, value, stringify, pretty, onChange }, { editValue, parseError }) {
return (
-
{
- onChange(JSON.parse(editValue));
- } }
- canAccept={ () => {
- try { JSON.parse(editValue) }
- catch (exc) { this.setState({ parseError: exc.message }); return false; }
- return true;
- } }>
-
-
+
{
- this.setState({ parseError: null,
+ const dlg = this.dialogRef.current;
+ dlg.setState({ parseError: null,
editValue: stringify ?
pretty ? JSON.stringify(value, null, 2)
: JSON.stringify(value) : value });
- this.dialogRef.current.show();
+ dlg.show();
} }>