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

Bullet lists appearing as numbered lists with custom toolbar implementation #4124

Open
jmaitlandsoto opened this issue Apr 18, 2024 · 1 comment

Comments

@jmaitlandsoto
Copy link

After upgrading to v2.0.0 bulleted lists started showing as numbered lists. This works fine on previous versions.

I'm not sure if this has to do with my custom toolbar implementation, but I'll explain it anyway. My use case requires multiple different editors to share a single toolbar which is not supported out of the box. So I built a system that tracks which editor is currently selected, and implemented custom functions that apply formats (bold, italics, color, list, etc.) to the selected text.

This was inspired by the following comment #633 (comment)

To do this I created the toolbar UI which consists of a collection of buttons that each trigger some function that formats the selected text.

Below is the function that applies the bullet format. (The onNumberedList function is almost identical, instead it sets "list" format to "ordered")

  const onBulletedList = React.useCallback(() => {
    if (!currentFormats || !currentEditor) {
      return;
    }

    const range = currentEditor.getSelection();
    if (!range) {
      return;
    }
    currentEditor.formatLine(
      range.index,
      range.length,
      "list",
      currentFormats.list === "bullet" ? false : "bullet"
    );
    setCurrentFormats?.(currentEditor.getFormat());
  }, [currentFormats, currentEditor]);

Steps for Reproduction

  1. Install quill v2.0.0
  2. Create a Quill editor
  3. Apply the list format with value "bullet" via some custom function as shown above

Expected behavior:

To appear as an unordered (bullet) list.

Actual behavior:

Appears as an ordered list.

Platforms:

Firefox 124.0.2, Windows 10 Home

Version:

2.0.0

@c0ldst0rage
Copy link

c0ldst0rage commented May 15, 2024

For some reason...
v2.0 doesn't use <ul>, it uses <ol> and then specifies that items are bulleted using <li data-list="bullet">"
Not only this, but if you have any old v1.6 content that you insert using JavaScript that has <ul> then v2.0 actually sanitises (removes) it, leaving you with nothing and scratching your head.
I struggled with this, staring into my code thinking I was doing something wrong.
So I've had to pre-treat v1.6 by replacing <ul> with <ol> and then all the <li> with <li data-list="bullet">".
This seems like the beginning of a nightmare too, as I believe <code></code> may no longer work either as a <div> is used... I'll need to look into that too.
I've done some digging and I can't see a way of calling a function to convert 1.6 text to 2.0 text, that would be a godsend!

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

No branches or pull requests

2 participants