Skip to content

Commit 08be315

Browse files
authored
adding handler for text-shadow property (#18)
1 parent 9302e3e commit 08be315

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

example/example-node.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,13 @@ const htmlString = `<!DOCTYPE html>
14371437
</p>
14381438
</div>
14391439
1440+
<div>
1441+
<span style="text-shadow: 1px 1px 2px grey;">Add new domain</span> to Google Workspace
1442+
<p style="text-shadow: 1px 1px 2px grey;">This text has shadow.<strong> And this has shadow with strong tag.</strong> </p>
1443+
<p style="text-shadow:">This text has empty shadow property.</p>
1444+
<p style="text-shadow: none">This text has none shadow property.</p>
1445+
</div>
1446+
14401447
<p>Some tr styles cases</p>
14411448
<p>Color property only passed to tr</p>
14421449
<div align="left">

example/example.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,13 @@ const htmlString = `<!DOCTYPE html>
14371437
</p>
14381438
</div>
14391439
1440+
<div>
1441+
<span style="text-shadow: 1px 1px 2px grey;">Add new domain</span> to Google Workspace
1442+
<p style="text-shadow: 1px 1px 2px grey;">This text has shadow.<strong> And this has shadow with strong tag.</strong> </p>
1443+
<p style="text-shadow:">This text has empty shadow property.</p>
1444+
<p style="text-shadow: none">This text has none shadow property.</p>
1445+
</div>
1446+
14401447
<p>Some tr styles cases</p>
14411448
<p>Color property only passed to tr</p>
14421449
<div align="left">

example/react-example/src/App.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,13 @@ const htmlString = `<!DOCTYPE html>
14341434
</p>
14351435
</div>
14361436
1437+
<div>
1438+
<span style="text-shadow: 1px 1px 2px grey;">Add new domain</span> to Google Workspace
1439+
<p style="text-shadow: 1px 1px 2px grey;">This text has shadow.<strong> And this has shadow with strong tag.</strong> </p>
1440+
<p style="text-shadow:">This text has empty shadow property.</p>
1441+
<p style="text-shadow: none">This text has none shadow property.</p>
1442+
</div>
1443+
14371444
<p>Some tr styles cases</p>
14381445
<p>Color property only passed to tr</p>
14391446
<div align="left">

src/helpers/xml-builder.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,11 @@ const fixupTextDecorationLine = (line) => {
322322
}
323323
return line;
324324
};
325+
const buildTextShadow = () =>
326+
fragment({ namespaceAlias: { w: namespaces.w } })
327+
.ele('@w', 'shadow')
328+
.att('@w', 'val', true)
329+
.up();
325330

326331
// eslint-disable-next-line consistent-return
327332
const fixupLineHeight = (lineHeight, fontSize) => {
@@ -667,7 +672,9 @@ const modifiedStyleAttributesBuilder = (docxDocumentInstance, vNode, attributes,
667672
line: 'underline',
668673
};
669674
} else if (vNodeStyleKey === 'text-shadow') {
670-
modifiedAttributes.textShadow = vNodeStyleValue;
675+
if (vNodeStyleValue.trim() !== '' && vNodeStyleValue !== 'none') {
676+
modifiedAttributes.textShadow = vNodeStyleValue;
677+
}
671678
}
672679
}
673680
}
@@ -729,6 +736,8 @@ const buildFormatting = (htmlTag, options) => {
729736
return buildRunStyleFragment('Hyperlink');
730737
case 'textDecoration':
731738
return buildTextDecoration(options && options.textDecoration ? options.textDecoration : {});
739+
case 'textShadow':
740+
return buildTextShadow();
732741
}
733742

734743
return null;
@@ -750,6 +759,10 @@ const buildRunProperties = (attributes) => {
750759
if (key === 'textDecoration') {
751760
options.textDecoration = attributes[key];
752761
}
762+
763+
if (key === 'textShadow') {
764+
options.textShadow = attributes[key];
765+
}
753766

754767
const formattingFragment = buildFormatting(key, options);
755768
if (formattingFragment) {

0 commit comments

Comments
 (0)