@@ -54,12 +54,12 @@ import {
54
54
verticalAlignValues ,
55
55
imageType ,
56
56
internalRelationship ,
57
- defaultPercentageMarginValue ,
58
57
defaultTableBorderOptions ,
59
58
defaultTableBorderAttributeOptions
60
59
} from '../constants' ;
61
60
import { vNodeHasChildren } from '../utils/vnode' ;
62
61
import { isValidUrl } from '../utils/url' ;
62
+ import { isZeroOrTruthy } from '../utils/truthy-check' ;
63
63
64
64
const setUpDirectionalBorderStroke = ( borderStrike = 'nil' ) => ( {
65
65
top : borderStrike ,
@@ -335,7 +335,7 @@ const fixupLineHeight = (lineHeight, fontSize) => {
335
335
if ( ! isNaN ( lineHeight ) ) {
336
336
if ( fontSize ) {
337
337
const actualLineHeight = + lineHeight * fontSize ;
338
-
338
+
339
339
return HIPToTWIP ( actualLineHeight ) ;
340
340
} else {
341
341
// 240 TWIP or 12 point is default line height
@@ -356,7 +356,7 @@ const fixupLineHeight = (lineHeight, fontSize) => {
356
356
} else if ( percentageRegex . test ( lineHeight ) ) {
357
357
const matchedParts = lineHeight . match ( percentageRegex ) ;
358
358
return HIPToTWIP ( ( matchedParts [ 1 ] * fontSize ) / 100 ) ;
359
- }
359
+ }
360
360
else {
361
361
// 240 TWIP or 12 point is default line height
362
362
return 240 ;
@@ -522,7 +522,6 @@ const cssBorderParser = (borderString, defaultBorderOptions = { ...defaultTableB
522
522
return [ size , stroke , color ] ;
523
523
} ;
524
524
525
-
526
525
const modifiedStyleAttributesBuilder = ( docxDocumentInstance , vNode , attributes , options ) => {
527
526
const modifiedAttributes = { ...attributes } ;
528
527
@@ -602,23 +601,23 @@ const modifiedStyleAttributesBuilder = (docxDocumentInstance, vNode, attributes,
602
601
603
602
const { left, right, bottom } = margins
604
603
const indentation = { left, right }
605
- if ( left || right ) {
604
+ if ( isZeroOrTruthy ( left ) || isZeroOrTruthy ( right ) ) {
606
605
modifiedAttributes . indentation = indentation ;
607
606
}
608
- if ( bottom ) {
607
+ if ( isZeroOrTruthy ( bottom ) ) {
609
608
modifiedAttributes . afterSpacing = bottom ;
610
609
}
611
610
} else if ( vNodeStyleKey === 'margin-left' || vNodeStyleKey === 'margin-right' ) {
612
611
const leftMargin = fixupMargin ( vNodeStyle [ 'margin-left' ] ) ;
613
612
const rightMargin = fixupMargin ( vNodeStyle [ 'margin-right' ] ) ;
614
613
const indentation = { } ;
615
- if ( leftMargin ) {
614
+ if ( isZeroOrTruthy ( leftMargin ) ) {
616
615
indentation . left = leftMargin ;
617
616
}
618
- if ( rightMargin ) {
617
+ if ( isZeroOrTruthy ( rightMargin ) ) {
619
618
indentation . right = rightMargin ;
620
619
}
621
- if ( leftMargin || rightMargin ) {
620
+ if ( isZeroOrTruthy ( leftMargin ) || isZeroOrTruthy ( rightMargin ) ) {
622
621
modifiedAttributes . indentation = indentation ;
623
622
}
624
623
} else if ( vNodeStyleKey === 'margin-bottom' ) {
@@ -759,7 +758,7 @@ const buildRunProperties = (attributes) => {
759
758
if ( key === 'textDecoration' ) {
760
759
options . textDecoration = attributes [ key ] ;
761
760
}
762
-
761
+
763
762
if ( key === 'textShadow' ) {
764
763
options . textShadow = attributes [ key ] ;
765
764
}
0 commit comments