export class Editor {
	constructor(schema) {
		this.schema = schema
		this.editor = null
	}

	render(data) {
		const div = document.createElement('div')
		this.editor = new JSONEditor(div, {
			theme: 'spectre',
			iconlib: 'spectre',
			disable_collapse: true,
			disable_properties: true,
			schema: this.schema,
		});

		this.editor.on('ready', () => {
			this.editor.setValue(data)
		})

		return div
	}

	data() {
		return this.editor.getValue()
	}
}
