diff --git a/eveai_app/templates/eveai_json_editor.html b/eveai_app/templates/eveai_json_editor.html index b457a6d..b0c4fba 100644 --- a/eveai_app/templates/eveai_json_editor.html +++ b/eveai_app/templates/eveai_json_editor.html @@ -40,10 +40,10 @@ window.EveAI.JsonEditors = { mainMenuBar: options.mainMenuBar !== undefined ? options.mainMenuBar : true, navigationBar: options.navigationBar !== undefined ? options.navigationBar : false, statusBar: options.statusBar !== undefined ? options.statusBar : !isReadOnly, - onChange: (updatedContent, previousContent, { contentErrors, patchResult }) => { - // content is an object { json: unknown } | { text: string } - console.log('onChange', { updatedContent, previousContent, contentErrors, patchResult }) - } + onChange: options.onChange || ((updatedContent, previousContent, { contentErrors, patchResult }) => { + // Default onChange behavior - alleen loggen + console.log('onChange', { updatedContent, previousContent, contentErrors, patchResult }); + }) }; console.log('EditorProps', editorProps); @@ -107,13 +107,51 @@ document.addEventListener('DOMContentLoaded', function() { window.EveAI.JsonEditors.initialize(containerId, data, { mode: isReadOnly ? 'preview' : 'tree', readOnly: isReadOnly, - onChangeText: isReadOnly ? undefined : (jsonString) => { textarea.value = jsonString; } + onChange: isReadOnly ? undefined : (updatedContent, previousContent, { contentErrors, patchResult }) => { + // Automatische synchronisatie naar textarea bij elke wijziging + if (updatedContent.json !== undefined) { + textarea.value = JSON.stringify(updatedContent.json, null, 2); + } else if (updatedContent.text !== undefined) { + textarea.value = updatedContent.text; + } + console.log('Textarea automatisch bijgewerkt via onChange'); + } }); } catch (e) { console.error('Error parsing initial JSON for .json-editor:', e); container.innerHTML = `