quill
quill copied to clipboard
Unable to write "15. January 2024" due to automatic list identation
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
- Visit https://quilljs.com/playground/
- 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
When it got converted to 1.
, you can press CMD+z/Ctrl+z to undo. Does that work for you?
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."
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\])$/
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.
You can use quill-react-commercial.
It can support your demands like below gif.
It can start with any number in order list and can save this number in delta.