Skip to content

Please document an example for custom dropdowns in WYSIWYG configuration #46

@cadeyrn

Description

@cadeyrn

On https://docs.pimcore.com/platform/Quill_WYSWIYG_Editor/, you have a documentation for how to configure the toolbar of the Quill Editor. Example:

  modules: {
    toolbar: {
      container: [
        [{ header: [1, 2, 3, 4, 5, 6, false] }]
      ]
    } 
  }
}) }}

But let's say, I want to add a custom dropdown. This comment on GitHub helps for the first step. Based on that I could do something like:

{{  pimcore_wysiwyg('name', {
  modules: {
    toolbar: {
      container: [
        [{ header: [1, 2, 3, 4, 5, 6, false] }],
        [{ 'myOptions': ['Option 1', 'Option 2', 'Option 3'] }],
      ]
    } 
  }
}) }}
.ql-picker.ql-myDropdown .ql-picker-label {
  padding-right: 18px;
}

.ql-picker.ql-myDropdown .ql-picker-label::before {
  content: 'Options';
}

.ql-picker.ql-myDropdown .ql-picker-item[data-value='Option 1']::before {
  content: 'Option 1';
}

.ql-picker.ql-myDropdown .ql-picker-item[data-value='Option 2']::before {
  content: 'Option 2';
}

.ql-picker.ql-myDropdown .ql-picker-item[data-value='Option 3']::before {
  content: 'Option 3';
}

But how do I use the handlers property in the Twig template?

{{  pimcore_wysiwyg('name', {
  modules: {
    toolbar: {
      container: [
        [{ header: [1, 2, 3, 4, 5, 6, false] }],
        [{ 'myOptions': ['Option 1', 'Option 2', 'Option 3'] }],
      ],
      handlers: {
         /* what to do here?  */
         /* in JS, I would write something like: 
            'myOptions': function () {
              // do something
            }
         But what is the right way to define the JS function in Twig ? */
        }
      }
    } 
  }
}) }}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions