I have responded to your support ticket, but wanted to place some of that response here for others to be made aware.
Actually this isnât a bug just a feature limitation. Keep in mind that the custom code embed within the rich text element is a new feature for this year. What you see is version 1. What will be seen in version 2 is still being discussed with no timeline for a release at this time.
We are migrating our wordpress blogs to webflow CMS. We wrote a migration script to wrap our custom code inside of a <div class='webflow-emebed> before using the API to create the content such that the embeds show up correctly.
While the emebeds do show up appropriately, any future changes made to the content using the CMS editor deletes the emebeds.
Steps to recreate:
Create a live item using CMS API with a rich field text and some embedded code in this field.
Observe the item on the live site and see the embedded content render.
Go to CMS editor and select the item to edit on Webflow
Change content and hit save
Expected outcome:
Editor should show embeded code in the rich text editor of the content field
Changing the content field should not delete embeded code.
Actual outcome:
Rich field text editor does not show a placeholder for the embedded content
Embedded content gets overwritten and we lose data
Maybe someone from the tech team can point us in the right direction here, how do we get the CMS API to recognize legitimate embeded code in CMS items?
I am confident that you canât read or create code embeds via the API and when I tested I found zero workarounds. Really throws a thorn in the whole Webflow migrate Wordpress situation. My WP clients love using Gutenburg with custom blocks. No way to even show them a lesser solution.
@Swayam_Narain
I would like to see the code embed HTML you inserted into a RTF via the API. Was this on a create new item or update?
My test was an API read of an item that had an embed inserted through the designer, which would not display as well as CSV exports which did not include the embed. This by itself rules it our for me.
Thanks for that. I did some research and came back with an update.
Properly escaped code (CSS or JS) wrapped in a div with a class of .w-embed.w-script makes the roundtrip when posted via the API and then when exported as a CSV. It displays on the front-end. The embed element is not accessible in the designer for edits.
Interestingly, you can put images and other html with classes into the body of a rich-text field. Will render just fine on front end. The URLâs on images are not touched and are visible and editable as images in the designer (standard image dialog).
I even added webP image sources into a RTF and a layout with CSS grid and that worked. This opens some real possibilities! I am no longer constrained! Now forget about editing this content in the designer or editor but if you have a remote DB and use the API you could theoretically do what you want. BOOM.
Here is a front-end demo of a collection item RTF populated with code (dynamic images in a CSS grid, most are WebP) on the front end.
Here is a backend CMS Item shot. Note that the grid is not being implemented since that is invoked with custom code which does not show in the designer in this case.
Itâs as if the Editor saves our HTML embeds somewhere else. And thatâs how the API remembers them, thereafter.
The CherryTree outliner does that sort of thing. It supports embedding a picture, table, or code block in its HTML-like rich text nodes. But theyâre stored outside the rich text, in their own âcollectionsâ (database tables). There isnât even a <div> to mark their location.
So the solution seems to be, once youâve put in, via the API, an Embed, or any other Editor-unsupported HTML code (e.g., nested lists), then use only the API to update it. An external, WYSIWYG editor might be handy, in that case.
Hi, Thank you so much for your solution,
unfortunately I did like you said but there is no embed table it turns to plain text with a lot of space-line. Is the solution still workable?
Years later and this is still not fixed. We need to export our CMS collection, but everything is stripped out. Infuriating, as I logged this bug with support three years ago.
Not sure if this helps anyone else, I was experiencing an issue where the HTML was partially coming through. Things like <p> tags etc were all good, but as soon as it can to lists <li>, for some reason Webflow was creating the markup for lists, but was stripping any content between <li></li> tags. After running a bunch of requests through Postman, I determined that it was \n character that was tripping up webflow, so for me running replaceAll('\n', '') on the HTML data did the trick.