Skip to content

Commit 74dd90c

Browse files
authored
feat(Lists): return true from toList command when selection is in list with current list type (#88)
1 parent f1910c3 commit 74dd90c

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

demo/Playground.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ const Playground = React.memo<PlaygroundProps>((props) => {
7070
.use(MarkdownBlocksPreset, {
7171
image: false,
7272
heading: false,
73+
lists: {
74+
ulKey: keys.ulist,
75+
olKey: keys.olist,
76+
},
7377
breaks: {preferredBreak: breaks ? 'soft' : 'hard'},
7478
})
7579
.use(MarkdownMarksPreset, {

demo/keys.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
export const keys = {
2-
undo: 'cmd-z',
3-
redo: 'shift-cmd-z',
4-
bold: 'cmd-b',
5-
italic: 'cmd-i',
6-
underline: 'cmd-u',
7-
strike: 'shift-cmd-s',
8-
code: 'cmd-e',
2+
undo: 'mod-z',
3+
redo: 'shift-mod-z',
4+
bold: 'mod-b',
5+
italic: 'mod-i',
6+
underline: 'mod-u',
7+
strike: 'shift-mod-s',
8+
code: 'mod-e',
9+
ulist: 'mod-shift-l',
10+
olist: 'mod-shift-m',
911
};

src/extensions/markdown/Lists/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function toList(listType: NodeType): Command {
99
return (state, dispatch) => {
1010
const parentList = findAnyParentList(state.schema)(state.selection);
1111
if (parentList) {
12-
if (listType === parentList.node.type) return false;
12+
if (listType === parentList.node.type) return true;
1313

1414
dispatch?.(state.tr.setNodeMarkup(parentList.pos, listType));
1515
return true;

0 commit comments

Comments
 (0)