1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00

Mobile,Desktop: Fixes #11135: Fix incorrect list switching behavior (#11137)

This commit is contained in:
Henry Heino 2024-09-27 13:28:56 -07:00 committed by GitHub
parent eda2c69334
commit 948ca605b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 3 deletions

View File

@ -232,4 +232,19 @@ describe('markdownCommands.toggleList', () => {
);
expect(editor.state.selection.main.from).toBe(preSubListText.length);
});
it('should not treat a list of IP addresses as a numbered list', async () => {
const initialDocText = '192.168.1.1. This\n127.0.0.1. is\n0.0.0.0. a list';
const editor = await createTestEditor(
initialDocText,
EditorSelection.range(0, initialDocText.length),
[],
);
toggleList(ListType.UnorderedList)(editor);
expect(editor.state.doc.toString()).toBe(
'- 192.168.1.1. This\n- 127.0.0.1. is\n- 0.0.0.0. a list',
);
});
});

View File

@ -132,9 +132,9 @@ export const toggleList = (listType: ListType): Command => {
// RegExps for different list types. The regular expressions MUST
// be mutually exclusive.
// `(?!\[[ xX]+\])` means "not followed by [x] or [ ]".
const bulletedRegex = /^\s*([-*])\s(?!\[[ xX]+\])/;
const checklistRegex = /^\s*[-*]\s\[[ xX]+\]\s?/;
const numberedRegex = /^\s*\d+\.\s?/;
const bulletedRegex = /^\s*([-*])\s(?!\[[ xX]+\]\s)/;
const checklistRegex = /^\s*[-*]\s\[[ xX]+\]\s/;
const numberedRegex = /^\s*\d+\.\s/;
const listRegexes: Record<ListType, RegExp> = {
[ListType.OrderedList]: numberedRegex,