The preview functionality is handled in modules/Collections/assets/collection-entrypreview.tag , basically Cockpit will include in an iframe a target url and send the entry json to that iframe using postMessage command (check the updateIframe() definition on that file).
Not sure if we are talking on the same Preview functionality, the Cockpit preview will call an URL (your frontend application) that you define and it will run the result of that URL in an iframe passing the entry data via a post message call.
@alessandro92 I’m sorry, but I don’t understand your question.
What are bees? I guess, you mean rest api endpoints.
What is your actual goal? Are you trying to use the content preview feature for a single collection entry while logged in the admin ui? If so, here is a short explanation, how to use it:
If not, try to explain, what you mean with “preview” and what you expect to see when you call your custom api endpoint /api/preject.
edit: We wrote at the same time. After reading your post from a minute ago, I understand your problem. Let me think about it…
You could modify the entrypreview component. It should work with copy/pasting it to /config/tags/entrypreview.tag, but I didn’t test it. Than change the updateIframe function so it sends the data in a format you need. But you still have to listen to the postMessage on your frontend side. If the entry preview component will be updated in the future, you will miss it, because of your outdated, modified one. I don’t recommend this idea.
The better option: Transform the data to your needs in your frontend and then update the page.
window.addEventListener('message', function(event) {
var entry = event.data.entry;
// modify entry to your needs
// update your page with modified data
// optional: Do the modification server side, send the event data to a custom cockpit
// api endpoint and return the data in a format, you like
}, false);
And don’t forget, that it is a live update, that works without saving the entry. This is why it uses the iframe postMessage method.