Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Quill Options configurable #312

Open
philippguertler opened this issue Feb 26, 2020 · 1 comment
Open

Make Quill Options configurable #312

philippguertler opened this issue Feb 26, 2020 · 1 comment

Comments

@philippguertler
Copy link
Contributor

philippguertler commented Feb 26, 2020

Currently the quill options are hardcoded here:

const toolbarOptions = [
[{ header: [1, 2, 3, 4, 5, 6, false] }],
['bold', 'italic', 'underline'],
[{ list: 'ordered' }, { list: 'bullet' }],
[{ script: 'sub' }, { script: 'super' }],
[{ align: [] }],
['link', 'mesh-link'],
tableOptions(),
['clean']
];
function tableOptions(): any[] {
const maxRows = 10;
const maxCols = 5;
const tableOptions = [];
for (let r = 1; r <= maxRows; r++) {
for (let c = 1; c <= maxCols; c++) {
tableOptions.push('newtable_' + r + '_' + c);
}
}
return [{ table: tableOptions }, { table: 'append-row' }, { table: 'append-col' }];
}

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

@deckdom
Copy link
Contributor

deckdom commented Mar 2, 2020

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants