@@ -108,6 +108,20 @@ const createTableStyle = (exporter: ODTExporter<any, any, any>) => {
108108 return cellName ;
109109} ;
110110
111+ const wrapWithLists = (
112+ content : React . ReactNode ,
113+ level : number
114+ ) : React . ReactNode => {
115+ if ( level <= 0 ) {
116+ return content ;
117+ }
118+ return (
119+ < TextList >
120+ < TextListItem > { wrapWithLists ( content , level - 1 ) } </ TextListItem >
121+ </ TextList >
122+ ) ;
123+ } ;
124+
111125export const odtBlockMappingForDefaultSchema : BlockMapping <
112126 DefaultBlockSchema ,
113127 any ,
@@ -144,21 +158,57 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
144158 ) ;
145159 } ,
146160
147- bulletListItem : ( block , exporter ) => (
148- < TextList text :style-name = "WWNum1" >
149- < TextListItem >
150- < TextP > { exporter . transformInlineContent ( block . content ) } </ TextP >
151- </ TextListItem >
152- </ TextList >
153- ) ,
161+ /**
162+ * Note: we wrap each list item in it's own list element.
163+ * This is not the cleanest solution, it would be nicer to recognize subsequent
164+ * list items and wrap them in the same list element.
165+ *
166+ * However, Word DocX -> ODT export actually does the same thing, so
167+ * for now it seems reasonable.
168+ *
169+ * (LibreOffice does nicely wrap the list items in the same list element)
170+ */
171+ bulletListItem : ( block , exporter , nestingLevel ) => {
172+ const styleName = createParagraphStyle (
173+ exporter as ODTExporter < any , any , any > ,
174+ block . props
175+ ) ;
176+ return (
177+ < TextList text :style-name = "WWNum1" >
178+ < TextListItem >
179+ { wrapWithLists (
180+ < TextP text :style-name = { styleName } >
181+ { exporter . transformInlineContent ( block . content ) }
182+ </ TextP > ,
183+ nestingLevel
184+ ) }
185+ </ TextListItem >
186+ </ TextList >
187+ ) ;
188+ } ,
154189
155- numberedListItem : ( block , exporter ) => (
156- < TextList text :style-name = "No_20_List" >
157- < TextListItem >
158- < TextP > { exporter . transformInlineContent ( block . content ) } </ TextP >
159- </ TextListItem >
160- </ TextList >
161- ) ,
190+ numberedListItem : ( block , exporter , nestingLevel , numberedListIndex ) => {
191+ const styleName = createParagraphStyle (
192+ exporter as ODTExporter < any , any , any > ,
193+ block . props
194+ ) ;
195+ // continue numbering from the previous list item if this is not the first item
196+ const continueNumbering = ( numberedListIndex || 0 ) > 1 ? "true" : "false" ;
197+ return (
198+ < TextList
199+ text :style-name = "No_20_List"
200+ text :continue-numbering = { continueNumbering } >
201+ < TextListItem >
202+ { wrapWithLists (
203+ < TextP text :style-name = { styleName } >
204+ { exporter . transformInlineContent ( block . content ) }
205+ </ TextP > ,
206+ nestingLevel
207+ ) }
208+ </ TextListItem >
209+ </ TextList >
210+ ) ;
211+ } ,
162212
163213 checkListItem : ( block , exporter ) => (
164214 < TextP >
0 commit comments