Skip to content

Commit

Permalink
Fix custom start for ordered lists
Browse files Browse the repository at this point in the history
  • Loading branch information
mmachatschek authored and hanspagel committed Jul 15, 2021
1 parent 97dd951 commit 2559ef1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions docs/src/demos/Nodes/OrderedList/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ context('/demos/Nodes/OrderedList', () => {
.should('contain', 'List Item 2')
})

it('should make a ordered list from a number other than number one', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.commands.clearContent()
})

cy.get('.ProseMirror')
.type('2. List Item 1{enter}List Item 2')

cy.get('.ProseMirror')
.find('ol')
.should('have.attr', 'start', '2')
})

it('should remove the ordered list after pressing backspace', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.commands.clearContent()
Expand Down
4 changes: 2 additions & 2 deletions packages/extension-ordered-list/src/ordered-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export const OrderedList = Node.create<OrderedListOptions>({
wrappingInputRule(
inputRegex,
this.type,
match => ({ order: +match[1] }),
(match, node) => node.childCount + node.attrs.order === +match[1],
match => ({ start: +match[1] }),
(match, node) => node.childCount + node.attrs.start === +match[1],
),
]
},
Expand Down

0 comments on commit 2559ef1

Please sign in to comment.