From ceb08fe13d57403685b13a77e8d843c1ce490f75 Mon Sep 17 00:00:00 2001 From: jos Date: Sun, 1 Sep 2019 16:37:57 +0200 Subject: [PATCH] Some fixes and updates in examples --- examples/12_autocomplete_dynamic.html | 6 +- examples/react_advanced_demo/.env | 1 + .../react_advanced_demo/package-lock.json | 96 +------------------ examples/react_advanced_demo/package.json | 12 +++ .../src/JSONEditorReact.js | 24 ++--- examples/react_demo/.env | 1 + examples/react_demo/package-lock.json | 96 +------------------ examples/react_demo/package.json | 12 +++ examples/react_demo/src/JSONEditorDemo.js | 4 +- 9 files changed, 47 insertions(+), 205 deletions(-) create mode 100644 examples/react_advanced_demo/.env create mode 100644 examples/react_demo/.env diff --git a/examples/12_autocomplete_dynamic.html b/examples/12_autocomplete_dynamic.html index d4da92c..b9aca39 100644 --- a/examples/12_autocomplete_dynamic.html +++ b/examples/12_autocomplete_dynamic.html @@ -38,7 +38,11 @@ getOptions: function (text, path, input, editor) { return new Promise(function (resolve, reject) { const options = extractUniqueWords(editor.get()) - if (options.length > 0) resolve(options) else reject() + if (options.length > 0) { + resolve(options) + } else { + reject() + } }) } } diff --git a/examples/react_advanced_demo/.env b/examples/react_advanced_demo/.env new file mode 100644 index 0000000..6f809cc --- /dev/null +++ b/examples/react_advanced_demo/.env @@ -0,0 +1 @@ +SKIP_PREFLIGHT_CHECK=true diff --git a/examples/react_advanced_demo/package-lock.json b/examples/react_advanced_demo/package-lock.json index b975224..f4aef74 100644 --- a/examples/react_advanced_demo/package-lock.json +++ b/examples/react_advanced_demo/package-lock.json @@ -7677,101 +7677,7 @@ } }, "jsoneditor": { - "version": "file:../..", - "requires": { - "ajv": "6.10.2", - "brace": "0.11.1", - "javascript-natural-sort": "0.7.1", - "jmespath": "0.15.0", - "json-source-map": "0.4.0", - "mobius1-selectr": "2.4.13", - "picomodal": "3.0.0", - "vanilla-picker": "2.9.1" - }, - "dependencies": { - "@sphinxxxx/color-conversion": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/@sphinxxxx/color-conversion/-/color-conversion-2.2.2.tgz", - "integrity": "sha512-XExJS3cLqgrmNBIP3bBw6+1oQ1ksGjFh0+oClDKFYpCCqx/hlqwWO5KO/S63fzUo67SxI9dMrF0y5T/Ey7h8Zw==" - }, - "ajv": { - "version": "6.10.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", - "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", - "requires": { - "fast-deep-equal": "^2.0.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "brace": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/brace/-/brace-0.11.1.tgz", - "integrity": "sha1-SJb8ydVE7vRfS7dmDbMg07N5/lg=" - }, - "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" - }, - "fast-json-stable-stringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" - }, - "javascript-natural-sort": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz", - "integrity": "sha1-+eIwPUUH9tdDVac2ZNFED7Wg71k=" - }, - "jmespath": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", - "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=" - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" - }, - "json-source-map": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/json-source-map/-/json-source-map-0.4.0.tgz", - "integrity": "sha1-7qg3/jzi8r/VsTaHd5QGNUQjw1U=" - }, - "mobius1-selectr": { - "version": "2.4.13", - "resolved": "https://registry.npmjs.org/mobius1-selectr/-/mobius1-selectr-2.4.13.tgz", - "integrity": "sha512-Mk9qDrvU44UUL0EBhbAA1phfQZ7aMZPjwtL7wkpiBzGh8dETGqfsh50mWoX9EkjDlkONlErWXArHCKfoxVg0Bw==" - }, - "picomodal": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/picomodal/-/picomodal-3.0.0.tgz", - "integrity": "sha1-+s0w9PvzSoCcHgTqUl8ATzmcC4I=" - }, - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" - }, - "uri-js": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", - "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", - "requires": { - "punycode": "^2.1.0" - } - }, - "vanilla-picker": { - "version": "2.9.1", - "resolved": "https://registry.npmjs.org/vanilla-picker/-/vanilla-picker-2.9.1.tgz", - "integrity": "sha512-JcXwFwclAdfJ1eJWeiLdM9sYMPfmrUEqzCOeO74QaAgdZpe8VyBldSlimZfLP8OefBXWGH+wL80QwhP2TSv0eg==", - "requires": { - "@sphinxxxx/color-conversion": "^2.2.1" - } - } - } + "version": "file:../.." }, "jsonfile": { "version": "4.0.0", diff --git a/examples/react_advanced_demo/package.json b/examples/react_advanced_demo/package.json index bf2f4c5..3ba430c 100644 --- a/examples/react_advanced_demo/package.json +++ b/examples/react_advanced_demo/package.json @@ -14,5 +14,17 @@ "build": "react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] } } diff --git a/examples/react_advanced_demo/src/JSONEditorReact.js b/examples/react_advanced_demo/src/JSONEditorReact.js index d135985..5cd911a 100644 --- a/examples/react_advanced_demo/src/JSONEditorReact.js +++ b/examples/react_advanced_demo/src/JSONEditorReact.js @@ -27,27 +27,27 @@ export default class JSONEditorReact extends Component { this.schemaRefs = cloneDeep(this.props.schemaRefs); } - componentWillUpdate(nextProps, nextState) { - if ('json' in nextProps) { - this.jsoneditor.update(nextProps.json); + componentDidUpdate() { + if ('json' in this.props) { + this.jsoneditor.update(this.props.json); } - if ('text' in nextProps) { - this.jsoneditor.updateText(nextProps.text); + if ('text' in this.props) { + this.jsoneditor.updateText(this.props.text); } - if ('mode' in nextProps) { - this.jsoneditor.setMode(nextProps.mode); + if ('mode' in this.props) { + this.jsoneditor.setMode(this.props.mode); } // store a clone of the schema to keep track on when it actually changes. // (When using a PureComponent all of this would be redundant) - const schemaChanged = !isEqual(nextProps.schema, this.schema); - const schemaRefsChanged = !isEqual(nextProps.schemaRefs, this.schemaRefs); + const schemaChanged = !isEqual(this.props.schema, this.schema); + const schemaRefsChanged = !isEqual(this.props.schemaRefs, this.schemaRefs); if (schemaChanged || schemaRefsChanged) { - this.schema = cloneDeep(nextProps.schema); - this.schemaRefs = cloneDeep(nextProps.schemaRefs); - this.jsoneditor.setSchema(nextProps.schema, nextProps.schemaRefs); + this.schema = cloneDeep(this.props.schema); + this.schemaRefs = cloneDeep(this.props.schemaRefs); + this.jsoneditor.setSchema(this.props.schema, this.props.schemaRefs); } } diff --git a/examples/react_demo/.env b/examples/react_demo/.env new file mode 100644 index 0000000..6f809cc --- /dev/null +++ b/examples/react_demo/.env @@ -0,0 +1 @@ +SKIP_PREFLIGHT_CHECK=true diff --git a/examples/react_demo/package-lock.json b/examples/react_demo/package-lock.json index 31c37c1..5a9a693 100644 --- a/examples/react_demo/package-lock.json +++ b/examples/react_demo/package-lock.json @@ -7677,101 +7677,7 @@ } }, "jsoneditor": { - "version": "file:../..", - "requires": { - "ajv": "6.10.2", - "brace": "0.11.1", - "javascript-natural-sort": "0.7.1", - "jmespath": "0.15.0", - "json-source-map": "0.4.0", - "mobius1-selectr": "2.4.13", - "picomodal": "3.0.0", - "vanilla-picker": "2.9.1" - }, - "dependencies": { - "@sphinxxxx/color-conversion": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/@sphinxxxx/color-conversion/-/color-conversion-2.2.2.tgz", - "integrity": "sha512-XExJS3cLqgrmNBIP3bBw6+1oQ1ksGjFh0+oClDKFYpCCqx/hlqwWO5KO/S63fzUo67SxI9dMrF0y5T/Ey7h8Zw==" - }, - "ajv": { - "version": "6.10.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", - "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", - "requires": { - "fast-deep-equal": "^2.0.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "brace": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/brace/-/brace-0.11.1.tgz", - "integrity": "sha1-SJb8ydVE7vRfS7dmDbMg07N5/lg=" - }, - "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" - }, - "fast-json-stable-stringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" - }, - "javascript-natural-sort": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz", - "integrity": "sha1-+eIwPUUH9tdDVac2ZNFED7Wg71k=" - }, - "jmespath": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", - "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=" - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" - }, - "json-source-map": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/json-source-map/-/json-source-map-0.4.0.tgz", - "integrity": "sha1-7qg3/jzi8r/VsTaHd5QGNUQjw1U=" - }, - "mobius1-selectr": { - "version": "2.4.13", - "resolved": "https://registry.npmjs.org/mobius1-selectr/-/mobius1-selectr-2.4.13.tgz", - "integrity": "sha512-Mk9qDrvU44UUL0EBhbAA1phfQZ7aMZPjwtL7wkpiBzGh8dETGqfsh50mWoX9EkjDlkONlErWXArHCKfoxVg0Bw==" - }, - "picomodal": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/picomodal/-/picomodal-3.0.0.tgz", - "integrity": "sha1-+s0w9PvzSoCcHgTqUl8ATzmcC4I=" - }, - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" - }, - "uri-js": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", - "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", - "requires": { - "punycode": "^2.1.0" - } - }, - "vanilla-picker": { - "version": "2.9.1", - "resolved": "https://registry.npmjs.org/vanilla-picker/-/vanilla-picker-2.9.1.tgz", - "integrity": "sha512-JcXwFwclAdfJ1eJWeiLdM9sYMPfmrUEqzCOeO74QaAgdZpe8VyBldSlimZfLP8OefBXWGH+wL80QwhP2TSv0eg==", - "requires": { - "@sphinxxxx/color-conversion": "^2.2.1" - } - } - } + "version": "file:../.." }, "jsonfile": { "version": "4.0.0", diff --git a/examples/react_demo/package.json b/examples/react_demo/package.json index e3bcb18..5258902 100644 --- a/examples/react_demo/package.json +++ b/examples/react_demo/package.json @@ -13,5 +13,17 @@ "build": "react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] } } diff --git a/examples/react_demo/src/JSONEditorDemo.js b/examples/react_demo/src/JSONEditorDemo.js index d79e291..34061cd 100644 --- a/examples/react_demo/src/JSONEditorDemo.js +++ b/examples/react_demo/src/JSONEditorDemo.js @@ -22,8 +22,8 @@ export default class JSONEditorDemo extends Component { } } - componentWillUpdate(nextProps, nextState) { - this.jsoneditor.update(nextProps.json); + componentDidUpdate() { + this.jsoneditor.update(this.props.json); } render() {