diff --git a/vmfedit/src/main/java/eu/mihosoft/vmf/vmfedit/JsonEditorAppController.java b/vmfedit/src/main/java/eu/mihosoft/vmf/vmfedit/JsonEditorAppController.java index 0d8841b..0127d94 100644 --- a/vmfedit/src/main/java/eu/mihosoft/vmf/vmfedit/JsonEditorAppController.java +++ b/vmfedit/src/main/java/eu/mihosoft/vmf/vmfedit/JsonEditorAppController.java @@ -130,6 +130,9 @@ private void handleLoadDocument() { jsonEditorControl.setSchema(null); } + // remove schema from content + + jsonEditorControl.setValue(content); currentFile = file; diff --git a/vmfedit/src/main/resources/eu/mihosoft/vmf/vmfedit/json-editor.html b/vmfedit/src/main/resources/eu/mihosoft/vmf/vmfedit/json-editor.html index 8c387a6..e5f6408 100644 --- a/vmfedit/src/main/resources/eu/mihosoft/vmf/vmfedit/json-editor.html +++ b/vmfedit/src/main/resources/eu/mihosoft/vmf/vmfedit/json-editor.html @@ -65,19 +65,40 @@ currentValue = editor.getValue(); editor.destroy(); } + + const editorSchema = { + ...schema, + properties: { + ...(schema.properties || {}), + $schema: { + type: 'string', + options: { + hidden: true + }, + // readOnly: true + } + } + }; + editor = new JSONEditor(document.getElementById('editor_holder'), { - schema: schema, + schema: editorSchema, theme: 'bootstrap3', iconlib: 'fontawesome5', disable_edit_json: true, - no_additional_properties: true, + no_additional_properties: false, prompt_before_delete: false, required_by_default: true, + exclude_attributes: ['$schema'], // Explicitly exclude $schema }); // Add change listener editor.on('change', function() { + // Preserve $schema if it exists in currentValue + if (currentValue.$schema) { + value.$schema = currentValue.$schema; + } + // add a div to show a timestamp, keep editor in the editor_log div // var log = document.getElementById('editor_log'); // var logEntry = document.createElement('div');