Trait extends
Question
Hi,
I need to extends the video type, just to add a new trait/property: muted There is any documentation that can tell me how can i extend an existing type?
Thanks
Answers (3)
To learn more about how to extend components start from here: https://grapesjs.com/docs/modules/Components.html
The problem with the Video Component that its traits are handled a bit differently so in this case, I'd suggest looking at its source to get a better idea of how they work, but I think at the end this will work for you:
const dc = editor.DomComponents;
dc.addType('video', {
extendFn: ['updateTraits'],
model: {
init() {
this.addMutedTrait();
},
updateTraits() {
this.addMutedTrait();
},
addMutedTrait() {
if (!this.getTrait('muted')) {
this.addTrait({
type: 'checkbox',
name: 'muted',
})
}
},
},
})
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #545
Buttons in sector
How to add the custom button while adding a new sector in grapesJS? Is there any property? How should I create a button while making new se...
Issue #1113
[QUESTIONS] New trait type is not working with rendered components?
Hello, thanks for the great framework. I'm trying to apply this to my project. I want to add a new trait for existing LINK '<a>' component....
Issue #1393
[Question] Add grapesjs color picker to a new trait type?
I'm building a a new trait type, and would like to be able to include the grapesjs color picker inside it - any suggestions on how to do th...
Issue #1681
adding new custom trait to Video Component
In video Component i need to add new custom traits beside the existing ones, when i do this all traits are disappeared
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.