Set Toolbar on every Component
Question
Hi @artf
Is there any standard way to add a new toolbar on every component
I've tried this way
editor.Components.getTypes().map(type => {
editor.Components.addType(type.id, {
model: {
defaults: {
toolbar,
traits:[
...editor.Components.getType(type.id).model.prototype.defaults.traits,
...[
]
]
},
}
})
});
const toolbar = [{
attributes: {
class: 'fa fa-arrow-up'
},
command: e => e.runCommand('core:component-exit', {
force: 1
})
}, {
attributes: {
class: 'fa fa-arrows gjs-no-touch-actions',
draggable: true
},
command: 'tlb-move'
}, {
attributes: {
class: 'fa fa-clone'
},
command: 'tlb-clone'
}, {
attributes: {
class: 'fa fa-trash-o'
},
command: 'tlb-delete'
},{
attributes: {
class: 'fa fa-gear'
},
command: e => {
alert("hi")
}
}]
When I run this code on the browser console it's working as expected but when I placed this code In the component file this is not working when we define a new trait for all the components it's working fine.
For Toolbar it's not working and I also tried to place a code in editor. on('load') but no luck.
Any suggestion?
Thanks
FYI @david-polak
@arthuralmeidap
Answers (1)
Follow the issue template (version, live demo, etc.)
Related Questions and Answers
Continue research with similar issue discussions.
Issue #4796
Custom Traits not Updating if using mjml
This Method Works Fine for Normal HTML. But When I Tried With MJML For MJ-IMAGE Tag The Src is Updated in TR Tag but not updated in img tag...
Issue #4335
BUG: No way to upload background video component in the editor , Please suggest if there is any way to upload background video
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v9 Reproducible demo link Not there...
Issue #1407
[QUESTIONS] EXTRA TBODY ADDED EVERY TIME I SAVED THE HTML DATA.
Hi @artf, I had an issue when I have tables in the editor and I add new rows then if my table is saved when is loaded again an extra tbody...
Issue #1654
In React if we define as component, grapesjs component is not taking that component? Is there a way to achive this ?
WARNING READ and FOLLOW next 5 steps, then REMOVE them before posting the issueFollow CONTRIBUTING Guidelines https://github.com/artf/grape...
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.