Enrich Components html #4907
-
Hallo @ALL, i am building a laravel / php application and using also grapesjs to build pages for the application. Inside these pages i want to conditionally render sections / components if the logged in user is a normal user or an admin. I came along to use a struture like this to mark fragements / components of the page as conditional:
Inside grapesjs i have added a trait to all components to select the user role to decide the component should be rendered. I do came along with the following code:
If i do it like that the following code leads to a inifinte loop How do i get the html from the component and wrap it into the conditional i am aiming for? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You have to store the original model before is updated editor.Components.getTypes().map(type => {
const originalModel = type.model;
editor.Components.addType(type.id, {
// ...
return originalModel.prototype.toHTML.apply(this);
// ...
})
}) |
Beta Was this translation helpful? Give feedback.
-
For everyone interested into the full code. This is what works:
|
Beta Was this translation helpful? Give feedback.
You have to store the original model before is updated