@@ -108,6 +108,20 @@ const createTableStyle = (exporter: ODTExporter<any, any, any>) => {
108
108
return cellName ;
109
109
} ;
110
110
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
+
111
125
export const odtBlockMappingForDefaultSchema : BlockMapping <
112
126
DefaultBlockSchema ,
113
127
any ,
@@ -144,21 +158,57 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
144
158
) ;
145
159
} ,
146
160
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
+ } ,
154
189
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
+ } ,
162
212
163
213
checkListItem : ( block , exporter ) => (
164
214
< TextP >
0 commit comments