[QUESTION] model.get('toolbar') always return null
Question
Hi @artf I am trying to add a custom toolbar to my custom component without changing the default toolbar. So I expect it to be like [movable, copyable, removable, newToolbar]. I use this #266 as a reference.
model: {
// ...
initToolbar () {
const tb = this.get('toolbar')
console.log(tb) // Return null
tb.unshift({
attributes: { class: 'fa fa-plane' },
command: 'some-command'
})
this.set('toolbar', tb)
},
// ...
}
But strangely this.get('toolbar') always return null.
Is this something normal?
I got this instead

Answers (3)
The extendFn was added from https://github.com/artf/grapesjs/releases/tag/v0.14.61 in the demo you're using the 0.14.57
I am so sorry, it's my mistake. Thanks for your guidance
Yes, if you override the original initToolbar method the toolbar property is never created, so you have to call the parent one first. Try with this component creation helper
extendFn: ['initToolbar'], // array of model functions to extend
model: {
// ...
initToolbar () {
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2697
[QUESTION] Problem with custom component type and table cell
Hello! I'm trying to add custom component type: And also I'm adding new block: But when I drop this block on the canvas the <td> tag doesn'...
Issue #2943
BUG: this.get('content') returns empty string when trying to add custom component type
Version: 0.16.18 Are you able to reproduce the bug from the demo?>> Demo <<< [ X ] Yes [ ] No What is the expected behavior? Expecting this...
Issue #2777
[QUESTION] How to update styles in Style Manager
Hello. I created custom component where I set backgraound-image via custom asset manager Custom block code: Command which I run to set new...
Issue #2696
[QUESTION]: How can I create block with background image with behavior like built-in "image"?
Hello, I'm trying to create block with background image (similar to Grapedrop Image Box). I added new component like this: And also I added...
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.