@@ -71,7 +71,7 @@ export default {
7171 } ,
7272
7373 isValueEditable ( ) {
74- const type = this . valueType
74+ const type = this . interpretedValueType
7575 return this . isEditable &&
7676 (
7777 type === 'null' ||
@@ -83,7 +83,7 @@ export default {
8383 } ,
8484
8585 isSubfieldsEditable ( ) {
86- return this . isEditable && ( this . valueType === 'array' || this . valueType === 'plain-object' )
86+ return this . isEditable && ( this . interpretedValueType === 'array' || this . interpretedValueType === 'plain-object' )
8787 } ,
8888
8989 valueValid ( ) {
@@ -145,7 +145,12 @@ export default {
145145 if ( currentEditedField && currentEditedField !== this ) {
146146 currentEditedField . cancelEdit ( )
147147 }
148- this . editedValue = this . transformSpecialTokens ( JSON . stringify ( this . field . value ) , true )
148+ let valueToEdit = this . field . value
149+ // Edit custom value (we don't want to edit the whole custom value data object)
150+ if ( this . valueType === 'custom' ) {
151+ valueToEdit = valueToEdit . _custom . value
152+ }
153+ this . editedValue = this . transformSpecialTokens ( JSON . stringify ( valueToEdit ) , true )
149154 this . editedKey = this . field . key
150155 this . editing = true
151156 currentEditedField = this
@@ -166,7 +171,16 @@ export default {
166171 submitEdit ( ) {
167172 if ( this . editValid ) {
168173 this . editing = false
169- const value = this . transformSpecialTokens ( this . editedValue , false )
174+ let value = this . transformSpecialTokens ( this . editedValue , false )
175+ // We need to send the entire custom value data object
176+ if ( this . valueType === 'custom' ) {
177+ value = JSON . stringify ( {
178+ _custom : {
179+ ...this . field . value . _custom ,
180+ value : JSON . parse ( value ) , // Input
181+ } ,
182+ } )
183+ }
170184 const newKey = this . editedKey !== this . field . key ? this . editedKey : undefined
171185 this . sendEdit ( { value, newKey } )
172186 this . $emit ( 'submit-edit' )
@@ -212,9 +226,9 @@ export default {
212226
213227 addNewValue ( ) {
214228 let key
215- if ( this . valueType === 'array' ) {
229+ if ( this . interpretedValueType === 'array' ) {
216230 key = this . field . value . length
217- } else if ( this . valueType === 'plain-object' ) {
231+ } else if ( this . interpretedValueType === 'plain-object' ) {
218232 let i = 1
219233 while ( this . field . value . hasOwnProperty ( key = `prop${ i } ` ) ) i ++
220234 }
0 commit comments