Some fixes and updates in examples

This commit is contained in:
jos 2019-09-01 16:37:57 +02:00
parent 9d018c408a
commit ceb08fe13d
9 changed files with 47 additions and 205 deletions

View File

@ -38,7 +38,11 @@
getOptions: function (text, path, input, editor) { getOptions: function (text, path, input, editor) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
const options = extractUniqueWords(editor.get()) const options = extractUniqueWords(editor.get())
if (options.length > 0) resolve(options) else reject() if (options.length > 0) {
resolve(options)
} else {
reject()
}
}) })
} }
} }

View File

@ -0,0 +1 @@
SKIP_PREFLIGHT_CHECK=true

View File

@ -7677,101 +7677,7 @@
} }
}, },
"jsoneditor": { "jsoneditor": {
"version": "file:../..", "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"
}
}
}
}, },
"jsonfile": { "jsonfile": {
"version": "4.0.0", "version": "4.0.0",

View File

@ -14,5 +14,17 @@
"build": "react-scripts build", "build": "react-scripts build",
"test": "react-scripts test --env=jsdom", "test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject" "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"
]
} }
} }

View File

@ -27,27 +27,27 @@ export default class JSONEditorReact extends Component {
this.schemaRefs = cloneDeep(this.props.schemaRefs); this.schemaRefs = cloneDeep(this.props.schemaRefs);
} }
componentWillUpdate(nextProps, nextState) { componentDidUpdate() {
if ('json' in nextProps) { if ('json' in this.props) {
this.jsoneditor.update(nextProps.json); this.jsoneditor.update(this.props.json);
} }
if ('text' in nextProps) { if ('text' in this.props) {
this.jsoneditor.updateText(nextProps.text); this.jsoneditor.updateText(this.props.text);
} }
if ('mode' in nextProps) { if ('mode' in this.props) {
this.jsoneditor.setMode(nextProps.mode); this.jsoneditor.setMode(this.props.mode);
} }
// store a clone of the schema to keep track on when it actually changes. // store a clone of the schema to keep track on when it actually changes.
// (When using a PureComponent all of this would be redundant) // (When using a PureComponent all of this would be redundant)
const schemaChanged = !isEqual(nextProps.schema, this.schema); const schemaChanged = !isEqual(this.props.schema, this.schema);
const schemaRefsChanged = !isEqual(nextProps.schemaRefs, this.schemaRefs); const schemaRefsChanged = !isEqual(this.props.schemaRefs, this.schemaRefs);
if (schemaChanged || schemaRefsChanged) { if (schemaChanged || schemaRefsChanged) {
this.schema = cloneDeep(nextProps.schema); this.schema = cloneDeep(this.props.schema);
this.schemaRefs = cloneDeep(nextProps.schemaRefs); this.schemaRefs = cloneDeep(this.props.schemaRefs);
this.jsoneditor.setSchema(nextProps.schema, nextProps.schemaRefs); this.jsoneditor.setSchema(this.props.schema, this.props.schemaRefs);
} }
} }

1
examples/react_demo/.env Normal file
View File

@ -0,0 +1 @@
SKIP_PREFLIGHT_CHECK=true

View File

@ -7677,101 +7677,7 @@
} }
}, },
"jsoneditor": { "jsoneditor": {
"version": "file:../..", "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"
}
}
}
}, },
"jsonfile": { "jsonfile": {
"version": "4.0.0", "version": "4.0.0",

View File

@ -13,5 +13,17 @@
"build": "react-scripts build", "build": "react-scripts build",
"test": "react-scripts test --env=jsdom", "test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject" "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"
]
} }
} }

View File

@ -22,8 +22,8 @@ export default class JSONEditorDemo extends Component {
} }
} }
componentWillUpdate(nextProps, nextState) { componentDidUpdate() {
this.jsoneditor.update(nextProps.json); this.jsoneditor.update(this.props.json);
} }
render() { render() {