Skip to content

Commit 770998a

Browse files
committed
fix: toggle list
1 parent b45b452 commit 770998a

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

packages/super-editor/src/core/commands/toggleList.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-check
12
import { TextSelection } from 'prosemirror-state';
23
import { findParentNode } from '../helpers/findParentNode.js';
34
import { ListHelpers } from '@helpers/list-numbering-helpers.js';
@@ -98,7 +99,7 @@ function computeListLevels(liNodes) {
9899
* @param {Object} param0
99100
* @param {import("prosemirror-model").Node} param0.oldList
100101
* @param {import("prosemirror-model").NodeType} param0.toType
101-
* @param {import("prosemirror-view").EditorView} param0.editor
102+
* @param {import("../Editor.js").Editor} param0.editor
102103
* @param {import("prosemirror-model").Schema} param0.schema
103104
* @param {String|null} param0.fixedNumId
104105
* @returns {import("prosemirror-model").Node}
@@ -110,7 +111,7 @@ export function rebuildListNodeWithNewNum({ oldList, toType, editor, schema, fix
110111
// Always create a list definition + numId for the target kind (bullet or ordered)
111112
const numId = fixedNumId ?? ListHelpers.getNewListId(editor);
112113
if (fixedNumId == null) {
113-
ListHelpers.generateNewListDefinition?.({ numId, listType: toType, editor });
114+
ListHelpers.generateNewListDefinition?.({ numId: Number(numId), listType: toType, editor });
114115
}
115116

116117
// Collect list items
@@ -133,7 +134,8 @@ export function rebuildListNodeWithNewNum({ oldList, toType, editor, schema, fix
133134
? li.attrs.listLevel
134135
: [level + 1];
135136

136-
const details = ListHelpers.getListDefinitionDetails?.({ numId, level, listType: toType, editor }) || {};
137+
const details =
138+
ListHelpers.getListDefinitionDetails?.({ numId: Number(numId), level, listType: toType, editor }) || {};
137139

138140
const effectiveFmt = isOrdered ? details.numFmt || 'decimal' : details.numFmt || 'bullet';
139141
const effectiveLvlText = isOrdered ? details.lvlText || '%1.' : details.lvlText || '•';
@@ -180,7 +182,7 @@ export function rebuildListNodeWithNewNum({ oldList, toType, editor, schema, fix
180182
* @param {Object} param0
181183
* @param {Array<{ node: import("prosemirror-model").Node, pos: number }>} param0.paragraphs
182184
* @param {'ordered'|'bullet'} param0.targetKind
183-
* @param {import("prosemirror-view").EditorView} param0.editor
185+
* @param {import("../Editor.js").Editor} param0.editor
184186
* @param {import("prosemirror-model").Schema} param0.schema
185187
* @returns {import("prosemirror-model").Node}
186188
*/
@@ -330,7 +332,7 @@ export const toggleList =
330332
toType: TargetType,
331333
editor,
332334
schema: editor.schema,
333-
fixedNumId: sharedNumId,
335+
fixedNumId: String(sharedNumId),
334336
});
335337
tr.replaceWith(mapped, mapped + oldList.nodeSize, newList);
336338
}

0 commit comments

Comments
 (0)