Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
$(document).ready( ()=> {
/////////////////////////////////////////////////////////////
// Sets up config editor
//
/////////////////////////////////////////////////////////////
var editor = new JSONEditor($('.test-config')[ 0 ], {
search: false
})
var defaultTestConfig = {
dumpParticles: false,
maxParticles: 1000,
timeStep: 0.1,
nbSteps: 5000,
emitters: [ {
id: 0,
position: {
x: 0,
y: 0,
z: 0
},
emissionRate: 4000,
done.textContent = "Apply";
done.title = "Upload the new privacy policy and refresh all views.";
this.privacyEditor.appendChild(done);
const cancel = document.createElement("button");
cancel.textContent = "Cancel";
cancel.title = "Do not update the privacy policy.";
this.privacyEditor.appendChild(cancel);
const save = document.createElement("button");
save.textContent = "Save";
save.title = "Write the privacy policy to disk, overwriting the existing policy on disk.";
this.privacyEditor.appendChild(save);
const editOptions: JSONEditorOptions = { mode: "text", mainMenuBar: false, statusBar: false };
const editor = new JSONEditor(this.privacyEditor, editOptions, "{}");
editor.set(this.privacySchema);
const destroy = () => {
this.privacyEditor.style.display = "none";
editor.destroy();
removeAllChildren(this.privacyEditor);
};
done.onclick = () => {
try {
const json = editor.getText(); // throws when text is invalid
this.privacySchema = JSON.parse(json);
this.uploadPrivacy(json);
destroy();
} catch (exception) {
this.loadMenuPage.reportError(exception.toString());
}
};
componentDidMount () {
// copy all properties into options for the editor
// (except the properties for the JSONEditorReact component itself)
const options = Object.assign({}, this.props);
delete options.json;
delete options.text;
this.jsoneditor = new JSONEditor(this.container, options);
if ('json' in this.props) {
this.jsoneditor.set(this.props.json);
}
if ('text' in this.props) {
this.jsoneditor.setText(this.props.text);
}
this.schema = cloneDeep(this.props.schema);
this.schemaRefs = cloneDeep(this.props.schemaRefs);
}
initEditor(el, options, json){
this.$options.editor = new JSONEditor(el, options, json)
}
}
name: 'foo',
schema: {},
schemaRefs: { "otherSchema": {}},
search: false,
indentation: 2,
theme: 'default'
};
options = {
onEditable(node: Node) {
return {field: true, value: false};
}
};
let jsonEditor: JSONEditor;
jsonEditor = new JSONEditor(document.body);
jsonEditor = new JSONEditor(document.body, {});
jsonEditor = new JSONEditor(document.body, options, {foo: 'bar'});
jsonEditor.collapseAll();
jsonEditor.destroy();
jsonEditor.expandAll();
jsonEditor.focus();
jsonEditor.set({foo: 'bar'});
jsonEditor.setMode('text');
jsonEditor.setName('foo');
jsonEditor.setName();
jsonEditor.setSchema({});
jsonEditor.setText('{foo: 1}');
jsonEditor.format();
jsonEditor.compact();
jsonEditor.repair();
$(document).ready( ()=> {
var editor = new JSONEditor($('.test-config')[ 0 ], {
search: false
})
var defaultTestConfig = {
dumpParticles: false,
maxParticles: 1000,
timeStep: 0.1,
nbSteps: 5000,
emitters: [ {
id: 0,
position: {
x: 0,
y: 0,
z: 0
},
emissionRate: 4000,
private initEditor() {
this.editor = new JSONEditor(this.rootElement.nativeElement, this.options, this.defaultBody);
this.subscriptions = this.eventToObservable('change').subscribe(event => {
const value = this.valid();
if (value) {
this.bodyChange.emit(value);
}
});
}
const options = {
name: this.name,
navigationBar: false,
search: false,
mode: this.mode,
modes: this.modes,
onEditable: (node) => !this.readonly,
onChange: () => {
if (this.$jsoneditor) {
const json = this.$jsoneditor.get()
this.$emit('input', json)
}
},
templates: this.templates
}
this.$jsoneditor = new JSONEditor(this.$el, options)
this.$jsoneditor.set(this.value || {})
this.$jsoneditor.expandAll()
},
beforeDestroy () {
ngAfterViewInit() {
let touched = false;
this.editor = new JSONEditor(this.editorEl.nativeElement, {
mode: 'tree',
modes: ['tree', 'code', 'view', 'text'],
onChange: () => {
if (!touched) {
touched = true;
this.onTouch();
}
let value;
try {
value = this.editor.get();
} catch (e) {}
if (value) {
this.onChange(value);
useEffect(() => {
jsoneditor.current = new JSONEditor(container.current, {
mode,
onChangeJSON: (...args) => onChangeJSONRef.current(...args),
history: false
});
return () => {
jsoneditor.current.destroy();
};
}, [mode]);
useEffect(() => {