Skip to content

Latest commit

 

History

History
72 lines (56 loc) · 1.64 KB

README.md

File metadata and controls

72 lines (56 loc) · 1.64 KB

tiptap-extension-ordered-list

Tiptap ordered list extension with custom list-style-type support.


NPM URL version



Install

npm install tiptap-extension-ordered-list -S

Usage

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();
}

Options

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" },
    }),
  ],
});

Relations

@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