From 2559ef1af13b5fe2f219c7e3c15f421f223f9662 Mon Sep 17 00:00:00 2001 From: Markus Machatschek Date: Thu, 15 Jul 2021 09:28:24 +0200 Subject: [PATCH] Fix custom start for ordered lists --- docs/src/demos/Nodes/OrderedList/index.spec.js | 13 +++++++++++++ packages/extension-ordered-list/src/ordered-list.ts | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/src/demos/Nodes/OrderedList/index.spec.js b/docs/src/demos/Nodes/OrderedList/index.spec.js index 857065021a8..d4f2704ce4c 100644 --- a/docs/src/demos/Nodes/OrderedList/index.spec.js +++ b/docs/src/demos/Nodes/OrderedList/index.spec.js @@ -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() diff --git a/packages/extension-ordered-list/src/ordered-list.ts b/packages/extension-ordered-list/src/ordered-list.ts index 38d880bc6cb..04f9209b57c 100644 --- a/packages/extension-ordered-list/src/ordered-list.ts +++ b/packages/extension-ordered-list/src/ordered-list.ts @@ -77,8 +77,8 @@ export const OrderedList = Node.create({ 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], ), ] },