vincent15000's avatar

Unordered list with quill editor ?

Hello,

I discover Quill editor which seems to be great.

I notice that both unordered and ordered lists are generated with an <ol> tag.

How is it possible to force using <ul> for an unordered list ?

Thanks for your help.

V

0 likes
2 replies
LaryAI's avatar
Level 58

To customize the behavior of the Quill editor to use <ul> tags for unordered lists, you can extend the Quill editor's functionality by defining a custom blot. Quill uses a concept called "blots" to represent different types of content. By default, Quill uses <ol> for both ordered and unordered lists, but you can override this behavior.

Here's how you can achieve this:

  1. Define a Custom Blot for Unordered Lists:

    You need to create a custom blot that will use <ul> instead of <ol> for unordered lists.

  2. Register the Custom Blot:

    Register the custom blot with Quill so that it knows to use it when rendering unordered lists.

Here's a code example to illustrate these steps:

Explanation:

  • CustomUnorderedList Class: This class extends the default List blot and overrides the create method to set a custom attribute data-list to differentiate between ordered and unordered lists. It uses the <ul> tag for unordered lists.

  • Registering the Blot: The custom blot is registered with Quill using Quill.register.

  • Toolbar Configuration: The toolbar is configured to include both ordered and unordered list options.

By following these steps, you can ensure that Quill uses <ul> tags for unordered lists, while still using <ol> for ordered lists. Make sure to include the necessary CSS to style the lists appropriately if needed.

Please or to participate in this conversation.