Skip to content

Commit 842d9e3

Browse files
add max level to json tree view
1 parent b0839ef commit 842d9e3

File tree

1 file changed

+5
-0
lines changed
  • editor-packages/editor-devtools/components/visualization/json-visualization

1 file changed

+5
-0
lines changed

editor-packages/editor-devtools/components/visualization/json-visualization/json-tree.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ export function JsonTree({
4242
theme = monokai,
4343
backgroundColor,
4444
sortkeys = false,
45+
expandMaxLevel = 5,
4546
omitkeys = [],
4647
}: {
4748
data: any;
4849
hideRoot?: boolean;
4950
expandRoot?: boolean;
5051
expandParent?: boolean;
52+
expandMaxLevel?: number;
5153
theme?: Theme;
5254
backgroundColor?: React.CSSProperties["backgroundColor"];
5355
sortkeys?: ReadonlyArray<string> | boolean;
@@ -100,6 +102,9 @@ export function JsonTree({
100102
if (level === 0) {
101103
return expandRoot;
102104
}
105+
if (expandMaxLevel > 0 && level > expandMaxLevel) {
106+
return false;
107+
}
103108
if (keypath[keypath.length - 1] === "parent") {
104109
return expandParent;
105110
}

0 commit comments

Comments
 (0)