npm install tiptap-extension-ordered-list -S
const listType = e.target.dataset.listType; // decimal lower-alpha lower-roman upper-alpha upper-roman
let chain = editor.chain().focus();
// 开启列表类型
if (!editor.isActive("orderedList")) {
chain.toggleOrderedList().updateAttributes("orderedList", { listStyleType });
}
// 切换列表类型
else if (editor.getAttributes("orderedList").listStyleType !== listStyleType) {
chain.updateAttributes("orderedList", { listStyleType });
}
// 关闭列表类型
else {
chain.toggleOrderedList();
}
Add listStyleType
option, other options are same as @tiptap/extension-ordered-list
import OrderedList from "tiptap-extension-ordered-list";
const editor = new Editor({
element: document.querySelector(".editor"),
extensions: [
StarterKit,
OrderedList.configure({
listStyleType: "decimal", // default decimal
HTMLAttributes: { class: "list-paddingleft-1" },
}),
],
});
@tiptap/extension-ordered-list: https://github.com/ueberdosis/tiptap/tree/develop/packages/extension-ordered-list
tiptap-appmsg-editor: https://github.com/KID-1912/tiptap-appmsg-editor