gentics / mesh-ui

Gentics Mesh UI
https://getmesh.io
Apache License 2.0
23 stars 27 forks source link

Make Quill Options configurable #312

Open philippguertler opened 4 years ago

philippguertler commented 4 years ago

Currently the quill options are hardcoded here:

https://github.com/gentics/mesh-ui/blob/ab6a0b6e8ef907adcf639fd01514c01f05a3d7fa/src/app/form-generator/components/html-field/html-field.component.ts#L32-L58

It would be nice to make it configurable in the mesh-ui-config.js

deckdom commented 4 years ago

Would be great if it's possible to define these settings based on the node/micronode which has the HTML field set. An plain object or a function similar to the previewUrls would be nice:

{
  formattingOptions: [
    [{ header: [1, 2, 3, 4, 5, 6, false] }],
    ['bold', 'italic', 'underline'], 

     [{ list: 'ordered' }, { list: 'bullet' }], 
     [{ script: 'sub' }, { script: 'super' }], 
  ],
}
{
  formattingOptions: function(node, microNode) {
    var options = [];
    switch (node.schema.name) {
      case 'category':
        options.push(['bold', 'italic', 'underline']);
        break;
    }
    switch (microNode.schema.name) {
      case 'text':
        options.push([{ list: 'ordered' }, { list: 'bullet' }], [{ script: 'sub' }, { script: 'super' }]);
        break;
    }
    return options;
  },
}

The check can then simply be done with the type of it: typeof config.formattingOptions === 'function'