From e481a98a4b1216bc39c5cd32056070e37555db18 Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Wed, 8 Dec 2021 14:12:58 -0700 Subject: [PATCH 1/2] use ordered list start index when rendering --- src/components/ContentNode.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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: From c6b74f2e3cabc0bfd980cb7641633f49236f73ea Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Wed, 8 Dec 2021 15:02:32 -0700 Subject: [PATCH 2/2] add test for ordered list start attr --- tests/unit/components/ContentNode.spec.js | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) 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);