Skip to content

Commit

Permalink
- schema is now hidden in editor if present, but other additional par…
Browse files Browse the repository at this point in the history
…ameters besides the schema are allowed
  • Loading branch information
miho committed Jan 23, 2025
1 parent 2a05f6b commit 4e773fd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ private void handleLoadDocument() {
jsonEditorControl.setSchema(null);
}

// remove schema from content


jsonEditorControl.setValue(content);

currentFile = file;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 4e773fd

Please sign in to comment.