November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi,
I never tried this with IList but you can try extending valid elements attributes extended_valid_elements
for XhtmlString property using TinyMCE configuration and add your custom data attributes as valid elements
.AddSetting("extended_valid_elements", // List of valid elements in the editor, this includes scritps (for js), iframe, and several others. What you send inside the [] are the allowed inner elements for that tag
"script[language|type|src],iframe[src|alt|title|width|height|align|name|style],picture,source[srcset|media],a[id|href|target|onclick|class],span[*],div[*]")
Do you get the same behavior if you add the following attributes to your XhtmlContent property?
public class ListModel
{
[JsonProperty]
[JsonConverter(typeof(XhtmlStringJsonConverter))]
public XhtmlString XhtmlContent { get;set; }
}
I'm on version 11.20.11
I have a model that looks like this:
And a property
If I add a new item to the collection, and add a block to the text field, it gets saved as <div data-contentlink="31223" data-classid="36f4349b-8093-492b-b616-05d8964e4c89" class="epi-contentfragment" contenteditable="false">Test</div> in the list.
This stays fine until i publish the page. When I publish, all attributes but the class are removed from the div, making the block invalid. Is there a way to prevent this?
I would rewrite it to use a contentarea instead, but this is on an existing project, so I don't want to lose data.