Issue #1475Opened October 2, 2018by shlomoko0 reactions

[Question] adding filter to styleManager

Question

Hi, I am trying to add a filter property to Styles. The problem that I am having is that the property demands 2 arguments: 1. The type of filter 2. The strength. e.g filter: blur(10%). the problem I am having is that when added to the css file I am getting- filter: blur 10%. I understand that I should be using property.functionName to fix this, but cannot figure out how (there appear to be no examples of this in the existing libraries).

The code I have is:

   sm.addProperty('Extra', {
      name: 'Filter',
      property: 'filter',
      type: 'stack',
      properties: [{
        property: 'filter_type',
        type: 'select',
        defaults: 'none',
        list: [{ value: 'none' }, { value: 'blur'} ,{ value: 'brightness'},{ value: 'contrast'} ,{ value: 'drop-shadow'} ,{ value: 'grayscale'} ,{ value: 'hue-rotate'} ,{ value: 'invert'} ,{ value: 'opacity'} ,{ value: 'saturate'} ,{ value: 'sepia'} ,{ value: 'url'}],
      },{
        property: 'filter_strength',
        type: 'slider',
        name: 'Strength',
        units: ['%'],
        defaults: 100,
        step: 1,
        max: 100,
        min:0,
      }],
      functionName: () => {

      }

    });

Thank you

Answers (3)

artfOctober 8, 20180 reactions

Hi @shlomoko to make the filter work properly via stack type you have to add a custom style manager type, because, as you already noticed, you have to deal with dynamic stuff (eg. functionName). Unfortunately, we didn't document that part yet and the only example we have is grapesjs-style-gradient. Extending the stack property might be even a bit harder (probably will require also some enhancement on the current API), so I'll try to provide an example of this case.

lock[bot]November 4, 20190 reactions

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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.