tiptap/docs/api/nodes/ordered-list.md
Hari Haran 36bb1e1041
feat: #3540 Ability to preserve marks on lists (#3541)
* feat: #3540 Ability to preserve marks on lists

* feat: preserveAttrs in list items

* `keepMarks` is working, but need help with `keepAttrs`

* fix: conflict

* avoid casting
2023-02-22 10:13:28 +01:00

2.2 KiB
Raw Blame History

description icon
If a bullet list doesnt look serious enough, put some numbers in front of it. list-ordered

OrderedList

Version Downloads

This extension enables you to use ordered lists in the editor. They are rendered as <ol> HTML tags.

Type 1.  (or any other number followed by a dot) at the beginning of a new line and it will magically transform to a ordered list.

Installation

npm install @tiptap/extension-ordered-list @tiptap/extension-list-item

This extension requires the ListItem node.

Settings

HTMLAttributes

Custom HTML attributes that should be added to the rendered HTML tag.

OrderedList.configure({
  HTMLAttributes: {
    class: 'my-custom-class',
  },
})

itemTypeName

Specify the list item name.

Default: 'listItem'

OrderedList.configure({
  itemTypeName: 'listItem',
})

keepMarks

Decides whether to keep the marks from a previous line after toggling the list either using inputRule or using the button

Default: false

OrderedList.configure({
  keepMarks: true,
})

keepAttributes

Decides whether to keep the attributes from a previous line after toggling the list either using inputRule or using the button

Default: false

OrderedList.configure({
  keepAttributes: true,
})

Commands

toggleOrderedList()

Toggle an ordered list.

editor.commands.toggleOrderedList()

Keyboard shortcuts

Command Windows/Linux macOS
toggleOrderedList Control Shift 7 Cmd Shift 7

Source code

packages/extension-ordered-list/

Usage

https://embed.tiptap.dev/preview/Nodes/OrderedList