@@ -218,11 +218,31 @@ public function getInputHtml($value, ElementInterface $element = null): string
218218 '" ' . $ view ->namespaceInputName ($ this ->handle ) . '" ' .
219219 '); ' );
220220
221+ $ rawNodes = $ value ->getRawNodes ();
222+
223+ // Normalise the content a little to handle special characters.
224+ // TODO: This is temporary, but helps transition people with issues _now_ but is
225+ // handled in `Nodes::serializeContent()` and `StringHelper::htmlEncode($text, ENT_NOQUOTES)`
226+ foreach ($ rawNodes as $ rawNodeKey => $ rawNode ) {
227+ $ content = $ rawNode ['content ' ] ?? [];
228+
229+ foreach ($ content as $ contentKey => $ block ) {
230+ // We only want to modify simple nodes and their text content, not complicated
231+ // nodes like VizyBlocks, which could mess things up as fields control their content.
232+ $ text = $ block ['text ' ] ?? '' ;
233+
234+ // Decode some HTML entities
235+ $ text = StringHelper::htmlDecode ($ text );
236+
237+ $ rawNodes [$ rawNodeKey ]['content ' ][$ contentKey ]['text ' ] = $ text ;
238+ }
239+ }
240+
221241 return $ view ->renderTemplate ('vizy/field/input ' , [
222242 'id ' => $ id ,
223243 'name ' => $ this ->handle ,
224244 'field ' => $ this ,
225- 'value ' => Json::encode ($ value -> getRawNodes () , JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_QUOT ),
245+ 'value ' => Json::encode ($ rawNodes , JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_QUOT ),
226246 'settings ' => Json::encode ($ settings , JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_QUOT ),
227247 ]);
228248 }
0 commit comments