diff --git a/src/components/ContentNode.vue b/src/components/ContentNode.vue index 6db878f2f..085eaf306 100644 --- a/src/components/ContentNode.vue +++ b/src/components/ContentNode.vue @@ -236,7 +236,11 @@ function renderNode(createElement, references) { node.text )); case BlockType.orderedList: - return createElement('ol', {}, ( + return createElement('ol', { + attrs: { + start: node.start, + }, + }, ( renderListItems(node.items) )); case BlockType.paragraph: diff --git a/tests/unit/components/ContentNode.spec.js b/tests/unit/components/ContentNode.spec.js index 423deb0bb..2ac5fc9dd 100644 --- a/tests/unit/components/ContentNode.spec.js +++ b/tests/unit/components/ContentNode.spec.js @@ -205,6 +205,51 @@ describe('ContentNode', () => { const list = wrapper.find('.content ol'); expect(list.exists()).toBe(true); + expect(list.attributes('start')).toBeUndefined(); + + const items = list.findAll('li'); + expect(items.length).toBe(2); + expect(items.at(0).find('p').text()).toBe('foo'); + expect(items.at(1).find('p').text()).toBe('bar'); + }); + + it('renders an
    with
  1. items and a custom start index', () => { + const wrapper = mountWithItem({ + type: 'orderedList', + start: 2, + items: [ + { + content: [ + { + type: 'paragraph', + inlineContent: [ + { + type: 'text', + text: 'foo', + }, + ], + }, + ], + }, + { + content: [ + { + type: 'paragraph', + inlineContent: [ + { + type: 'text', + text: 'bar', + }, + ], + }, + ], + }, + ], + }); + + const list = wrapper.find('.content ol'); + expect(list.exists()).toBe(true); + expect(list.attributes('start')).toBe('2'); const items = list.findAll('li'); expect(items.length).toBe(2);