area17 / twill

Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. Chat with us on Discord at https://discord.gg/cnWk7EFv8R.
https://twillcms.com
Apache License 2.0
3.76k stars 574 forks source link

Quill Custom action #650

Closed dacastro4 closed 3 years ago

dacastro4 commented 4 years ago

I don't know if it possible but I would like to add a custom action to Quill using this guide Cloning Medium with Parchment and this codepen example:

layout-lab commented 4 years ago

Hi @dacastro4, did you have any joy with this? I'm also looking to add some inline text styles.

dacastro4 commented 4 years ago

@layout-lab unfortunately, I did not

layout-lab commented 4 years ago

Hi @dacastro4,

I've taken a look at this, and have managed to get it to work by editing the Twill vendor files which isn't desirable, but may help you. If anyone knows how to extend the below files, I'd love to hear your input.

The editor configuration is contained in this file: https://github.com/area17/twill/blob/e780bcfde8ceed86486c0eee98387bca376db86a/frontend/js/libs/Quill/QuillConfiguration.js#L1

The Quill docs have info on adding fonts to the whitelist: https://quilljs.com/guides/how-to-customize-quill/#customizing-attributors I therefore added the following to the aforementioned config file:

var FontAttributor = Quill.import('formats/font')
var fonts = ['impact', 'courier']
FontAttributor.whitelist = fonts
Quill.register(FontAttributor, true)

Some CSS needs to be added to display the drop down items. I added my CSS to the VUE file below, although it's probably possible to push this elsewhere. https://github.com/area17/twill/blob/e780bcfde8ceed86486c0eee98387bca376db86a/frontend/js/components/Wysiwyg.vue#L309

  .ql-snow .ql-picker.ql-font span[data-value="impact"]::before {
    content: "Impact";
  }
  .ql-snow .ql-picker.ql-font span[data-value="courier"]::before {
    content: "Courier";
  }

In the Wysiwyg formField I added this to toolbarOptions :

['font' => ['', 'impact', 'courier'] ],

Hope this helps!