GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.36k stars 4.05k forks source link

Add Trait For wrapper #3237

Closed Abhisheknanda1344463 closed 3 years ago

Abhisheknanda1344463 commented 3 years ago

Hi @artf
I've added trait for wrapper this way. How can I perform the init function for the same Here is the code

  editor.getWrapper().set('traits',
    [
      {
        changeProp: 1,
        name: 'abc',
        label: 'abc',
        type: 'checkbox',
        changeProp: 1
      },
    ],
  )

@artf Could you please help me? Thanks.

Abhisheknanda1344463 commented 3 years ago

@ryandeba Any suggestion?

Abhisheknanda1344463 commented 3 years ago

@artf Could you please help me here?

artf commented 3 years ago

You can use this option from components on init https://github.com/artf/grapesjs/blob/69e5ab2c1176e6fdeac1b058398cca55efe92df3/src/dom_components/config/config.js#L9

PS: stop annoying other people with your issues, please or I have to block you from this repo

Abhisheknanda1344463 commented 3 years ago

Sorry @artf I'll keep this in mind. Thanks

Abhisheknanda1344463 commented 3 years ago

@artf i've manage to add trait for wrapper how could i peform init function for trait Not getting the exact way

var editor = grapesjs.init({
    domComponents: {
      wrapper: {
        removable: false,
        copyable: false,
        draggable: false,
        components: [],
        traits: [
          {
            name: 'abc',
            type: 'checkbox',
            label: 'abc',
            changeProp: 1,
          },
        ],
        init(){
          this.on('change:abc', this.abc);
        },
        updateScroll(){
          alert("jo");
        },
        stylable: [
          'background',
          'background-color',
          'background-image',
          'background-repeat',
          'background-attachment',
          'background-position',
          'background-size'
        ],
      },
    }
 });
artf commented 3 years ago

domComponents.wrapper is only for props... You can always extend the wrapper component