@ -161,6 +161,10 @@ doc.addSection({
|
|||||||
text: "and then underlined ",
|
text: "and then underlined ",
|
||||||
underline: {},
|
underline: {},
|
||||||
}),
|
}),
|
||||||
|
new TextRun({
|
||||||
|
text: "and then emphasis-mark ",
|
||||||
|
emphasisMark: {},
|
||||||
|
}),
|
||||||
new TextRun({
|
new TextRun({
|
||||||
text: "and back to normal.",
|
text: "and back to normal.",
|
||||||
}),
|
}),
|
||||||
|
@ -22,7 +22,8 @@ const name = new TextRun({
|
|||||||
### Run formatting
|
### Run formatting
|
||||||
|
|
||||||
- `bold`, `italics`, `smallCaps`, `allCaps`, `strike`, `doubleStrike`, `subScript`, `superScript`: Set the formatting property to true
|
- `bold`, `italics`, `smallCaps`, `allCaps`, `strike`, `doubleStrike`, `subScript`, `superScript`: Set the formatting property to true
|
||||||
- `underline(style="single", color=null)`: Set the underline style and color
|
- `underline({type="single", color=null})`: Set the underline style and color
|
||||||
|
- `emphasisMark({type="dot"})`: Set the emphasis mark style
|
||||||
- `color(color)`: Set the text color, using 6 hex characters for RRGGBB (no leading `#`)
|
- `color(color)`: Set the text color, using 6 hex characters for RRGGBB (no leading `#`)
|
||||||
- `size(halfPts)`: Set the font size, measured in half-points
|
- `size(halfPts)`: Set the font size, measured in half-points
|
||||||
- `font(name)`: Set the run's font
|
- `font(name)`: Set the run's font
|
||||||
|
@ -68,6 +68,15 @@ const text = new TextRun({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Emphasis Mark
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const text = new TextRun({
|
||||||
|
text: "and then emphasis mark",
|
||||||
|
emphasisMark: {},
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
### Strike through
|
### Strike through
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
|
76
package-lock.json
generated
76
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "docx",
|
"name": "docx",
|
||||||
"version": "5.0.2",
|
"version": "5.1.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -191,7 +191,7 @@
|
|||||||
},
|
},
|
||||||
"@sinonjs/formatio": {
|
"@sinonjs/formatio": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz",
|
"resolved": "http://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz",
|
||||||
"integrity": "sha512-ls6CAMA6/5gG+O/IdsBcblvnd8qcO/l1TYoNeAzp3wcISOxlPXQEus0mLcdwazEkWjaBdaJ3TaxmNgCLWwvWzg==",
|
"integrity": "sha512-ls6CAMA6/5gG+O/IdsBcblvnd8qcO/l1TYoNeAzp3wcISOxlPXQEus0mLcdwazEkWjaBdaJ3TaxmNgCLWwvWzg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -256,7 +256,7 @@
|
|||||||
},
|
},
|
||||||
"@types/fs-extra": {
|
"@types/fs-extra": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-5.0.1.tgz",
|
"resolved": "http://registry.npmjs.org/@types/fs-extra/-/fs-extra-5.0.1.tgz",
|
||||||
"integrity": "sha512-h3wnflb+jMTipvbbZnClgA2BexrT4w0GcfoCz5qyxd0IRsbqhLSyesM6mqZTAnhbVmhyTm5tuxfRu9R+8l+lGw==",
|
"integrity": "sha512-h3wnflb+jMTipvbbZnClgA2BexrT4w0GcfoCz5qyxd0IRsbqhLSyesM6mqZTAnhbVmhyTm5tuxfRu9R+8l+lGw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -296,7 +296,7 @@
|
|||||||
},
|
},
|
||||||
"@types/lodash": {
|
"@types/lodash": {
|
||||||
"version": "4.14.104",
|
"version": "4.14.104",
|
||||||
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.104.tgz",
|
"resolved": "http://registry.npmjs.org/@types/lodash/-/lodash-4.14.104.tgz",
|
||||||
"integrity": "sha512-ufQcVg4daO8xQ5kopxRHanqFdL4AI7ondQkV+2f+7mz3gvp0LkBx2zBRC6hfs3T87mzQFmf5Fck7Fi145Ul6NQ==",
|
"integrity": "sha512-ufQcVg4daO8xQ5kopxRHanqFdL4AI7ondQkV+2f+7mz3gvp0LkBx2zBRC6hfs3T87mzQFmf5Fck7Fi145Ul6NQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -319,9 +319,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "13.1.6",
|
"version": "14.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-13.1.6.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.5.tgz",
|
||||||
"integrity": "sha512-Jg1F+bmxcpENHP23sVKkNuU3uaxPnsBMW0cLjleiikFKomJQbsn0Cqk2yDvQArqzZN6ABfBkZ0To7pQ8sLdWDg=="
|
"integrity": "sha512-90hiq6/VqtQgX8Sp0EzeIsv3r+ellbGj4URKj5j30tLlZvRUpnAe9YbYnjl3pJM93GyXU0tghHhvXHq+5rnCKA=="
|
||||||
},
|
},
|
||||||
"@types/request": {
|
"@types/request": {
|
||||||
"version": "2.48.1",
|
"version": "2.48.1",
|
||||||
@ -702,7 +702,7 @@
|
|||||||
},
|
},
|
||||||
"util": {
|
"util": {
|
||||||
"version": "0.10.3",
|
"version": "0.10.3",
|
||||||
"resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
|
"resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz",
|
||||||
"integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
|
"integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -731,7 +731,7 @@
|
|||||||
},
|
},
|
||||||
"async": {
|
"async": {
|
||||||
"version": "0.9.2",
|
"version": "0.9.2",
|
||||||
"resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz",
|
"resolved": "http://registry.npmjs.org/async/-/async-0.9.2.tgz",
|
||||||
"integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=",
|
"integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -755,7 +755,7 @@
|
|||||||
},
|
},
|
||||||
"awesome-typescript-loader": {
|
"awesome-typescript-loader": {
|
||||||
"version": "3.5.0",
|
"version": "3.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/awesome-typescript-loader/-/awesome-typescript-loader-3.5.0.tgz",
|
"resolved": "http://registry.npmjs.org/awesome-typescript-loader/-/awesome-typescript-loader-3.5.0.tgz",
|
||||||
"integrity": "sha512-qzgm9SEvodVkSi9QY7Me1/rujg+YBNMjayNSAyzNghwTEez++gXoPCwMvpbHRG7wrOkDCiF6dquvv9ESmUBAuw==",
|
"integrity": "sha512-qzgm9SEvodVkSi9QY7Me1/rujg+YBNMjayNSAyzNghwTEez++gXoPCwMvpbHRG7wrOkDCiF6dquvv9ESmUBAuw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -799,7 +799,7 @@
|
|||||||
},
|
},
|
||||||
"chalk": {
|
"chalk": {
|
||||||
"version": "1.1.3",
|
"version": "1.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
"resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||||
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -1285,7 +1285,7 @@
|
|||||||
},
|
},
|
||||||
"chai": {
|
"chai": {
|
||||||
"version": "3.5.0",
|
"version": "3.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/chai/-/chai-3.5.0.tgz",
|
"resolved": "http://registry.npmjs.org/chai/-/chai-3.5.0.tgz",
|
||||||
"integrity": "sha1-TQJjewZ/6Vi9v906QOxW/vc3Mkc=",
|
"integrity": "sha1-TQJjewZ/6Vi9v906QOxW/vc3Mkc=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -1507,7 +1507,7 @@
|
|||||||
},
|
},
|
||||||
"commander": {
|
"commander": {
|
||||||
"version": "2.15.1",
|
"version": "2.15.1",
|
||||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
|
"resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
|
||||||
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
|
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -1763,7 +1763,7 @@
|
|||||||
},
|
},
|
||||||
"deep-eql": {
|
"deep-eql": {
|
||||||
"version": "0.1.3",
|
"version": "0.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz",
|
"resolved": "http://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz",
|
||||||
"integrity": "sha1-71WKyrjeJSBs1xOQbXTlaTDrafI=",
|
"integrity": "sha1-71WKyrjeJSBs1xOQbXTlaTDrafI=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -2586,7 +2586,7 @@
|
|||||||
},
|
},
|
||||||
"fast-deep-equal": {
|
"fast-deep-equal": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
|
"resolved": "http://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
|
||||||
"integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=",
|
"integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -3927,7 +3927,7 @@
|
|||||||
"is-buffer": {
|
"is-buffer": {
|
||||||
"version": "1.1.6",
|
"version": "1.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
|
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
|
||||||
"integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=",
|
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"is-ci": {
|
"is-ci": {
|
||||||
@ -4351,7 +4351,7 @@
|
|||||||
},
|
},
|
||||||
"jsesc": {
|
"jsesc": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz",
|
"resolved": "http://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz",
|
||||||
"integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=",
|
"integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -4483,7 +4483,7 @@
|
|||||||
},
|
},
|
||||||
"load-json-file": {
|
"load-json-file": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
|
"resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
|
||||||
"integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=",
|
"integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -4777,7 +4777,7 @@
|
|||||||
"minimatch": {
|
"minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||||
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
|
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
@ -4812,7 +4812,7 @@
|
|||||||
},
|
},
|
||||||
"mkdirp": {
|
"mkdirp": {
|
||||||
"version": "0.5.1",
|
"version": "0.5.1",
|
||||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
"resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -4967,7 +4967,7 @@
|
|||||||
},
|
},
|
||||||
"ncp": {
|
"ncp": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/ncp/-/ncp-1.0.1.tgz",
|
"resolved": "http://registry.npmjs.org/ncp/-/ncp-1.0.1.tgz",
|
||||||
"integrity": "sha1-0VNn5cuHQyuhF9K/gP30Wuz7QkY=",
|
"integrity": "sha1-0VNn5cuHQyuhF9K/gP30Wuz7QkY=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -4985,7 +4985,7 @@
|
|||||||
},
|
},
|
||||||
"next-tick": {
|
"next-tick": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
|
"resolved": "http://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
|
||||||
"integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=",
|
"integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -5518,7 +5518,7 @@
|
|||||||
},
|
},
|
||||||
"os-locale": {
|
"os-locale": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz",
|
"resolved": "http://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz",
|
||||||
"integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=",
|
"integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -5695,7 +5695,7 @@
|
|||||||
},
|
},
|
||||||
"path-is-absolute": {
|
"path-is-absolute": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
"resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
|
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -5766,7 +5766,7 @@
|
|||||||
},
|
},
|
||||||
"pify": {
|
"pify": {
|
||||||
"version": "2.3.0",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
|
"resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
|
||||||
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
|
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -6467,7 +6467,7 @@
|
|||||||
},
|
},
|
||||||
"safe-regex": {
|
"safe-regex": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
|
"resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
|
||||||
"integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
|
"integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -7034,7 +7034,7 @@
|
|||||||
},
|
},
|
||||||
"strip-ansi": {
|
"strip-ansi": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
"resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
||||||
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
|
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -7052,7 +7052,7 @@
|
|||||||
},
|
},
|
||||||
"strip-eof": {
|
"strip-eof": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
|
"resolved": "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
|
||||||
"integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=",
|
"integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -7440,7 +7440,7 @@
|
|||||||
},
|
},
|
||||||
"typedoc": {
|
"typedoc": {
|
||||||
"version": "0.11.1",
|
"version": "0.11.1",
|
||||||
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.11.1.tgz",
|
"resolved": "http://registry.npmjs.org/typedoc/-/typedoc-0.11.1.tgz",
|
||||||
"integrity": "sha512-jdNIoHm5wkZqxQTe/g9AQ3LKnZyrzHXqu6A/c9GUOeJyBWLxNr7/Dm3rwFvLksuxRNwTvY/0HRDU9sJTa9WQSg==",
|
"integrity": "sha512-jdNIoHm5wkZqxQTe/g9AQ3LKnZyrzHXqu6A/c9GUOeJyBWLxNr7/Dm3rwFvLksuxRNwTvY/0HRDU9sJTa9WQSg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -7482,7 +7482,7 @@
|
|||||||
},
|
},
|
||||||
"typescript": {
|
"typescript": {
|
||||||
"version": "2.7.2",
|
"version": "2.7.2",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.7.2.tgz",
|
"resolved": "http://registry.npmjs.org/typescript/-/typescript-2.7.2.tgz",
|
||||||
"integrity": "sha512-p5TCYZDAO0m4G344hD+wx/LATebLWZNkkh2asWUFqSsD2OrDNhbAHuSjobrmsUmdzjJjEeZVU9g1h3O6vpstnw==",
|
"integrity": "sha512-p5TCYZDAO0m4G344hD+wx/LATebLWZNkkh2asWUFqSsD2OrDNhbAHuSjobrmsUmdzjJjEeZVU9g1h3O6vpstnw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
}
|
}
|
||||||
@ -7586,7 +7586,7 @@
|
|||||||
},
|
},
|
||||||
"yargs": {
|
"yargs": {
|
||||||
"version": "3.10.0",
|
"version": "3.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz",
|
"resolved": "http://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz",
|
||||||
"integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=",
|
"integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -8015,7 +8015,7 @@
|
|||||||
},
|
},
|
||||||
"load-json-file": {
|
"load-json-file": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz",
|
"resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz",
|
||||||
"integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=",
|
"integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -8216,7 +8216,7 @@
|
|||||||
},
|
},
|
||||||
"winston": {
|
"winston": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/winston/-/winston-2.1.1.tgz",
|
"resolved": "http://registry.npmjs.org/winston/-/winston-2.1.1.tgz",
|
||||||
"integrity": "sha1-PJNJ0ZYgf9G9/51LxD73JRDjoS4=",
|
"integrity": "sha1-PJNJ0ZYgf9G9/51LxD73JRDjoS4=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -8231,13 +8231,13 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": {
|
"async": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/async/-/async-1.0.0.tgz",
|
"resolved": "http://registry.npmjs.org/async/-/async-1.0.0.tgz",
|
||||||
"integrity": "sha1-+PwEyjoTeErenhZBr5hXjPvWR6k=",
|
"integrity": "sha1-+PwEyjoTeErenhZBr5hXjPvWR6k=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"colors": {
|
"colors": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz",
|
"resolved": "http://registry.npmjs.org/colors/-/colors-1.0.3.tgz",
|
||||||
"integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=",
|
"integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -8257,7 +8257,7 @@
|
|||||||
},
|
},
|
||||||
"wrap-ansi": {
|
"wrap-ansi": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
|
"resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
|
||||||
"integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=",
|
"integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -8391,7 +8391,7 @@
|
|||||||
},
|
},
|
||||||
"yargs": {
|
"yargs": {
|
||||||
"version": "4.8.1",
|
"version": "4.8.1",
|
||||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz",
|
"resolved": "http://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz",
|
||||||
"integrity": "sha1-wMQpJMpKqmsObaFznfshZDn53cA=",
|
"integrity": "sha1-wMQpJMpKqmsObaFznfshZDn53cA=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -8435,7 +8435,7 @@
|
|||||||
},
|
},
|
||||||
"yargs-parser": {
|
"yargs-parser": {
|
||||||
"version": "2.4.1",
|
"version": "2.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-2.4.1.tgz",
|
"resolved": "http://registry.npmjs.org/yargs-parser/-/yargs-parser-2.4.1.tgz",
|
||||||
"integrity": "sha1-hVaN488VD/SfpRgl8DqMiA3cxcQ=",
|
"integrity": "sha1-hVaN488VD/SfpRgl8DqMiA3cxcQ=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "docx",
|
"name": "docx",
|
||||||
"version": "5.1.0",
|
"version": "5.1.1",
|
||||||
"description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
|
"description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -50,7 +50,7 @@
|
|||||||
"types": "./build/index.d.ts",
|
"types": "./build/index.d.ts",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/jszip": "^3.1.4",
|
"@types/jszip": "^3.1.4",
|
||||||
"@types/node": "^13.1.6",
|
"@types/node": "^14.0.5",
|
||||||
"jszip": "^3.1.5",
|
"jszip": "^3.1.5",
|
||||||
"shortid": "^2.2.15",
|
"shortid": "^2.2.15",
|
||||||
"xml": "^1.0.1",
|
"xml": "^1.0.1",
|
||||||
|
@ -3,7 +3,7 @@ import { expect } from "chai";
|
|||||||
import { Formatter } from "export/formatter";
|
import { Formatter } from "export/formatter";
|
||||||
import { EMPTY_OBJECT } from "file/xml-components";
|
import { EMPTY_OBJECT } from "file/xml-components";
|
||||||
|
|
||||||
import { AlignmentType, TabStopPosition } from "../paragraph";
|
import { AlignmentType, EmphasisMarkType, TabStopPosition } from "../paragraph";
|
||||||
import { UnderlineType } from "../paragraph/run/underline";
|
import { UnderlineType } from "../paragraph/run/underline";
|
||||||
import { ShadingType } from "../table";
|
import { ShadingType } from "../table";
|
||||||
import { AbstractNumbering } from "./abstract-numbering";
|
import { AbstractNumbering } from "./abstract-numbering";
|
||||||
@ -433,7 +433,16 @@ describe("AbstractNumbering", () => {
|
|||||||
const tree = new Formatter().format(abstractNumbering);
|
const tree = new Formatter().format(abstractNumbering);
|
||||||
expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
|
expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
|
||||||
"w:rPr": [
|
"w:rPr": [
|
||||||
{ "w:rFonts": { _attr: { "w:ascii": "Times", "w:cs": "Times", "w:eastAsia": "Times", "w:hAnsi": "Times" } } },
|
{
|
||||||
|
"w:rFonts": {
|
||||||
|
_attr: {
|
||||||
|
"w:ascii": "Times",
|
||||||
|
"w:cs": "Times",
|
||||||
|
"w:eastAsia": "Times",
|
||||||
|
"w:hAnsi": "Times",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -582,6 +591,48 @@ describe("AbstractNumbering", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#emphasisMark", () => {
|
||||||
|
it("should set emphasisMark to 'dot' if no arguments are given", () => {
|
||||||
|
const abstractNumbering = new AbstractNumbering(1, [
|
||||||
|
{
|
||||||
|
level: 0,
|
||||||
|
format: "lowerRoman",
|
||||||
|
text: "%0.",
|
||||||
|
style: {
|
||||||
|
run: {
|
||||||
|
emphasisMark: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
const tree = new Formatter().format(abstractNumbering);
|
||||||
|
expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
|
||||||
|
"w:rPr": [{ "w:em": { _attr: { "w:val": "dot" } } }],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should set the style if given", () => {
|
||||||
|
const abstractNumbering = new AbstractNumbering(1, [
|
||||||
|
{
|
||||||
|
level: 0,
|
||||||
|
format: "lowerRoman",
|
||||||
|
text: "%0.",
|
||||||
|
style: {
|
||||||
|
run: {
|
||||||
|
emphasisMark: {
|
||||||
|
type: EmphasisMarkType.DOT,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
const tree = new Formatter().format(abstractNumbering);
|
||||||
|
expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({
|
||||||
|
"w:rPr": [{ "w:em": { _attr: { "w:val": "dot" } } }],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("#color", () => {
|
it("#color", () => {
|
||||||
const abstractNumbering = new AbstractNumbering(1, [
|
const abstractNumbering = new AbstractNumbering(1, [
|
||||||
{
|
{
|
||||||
|
@ -177,6 +177,10 @@ export class LevelBase extends XmlComponent {
|
|||||||
this.runProperties.push(new formatting.Underline(style.run.underline.type, style.run.underline.color));
|
this.runProperties.push(new formatting.Underline(style.run.underline.type, style.run.underline.color));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (style.run.emphasisMark) {
|
||||||
|
this.runProperties.push(new formatting.EmphasisMark(style.run.emphasisMark.type));
|
||||||
|
}
|
||||||
|
|
||||||
if (style.run.color) {
|
if (style.run.color) {
|
||||||
this.runProperties.push(new formatting.Color(style.run.color));
|
this.runProperties.push(new formatting.Color(style.run.color));
|
||||||
}
|
}
|
||||||
|
@ -147,17 +147,6 @@ export class Numbering extends XmlComponent {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
level: 9,
|
|
||||||
format: "bullet",
|
|
||||||
text: "\u2726",
|
|
||||||
alignment: AlignmentType.LEFT,
|
|
||||||
style: {
|
|
||||||
paragraph: {
|
|
||||||
indent: { left: 720, hanging: 360 },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.createConcreteNumbering(abstractNumbering);
|
this.createConcreteNumbering(abstractNumbering);
|
||||||
|
29
src/file/paragraph/run/emphasis-mark.spec.ts
Normal file
29
src/file/paragraph/run/emphasis-mark.spec.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import * as em from "./emphasis-mark";
|
||||||
|
|
||||||
|
describe("EmphasisMark", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a new EmphasisMark object with w:em as the rootKey", () => {
|
||||||
|
const emphasisMark = new em.EmphasisMark();
|
||||||
|
const tree = new Formatter().format(emphasisMark);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:em": { _attr: { "w:val": "dot" } },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("DotEmphasisMark", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should put value in attribute", () => {
|
||||||
|
const emphasisMark = new em.DotEmphasisMark();
|
||||||
|
const tree = new Formatter().format(emphasisMark);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:em": { _attr: { "w:val": "dot" } },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
28
src/file/paragraph/run/emphasis-mark.ts
Normal file
28
src/file/paragraph/run/emphasis-mark.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
export enum EmphasisMarkType {
|
||||||
|
DOT = "dot",
|
||||||
|
}
|
||||||
|
|
||||||
|
export abstract class BaseEmphasisMark extends XmlComponent {
|
||||||
|
protected constructor(emphasisMarkType: EmphasisMarkType) {
|
||||||
|
super("w:em");
|
||||||
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
|
val: emphasisMarkType,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class EmphasisMark extends BaseEmphasisMark {
|
||||||
|
constructor(emphasisMarkType: EmphasisMarkType = EmphasisMarkType.DOT) {
|
||||||
|
super(emphasisMarkType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DotEmphasisMark extends BaseEmphasisMark {
|
||||||
|
constructor() {
|
||||||
|
super(EmphasisMarkType.DOT);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
import { Attributes, XmlComponent } from "file/xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export { Underline } from "./underline";
|
export { Underline } from "./underline";
|
||||||
|
export { EmphasisMark } from "./emphasis-mark";
|
||||||
export { SubScript, SuperScript } from "./script";
|
export { SubScript, SuperScript } from "./script";
|
||||||
export { RunFonts } from "./run-fonts";
|
export { RunFonts } from "./run-fonts";
|
||||||
|
|
||||||
|
@ -5,4 +5,5 @@ export * from "./picture-run";
|
|||||||
export * from "./run-fonts";
|
export * from "./run-fonts";
|
||||||
export * from "./sequential-identifier";
|
export * from "./sequential-identifier";
|
||||||
export * from "./underline";
|
export * from "./underline";
|
||||||
|
export * from "./emphasis-mark";
|
||||||
export * from "./tab";
|
export * from "./tab";
|
||||||
|
@ -5,6 +5,7 @@ import { Formatter } from "export/formatter";
|
|||||||
import { ShadingType } from "file/table";
|
import { ShadingType } from "file/table";
|
||||||
|
|
||||||
import { Run } from "./";
|
import { Run } from "./";
|
||||||
|
import { EmphasisMarkType } from "./emphasis-mark";
|
||||||
import { PageNumber } from "./run";
|
import { PageNumber } from "./run";
|
||||||
import { UnderlineType } from "./underline";
|
import { UnderlineType } from "./underline";
|
||||||
|
|
||||||
@ -84,6 +85,30 @@ describe("Run", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#emphasisMark()", () => {
|
||||||
|
it("should default to 'dot'", () => {
|
||||||
|
const run = new Run({
|
||||||
|
emphasisMark: {},
|
||||||
|
});
|
||||||
|
const tree = new Formatter().format(run);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:r": [{ "w:rPr": [{ "w:em": { _attr: { "w:val": "dot" } } }] }],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should set the style type if given", () => {
|
||||||
|
const run = new Run({
|
||||||
|
emphasisMark: {
|
||||||
|
type: EmphasisMarkType.DOT,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const tree = new Formatter().format(run);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:r": [{ "w:rPr": [{ "w:em": { _attr: { "w:val": "dot" } } }] }],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("#smallCaps()", () => {
|
describe("#smallCaps()", () => {
|
||||||
it("it should add smallCaps to the properties", () => {
|
it("it should add smallCaps to the properties", () => {
|
||||||
const run = new Run({
|
const run = new Run({
|
||||||
@ -235,7 +260,16 @@ describe("Run", () => {
|
|||||||
"w:r": [
|
"w:r": [
|
||||||
{
|
{
|
||||||
"w:rPr": [
|
"w:rPr": [
|
||||||
{ "w:rFonts": { _attr: { "w:ascii": "Times", "w:cs": "Times", "w:eastAsia": "Times", "w:hAnsi": "Times" } } },
|
{
|
||||||
|
"w:rFonts": {
|
||||||
|
_attr: {
|
||||||
|
"w:ascii": "Times",
|
||||||
|
"w:cs": "Times",
|
||||||
|
"w:eastAsia": "Times",
|
||||||
|
"w:hAnsi": "Times",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -6,6 +6,7 @@ import { FootnoteReferenceRun } from "file/footnotes/footnote/run/reference-run"
|
|||||||
import { FieldInstruction } from "file/table-of-contents/field-instruction";
|
import { FieldInstruction } from "file/table-of-contents/field-instruction";
|
||||||
import { Break } from "./break";
|
import { Break } from "./break";
|
||||||
import { Caps, SmallCaps } from "./caps";
|
import { Caps, SmallCaps } from "./caps";
|
||||||
|
import { EmphasisMark, EmphasisMarkType } from "./emphasis-mark";
|
||||||
import { Begin, End, Separate } from "./field";
|
import { Begin, End, Separate } from "./field";
|
||||||
import {
|
import {
|
||||||
Bold,
|
Bold,
|
||||||
@ -38,6 +39,9 @@ export interface IRunOptions {
|
|||||||
readonly color?: string;
|
readonly color?: string;
|
||||||
readonly type?: UnderlineType;
|
readonly type?: UnderlineType;
|
||||||
};
|
};
|
||||||
|
readonly emphasisMark?: {
|
||||||
|
readonly type?: EmphasisMarkType;
|
||||||
|
};
|
||||||
readonly color?: string;
|
readonly color?: string;
|
||||||
readonly size?: number;
|
readonly size?: number;
|
||||||
readonly rightToLeft?: boolean;
|
readonly rightToLeft?: boolean;
|
||||||
@ -90,6 +94,10 @@ export class Run extends XmlComponent {
|
|||||||
this.properties.push(new Underline(options.underline.type, options.underline.color));
|
this.properties.push(new Underline(options.underline.type, options.underline.color));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.emphasisMark) {
|
||||||
|
this.properties.push(new EmphasisMark(options.emphasisMark.type));
|
||||||
|
}
|
||||||
|
|
||||||
if (options.color) {
|
if (options.color) {
|
||||||
this.properties.push(new Color(options.color));
|
this.properties.push(new Color(options.color));
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { EmphasisMarkType } from "./emphasis-mark";
|
||||||
|
|
||||||
import { Formatter } from "export/formatter";
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
import { UnderlineType } from "./underline";
|
import { UnderlineType } from "./underline";
|
||||||
@ -44,6 +46,9 @@ describe("SymbolRun", () => {
|
|||||||
color: "red",
|
color: "red",
|
||||||
type: UnderlineType.DOUBLE,
|
type: UnderlineType.DOUBLE,
|
||||||
},
|
},
|
||||||
|
emphasisMark: {
|
||||||
|
type: EmphasisMarkType.DOT,
|
||||||
|
},
|
||||||
color: "green",
|
color: "green",
|
||||||
size: 40,
|
size: 40,
|
||||||
highlight: "yellow",
|
highlight: "yellow",
|
||||||
@ -59,6 +64,7 @@ describe("SymbolRun", () => {
|
|||||||
{ "w:i": { _attr: { "w:val": true } } },
|
{ "w:i": { _attr: { "w:val": true } } },
|
||||||
{ "w:iCs": { _attr: { "w:val": true } } },
|
{ "w:iCs": { _attr: { "w:val": true } } },
|
||||||
{ "w:u": { _attr: { "w:val": "double", "w:color": "red" } } },
|
{ "w:u": { _attr: { "w:val": "double", "w:color": "red" } } },
|
||||||
|
{ "w:em": { _attr: { "w:val": "dot" } } },
|
||||||
{ "w:color": { _attr: { "w:val": "green" } } },
|
{ "w:color": { _attr: { "w:val": "green" } } },
|
||||||
{ "w:sz": { _attr: { "w:val": 40 } } },
|
{ "w:sz": { _attr: { "w:val": 40 } } },
|
||||||
{ "w:szCs": { _attr: { "w:val": 40 } } },
|
{ "w:szCs": { _attr: { "w:val": 40 } } },
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { AlignmentType, IIndentAttributesProperties, ISpacingProperties, UnderlineType } from "../paragraph";
|
import { AlignmentType, EmphasisMarkType, IIndentAttributesProperties, ISpacingProperties, UnderlineType } from "../paragraph";
|
||||||
import { ShadingType } from "../table";
|
import { ShadingType } from "../table";
|
||||||
|
|
||||||
export interface IRunStyleOptions {
|
export interface IRunStyleOptions {
|
||||||
@ -15,6 +15,9 @@ export interface IRunStyleOptions {
|
|||||||
readonly type?: UnderlineType;
|
readonly type?: UnderlineType;
|
||||||
readonly color?: string;
|
readonly color?: string;
|
||||||
};
|
};
|
||||||
|
readonly emphasisMark?: {
|
||||||
|
readonly type?: EmphasisMarkType;
|
||||||
|
};
|
||||||
readonly color?: string;
|
readonly color?: string;
|
||||||
readonly font?: string;
|
readonly font?: string;
|
||||||
readonly characterSpacing?: number;
|
readonly characterSpacing?: number;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
|
||||||
import { Formatter } from "export/formatter";
|
import { Formatter } from "export/formatter";
|
||||||
|
import { EmphasisMarkType } from "file/paragraph/run/emphasis-mark";
|
||||||
import { UnderlineType } from "file/paragraph/run/underline";
|
import { UnderlineType } from "file/paragraph/run/underline";
|
||||||
import { ShadingType } from "file/table";
|
import { ShadingType } from "file/table";
|
||||||
import { EMPTY_OBJECT } from "file/xml-components";
|
import { EMPTY_OBJECT } from "file/xml-components";
|
||||||
@ -412,6 +413,66 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#emphasisMark", () => {
|
||||||
|
it("should set emphasisMark to 'dot' if no arguments are given", () => {
|
||||||
|
const style = new CharacterStyle({
|
||||||
|
id: "myStyleId",
|
||||||
|
run: {
|
||||||
|
emphasisMark: {},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const tree = new Formatter().format(style);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:style": [
|
||||||
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
||||||
|
{
|
||||||
|
"w:rPr": [{ "w:em": { _attr: { "w:val": "dot" } } }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:uiPriority": {
|
||||||
|
_attr: {
|
||||||
|
"w:val": 99,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should set the style if given", () => {
|
||||||
|
const style = new CharacterStyle({
|
||||||
|
id: "myStyleId",
|
||||||
|
run: {
|
||||||
|
emphasisMark: {
|
||||||
|
type: EmphasisMarkType.DOT,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const tree = new Formatter().format(style);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:style": [
|
||||||
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
||||||
|
{
|
||||||
|
"w:rPr": [{ "w:em": { _attr: { "w:val": "dot" } } }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:uiPriority": {
|
||||||
|
_attr: {
|
||||||
|
"w:val": 99,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:unhideWhenUsed": EMPTY_OBJECT,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("#superScript", () => {
|
it("#superScript", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new CharacterStyle({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
@ -616,7 +677,17 @@ describe("CharacterStyle", () => {
|
|||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
||||||
{
|
{
|
||||||
"w:rPr": [{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }],
|
"w:rPr": [
|
||||||
|
{
|
||||||
|
"w:shd": {
|
||||||
|
_attr: {
|
||||||
|
"w:val": "pct10",
|
||||||
|
"w:fill": "00FFFF",
|
||||||
|
"w:color": "FF0000",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"w:uiPriority": {
|
"w:uiPriority": {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { EmphasisMarkType } from "file/paragraph/run/emphasis-mark";
|
||||||
import * as formatting from "file/paragraph/run/formatting";
|
import * as formatting from "file/paragraph/run/formatting";
|
||||||
import { RunProperties } from "file/paragraph/run/properties";
|
import { RunProperties } from "file/paragraph/run/properties";
|
||||||
import { UnderlineType } from "file/paragraph/run/underline";
|
import { UnderlineType } from "file/paragraph/run/underline";
|
||||||
@ -23,6 +24,9 @@ export interface IBaseCharacterStyleOptions {
|
|||||||
readonly type?: UnderlineType;
|
readonly type?: UnderlineType;
|
||||||
readonly color?: string;
|
readonly color?: string;
|
||||||
};
|
};
|
||||||
|
readonly emphasisMark?: {
|
||||||
|
readonly type?: EmphasisMarkType;
|
||||||
|
};
|
||||||
readonly color?: string;
|
readonly color?: string;
|
||||||
readonly font?: string;
|
readonly font?: string;
|
||||||
readonly characterSpacing?: number;
|
readonly characterSpacing?: number;
|
||||||
@ -104,6 +108,10 @@ export class CharacterStyle extends Style {
|
|||||||
this.runProperties.push(new formatting.Underline(options.run.underline.type, options.run.underline.color));
|
this.runProperties.push(new formatting.Underline(options.run.underline.type, options.run.underline.color));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.run.emphasisMark) {
|
||||||
|
this.runProperties.push(new formatting.EmphasisMark(options.run.emphasisMark.type));
|
||||||
|
}
|
||||||
|
|
||||||
if (options.run.color) {
|
if (options.run.color) {
|
||||||
this.runProperties.push(new formatting.Color(options.run.color));
|
this.runProperties.push(new formatting.Color(options.run.color));
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
|
||||||
import { Formatter } from "export/formatter";
|
import { Formatter } from "export/formatter";
|
||||||
import { AlignmentType, TabStopPosition } from "file/paragraph";
|
import { AlignmentType, EmphasisMarkType, TabStopPosition } from "file/paragraph";
|
||||||
import { UnderlineType } from "file/paragraph/run/underline";
|
import { UnderlineType } from "file/paragraph/run/underline";
|
||||||
import { ShadingType } from "file/table";
|
import { ShadingType } from "file/table";
|
||||||
import { EMPTY_OBJECT } from "file/xml-components";
|
import { EMPTY_OBJECT } from "file/xml-components";
|
||||||
@ -49,7 +49,15 @@ describe("ParagraphStyle", () => {
|
|||||||
const style = new ParagraphStyle({ id: "myStyleId", quickFormat: true });
|
const style = new ParagraphStyle({ id: "myStyleId", quickFormat: true });
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:qFormat": EMPTY_OBJECT }],
|
"w:style": [
|
||||||
|
{
|
||||||
|
_attr: {
|
||||||
|
"w:type": "paragraph",
|
||||||
|
"w:styleId": "myStyleId",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ "w:qFormat": EMPTY_OBJECT },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -299,7 +307,15 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:pPr": [{ "w:keepLines": EMPTY_OBJECT }] }],
|
"w:style": [
|
||||||
|
{
|
||||||
|
_attr: {
|
||||||
|
"w:type": "paragraph",
|
||||||
|
"w:styleId": "myStyleId",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ "w:pPr": [{ "w:keepLines": EMPTY_OBJECT }] },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -312,7 +328,15 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:pPr": [{ "w:keepNext": EMPTY_OBJECT }] }],
|
"w:style": [
|
||||||
|
{
|
||||||
|
_attr: {
|
||||||
|
"w:type": "paragraph",
|
||||||
|
"w:styleId": "myStyleId",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ "w:pPr": [{ "w:keepNext": EMPTY_OBJECT }] },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -473,7 +497,16 @@ describe("ParagraphStyle", () => {
|
|||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{
|
{
|
||||||
"w:rPr": [
|
"w:rPr": [
|
||||||
{ "w:rFonts": { _attr: { "w:ascii": "Times", "w:cs": "Times", "w:eastAsia": "Times", "w:hAnsi": "Times" } } },
|
{
|
||||||
|
"w:rFonts": {
|
||||||
|
_attr: {
|
||||||
|
"w:ascii": "Times",
|
||||||
|
"w:cs": "Times",
|
||||||
|
"w:eastAsia": "Times",
|
||||||
|
"w:hAnsi": "Times",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -550,7 +583,17 @@ describe("ParagraphStyle", () => {
|
|||||||
"w:style": [
|
"w:style": [
|
||||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
{
|
{
|
||||||
"w:rPr": [{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }],
|
"w:rPr": [
|
||||||
|
{
|
||||||
|
"w:shd": {
|
||||||
|
_attr: {
|
||||||
|
"w:val": "pct10",
|
||||||
|
"w:fill": "00FFFF",
|
||||||
|
"w:color": "FF0000",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@ -617,6 +660,46 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#emphasisMark", () => {
|
||||||
|
it("should set emphasisMark to 'dot' if no arguments are given", () => {
|
||||||
|
const style = new ParagraphStyle({
|
||||||
|
id: "myStyleId",
|
||||||
|
run: {
|
||||||
|
emphasisMark: {},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const tree = new Formatter().format(style);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:style": [
|
||||||
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
|
{
|
||||||
|
"w:rPr": [{ "w:em": { _attr: { "w:val": "dot" } } }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should set the style if given", () => {
|
||||||
|
const style = new ParagraphStyle({
|
||||||
|
id: "myStyleId",
|
||||||
|
run: {
|
||||||
|
emphasisMark: {
|
||||||
|
type: EmphasisMarkType.DOT,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const tree = new Formatter().format(style);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:style": [
|
||||||
|
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
|
{
|
||||||
|
"w:rPr": [{ "w:em": { _attr: { "w:val": "dot" } } }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("#color", () => {
|
it("#color", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new ParagraphStyle({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
@ -639,7 +722,15 @@ describe("ParagraphStyle", () => {
|
|||||||
const style = new ParagraphStyle({ id: "myStyleId", link: "MyLink" });
|
const style = new ParagraphStyle({ id: "myStyleId", link: "MyLink" });
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:link": { _attr: { "w:val": "MyLink" } } }],
|
"w:style": [
|
||||||
|
{
|
||||||
|
_attr: {
|
||||||
|
"w:type": "paragraph",
|
||||||
|
"w:styleId": "myStyleId",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ "w:link": { _attr: { "w:val": "MyLink" } } },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -647,7 +738,15 @@ describe("ParagraphStyle", () => {
|
|||||||
const style = new ParagraphStyle({ id: "myStyleId", semiHidden: true });
|
const style = new ParagraphStyle({ id: "myStyleId", semiHidden: true });
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:semiHidden": EMPTY_OBJECT }],
|
"w:style": [
|
||||||
|
{
|
||||||
|
_attr: {
|
||||||
|
"w:type": "paragraph",
|
||||||
|
"w:styleId": "myStyleId",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ "w:semiHidden": EMPTY_OBJECT },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -672,7 +771,15 @@ describe("ParagraphStyle", () => {
|
|||||||
const style = new ParagraphStyle({ id: "myStyleId", unhideWhenUsed: true });
|
const style = new ParagraphStyle({ id: "myStyleId", unhideWhenUsed: true });
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:unhideWhenUsed": EMPTY_OBJECT }],
|
"w:style": [
|
||||||
|
{
|
||||||
|
_attr: {
|
||||||
|
"w:type": "paragraph",
|
||||||
|
"w:styleId": "myStyleId",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ "w:unhideWhenUsed": EMPTY_OBJECT },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -114,6 +114,10 @@ export class ParagraphStyle extends Style {
|
|||||||
this.runProperties.push(new formatting.Underline(options.run.underline.type, options.run.underline.color));
|
this.runProperties.push(new formatting.Underline(options.run.underline.type, options.run.underline.color));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.run.emphasisMark) {
|
||||||
|
this.runProperties.push(new formatting.EmphasisMark(options.run.emphasisMark.type));
|
||||||
|
}
|
||||||
|
|
||||||
if (options.run.color) {
|
if (options.run.color) {
|
||||||
this.runProperties.push(new formatting.Color(options.run.color));
|
this.runProperties.push(new formatting.Color(options.run.color));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user