@@ -7,7 +7,7 @@ import { ODTExporter } from "../odtExporter.js";
7
7
import {
8
8
DrawFrame ,
9
9
DrawImage ,
10
- StyleBackgroundFill ,
10
+ LoextGraphicProperties ,
11
11
StyleParagraphProperties ,
12
12
StyleStyle ,
13
13
StyleTableCellProperties ,
@@ -32,7 +32,8 @@ const createParagraphStyle = (
32
32
parentStyleName ?: string
33
33
) => {
34
34
const styles : Record < string , string > = { } ;
35
- const children : React . ReactNode [ ] = [ ] ;
35
+ const styleChildren : React . ReactNode [ ] = [ ] ;
36
+ const paragraphChildren : React . ReactNode [ ] = [ ] ;
36
37
37
38
if ( props . textAlignment && props . textAlignment !== "left" ) {
38
39
const alignmentMap = {
@@ -50,7 +51,12 @@ const createParagraphStyle = (
50
51
exporter . options . colors [
51
52
props . backgroundColor as keyof typeof exporter . options . colors
52
53
] . background ;
53
- children . push ( < StyleBackgroundFill color = { color } /> ) ;
54
+ styleChildren . push (
55
+ < >
56
+ < LoextGraphicProperties draw :fill = "solid" draw :fill-color = { color } />
57
+ < StyleParagraphProperties fo :background-color = { color } />
58
+ </ >
59
+ ) ;
54
60
}
55
61
56
62
if ( props . textColor && props . textColor !== "default" ) {
@@ -61,7 +67,11 @@ const createParagraphStyle = (
61
67
styles [ "fo:color" ] = color ;
62
68
}
63
69
64
- if ( Object . keys ( styles ) . length === 0 && children . length === 0 ) {
70
+ if (
71
+ Object . keys ( styles ) . length === 0 &&
72
+ styleChildren . length === 0
73
+ // && paragraphChildren.length === 0
74
+ ) {
65
75
return parentStyleName ;
66
76
}
67
77
@@ -70,9 +80,13 @@ const createParagraphStyle = (
70
80
style :family = "paragraph"
71
81
style :name = { name }
72
82
style :parent-style-name = { parentStyleName } >
73
- < StyleParagraphProperties { ...styles } >
74
- { children }
75
- </ StyleParagraphProperties >
83
+ { styleChildren }
84
+ { paragraphChildren . length > 0 ||
85
+ ( Object . keys ( styles ) . length > 0 && (
86
+ < StyleParagraphProperties { ...styles } >
87
+ { paragraphChildren }
88
+ </ StyleParagraphProperties >
89
+ ) ) }
76
90
</ StyleStyle >
77
91
) ) ;
78
92
} ;
@@ -118,7 +132,7 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
118
132
const customStyleName = createParagraphStyle (
119
133
exporter as ODTExporter < any , any , any > ,
120
134
block . props ,
121
- "Heading " + block . props . level
135
+ "Heading_20_ " + block . props . level
122
136
) ;
123
137
const styleName = customStyleName ;
124
138
@@ -131,15 +145,15 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
131
145
} ,
132
146
133
147
bulletListItem : ( block , exporter ) => (
134
- < TextList text :style-name = "LFO1 " >
148
+ < TextList text :style-name = "WWNum1 " >
135
149
< TextListItem >
136
150
< TextP > { exporter . transformInlineContent ( block . content ) } </ TextP >
137
151
</ TextListItem >
138
152
</ TextList >
139
153
) ,
140
154
141
155
numberedListItem : ( block , exporter ) => (
142
- < TextList text :style-name = "LFO3 " >
156
+ < TextList text :style-name = "No_20_List " >
143
157
< TextListItem >
144
158
< TextP > { exporter . transformInlineContent ( block . content ) } </ TextP >
145
159
</ TextListItem >
@@ -163,10 +177,35 @@ export const odtBlockMappingForDefaultSchema: BlockMapping<
163
177
} ,
164
178
165
179
table : ( block , exporter ) => {
166
- const styleName = createTableStyle ( exporter as ODTExporter < any , any , any > ) ;
180
+ const ex = exporter as ODTExporter < any , any , any > ;
181
+ const styleName = createTableStyle ( ex ) ;
167
182
168
183
return (
169
184
< Table >
185
+ { block . content . rows [ 0 ] ?. cells . map ( ( el , i ) => {
186
+ let width : any = block . content . columnWidths [ i ] ;
187
+
188
+ if ( ! width ) {
189
+ // width = "3in";
190
+ } else {
191
+ width = "5in" ;
192
+ }
193
+ if ( width ) {
194
+ const style = ex . registerStyle ( ( name ) => (
195
+ < StyleStyle style :name = { name } style :family = "table-column" >
196
+ < style :table-column-properties style :column-width = { width } />
197
+ </ StyleStyle >
198
+ ) ) ;
199
+ return < table :table-column table :style-name = { style } /> ;
200
+ } else {
201
+ const style = ex . registerStyle ( ( name ) => (
202
+ < StyleStyle style :name = { name } style :family = "table-column" >
203
+ < style :table-column-properties style :use-optimal-column-width = "true" />
204
+ </ StyleStyle >
205
+ ) ) ;
206
+ return < table :table-column table :style-name = { style } /> ;
207
+ }
208
+ } ) }
170
209
{ block . content . rows . map ( ( row ) => (
171
210
< TableRow >
172
211
{ row . cells . map ( ( cell ) => (
0 commit comments