diff --git a/example/example-node.js b/example/example-node.js index 403048e..17c0667 100644 --- a/example/example-node.js +++ b/example/example-node.js @@ -1437,6 +1437,13 @@ const htmlString = `

+
+ Add new domain to Google Workspace +

This text has shadow. And this has shadow with strong tag.

+

This text has empty shadow property.

+

This text has none shadow property.

+
+

Some tr styles cases

Color property only passed to tr

diff --git a/example/example.js b/example/example.js index 33d17f5..adaf83d 100644 --- a/example/example.js +++ b/example/example.js @@ -1437,6 +1437,13 @@ const htmlString = `

+
+ Add new domain to Google Workspace +

This text has shadow. And this has shadow with strong tag.

+

This text has empty shadow property.

+

This text has none shadow property.

+
+

Some tr styles cases

Color property only passed to tr

diff --git a/example/react-example/src/App.js b/example/react-example/src/App.js index 318196e..e457654 100644 --- a/example/react-example/src/App.js +++ b/example/react-example/src/App.js @@ -1434,6 +1434,13 @@ const htmlString = `

+
+ Add new domain to Google Workspace +

This text has shadow. And this has shadow with strong tag.

+

This text has empty shadow property.

+

This text has none shadow property.

+
+

Some tr styles cases

Color property only passed to tr

diff --git a/src/helpers/xml-builder.js b/src/helpers/xml-builder.js index e5a6045..0ad0265 100644 --- a/src/helpers/xml-builder.js +++ b/src/helpers/xml-builder.js @@ -322,6 +322,11 @@ const fixupTextDecorationLine = (line) => { } return line; }; +const buildTextShadow = () => + fragment({ namespaceAlias: { w: namespaces.w } }) + .ele('@w', 'shadow') + .att('@w', 'val', true) + .up(); // eslint-disable-next-line consistent-return const fixupLineHeight = (lineHeight, fontSize) => { @@ -667,7 +672,9 @@ const modifiedStyleAttributesBuilder = (docxDocumentInstance, vNode, attributes, line: 'underline', }; } else if (vNodeStyleKey === 'text-shadow') { - modifiedAttributes.textShadow = vNodeStyleValue; + if (vNodeStyleValue.trim() !== '' && vNodeStyleValue !== 'none') { + modifiedAttributes.textShadow = vNodeStyleValue; + } } } } @@ -729,6 +736,8 @@ const buildFormatting = (htmlTag, options) => { return buildRunStyleFragment('Hyperlink'); case 'textDecoration': return buildTextDecoration(options && options.textDecoration ? options.textDecoration : {}); + case 'textShadow': + return buildTextShadow(); } return null; @@ -750,6 +759,10 @@ const buildRunProperties = (attributes) => { if (key === 'textDecoration') { options.textDecoration = attributes[key]; } + + if (key === 'textShadow') { + options.textShadow = attributes[key]; + } const formattingFragment = buildFormatting(key, options); if (formattingFragment) {