File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ plugins: [
112
112
| ------------------------ | ------ | --------------------------------------------------------------------------------------- | ---------------------------------------------- | -------- |
113
113
| data | normal | JSON data | JSON object | - |
114
114
| deep | normal | Data depth, data larger than this depth will not be expanded | number | Infinity |
115
+ | deepCollapseChildren | normal | Whether children collapsed by ` deep ` prop should also be collapsed | boolean | false |
115
116
| showLength | normal | Whether to show the length when closed | boolean | false |
116
117
| showLine | normal | Whether to show the line | boolean | true |
117
118
| showDoubleQuotes | normal | Whether to show doublequotes on key | boolean | true |
Original file line number Diff line number Diff line change 34
34
<option :value =" 4" >4</option >
35
35
</select >
36
36
</div >
37
+ <div >
38
+ <label >deepCollapseChildren</label >
39
+ <input v-model =" deepCollapseChildren" type =" checkbox" />
40
+ </div >
37
41
</div >
38
42
</div >
39
43
<div class =" block" >
40
44
<h3 >vue-json-pretty:</h3 >
41
45
<vue-json-pretty
42
46
:data =" state.data"
43
47
:deep =" state.deep"
48
+ :deepCollapseChildren =" deepCollapseChildren"
44
49
:show-double-quotes =" state.showDoubleQuotes"
45
50
:show-length =" state.showLength"
46
51
:show-line =" state.showLine"
@@ -96,6 +101,7 @@ export default defineComponent({
96
101
collapsedOnClickBrackets: true ,
97
102
useCustomLinkFormatter: false ,
98
103
deep: 3 ,
104
+ deepCollapseChildren: false ,
99
105
});
100
106
101
107
const customLinkFormatter = (data , key , path , defaultFormatted ) => {
Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ export default defineComponent({
20
20
type : Number ,
21
21
default : Infinity ,
22
22
} ,
23
+ deepCollapseChildren : {
24
+ type : Boolean ,
25
+ default : false ,
26
+ } ,
23
27
// Data root path.
24
28
path : {
25
29
type : String ,
@@ -57,9 +61,12 @@ export default defineComponent({
57
61
translateY : 0 ,
58
62
visibleData : null as FlatDataType | null ,
59
63
hiddenPaths : jsonFlatten ( props . data , props . path ) . reduce ( ( acc , item ) => {
64
+ const depthComparison = this . deepCollapseChildren
65
+ ? item . level >= this . deep
66
+ : item . level === this . deep ;
60
67
if (
61
68
( item . type === 'objectStart' || item . type === 'arrayStart' ) &&
62
- item . level === props . deep
69
+ depthComparison
63
70
) {
64
71
return {
65
72
...acc ,
You can’t perform that action at this time.
0 commit comments