You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-03 23:50:33 +02:00
@ -63,6 +63,35 @@ describe('markdownCommands.toggleList', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not toggle a the full list when the cursor is on a blank line', async () => {
|
||||||
|
const checklistStartText = [
|
||||||
|
'# Test',
|
||||||
|
'',
|
||||||
|
'- [ ] This',
|
||||||
|
'- [ ] is',
|
||||||
|
'',
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
|
const checklistEndText = [
|
||||||
|
'- [ ] a',
|
||||||
|
'- [ ] test',
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
|
const editor = await createTestEditor(
|
||||||
|
`${checklistStartText}\n${checklistEndText}`,
|
||||||
|
|
||||||
|
// Place the cursor on the blank line between the checklist
|
||||||
|
// regions
|
||||||
|
EditorSelection.cursor(unorderedListText.length + 1),
|
||||||
|
['BulletList', 'ATXHeading1'],
|
||||||
|
);
|
||||||
|
|
||||||
|
// Should create a checkbox on the blank line
|
||||||
|
toggleList(ListType.CheckList)(editor);
|
||||||
|
expect(editor.state.doc.toString()).toBe(
|
||||||
|
`${checklistStartText}- [ ] \n${checklistEndText}`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// it('should correctly replace an unordered list with a checklist', async () => {
|
// it('should correctly replace an unordered list with a checklist', async () => {
|
||||||
// const editor = await createEditor(
|
// const editor = await createEditor(
|
||||||
|
@ -183,8 +183,11 @@ export const toggleList = (listType: ListType): Command => {
|
|||||||
const origFirstLineIndentation = firstLineIndentation;
|
const origFirstLineIndentation = firstLineIndentation;
|
||||||
const origContainerType = containerType;
|
const origContainerType = containerType;
|
||||||
|
|
||||||
// Grow [sel] to the smallest containing list
|
// Grow `sel` to the smallest containing list, unless the
|
||||||
if (sel.empty) {
|
// cursor is on an empty line, in which case, the user
|
||||||
|
// probably wants to add a list item (and not select the entire
|
||||||
|
// list).
|
||||||
|
if (sel.empty && fromLine.text.trim() !== '') {
|
||||||
sel = growSelectionToNode(state, sel, [orderedListTag, unorderedListTag]);
|
sel = growSelectionToNode(state, sel, [orderedListTag, unorderedListTag]);
|
||||||
computeSelectionProps();
|
computeSelectionProps();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user