@@ -45,15 +45,9 @@ const fieldsCount = computed(() => {
45
45
else
46
46
return 0
47
47
})
48
-
48
+ const normalizedPath = computed (() => props . data . path || [ props . data . key ])
49
49
// normalized display key
50
- const normalizedDisplayedKey = computed (() => {
51
- const key = props .data .key
52
- const lastDotIndex = key .lastIndexOf (' .' )
53
- if (lastDotIndex === - 1 )
54
- return key
55
- return key .slice (lastDotIndex + 1 )
56
- })
50
+ const normalizedDisplayedKey = computed (() => normalizedPath .value [normalizedPath .value .length - 1 ])
57
51
58
52
// normalized display value
59
53
const normalizedDisplayedValue = computed (() => {
@@ -90,7 +84,8 @@ const normalizedDisplayedChildren = computed(() => {
90
84
if (isArray (value )) {
91
85
const sliced = value .slice (0 , limit .value )
92
86
return sliced .map ((item , i ) => ({
93
- key: ` ${props .data .key }.${i } ` ,
87
+ key: i .toString (),
88
+ path: [... normalizedPath .value , i .toString ()],
94
89
value: item ,
95
90
... inherit ,
96
91
editable: props .data .editable && ! isUneditableType ,
@@ -99,7 +94,8 @@ const normalizedDisplayedChildren = computed(() => {
99
94
}
100
95
else if (isObject (value )) {
101
96
displayedChildren = Object .keys (value ).slice (0 , limit .value ).map (key => ({
102
- key: ` ${props .data .key }.${key } ` ,
97
+ key ,
98
+ path: [... normalizedPath .value , key ],
103
99
value: value [key ],
104
100
... inherit ,
105
101
editable: props .data .editable && ! isUneditableType ,
@@ -137,7 +133,7 @@ watch(() => editing.value, (v) => {
137
133
function submit() {
138
134
const data = props .data
139
135
editInspectorState ({
140
- path: data . key . split ( ' . ' ) ,
136
+ path: normalizedPath . value ,
141
137
inspectorId: state .value .inspectorId ,
142
138
type: data .stateType ! ,
143
139
nodeId ,
@@ -163,10 +159,8 @@ function addNewProp(type: EditorAddNewPropType) {
163
159
164
160
function submitDrafting() {
165
161
const data = props .data
166
- const path = data .key .split (' .' )
167
- path .push (draftingNewProp .value .key )
168
162
editInspectorState ({
169
- path ,
163
+ path: [ ... normalizedPath . value , draftingNewProp . value . key ] ,
170
164
inspectorId: state .value .inspectorId ,
171
165
type: data .stateType ! ,
172
166
nodeId ,
0 commit comments