quill icon indicating copy to clipboard operation
quill copied to clipboard

Unable to write "15. January 2024" due to automatic list identation

Open Puge96 opened this issue 1 year ago • 5 comments

Hi everybody

Is there someway you can disable automatic indentation to numbered list but still keep the numbered list available in the toolbar?

With the default settings for the editor you cannot write "15. January 2024" As it will change "15." to "1." as a numbered list.

Steps for Reproduction

  1. Visit https://quilljs.com/playground/
  2. Write any numbers and end with a dot (.)

Expected behavior: Numbers stays like they are i.e "15."

Actual behavior: Text is changed to a numbered list starting with the first number in the sequence i.e "1."

Platforms: Windows 10, Chrome Version 120.0.6099.217

Version: Latest

Puge96 avatar Jan 15 '24 08:01 Puge96

When it got converted to 1. , you can press CMD+z/Ctrl+z to undo. Does that work for you?

luin avatar Jan 15 '24 08:01 luin

Thank you for the quick response.

It does work.

Is there someway you can prevent this default behavior if number sequence is more than one digit?

Do it for "9." but prevent the automatic formatting for "10."

Puge96 avatar Jan 15 '24 08:01 Puge96

The easiest way is to customize the prefix regex in https://github.com/quilljs/quill/blob/v2.0.0-beta.0/packages/quill/src/modules/keyboard.ts#L543:

import Keyboard from 'quill/modules/keyboard';

Keyboard.DEFAULTS.bindings['list autofill'].prefix = /^\s*?([01]\.|-|\*|\[ ?\]|\[x\])$/

luin avatar Jan 15 '24 08:01 luin

Another quick alternative might be something like this:

new Quill(editorEl, {
  modules: {
    keyboard: {
      bindings: {
        "list autofill": {
          shortKey: true
        }
      }
    },
  },
});

This makes it so that the automatic list conversion only happens if "ctrl" + "space" is pressed.

katywings avatar Feb 27 '24 21:02 katywings

You can use quill-react-commercial.

It can support your demands like below gif. quill-order-list

It can start with any number in order list and can save this number in delta.

ludejun avatar May 06 '24 02:05 ludejun