diff --git a/src/app/App.ts b/src/app/App.ts index 540d604a..06fa3b70 100644 --- a/src/app/App.ts +++ b/src/app/App.ts @@ -61,6 +61,7 @@ export const App = { model: new Property(null), jsonOutput: new Property(''), errorsVisible: new Property(false), + treeMinimized: new Property(false), jsonError: new Property(null), preview: new Property(null) .watch(p => Tracker.dimPreview(p?.getName() ?? 'none')), diff --git a/src/app/components/Octicon.ts b/src/app/components/Octicon.ts index 877a0c36..8100f9e3 100644 --- a/src/app/components/Octicon.ts +++ b/src/app/components/Octicon.ts @@ -10,6 +10,7 @@ export const Octicon = { download: '', eye: '', eye_closed: '', + fold: '', gear: '', globe: '', history: '', diff --git a/src/app/components/panels/TreePanel.ts b/src/app/components/panels/TreePanel.ts index 5bf95899..e01315d5 100644 --- a/src/app/components/panels/TreePanel.ts +++ b/src/app/components/panels/TreePanel.ts @@ -36,6 +36,9 @@ export const TreePanel = (view: View, model: DataModel) => { view.mount(el, getContent(), false) } }) + App.treeMinimized.watch(() => { + view.mount(el, getContent(), false) + }) model.addListener({ invalidated() { view.mount(el, getContent(), false) @@ -47,6 +50,11 @@ export const TreePanel = (view: View, model: DataModel) => { }) return `
+
+ ${Octicon.fold} +
${Octicon.tag} diff --git a/src/app/hooks/renderHtml.ts b/src/app/hooks/renderHtml.ts index 09c64148..596320e5 100644 --- a/src/app/hooks/renderHtml.ts +++ b/src/app/hooks/renderHtml.ts @@ -176,7 +176,9 @@ export const renderHtml: Hook<[any, Mounter], [string, string, string]> = { let body = '' if (typeof value === 'object' && value !== undefined && (!(node.optional() && value === undefined))) { const activeFields = getActiveFields(path) - body = Object.keys(activeFields) + body = (App.treeMinimized.get() + ? Object.keys(activeFields).filter(k => value[k] !== undefined) + : Object.keys(activeFields)) .filter(k => activeFields[k].enabled(path)) .map(k => { const field = activeFields[k] diff --git a/src/config.json b/src/config.json index 2b2a94f5..383f6905 100644 --- a/src/config.json +++ b/src/config.json @@ -180,6 +180,7 @@ { "id": "loot_table", "dynamic": true }, { "id": "mob_effect" }, { "id": "pos_rule_test", "minVersion": "1.16" }, + { "id": "potion", "minVersion": "1.15" }, { "id": "predicate", "dynamic": true }, { "id": "recipe", "dynamic": true }, { "id": "rule_test", "minVersion": "1.16" }, diff --git a/src/locales/en.json b/src/locales/en.json index 10373d8e..0d7cca55 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -9,6 +9,7 @@ "item-modifier": "Item Modifier", "language": "Language", "loot-table": "Loot Table", + "minimize": "Minimize", "predicate": "Predicate", "redo": "Redo", "reset": "Reset",