Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
b210608e56 | |||
74353104dc | |||
825136d1c9 | |||
b2fea471f1 | |||
e9adb8b0ed | |||
5d6bc039d0 | |||
27638063c8 | |||
f6a4d78ab7 | |||
4061e31400 | |||
74db67689f | |||
2213eb28cb | |||
d1b45d416b | |||
f72f7e7514 | |||
0165cfb3e5 | |||
ef747486c0 | |||
e0b2f59c2f |
104
.github/workflows/default.yml
vendored
Normal file
104
.github/workflows/default.yml
vendored
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
name: Default
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repo
|
||||||
|
uses: actions/checkout@master
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm ci
|
||||||
|
- name: Build
|
||||||
|
run: npm run build
|
||||||
|
- name: Archive Production Artifact
|
||||||
|
uses: actions/upload-artifact@master
|
||||||
|
with:
|
||||||
|
name: build
|
||||||
|
path: build
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repo
|
||||||
|
uses: actions/checkout@master
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm ci
|
||||||
|
- name: Test
|
||||||
|
run: npm run test.coverage
|
||||||
|
lint:
|
||||||
|
name: Lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repo
|
||||||
|
uses: actions/checkout@master
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm ci
|
||||||
|
- name: Lint
|
||||||
|
run: npm run lint
|
||||||
|
prettier:
|
||||||
|
name: Prettier
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repo
|
||||||
|
uses: actions/checkout@master
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm ci
|
||||||
|
- name: Prettier
|
||||||
|
run: npm run style
|
||||||
|
demos:
|
||||||
|
name: Run Demos
|
||||||
|
needs: [build]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repo
|
||||||
|
uses: actions/checkout@master
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm ci
|
||||||
|
- name: Download Artifact
|
||||||
|
uses: actions/download-artifact@master
|
||||||
|
with:
|
||||||
|
name: build
|
||||||
|
path: build
|
||||||
|
- name: Run demos
|
||||||
|
run: |
|
||||||
|
npm run ts-node -- ./demo/1-basic.ts
|
||||||
|
npm run ts-node -- ./demo/2-declaritive-styles.ts
|
||||||
|
npm run ts-node -- ./demo/3-numbering-and-bullet-points.ts
|
||||||
|
npm run ts-node -- ./demo/4-basic-table.ts
|
||||||
|
npm run ts-node -- ./demo/5-images.ts
|
||||||
|
npm run ts-node -- ./demo/6-page-borders.ts
|
||||||
|
npm run ts-node -- ./demo/7-landscape.ts
|
||||||
|
npm run ts-node -- ./demo/8-header-footer.ts
|
||||||
|
npm run ts-node -- ./demo/9-images-in-header-and-footer.ts
|
||||||
|
npm run ts-node -- ./demo/10-my-cv.ts
|
||||||
|
npm run ts-node -- ./demo/11-declaritive-styles-2.ts
|
||||||
|
npm run ts-node -- ./demo/12-scaling-images.ts
|
||||||
|
npm run ts-node -- ./demo/13-xml-styles.ts
|
||||||
|
npm run ts-node -- ./demo/14-page-numbers.ts
|
||||||
|
npm run ts-node -- ./demo/15-page-break-before.ts
|
||||||
|
npm run ts-node -- ./demo/16-multiple-sections.ts
|
||||||
|
npm run ts-node -- ./demo/17-footnotes.ts
|
||||||
|
npm run ts-node -- ./demo/18-image-from-buffer.ts
|
||||||
|
npm run ts-node -- ./demo/19-export-to-base64.ts
|
||||||
|
npm run ts-node -- ./demo/20-table-cell-borders.ts
|
||||||
|
npm run ts-node -- ./demo/21-bookmarks.ts
|
||||||
|
npm run ts-node -- ./demo/22-right-to-left-text.ts
|
||||||
|
npm run ts-node -- ./demo/23-base64-images.ts
|
||||||
|
npm run ts-node -- ./demo/24-images-to-table-cell.ts
|
||||||
|
npm run ts-node -- ./demo/26-paragraph-borders.ts
|
||||||
|
npm run ts-node -- ./demo/27-declaritive-styles-3.ts
|
||||||
|
npm run ts-node -- ./demo/28-table-of-contents.ts
|
||||||
|
npm run ts-node -- ./demo/29-numbered-lists.ts
|
||||||
|
npm run ts-node -- ./demo/30-template-document.ts
|
||||||
|
npm run ts-node -- ./demo/31-tables.ts
|
||||||
|
npm run ts-node -- ./demo/32-merge-and-shade-table-cells.ts
|
||||||
|
npm run ts-node -- ./demo/33-sequential-captions.ts
|
||||||
|
npm run ts-node -- ./demo/34-floating-tables.ts
|
@ -11,6 +11,7 @@
|
|||||||
[![NPM version][npm-image]][npm-url]
|
[![NPM version][npm-image]][npm-url]
|
||||||
[![Downloads per month][downloads-image]][downloads-url]
|
[![Downloads per month][downloads-image]][downloads-url]
|
||||||
[![Build Status][travis-image]][travis-url]
|
[![Build Status][travis-image]][travis-url]
|
||||||
|
[![GitHub Action Workflow Status][github-actions-workflow-image]][github-actions-workflow-url]
|
||||||
[![Dependency Status][daviddm-image]][daviddm-url]
|
[![Dependency Status][daviddm-image]][daviddm-url]
|
||||||
[![Known Vulnerabilities][snky-image]][snky-url]
|
[![Known Vulnerabilities][snky-image]][snky-url]
|
||||||
[![Chat on Gitter][gitter-image]][gitter-url]
|
[![Chat on Gitter][gitter-image]][gitter-url]
|
||||||
@ -85,6 +86,7 @@ Read the contribution guidelines [here](https://docx.js.org/#/contribution-guide
|
|||||||
[<img src="https://i.imgur.com/QEZXU5b.png" alt="drawing" height="50"/>](https://www.beekast.com/)
|
[<img src="https://i.imgur.com/QEZXU5b.png" alt="drawing" height="50"/>](https://www.beekast.com/)
|
||||||
[<img src="https://imgur.com/XVU6aoi.png" alt="drawing" height="50"/>](https://herraizsoto.com/)
|
[<img src="https://imgur.com/XVU6aoi.png" alt="drawing" height="50"/>](https://herraizsoto.com/)
|
||||||
[<img src="https://i.imgur.com/fn1xccG.png" alt="drawing" height="50"/>](http://www.ativer.com.br/)
|
[<img src="https://i.imgur.com/fn1xccG.png" alt="drawing" height="50"/>](http://www.ativer.com.br/)
|
||||||
|
[<img src="https://i.imgur.com/cmykN7c.png" alt="drawing"/>](https://www.arity.co/)
|
||||||
|
|
||||||
|
|
||||||
...and many more!
|
...and many more!
|
||||||
@ -102,6 +104,8 @@ Made with 💖
|
|||||||
[downloads-url]: https://npmjs.org/package/docx
|
[downloads-url]: https://npmjs.org/package/docx
|
||||||
[travis-image]: https://travis-ci.org/dolanmiu/docx.svg?branch=master
|
[travis-image]: https://travis-ci.org/dolanmiu/docx.svg?branch=master
|
||||||
[travis-url]: https://travis-ci.org/dolanmiu/docx
|
[travis-url]: https://travis-ci.org/dolanmiu/docx
|
||||||
|
[github-actions-workflow-image]: https://github.com/dolanmiu/docx/workflows/Default/badge.svg
|
||||||
|
[github-actions-workflow-url]: https://github.com/dolanmiu/docx/actions
|
||||||
[daviddm-image]: https://david-dm.org/dolanmiu/docx.svg?theme=shields.io
|
[daviddm-image]: https://david-dm.org/dolanmiu/docx.svg?theme=shields.io
|
||||||
[daviddm-url]: https://david-dm.org/dolanmiu/docx
|
[daviddm-url]: https://david-dm.org/dolanmiu/docx
|
||||||
[snky-image]: https://snyk.io/test/github/dolanmiu/docx/badge.svg
|
[snky-image]: https://snyk.io/test/github/dolanmiu/docx/badge.svg
|
||||||
|
14
package-lock.json
generated
14
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "docx",
|
"name": "docx",
|
||||||
"version": "5.3.0",
|
"version": "5.4.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -576,9 +576,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/mocha": {
|
"@types/mocha": {
|
||||||
"version": "8.0.3",
|
"version": "8.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.0.4.tgz",
|
||||||
"integrity": "sha512-vyxR57nv8NfcU0GZu8EUXZLTbCMupIUwy95LJ6lllN+JRPG25CwMHoB1q5xKh8YKhQnHYRAn4yW2yuHbf/5xgg==",
|
"integrity": "sha512-M4BwiTJjHmLq6kjON7ZoI2JMlBvpY3BYSdiP6s/qCT3jb1s9/DeJF0JELpAxiVSIxXDzfNKe+r7yedMIoLbknQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
@ -670,9 +670,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/webpack": {
|
"@types/webpack": {
|
||||||
"version": "4.41.24",
|
"version": "4.41.25",
|
||||||
"resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.24.tgz",
|
"resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.25.tgz",
|
||||||
"integrity": "sha512-1A0MXPwZiMOD3DPMuOKUKcpkdPo8Lq33UGggZ7xio6wJ/jV1dAu5cXDrOfGDnldUroPIRLsr/DT43/GqOA4RFQ==",
|
"integrity": "sha512-cr6kZ+4m9lp86ytQc1jPOJXgINQyz3kLLunZ57jznW+WIAL0JqZbGubQk4GlD42MuQL5JGOABrxdpqqWeovlVQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/anymatch": "*",
|
"@types/anymatch": "*",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "docx",
|
"name": "docx",
|
||||||
"version": "5.4.0",
|
"version": "5.4.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": {
|
||||||
|
@ -19,3 +19,9 @@ export type MathComponent =
|
|||||||
| MathCurlyBrackets
|
| MathCurlyBrackets
|
||||||
| MathAngledBrackets
|
| MathAngledBrackets
|
||||||
| MathSquareBrackets;
|
| MathSquareBrackets;
|
||||||
|
|
||||||
|
// Needed because of: https://github.com/s-panferov/awesome-typescript-loader/issues/432
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
export const WORKAROUND4 = "";
|
||||||
|
@ -6,12 +6,12 @@ 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";
|
||||||
|
|
||||||
import { CharacterStyle } from "./character-style";
|
import { StyleForCharacter } from "./character-style";
|
||||||
|
|
||||||
describe("CharacterStyle", () => {
|
describe("CharacterStyle", () => {
|
||||||
describe("#constructor", () => {
|
describe("#constructor", () => {
|
||||||
it("should set the style type to character and use the given style id", () => {
|
it("should set the style type to character and use the given style id", () => {
|
||||||
const style = new CharacterStyle({ id: "myStyleId" });
|
const style = new StyleForCharacter({ id: "myStyleId" });
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
@ -31,7 +31,7 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should set the name of the style, if given", () => {
|
it("should set the name of the style, if given", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
name: "Style Name",
|
name: "Style Name",
|
||||||
});
|
});
|
||||||
@ -55,7 +55,7 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should add smallCaps", () => {
|
it("should add smallCaps", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
smallCaps: true,
|
smallCaps: true,
|
||||||
@ -83,7 +83,7 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should add allCaps", () => {
|
it("should add allCaps", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
allCaps: true,
|
allCaps: true,
|
||||||
@ -111,7 +111,7 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should add strike", () => {
|
it("should add strike", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
strike: true,
|
strike: true,
|
||||||
@ -139,7 +139,7 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should add double strike", () => {
|
it("should add double strike", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
doubleStrike: true,
|
doubleStrike: true,
|
||||||
@ -167,7 +167,7 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should add sub script", () => {
|
it("should add sub script", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
subScript: true,
|
subScript: true,
|
||||||
@ -203,7 +203,7 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should add font by name", () => {
|
it("should add font by name", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
font: "test font",
|
font: "test font",
|
||||||
@ -242,7 +242,7 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should add font for ascii and eastAsia", () => {
|
it("should add font for ascii and eastAsia", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
font: {
|
font: {
|
||||||
@ -282,7 +282,7 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should add character spacing", () => {
|
it("should add character spacing", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
characterSpacing: 100,
|
characterSpacing: 100,
|
||||||
@ -312,7 +312,7 @@ describe("CharacterStyle", () => {
|
|||||||
|
|
||||||
describe("formatting methods: style attributes", () => {
|
describe("formatting methods: style attributes", () => {
|
||||||
it("#basedOn", () => {
|
it("#basedOn", () => {
|
||||||
const style = new CharacterStyle({ id: "myStyleId", basedOn: "otherId" });
|
const style = new StyleForCharacter({ id: "myStyleId", basedOn: "otherId" });
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
@ -357,7 +357,7 @@ describe("CharacterStyle", () => {
|
|||||||
];
|
];
|
||||||
sizeTests.forEach(({ size, sizeComplexScript, expected }) => {
|
sizeTests.forEach(({ size, sizeComplexScript, expected }) => {
|
||||||
it(`#size ${size} cs ${sizeComplexScript}`, () => {
|
it(`#size ${size} cs ${sizeComplexScript}`, () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: { size, sizeComplexScript },
|
run: { size, sizeComplexScript },
|
||||||
});
|
});
|
||||||
@ -385,7 +385,7 @@ describe("CharacterStyle", () => {
|
|||||||
|
|
||||||
describe("#underline", () => {
|
describe("#underline", () => {
|
||||||
it("should set underline to 'single' if no arguments are given", () => {
|
it("should set underline to 'single' if no arguments are given", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
underline: {},
|
underline: {},
|
||||||
@ -413,7 +413,7 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should set the style if given", () => {
|
it("should set the style if given", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
underline: {
|
underline: {
|
||||||
@ -443,7 +443,7 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should set the style and color if given", () => {
|
it("should set the style and color if given", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
underline: {
|
underline: {
|
||||||
@ -476,7 +476,7 @@ describe("CharacterStyle", () => {
|
|||||||
|
|
||||||
describe("#emphasisMark", () => {
|
describe("#emphasisMark", () => {
|
||||||
it("should set emphasisMark to 'dot' if no arguments are given", () => {
|
it("should set emphasisMark to 'dot' if no arguments are given", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
emphasisMark: {},
|
emphasisMark: {},
|
||||||
@ -504,7 +504,7 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should set the style if given", () => {
|
it("should set the style if given", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
emphasisMark: {
|
emphasisMark: {
|
||||||
@ -535,7 +535,7 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#superScript", () => {
|
it("#superScript", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
superScript: true,
|
superScript: true,
|
||||||
@ -571,7 +571,7 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#color", () => {
|
it("#color", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
color: "123456",
|
color: "123456",
|
||||||
@ -616,7 +616,7 @@ describe("CharacterStyle", () => {
|
|||||||
];
|
];
|
||||||
boldTests.forEach(({ bold, boldComplexScript, expected }) => {
|
boldTests.forEach(({ bold, boldComplexScript, expected }) => {
|
||||||
it(`#bold ${bold} cs ${boldComplexScript}`, () => {
|
it(`#bold ${bold} cs ${boldComplexScript}`, () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: { bold, boldComplexScript },
|
run: { bold, boldComplexScript },
|
||||||
});
|
});
|
||||||
@ -660,7 +660,7 @@ describe("CharacterStyle", () => {
|
|||||||
];
|
];
|
||||||
italicsTests.forEach(({ italics, italicsComplexScript, expected }) => {
|
italicsTests.forEach(({ italics, italicsComplexScript, expected }) => {
|
||||||
it(`#italics ${italics} cs ${italicsComplexScript}`, () => {
|
it(`#italics ${italics} cs ${italicsComplexScript}`, () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: { italics, italicsComplexScript },
|
run: { italics, italicsComplexScript },
|
||||||
});
|
});
|
||||||
@ -687,7 +687,7 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#link", () => {
|
it("#link", () => {
|
||||||
const style = new CharacterStyle({ id: "myStyleId", link: "MyLink" });
|
const style = new StyleForCharacter({ 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": [
|
"w:style": [
|
||||||
@ -708,7 +708,7 @@ describe("CharacterStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#semiHidden", () => {
|
it("#semiHidden", () => {
|
||||||
const style = new CharacterStyle({ id: "myStyleId", semiHidden: true });
|
const style = new StyleForCharacter({ 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": [
|
"w:style": [
|
||||||
@ -749,7 +749,7 @@ describe("CharacterStyle", () => {
|
|||||||
];
|
];
|
||||||
highlightTests.forEach(({ highlight, highlightComplexScript, expected }) => {
|
highlightTests.forEach(({ highlight, highlightComplexScript, expected }) => {
|
||||||
it(`#highlight ${highlight} cs ${highlightComplexScript}`, () => {
|
it(`#highlight ${highlight} cs ${highlightComplexScript}`, () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: { highlight, highlightComplexScript },
|
run: { highlight, highlightComplexScript },
|
||||||
});
|
});
|
||||||
@ -838,7 +838,7 @@ describe("CharacterStyle", () => {
|
|||||||
];
|
];
|
||||||
shadingTests.forEach(({ shadow, shading, shadingComplexScript, expected }) => {
|
shadingTests.forEach(({ shadow, shading, shadingComplexScript, expected }) => {
|
||||||
it("#shadow correctly", () => {
|
it("#shadow correctly", () => {
|
||||||
const style = new CharacterStyle({
|
const style = new StyleForCharacter({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: { shadow, shading, shadingComplexScript },
|
run: { shadow, shading, shadingComplexScript },
|
||||||
});
|
});
|
||||||
|
@ -15,7 +15,7 @@ export interface ICharacterStyleOptions extends IBaseCharacterStyleOptions {
|
|||||||
readonly name?: string;
|
readonly name?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CharacterStyle extends Style {
|
export class StyleForCharacter extends Style {
|
||||||
private readonly runProperties: RunProperties;
|
private readonly runProperties: RunProperties;
|
||||||
|
|
||||||
constructor(options: ICharacterStyleOptions) {
|
constructor(options: ICharacterStyleOptions) {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { UnderlineType } from "file/paragraph/run/underline";
|
import { UnderlineType } from "file/paragraph/run/underline";
|
||||||
|
|
||||||
import { CharacterStyle, IBaseCharacterStyleOptions } from "./character-style";
|
import { IBaseCharacterStyleOptions, StyleForCharacter } from "./character-style";
|
||||||
import { IBaseParagraphStyleOptions, IParagraphStyleOptions, ParagraphStyle } from "./paragraph-style";
|
import { IBaseParagraphStyleOptions, IParagraphStyleOptions, StyleForParagraph } from "./paragraph-style";
|
||||||
|
|
||||||
export class HeadingStyle extends ParagraphStyle {
|
export class HeadingStyle extends StyleForParagraph {
|
||||||
constructor(options: IParagraphStyleOptions) {
|
constructor(options: IParagraphStyleOptions) {
|
||||||
super({
|
super({
|
||||||
...options,
|
...options,
|
||||||
@ -84,7 +84,7 @@ export class Heading6Style extends HeadingStyle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ListParagraph extends ParagraphStyle {
|
export class ListParagraph extends StyleForParagraph {
|
||||||
constructor(options: IBaseParagraphStyleOptions) {
|
constructor(options: IBaseParagraphStyleOptions) {
|
||||||
super({
|
super({
|
||||||
...options,
|
...options,
|
||||||
@ -96,7 +96,7 @@ export class ListParagraph extends ParagraphStyle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class FootnoteText extends ParagraphStyle {
|
export class FootnoteText extends StyleForParagraph {
|
||||||
constructor(options: IBaseParagraphStyleOptions) {
|
constructor(options: IBaseParagraphStyleOptions) {
|
||||||
super({
|
super({
|
||||||
...options,
|
...options,
|
||||||
@ -121,7 +121,7 @@ export class FootnoteText extends ParagraphStyle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class FootnoteReferenceStyle extends CharacterStyle {
|
export class FootnoteReferenceStyle extends StyleForCharacter {
|
||||||
constructor(options: IBaseCharacterStyleOptions) {
|
constructor(options: IBaseCharacterStyleOptions) {
|
||||||
super({
|
super({
|
||||||
...options,
|
...options,
|
||||||
@ -136,7 +136,7 @@ export class FootnoteReferenceStyle extends CharacterStyle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class FootnoteTextChar extends CharacterStyle {
|
export class FootnoteTextChar extends StyleForCharacter {
|
||||||
constructor(options: IBaseCharacterStyleOptions) {
|
constructor(options: IBaseCharacterStyleOptions) {
|
||||||
super({
|
super({
|
||||||
...options,
|
...options,
|
||||||
@ -152,7 +152,7 @@ export class FootnoteTextChar extends CharacterStyle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class HyperlinkStyle extends CharacterStyle {
|
export class HyperlinkStyle extends StyleForCharacter {
|
||||||
constructor(options: IBaseCharacterStyleOptions) {
|
constructor(options: IBaseCharacterStyleOptions) {
|
||||||
super({
|
super({
|
||||||
...options,
|
...options,
|
||||||
|
@ -6,12 +6,12 @@ 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";
|
||||||
|
|
||||||
import { ParagraphStyle } from "./paragraph-style";
|
import { StyleForParagraph } from "./paragraph-style";
|
||||||
|
|
||||||
describe("ParagraphStyle", () => {
|
describe("ParagraphStyle", () => {
|
||||||
describe("#constructor", () => {
|
describe("#constructor", () => {
|
||||||
it("should set the style type to paragraph and use the given style id", () => {
|
it("should set the style type to paragraph and use the given style id", () => {
|
||||||
const style = new ParagraphStyle({ id: "myStyleId" });
|
const style = new StyleForParagraph({ id: "myStyleId" });
|
||||||
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:style": { _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||||
@ -19,7 +19,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should set the name of the style, if given", () => {
|
it("should set the name of the style, if given", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
name: "Style Name",
|
name: "Style Name",
|
||||||
});
|
});
|
||||||
@ -35,7 +35,7 @@ describe("ParagraphStyle", () => {
|
|||||||
|
|
||||||
describe("formatting methods: style attributes", () => {
|
describe("formatting methods: style attributes", () => {
|
||||||
it("#basedOn", () => {
|
it("#basedOn", () => {
|
||||||
const style = new ParagraphStyle({ id: "myStyleId", basedOn: "otherId" });
|
const style = new StyleForParagraph({ id: "myStyleId", basedOn: "otherId" });
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
@ -46,7 +46,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#quickFormat", () => {
|
it("#quickFormat", () => {
|
||||||
const style = new ParagraphStyle({ id: "myStyleId", quickFormat: true });
|
const style = new StyleForParagraph({ 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": [
|
"w:style": [
|
||||||
@ -62,7 +62,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#next", () => {
|
it("#next", () => {
|
||||||
const style = new ParagraphStyle({ id: "myStyleId", next: "otherId" });
|
const style = new StyleForParagraph({ id: "myStyleId", next: "otherId" });
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
@ -75,7 +75,7 @@ describe("ParagraphStyle", () => {
|
|||||||
|
|
||||||
describe("formatting methods: paragraph properties", () => {
|
describe("formatting methods: paragraph properties", () => {
|
||||||
it("#indent", () => {
|
it("#indent", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
paragraph: {
|
paragraph: {
|
||||||
indent: { left: 720 },
|
indent: { left: 720 },
|
||||||
@ -93,7 +93,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#spacing", () => {
|
it("#spacing", () => {
|
||||||
const style = new ParagraphStyle({ id: "myStyleId", paragraph: { spacing: { before: 50, after: 150 } } });
|
const style = new StyleForParagraph({ id: "myStyleId", paragraph: { spacing: { before: 50, after: 150 } } });
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
@ -106,7 +106,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#center", () => {
|
it("#center", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
paragraph: {
|
paragraph: {
|
||||||
alignment: AlignmentType.CENTER,
|
alignment: AlignmentType.CENTER,
|
||||||
@ -124,7 +124,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#character spacing", () => {
|
it("#character spacing", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
characterSpacing: 24,
|
characterSpacing: 24,
|
||||||
@ -142,7 +142,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#left", () => {
|
it("#left", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
paragraph: {
|
paragraph: {
|
||||||
alignment: AlignmentType.LEFT,
|
alignment: AlignmentType.LEFT,
|
||||||
@ -160,7 +160,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#right", () => {
|
it("#right", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
paragraph: {
|
paragraph: {
|
||||||
alignment: AlignmentType.RIGHT,
|
alignment: AlignmentType.RIGHT,
|
||||||
@ -178,7 +178,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#justified", () => {
|
it("#justified", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
paragraph: {
|
paragraph: {
|
||||||
alignment: AlignmentType.JUSTIFIED,
|
alignment: AlignmentType.JUSTIFIED,
|
||||||
@ -196,7 +196,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#thematicBreak", () => {
|
it("#thematicBreak", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
paragraph: {
|
paragraph: {
|
||||||
thematicBreak: true,
|
thematicBreak: true,
|
||||||
@ -229,7 +229,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#contextualSpacing", () => {
|
it("#contextualSpacing", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
paragraph: {
|
paragraph: {
|
||||||
contextualSpacing: true,
|
contextualSpacing: true,
|
||||||
@ -255,7 +255,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#leftTabStop", () => {
|
it("#leftTabStop", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
paragraph: {
|
paragraph: {
|
||||||
leftTabStop: 1200,
|
leftTabStop: 1200,
|
||||||
@ -277,7 +277,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#maxRightTabStop", () => {
|
it("#maxRightTabStop", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
paragraph: {
|
paragraph: {
|
||||||
rightTabStop: TabStopPosition.MAX,
|
rightTabStop: TabStopPosition.MAX,
|
||||||
@ -299,7 +299,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#keepLines", () => {
|
it("#keepLines", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
paragraph: {
|
paragraph: {
|
||||||
keepLines: true,
|
keepLines: true,
|
||||||
@ -320,7 +320,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#keepNext", () => {
|
it("#keepNext", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
paragraph: {
|
paragraph: {
|
||||||
keepNext: true,
|
keepNext: true,
|
||||||
@ -341,7 +341,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#outlineLevel", () => {
|
it("#outlineLevel", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
paragraph: {
|
paragraph: {
|
||||||
outlineLevel: 1,
|
outlineLevel: 1,
|
||||||
@ -381,7 +381,7 @@ describe("ParagraphStyle", () => {
|
|||||||
];
|
];
|
||||||
sizeTests.forEach(({ size, sizeComplexScript, expected }) => {
|
sizeTests.forEach(({ size, sizeComplexScript, expected }) => {
|
||||||
it(`#size ${size} cs ${sizeComplexScript}`, () => {
|
it(`#size ${size} cs ${sizeComplexScript}`, () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: { size, sizeComplexScript },
|
run: { size, sizeComplexScript },
|
||||||
});
|
});
|
||||||
@ -393,7 +393,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#smallCaps", () => {
|
it("#smallCaps", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
smallCaps: true,
|
smallCaps: true,
|
||||||
@ -411,7 +411,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#allCaps", () => {
|
it("#allCaps", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
allCaps: true,
|
allCaps: true,
|
||||||
@ -429,7 +429,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#strike", () => {
|
it("#strike", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
strike: true,
|
strike: true,
|
||||||
@ -447,7 +447,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#doubleStrike", () => {
|
it("#doubleStrike", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
doubleStrike: true,
|
doubleStrike: true,
|
||||||
@ -465,7 +465,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#subScript", () => {
|
it("#subScript", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
subScript: true,
|
subScript: true,
|
||||||
@ -483,7 +483,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#superScript", () => {
|
it("#superScript", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
superScript: true,
|
superScript: true,
|
||||||
@ -501,7 +501,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#font by name", () => {
|
it("#font by name", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
font: "Times",
|
font: "Times",
|
||||||
@ -530,7 +530,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#font for ascii and eastAsia", () => {
|
it("#font for ascii and eastAsia", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
font: {
|
font: {
|
||||||
@ -577,7 +577,7 @@ describe("ParagraphStyle", () => {
|
|||||||
];
|
];
|
||||||
boldTests.forEach(({ bold, boldComplexScript, expected }) => {
|
boldTests.forEach(({ bold, boldComplexScript, expected }) => {
|
||||||
it(`#bold ${bold} cs ${boldComplexScript}`, () => {
|
it(`#bold ${bold} cs ${boldComplexScript}`, () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: { bold, boldComplexScript },
|
run: { bold, boldComplexScript },
|
||||||
});
|
});
|
||||||
@ -606,7 +606,7 @@ describe("ParagraphStyle", () => {
|
|||||||
];
|
];
|
||||||
italicsTests.forEach(({ italics, italicsComplexScript, expected }) => {
|
italicsTests.forEach(({ italics, italicsComplexScript, expected }) => {
|
||||||
it(`#italics ${italics} cs ${italicsComplexScript}`, () => {
|
it(`#italics ${italics} cs ${italicsComplexScript}`, () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: { italics, italicsComplexScript },
|
run: { italics, italicsComplexScript },
|
||||||
});
|
});
|
||||||
@ -640,7 +640,7 @@ describe("ParagraphStyle", () => {
|
|||||||
];
|
];
|
||||||
highlightTests.forEach(({ highlight, highlightComplexScript, expected }) => {
|
highlightTests.forEach(({ highlight, highlightComplexScript, expected }) => {
|
||||||
it(`#highlight ${highlight} cs ${highlightComplexScript}`, () => {
|
it(`#highlight ${highlight} cs ${highlightComplexScript}`, () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: { highlight, highlightComplexScript },
|
run: { highlight, highlightComplexScript },
|
||||||
});
|
});
|
||||||
@ -714,7 +714,7 @@ describe("ParagraphStyle", () => {
|
|||||||
];
|
];
|
||||||
shadingTests.forEach(({ shadow, shading, shadingComplexScript, expected }) => {
|
shadingTests.forEach(({ shadow, shading, shadingComplexScript, expected }) => {
|
||||||
it("#shadow correctly", () => {
|
it("#shadow correctly", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: { shadow, shading, shadingComplexScript },
|
run: { shadow, shading, shadingComplexScript },
|
||||||
});
|
});
|
||||||
@ -727,7 +727,7 @@ describe("ParagraphStyle", () => {
|
|||||||
|
|
||||||
describe("#underline", () => {
|
describe("#underline", () => {
|
||||||
it("should set underline to 'single' if no arguments are given", () => {
|
it("should set underline to 'single' if no arguments are given", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
underline: {},
|
underline: {},
|
||||||
@ -745,7 +745,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should set the style if given", () => {
|
it("should set the style if given", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
underline: {
|
underline: {
|
||||||
@ -765,7 +765,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should set the style and color if given", () => {
|
it("should set the style and color if given", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
underline: {
|
underline: {
|
||||||
@ -788,7 +788,7 @@ describe("ParagraphStyle", () => {
|
|||||||
|
|
||||||
describe("#emphasisMark", () => {
|
describe("#emphasisMark", () => {
|
||||||
it("should set emphasisMark to 'dot' if no arguments are given", () => {
|
it("should set emphasisMark to 'dot' if no arguments are given", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
emphasisMark: {},
|
emphasisMark: {},
|
||||||
@ -806,7 +806,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should set the style if given", () => {
|
it("should set the style if given", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
emphasisMark: {
|
emphasisMark: {
|
||||||
@ -827,7 +827,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#color", () => {
|
it("#color", () => {
|
||||||
const style = new ParagraphStyle({
|
const style = new StyleForParagraph({
|
||||||
id: "myStyleId",
|
id: "myStyleId",
|
||||||
run: {
|
run: {
|
||||||
color: "123456",
|
color: "123456",
|
||||||
@ -845,7 +845,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#link", () => {
|
it("#link", () => {
|
||||||
const style = new ParagraphStyle({ id: "myStyleId", link: "MyLink" });
|
const style = new StyleForParagraph({ 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": [
|
"w:style": [
|
||||||
@ -861,7 +861,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#semiHidden", () => {
|
it("#semiHidden", () => {
|
||||||
const style = new ParagraphStyle({ id: "myStyleId", semiHidden: true });
|
const style = new StyleForParagraph({ 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": [
|
"w:style": [
|
||||||
@ -877,7 +877,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#uiPriority", () => {
|
it("#uiPriority", () => {
|
||||||
const style = new ParagraphStyle({ id: "myStyleId", uiPriority: 99 });
|
const style = new StyleForParagraph({ id: "myStyleId", uiPriority: 99 });
|
||||||
const tree = new Formatter().format(style);
|
const tree = new Formatter().format(style);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
"w:style": [
|
"w:style": [
|
||||||
@ -894,7 +894,7 @@ describe("ParagraphStyle", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("#unhideWhenUsed", () => {
|
it("#unhideWhenUsed", () => {
|
||||||
const style = new ParagraphStyle({ id: "myStyleId", unhideWhenUsed: true });
|
const style = new StyleForParagraph({ 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": [
|
"w:style": [
|
||||||
|
@ -21,7 +21,7 @@ export interface IParagraphStyleOptions extends IBaseParagraphStyleOptions {
|
|||||||
readonly name?: string;
|
readonly name?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ParagraphStyle extends Style {
|
export class StyleForParagraph extends Style {
|
||||||
private readonly paragraphProperties: ParagraphProperties;
|
private readonly paragraphProperties: ParagraphProperties;
|
||||||
private readonly runProperties: RunProperties;
|
private readonly runProperties: RunProperties;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { BaseXmlComponent, ImportedXmlComponent, XmlComponent } from "file/xml-components";
|
import { BaseXmlComponent, ImportedXmlComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
import { CharacterStyle, ParagraphStyle } from "./style";
|
import { StyleForCharacter, StyleForParagraph } from "./style";
|
||||||
import { ICharacterStyleOptions } from "./style/character-style";
|
import { ICharacterStyleOptions } from "./style/character-style";
|
||||||
import { IParagraphStyleOptions } from "./style/paragraph-style";
|
import { IParagraphStyleOptions } from "./style/paragraph-style";
|
||||||
export * from "./border";
|
export * from "./border";
|
||||||
@ -9,7 +9,7 @@ export interface IStylesOptions {
|
|||||||
readonly initialStyles?: BaseXmlComponent;
|
readonly initialStyles?: BaseXmlComponent;
|
||||||
readonly paragraphStyles?: IParagraphStyleOptions[];
|
readonly paragraphStyles?: IParagraphStyleOptions[];
|
||||||
readonly characterStyles?: ICharacterStyleOptions[];
|
readonly characterStyles?: ICharacterStyleOptions[];
|
||||||
readonly importedStyles?: (XmlComponent | ParagraphStyle | CharacterStyle | ImportedXmlComponent)[];
|
readonly importedStyles?: (XmlComponent | StyleForParagraph | StyleForCharacter | ImportedXmlComponent)[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Styles extends XmlComponent {
|
export class Styles extends XmlComponent {
|
||||||
@ -28,13 +28,13 @@ export class Styles extends XmlComponent {
|
|||||||
|
|
||||||
if (options.paragraphStyles) {
|
if (options.paragraphStyles) {
|
||||||
for (const style of options.paragraphStyles) {
|
for (const style of options.paragraphStyles) {
|
||||||
this.root.push(new ParagraphStyle(style));
|
this.root.push(new StyleForParagraph(style));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.characterStyles) {
|
if (options.characterStyles) {
|
||||||
for (const style of options.characterStyles) {
|
for (const style of options.characterStyles) {
|
||||||
this.root.push(new CharacterStyle(style));
|
this.root.push(new StyleForCharacter(style));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user