@@ -183,7 +183,6 @@ const buildHorizontalRuleProperties = (vNode) => {
183
183
const horizontalRulePropertiesFragment = fragment ( { namespaceAlias : { w : namespaces . w } } ) . ele ( 'w:pPr' ) ;
184
184
185
185
const modifiedAttributes = modifiedStyleAttributesBuilder ( null , vNode , { } , { isParagraph : false } ) ;
186
- console . log ( modifiedAttributes ) ;
187
186
if ( modifiedAttributes . lineHeight || modifiedAttributes . beforeSpacing || modifiedAttributes . afterSpacing ) {
188
187
const spacingFragment = buildSpacing (
189
188
modifiedAttributes . lineHeight ,
@@ -202,30 +201,41 @@ const buildHorizontalRuleProperties = (vNode) => {
202
201
let [ borderSize , borderVal , borderColor ] = cssBorderParser ( border , defaultHorizontalRuleOptions . borderOptions ) ;
203
202
if ( modifiedAttributes . height ) {
204
203
const heightValue = parseInt ( modifiedAttributes . height , 10 ) ;
205
- console . log ( heightValue ) ;
206
204
borderSize = heightValue ;
207
205
}
208
206
const borderFragment = buildBorder ( 'bottom' , borderSize , borderVal , borderColor ) ;
209
207
horizontalRulePropertiesFragment . import ( borderFragment ) ;
210
208
211
209
horizontalRulePropertiesFragment . up ( ) ;
212
- console . log ( horizontalRulePropertiesFragment ) ;
213
210
return horizontalRulePropertiesFragment ;
214
211
} ;
215
212
216
213
const buildHorizontalRule = ( vNode ) => {
217
214
const horizontalRuleFragment = fragment ( { namespaceAlias : { w : namespaces . w } } ) . ele ( 'w:p' ) ;
218
- console . log ( vNode ) ;
219
215
const propertiesFragment = buildHorizontalRuleProperties ( vNode ) ;
220
216
horizontalRuleFragment . import ( propertiesFragment ) ;
221
217
222
218
const runFragment = horizontalRuleFragment . ele ( 'w:r' ) ;
223
- runFragment . ele ( 'w:rPr' ) ;
219
+ const runPropertiesFragment = runFragment . ele ( 'w:rPr' ) ;
220
+
221
+ const {
222
+ height = defaultHorizontalRuleOptions . height ,
223
+ width = defaultHorizontalRuleOptions . width ,
224
+ backgroundColor = defaultHorizontalRuleOptions . backgroundColor ,
225
+ border = `${ defaultHorizontalRuleOptions . borderOptions . size } px ${ defaultHorizontalRuleOptions . borderOptions . val } ${ defaultHorizontalRuleOptions . borderOptions . color } `
226
+ } = vNode . properties . style || { } ;
227
+
228
+ const [ borderSize , borderVal , borderColor ] = cssBorderParser ( border , defaultHorizontalRuleOptions . borderOptions ) ;
229
+
230
+ runPropertiesFragment . ele ( 'w:shd' , { 'w:fill' : backgroundColor } ) . up ( ) ;
231
+ runPropertiesFragment . ele ( 'w:bdr' , { 'w:val' : borderVal , 'w:sz' : borderSize , 'w:color' : borderColor } ) . up ( ) ;
232
+
233
+ runFragment . ele ( 'w:t' , { 'xml:space' : 'preserve' } , ' ' . repeat ( parseInt ( width , 10 ) || 1 ) ) . up ( ) ;
224
234
runFragment . up ( ) ;
225
235
horizontalRuleFragment . up ( ) ;
226
236
227
237
return horizontalRuleFragment ;
228
- } ;
238
+ } ;
229
239
230
240
const buildVerticalAlignment = ( verticalAlignment ) => {
231
241
if ( verticalAlignment . toLowerCase ( ) === 'middle' ) {
@@ -781,6 +791,8 @@ const buildFormatting = (htmlTag, options) => {
781
791
return buildTextDecoration ( options && options . textDecoration ? options . textDecoration : { } ) ;
782
792
case 'textShadow' :
783
793
return buildTextShadow ( ) ;
794
+ case 'hr' :
795
+ return buildHorizontalRule ( ) ;
784
796
}
785
797
786
798
return null ;
0 commit comments