Closed aliibrahim123 closed 3 years ago
@artf
Don't use model.extend
/view.extend
, those are part of the old API.
This is an example of how properly extend traits on all components
const { Components } = editor;
Components.getTypes().forEach(({ id, model }) => {
Components.addType(id, {
model: {
defaults: {
traits: [ ...model.getDefaults().traits, 'new-trait', ]
},
},
})
});
This is a great solution artf, any tips on how to use this for components that have traits defined in a function?, as per the docs: https://grapesjs.com/docs/modules/Traits.html#add-traits-to-components
i am working on a script that add a trait on all the component type , but the comment type do not have the prototype object. code