slab / quill

Quill is a modern WYSIWYG editor built for compatibility and extensibility
https://quilljs.com
BSD 3-Clause "New" or "Revised" License
43.65k stars 3.39k forks source link

Custom class removed when editor is initialized #3123

Closed emeryowa closed 6 months ago

emeryowa commented 4 years ago

I have a requirement to implement custom classes when setting the font-size in Quill. As you probably know Quill has the option to set a small, large and huge font size by default and it will set the classes ql-size-small, ql-size-large, ql-size-huge respectively on the selected text.

I configured Quill to use font sizes xsmall, small, medium, large and xlarge. This works. I also configured Quill to use a custom class. My requirements is for Quill to set the class font-small instead of ql-size-small. I can make Quill to set the custom class correctly when selected from the dropdown, but I run into an issue when Quill initializes the editor with an HTML string containing the custom class: the custom class is removed. If I configure any class that starts with ql- it works apparently, but not with custom class starting with font-. Should I configure it somewhere to allow or trust my custom class?

FYI: I original posted this on ngx-quill repo, but was asked to submit the issue here

Steps for Reproduction

  1. Go to https://jsfiddle.net/12y4bc6v/
  2. Click "Get HTML" to log the editor content

Expected behavior: The editor's content should contain <span class="font-large"></span> from its initial value

Actual behavior: <span class="font-large"></span> is removed

Platforms:

Chrome Version 84.0.4147.105 (Official Build) (64-bit) on MacOS 10.15.4

Version:

1.3.7

emeryowa commented 4 years ago

I think this has something to do with font being a reserved keyword for Quill. Is that possible? This GH issue mentions a similar issue https://github.com/quilljs/quill/issues/1008#issuecomment-250389449

If I change the class prefix to font-size it seems to work fine. But I'm still not sure if it is possible to allow font as class prefix somehow

quill-bot commented 6 months ago

Quill 2.0 has been released (announcement post) with many changes and fixes. If this is still an issue please create a new issue after reviewing our updated Contributing guide :pray: