Issue #3233Opened January 15, 2021by Abhisheknanda13444630 reactions

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)

artfJanuary 27, 20210 reactions

Follow the issue template (version, live demo, etc.)

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.