Forum Discussion
Migrating HTML to Modern Pages - Looks great until page is edited, then content is lost
- Aug 02, 2018
The easiest way to understand what's valid HTML is to create a piece of text using all the layout and formatting options you need. Once you've that you can grab the page list item and look at the canvascontent1 field to obtain the generated HTML. You'll see that only a limited number of styles are supported and fixed set of classes for color and size information. Anything else you use can be initially displayed but will be lost during edit.
The easiest way to understand what's valid HTML is to create a piece of text using all the layout and formatting options you need. Once you've that you can grab the page list item and look at the canvascontent1 field to obtain the generated HTML. You'll see that only a limited number of styles are supported and fixed set of classes for color and size information. Anything else you use can be initially displayed but will be lost during edit.
Thanks, that helps. This will be tedious.
- Paul HermanyOct 18, 2018Copper Contributor
This is an older thread, but if anyone is still here, there seems to be a bug in SharePoint Modern Pages where table content is added through the UI. We added a small table of content to a page, saved it, published it, then when we went back to edit the content disappeared.
In other words, it might not just be a valid/invalid HTML thing. There might be a bigger issue here.
- Kirk LiemohnOct 18, 2018Brass Contributor
If you are using a "<table>" element, then you need to add wrap it with additional divs that have "canvasRteResponsiveTable" and "tableWrapper" classes. See my comment further above for more details.
- Paul HermanyOct 18, 2018Copper Contributor
Thanks for the reply! We are editing the content using the WYSIWYG editor, not through HTML, so adding an additional div is not relevant in this particular case. Whatever HTML is being generated by the OOTB editor is not able to be rendered in edit mode. As a result, switching to edit mode and saving the page with no changes will result in lost content.