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

All Browsers: entering a number with a dot (eg. "30.") creates an empty sorted list ("1.") instead of the simple text (for eg. final result "30. November") #2408

Closed natterstefan closed 6 months ago

natterstefan commented 5 years ago

Steps for Reproduction

screen capture on 2018-11-23 at 10-14-51

  1. Visit our lovely-editor storybook
  2. enter "30."
  3. now press space again

Here's the source code of the editor and here the storybook story.

It also happens on the playground with the following config:

var quill = new Quill('#editor-container', {
  modules: {
    toolbar: [
      [{ header: [1, 2, false] }],
      ['bold', 'italic', 'underline'],
      [{'list': 'ordered'}, {'list': 'bullet'}]
    ]
  },
  formats: [
    'header',
    'bold', 'italic', 'underline', 'strike', 'blockquote',
    'list', 'bullet', 'indent',
    'link', 'image'
  ],
  placeholder: 'Compose an epic...',
  theme: 'snow'  // or 'bubble'
});

screen capture on 2018-11-23 at 13-32-37

Expected behavior:

I would expect to get "30. "

Actual behavior:

But instead I get an unsorted list with no initial value.

Is there a setting I am missing? When I remove the list format it works, but lists (eg. added via menu bar) do not work of course then.

Platforms:

It happens on all browsers so far.

Version:

Must be 1.2.6, as I am using react-quill and it states it is using ^1.2.6

Thank you for your help!

DmitrySkripkin commented 5 years ago

There is keyboard binding called list autofill, you can overwrite it if you want and redefine prefix regexp like I did here CodePen. Or you can press Shift+Spacebar if you don't want list shortcut to be triggered.

natterstefan commented 5 years ago

@DmitrySkripkin I am gonna test it. Looks really promising. If it works, you have to send me your https://www.paypal.me/ or another link, please. Because I owe you a beer then 🍺. Damn, you made my day! I was wondering how I can resolve this.

DmitrySkripkin commented 5 years ago

@natterstefan you already helped everyone to find issue nobody noticed :)

I just wonder, do I need to create pull request for this issue, or it's "by design". Need approval from @jhchen, оr somebody who can make decisions.

jhchen commented 5 years ago

This UX is currently by design. Previously only 1. would trigger it but people did want to continue a list so we relaxed it to be any number but made ctrl+z undo just the autolist behavior so typing three zero period space ctrl+z would leave you with "30. ".

natterstefan commented 5 years ago

Hi @jhchen, thanks for the clarification. I understand the intent, but I still have some questions. Most likely some of the use cases below can be handled with custom keybindings, but it was not clear to me - without @DmitrySkripkin mentioning it - that I need to take care of these cases myself.

people did want to continue a list

Why does the list then not start with "30." but again with "1."?

This is what you wanted to achieve, right?

screen capture on 2018-12-07 at 11-10-34

But why can't the list not start with 30 as well? For instance, I want to count down from 30. to 1.

screen capture on 2018-12-07 at 11-10-58

Or what if I want to write something between two items of the list:

screen capture on 2018-12-07 at 11-13-37

And just for the record: Our customers in Switzerland thought this UX feature is a bug and created a story in the project to fix it.

This is one of their use cases:

screen capture on 2018-12-07 at 11-16-00

PS: how can I deactivate the entire "list autofill" binding? Do I have to create a prefix rule which the user "never" enters or how can I disable it?

DmitrySkripkin commented 5 years ago

Updated CodePen, now list formatting won't be triggered on "11. ".

natterstefan commented 5 years ago

Hi @DmitrySkripkin, thank you. Looks like the example was misleading. My fault, sorry. Actually, I would expect to start with "11." in the 3rd gif above. But the current implementation of the "list autofill" always starts at 1. No matter what I enter. See the 2nd example for instance, assuming I want to auto-formatting feature enabled and start a list with 30.

seagyn commented 5 years ago

A good example of this and what @natterstefan is wanting to achieve, is to look at Notes on iOS.

If you were to go 11. and hit space it create a list starting from 11. It's very handy for continuation of lists.

gutow commented 5 years ago

As it stands I agree this is a bug. The behavior I would expect from typing 'XX. ' (a number followed by a period and then a space at the beginning of a line) would be to start an ordered list with its start = XX (e.g. <ol start="XX">). Just as markdown does (see below):

  1. This is item 32 in the list.
  2. It is important to be able to do this because images and tables (when that feature is implemented) will break up the lists.

I would really like to see this feature. I am implementing a rich text editor in Jupyter notebook and JupyterLab. Quilljs is one of the prime contenders, but this is a problem for us.

sirgru commented 4 years ago

I don't think the list continuations are implementable in a satisfactory way with the current architecture, as they seem to be implemented with CSS counter which is reset on certain elements. This part would need context sensitive logic which defaults to list continuation, yet allows a popup which reverts it, as is done in Office since 2007.

I find list stating with '-' problematic, yet I want to start them with '*'. Reseting counters when the user types in 2. is almost never what the user intended, so this should be removed IMO. So finally I contended with this:

keyboard: {
      bindings: {
        'list autofill': {
          prefix: /^\s*(1{1,1}\.|\*)$/
        }
      }
    }
nguyen-thi-huyen-i-enter-asia commented 3 years ago

@gutow Have you found a solution yet?

gutow commented 3 years ago

@HuyenNguyen1209 No, I gave up on quill despite liking many of its features.

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:

ludejun commented 6 months ago

If you give up, you can use quill-react-commercial.

See the gif below: quill-order-list