[QUESTION]: New toolbar button works only for new added components and not for existing ones
See original GitHub issueHi everybody, can somebody explain me please why when I create a new custom toolbar button this button shows only when I add a new component and not an existing one even this components are the same. I was thinking that might be something about the editor initiation that I’m not including. @artf What am I missing to make it work on init? Here is an example of how I’m adding the button.
const scriptTypesSupport = ['default','wrapper','text','textnode','image','video','svg','link'];
scriptTypesSupport && scriptTypesSupport.forEach(type => {
const typeOpt = dc.getType(type).model;
dc.addType(type, {
model: {
initToolbar() {
typeOpt.prototype.initToolbar.apply(this, arguments);
const tb = this.get('toolbar');
const tbExists = tb.some(item => item.command === 'edit-component');
if (!tbExists) {
tb.unshift({ // unshift to be the first and push to be the last
command: 'edit-component',
label: '<i class="fa fa-code"></i>',
});
this.set('toolbar', tb);
}
}
}
});
})
It works perfectly but like I said only for new components added and not for existing ones (example, if I init the editor with some code inside the gjs container the components won’t have this new option in the toolbar)
Above you can see when I add a second link the toolbar have the new button (pencil) but the existing one doens’t.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Angular2: Display different "toolbar" components depending ...
What I want to achieve is that the toolbar is displaying different components, depending on the component/view that is rendered in the content ......
Read more >Customize the Quick Access Toolbar - Microsoft Support
The customizable Quick Access Toolbar contains a set of commands that are independent of the currently displayed tab on the ribbon. You can...
Read more >IC Toolbar z-button handling - SAP Blogs
During the latest project I realized that there is already new possibility to add a logic for z-button handling in IC toolbar.
Read more >How to Use Tool Bars (The Java™ Tutorials > Creating a GUI ...
Here is the code that adds the new components: //fourth button button = new JButton("Another button"); ... toolBar.add(button); //fifth component is NOT ......
Read more >Add a button to the toolbar - Mozilla - MDN Web Docs
Toolbar buttons are one of the main UI components available to extensions. Toolbar buttons live in the main browser toolbar and contain an ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Probably the editor doesn’t change a component during runtime when it’s model is changed, so the component on the canvas was created before the model was modified therefore it wont show the changes to the toolbar.
I’ve gotten around this by loading the canvas after loading all components and component modifications, but I guess depending on storage setup running
editor.load()
might fix that.