Made project Prettier compliant
This commit is contained in:
@ -3,7 +3,6 @@ import { ParagraphPropertiesDefaults } from "./paragraph-properties";
|
||||
import { RunPropertiesDefaults } from "./run-properties";
|
||||
|
||||
export class DocumentDefaults extends XmlComponent {
|
||||
|
||||
private runPropertiesDefaults: RunPropertiesDefaults;
|
||||
private paragraphPropertiesDefaults: ParagraphPropertiesDefaults;
|
||||
|
||||
|
@ -2,7 +2,6 @@ import { XmlComponent } from "file/xml-components";
|
||||
import { ParagraphProperties } from "../../paragraph/properties";
|
||||
|
||||
export class ParagraphPropertiesDefaults extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("w:pPrDefault");
|
||||
this.root.push(new ParagraphProperties());
|
||||
|
@ -3,12 +3,17 @@ import { Color, Italics, Size } from "../paragraph/run/formatting";
|
||||
import { Styles } from "./";
|
||||
// import { DocumentDefaults } from "./defaults";
|
||||
import {
|
||||
Heading1Style, Heading2Style, Heading3Style, Heading4Style, Heading5Style, Heading6Style,
|
||||
ListParagraph, TitleStyle,
|
||||
Heading1Style,
|
||||
Heading2Style,
|
||||
Heading3Style,
|
||||
Heading4Style,
|
||||
Heading5Style,
|
||||
Heading6Style,
|
||||
ListParagraph,
|
||||
TitleStyle,
|
||||
} from "./style";
|
||||
|
||||
export class DefaultStylesFactory {
|
||||
|
||||
public newInstance(): Styles {
|
||||
const styles = new Styles();
|
||||
styles.createDocumentDefaults();
|
||||
|
@ -4,18 +4,18 @@ import { DocumentDefaults } from "./defaults";
|
||||
import { ParagraphStyle } from "./style";
|
||||
|
||||
export class Styles extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("w:styles");
|
||||
this.root.push(new DocumentAttributes({
|
||||
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
||||
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
||||
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
||||
w14: "http://schemas.microsoft.com/office/word/2010/wordml",
|
||||
w15: "http://schemas.microsoft.com/office/word/2012/wordml",
|
||||
Ignorable: "w14 w15",
|
||||
}));
|
||||
|
||||
this.root.push(
|
||||
new DocumentAttributes({
|
||||
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
||||
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
||||
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
||||
w14: "http://schemas.microsoft.com/office/word/2010/wordml",
|
||||
w15: "http://schemas.microsoft.com/office/word/2012/wordml",
|
||||
Ignorable: "w14 w15",
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
public push(style: XmlComponent): Styles {
|
||||
|
@ -19,7 +19,6 @@ export class LatentStyleExceptionAttributes extends XmlAttributeComponent<ILaten
|
||||
}
|
||||
|
||||
export class LatentStyleException extends XmlComponent {
|
||||
|
||||
constructor(attributes: ILatentStyleExceptionAttributesProperties) {
|
||||
super("w:lsdException");
|
||||
this.root.push(new LatentStyleExceptionAttributes(attributes));
|
||||
|
@ -2,7 +2,6 @@ import { XmlComponent } from "file/xml-components";
|
||||
import { LatentStyleException } from "./exceptions";
|
||||
|
||||
export class LatentStyles extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("w:latentStyles");
|
||||
}
|
||||
|
@ -1,149 +1,211 @@
|
||||
/* tslint:disable */
|
||||
function createLsdException(name, uiPriority, qFormat?, semiHidden?, unhideWhenUsed?) {
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
return [{
|
||||
_attr: {
|
||||
'w:name': name,
|
||||
'w:uiPriority': uiPriority,
|
||||
'w:qFormat': qFormat,
|
||||
'w:semiHidden': semiHidden,
|
||||
'w:unhideWhenUsed': unhideWhenUsed
|
||||
}
|
||||
}];
|
||||
return [
|
||||
{
|
||||
_attr: {
|
||||
"w:name": name,
|
||||
"w:uiPriority": uiPriority,
|
||||
"w:qFormat": qFormat,
|
||||
"w:semiHidden": semiHidden,
|
||||
"w:unhideWhenUsed": unhideWhenUsed,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export function DefaultStyle() {
|
||||
var style = {
|
||||
'w:styles': [{
|
||||
_attr: {
|
||||
'xmlns:mc': 'http://schemas.openxmlformats.org/markup-compatibility/2006',
|
||||
'xmlns:r': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
|
||||
'xmlns:w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main',
|
||||
'xmlns:w14': 'http://schemas.microsoft.com/office/word/2010/wordml',
|
||||
'xmlns:w15': 'http://schemas.microsoft.com/office/word/2012/wordml',
|
||||
'mc:Ignorable': 'w14 w15'
|
||||
}
|
||||
}, {
|
||||
'w:docDefaults': [{
|
||||
'w:rPrDefault': [{
|
||||
'w:rPr': [{
|
||||
'w:rFonts': [{
|
||||
_attr: {
|
||||
'w:asciiTheme': "minorHAnsi",
|
||||
'w:eastAsiaTheme': "minorHAnsi",
|
||||
'w:hAnsiTheme': "minorHAnsi",
|
||||
'w:cstheme': "minorBidi"
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
'w:sz': [{
|
||||
_attr: {
|
||||
'w:val': "22"
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
'w:szCs': [{
|
||||
_attr: {
|
||||
'w:val': "22"
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
'w:lang': [{
|
||||
_attr: {
|
||||
'w:val': "en-GB",
|
||||
'w:eastAsia': "en-US",
|
||||
'w:bidi': "ar-SA"
|
||||
}
|
||||
}]
|
||||
}]
|
||||
}]
|
||||
}, {
|
||||
'w:pPrDefault': [{
|
||||
'w:pPr': [{
|
||||
'w:spacing': [{
|
||||
_attr: {
|
||||
'w:after': "160",
|
||||
'w:line': "259",
|
||||
'w:lineRule': "auto"
|
||||
}
|
||||
}]
|
||||
}]
|
||||
}]
|
||||
}]
|
||||
}, {
|
||||
'w:latentStyles': [{
|
||||
"w:styles": [
|
||||
{
|
||||
_attr: {
|
||||
'w:defLockedState': "0",
|
||||
'w:defUIPriority': "99",
|
||||
'w:defSemiHidden': "0",
|
||||
'w:defUnhideWhenUsed': "0",
|
||||
'w:defQFormat': "0",
|
||||
'w:count': "371"
|
||||
}
|
||||
}, {
|
||||
'w:lsdException': createLsdException('Normal', 0, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("heading 1", 9, 1, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("heading 2", 9, 1, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("heading 3", 9, 1, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("heading 4", 9, 1, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("heading 5", 9, 1, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("heading 6", 9, 1, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("heading 7", 9, 1, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("heading 8", 9, 1, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("heading 9", 9, 1, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("index 1", undefined, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("index 2", undefined, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("index 3", undefined, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("index 4", undefined, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("index 5", undefined, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("index 6", undefined, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("index 7", undefined, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("index 8", undefined, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("index 9", undefined, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("toc 1", 39, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("toc 2", 39, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("toc 3", 39, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("toc 4", 39, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("toc 5", 39, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("toc 6", 39, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("toc 7", 39, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("toc 8", 39, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("toc 9", 39, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("Normal Indent", undefined, undefined, 1, 1)
|
||||
}, {
|
||||
'w:lsdException': createLsdException("footnote text", undefined, undefined, 1, 1)
|
||||
}]
|
||||
}]
|
||||
"xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
||||
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
||||
"xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
||||
"xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml",
|
||||
"xmlns:w15": "http://schemas.microsoft.com/office/word/2012/wordml",
|
||||
"mc:Ignorable": "w14 w15",
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:docDefaults": [
|
||||
{
|
||||
"w:rPrDefault": [
|
||||
{
|
||||
"w:rPr": [
|
||||
{
|
||||
"w:rFonts": [
|
||||
{
|
||||
_attr: {
|
||||
"w:asciiTheme": "minorHAnsi",
|
||||
"w:eastAsiaTheme": "minorHAnsi",
|
||||
"w:hAnsiTheme": "minorHAnsi",
|
||||
"w:cstheme": "minorBidi",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"w:sz": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "22",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"w:szCs": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "22",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"w:lang": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "en-GB",
|
||||
"w:eastAsia": "en-US",
|
||||
"w:bidi": "ar-SA",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"w:pPrDefault": [
|
||||
{
|
||||
"w:pPr": [
|
||||
{
|
||||
"w:spacing": [
|
||||
{
|
||||
_attr: {
|
||||
"w:after": "160",
|
||||
"w:line": "259",
|
||||
"w:lineRule": "auto",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"w:latentStyles": [
|
||||
{
|
||||
_attr: {
|
||||
"w:defLockedState": "0",
|
||||
"w:defUIPriority": "99",
|
||||
"w:defSemiHidden": "0",
|
||||
"w:defUnhideWhenUsed": "0",
|
||||
"w:defQFormat": "0",
|
||||
"w:count": "371",
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("Normal", 0, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("heading 1", 9, 1, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("heading 2", 9, 1, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("heading 3", 9, 1, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("heading 4", 9, 1, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("heading 5", 9, 1, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("heading 6", 9, 1, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("heading 7", 9, 1, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("heading 8", 9, 1, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("heading 9", 9, 1, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("index 1", undefined, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("index 2", undefined, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("index 3", undefined, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("index 4", undefined, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("index 5", undefined, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("index 6", undefined, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("index 7", undefined, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("index 8", undefined, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("index 9", undefined, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("toc 1", 39, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("toc 2", 39, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("toc 3", 39, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("toc 4", 39, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("toc 5", 39, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("toc 6", 39, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("toc 7", 39, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("toc 8", 39, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("toc 9", 39, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("Normal Indent", undefined, undefined, 1, 1),
|
||||
},
|
||||
{
|
||||
"w:lsdException": createLsdException("footnote text", undefined, undefined, 1, 1),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
return style;
|
||||
};
|
||||
}
|
||||
|
@ -5,69 +5,55 @@ interface IComponentAttributes {
|
||||
}
|
||||
|
||||
class ComponentAttributes extends XmlAttributeComponent<IComponentAttributes> {
|
||||
protected xmlKeys = {val: "w:val"};
|
||||
protected xmlKeys = { val: "w:val" };
|
||||
}
|
||||
|
||||
export class Name extends XmlComponent {
|
||||
|
||||
constructor(value: string) {
|
||||
super("w:name");
|
||||
this.root.push(new ComponentAttributes({val: value}));
|
||||
this.root.push(new ComponentAttributes({ val: value }));
|
||||
}
|
||||
}
|
||||
|
||||
export class BasedOn extends XmlComponent {
|
||||
|
||||
constructor(value: string) {
|
||||
super("w:basedOn");
|
||||
this.root.push(new ComponentAttributes({val: value}));
|
||||
this.root.push(new ComponentAttributes({ val: value }));
|
||||
}
|
||||
}
|
||||
|
||||
export class Next extends XmlComponent {
|
||||
|
||||
constructor(value: string) {
|
||||
super("w:next");
|
||||
this.root.push(new ComponentAttributes({val: value}));
|
||||
this.root.push(new ComponentAttributes({ val: value }));
|
||||
}
|
||||
}
|
||||
|
||||
export class Link extends XmlComponent {
|
||||
|
||||
constructor(value: string) {
|
||||
super("w:link");
|
||||
this.root.push(new ComponentAttributes({val: value}));
|
||||
this.root.push(new ComponentAttributes({ val: value }));
|
||||
}
|
||||
}
|
||||
|
||||
export class UiPriority extends XmlComponent {
|
||||
|
||||
constructor(value: string) {
|
||||
super("w:uiPriority");
|
||||
// TODO: this value should be a ST_DecimalNumber
|
||||
this.root.push(new ComponentAttributes({val: value}));
|
||||
this.root.push(new ComponentAttributes({ val: value }));
|
||||
}
|
||||
}
|
||||
|
||||
export class UnhideWhenUsed extends XmlComponent {
|
||||
|
||||
}
|
||||
export class UnhideWhenUsed extends XmlComponent {}
|
||||
|
||||
export class QuickFormat extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("w:qFormat");
|
||||
}
|
||||
}
|
||||
|
||||
export class TableProperties extends XmlComponent {
|
||||
export class TableProperties extends XmlComponent {}
|
||||
|
||||
}
|
||||
export class RsId extends XmlComponent {}
|
||||
|
||||
export class RsId extends XmlComponent {
|
||||
|
||||
}
|
||||
|
||||
export class SemiHidden extends XmlComponent {
|
||||
|
||||
}
|
||||
export class SemiHidden extends XmlComponent {}
|
||||
|
@ -22,7 +22,6 @@ class StyleAttributes extends XmlAttributeComponent<IStyleAttributes> {
|
||||
}
|
||||
|
||||
export class Style extends XmlComponent {
|
||||
|
||||
constructor(attributes: IStyleAttributes, name?: string) {
|
||||
super("w:style");
|
||||
this.root.push(new StyleAttributes(attributes));
|
||||
@ -37,12 +36,11 @@ export class Style extends XmlComponent {
|
||||
}
|
||||
|
||||
export class ParagraphStyle extends Style {
|
||||
|
||||
private paragraphProperties: paragraph.ParagraphProperties;
|
||||
private runProperties: RunProperties;
|
||||
|
||||
constructor(styleId: string, name?: string) {
|
||||
super({type: "paragraph", styleId: styleId}, name);
|
||||
super({ type: "paragraph", styleId: styleId }, name);
|
||||
this.paragraphProperties = new paragraph.ParagraphProperties();
|
||||
this.runProperties = new RunProperties();
|
||||
this.root.push(this.paragraphProperties);
|
||||
@ -193,7 +191,6 @@ export class ParagraphStyle extends Style {
|
||||
}
|
||||
|
||||
export class HeadingStyle extends ParagraphStyle {
|
||||
|
||||
constructor(styleId: string, name: string) {
|
||||
super(styleId, name);
|
||||
this.basedOn("Normal");
|
||||
@ -203,56 +200,48 @@ export class HeadingStyle extends ParagraphStyle {
|
||||
}
|
||||
|
||||
export class TitleStyle extends HeadingStyle {
|
||||
|
||||
constructor() {
|
||||
super("Title", "Title");
|
||||
}
|
||||
}
|
||||
|
||||
export class Heading1Style extends HeadingStyle {
|
||||
|
||||
constructor() {
|
||||
super("Heading1", "Heading 1");
|
||||
}
|
||||
}
|
||||
|
||||
export class Heading2Style extends HeadingStyle {
|
||||
|
||||
constructor() {
|
||||
super("Heading2", "Heading 2");
|
||||
}
|
||||
}
|
||||
|
||||
export class Heading3Style extends HeadingStyle {
|
||||
|
||||
constructor() {
|
||||
super("Heading3", "Heading 3");
|
||||
}
|
||||
}
|
||||
|
||||
export class Heading4Style extends HeadingStyle {
|
||||
|
||||
constructor() {
|
||||
super("Heading4", "Heading 4");
|
||||
}
|
||||
}
|
||||
|
||||
export class Heading5Style extends HeadingStyle {
|
||||
|
||||
constructor() {
|
||||
super("Heading5", "Heading 5");
|
||||
}
|
||||
}
|
||||
|
||||
export class Heading6Style extends HeadingStyle {
|
||||
|
||||
constructor() {
|
||||
super("Heading6", "Heading 6");
|
||||
}
|
||||
}
|
||||
|
||||
export class ListParagraph extends ParagraphStyle {
|
||||
|
||||
constructor() {
|
||||
super("ListParagraph");
|
||||
this.root.push(new Name("List Paragraph"));
|
||||
|
@ -22,26 +22,26 @@ describe("Styles", () => {
|
||||
it("should create a new paragraph style and push it onto this collection", () => {
|
||||
styles.createParagraphStyle("pStyleId");
|
||||
const tree = new Formatter().format(styles)["w:styles"].filter((x) => !x._attr);
|
||||
expect(tree).to.deep.equal([{
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "pStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": []},
|
||||
],
|
||||
}]);
|
||||
expect(tree).to.deep.equal([
|
||||
{
|
||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "pStyleId" } }, { "w:pPr": [] }, { "w:rPr": [] }],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("should set the paragraph name if given", () => {
|
||||
styles.createParagraphStyle("pStyleId", "Paragraph Style");
|
||||
const tree = new Formatter().format(styles)["w:styles"].filter((x) => !x._attr);
|
||||
expect(tree).to.deep.equal([{
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "pStyleId"}},
|
||||
{"w:name": [{_attr: {"w:val": "Paragraph Style"}}]},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": []},
|
||||
],
|
||||
}]);
|
||||
expect(tree).to.deep.equal([
|
||||
{
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "pStyleId" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Paragraph Style" } }] },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -56,22 +56,23 @@ describe("Style", () => {
|
||||
});
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId", "w:default": true}},
|
||||
],
|
||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId", "w:default": true } }],
|
||||
});
|
||||
});
|
||||
|
||||
it("should set the name of the style, if given", () => {
|
||||
const style = new Style({
|
||||
type: "paragraph",
|
||||
styleId: "myStyleId",
|
||||
}, "Style Name");
|
||||
const style = new Style(
|
||||
{
|
||||
type: "paragraph",
|
||||
styleId: "myStyleId",
|
||||
},
|
||||
"Style Name",
|
||||
);
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:name": [{_attr: {"w:val": "Style Name"}}]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Style Name" } }] },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -82,31 +83,31 @@ describe("Style components", () => {
|
||||
it("Name#constructor", () => {
|
||||
const style = new components.Name("Style Name");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({"w:name": [{_attr: {"w:val": "Style Name"}}]});
|
||||
expect(tree).to.deep.equal({ "w:name": [{ _attr: { "w:val": "Style Name" } }] });
|
||||
});
|
||||
|
||||
it("BasedOn#constructor", () => {
|
||||
const style = new components.BasedOn("otherId");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({"w:basedOn": [{_attr: {"w:val": "otherId"}}]});
|
||||
expect(tree).to.deep.equal({ "w:basedOn": [{ _attr: { "w:val": "otherId" } }] });
|
||||
});
|
||||
|
||||
it("Next#constructor", () => {
|
||||
const style = new components.Next("otherId");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({"w:next": [{_attr: {"w:val": "otherId"}}]});
|
||||
expect(tree).to.deep.equal({ "w:next": [{ _attr: { "w:val": "otherId" } }] });
|
||||
});
|
||||
|
||||
it("Link#constructor", () => {
|
||||
const style = new components.Link("otherId");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({"w:link": [{_attr: {"w:val": "otherId"}}]});
|
||||
expect(tree).to.deep.equal({ "w:link": [{ _attr: { "w:val": "otherId" } }] });
|
||||
});
|
||||
|
||||
it("UiPriority#constructor", () => {
|
||||
const style = new components.UiPriority("123");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({"w:uiPriority": [{_attr: {"w:val": "123"}}]});
|
||||
expect(tree).to.deep.equal({ "w:uiPriority": [{ _attr: { "w:val": "123" } }] });
|
||||
});
|
||||
});
|
||||
|
||||
@ -116,11 +117,7 @@ describe("ParagraphStyle", () => {
|
||||
const style = new ParagraphStyle("myStyleId");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": []},
|
||||
],
|
||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:pPr": [] }, { "w:rPr": [] }],
|
||||
});
|
||||
});
|
||||
|
||||
@ -129,10 +126,10 @@ describe("ParagraphStyle", () => {
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:name": [{_attr: {"w:val": "Style Name"}}]},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": []},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Style Name" } }] },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -140,43 +137,40 @@ describe("ParagraphStyle", () => {
|
||||
|
||||
describe("formatting methods: style attributes", () => {
|
||||
it("#basedOn", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.basedOn("otherId");
|
||||
const style = new ParagraphStyle("myStyleId").basedOn("otherId");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": []},
|
||||
{"w:basedOn": [{_attr: {"w:val": "otherId"}}]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:basedOn": [{ _attr: { "w:val": "otherId" } }] },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#quickFormat", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.quickFormat();
|
||||
const style = new ParagraphStyle("myStyleId").quickFormat();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": []},
|
||||
{"w:qFormat": []},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:qFormat": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#next", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.next("otherId");
|
||||
const style = new ParagraphStyle("myStyleId").next("otherId");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": []},
|
||||
{"w:next": [{_attr: {"w:val": "otherId"}}]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:next": [{ _attr: { "w:val": "otherId" } }] },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -184,171 +178,176 @@ describe("ParagraphStyle", () => {
|
||||
|
||||
describe("formatting methods: paragraph properties", () => {
|
||||
it("#indent", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.indent({ left: 720 });
|
||||
const style = new ParagraphStyle("myStyleId").indent({ left: 720 });
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": [
|
||||
{"w:ind": [{_attr: {"w:left": 720}}]},
|
||||
]},
|
||||
{"w:rPr": []},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:pPr": [{ "w:ind": [{ _attr: { "w:left": 720 } }] }],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#spacing", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.spacing({before: 50, after: 150});
|
||||
const style = new ParagraphStyle("myStyleId").spacing({ before: 50, after: 150 });
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": [
|
||||
{"w:spacing": [{_attr: {"w:before": 50, "w:after": 150}}]},
|
||||
]},
|
||||
{"w:rPr": []},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:pPr": [{ "w:spacing": [{ _attr: { "w:before": 50, "w:after": 150 } }] }],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#center", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.center();
|
||||
const style = new ParagraphStyle("myStyleId").center();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": [
|
||||
{"w:jc": [{_attr: {"w:val": "center"}}]},
|
||||
]},
|
||||
{"w:rPr": []},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:pPr": [{ "w:jc": [{ _attr: { "w:val": "center" } }] }],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#left", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.left();
|
||||
const style = new ParagraphStyle("myStyleId").left();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": [
|
||||
{"w:jc": [{_attr: {"w:val": "left"}}]},
|
||||
]},
|
||||
{"w:rPr": []},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:pPr": [{ "w:jc": [{ _attr: { "w:val": "left" } }] }],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#right", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.right();
|
||||
const style = new ParagraphStyle("myStyleId").right();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": [
|
||||
{"w:jc": [{_attr: {"w:val": "right"}}]},
|
||||
]},
|
||||
{"w:rPr": []},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:pPr": [{ "w:jc": [{ _attr: { "w:val": "right" } }] }],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#justified", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.justified();
|
||||
const style = new ParagraphStyle("myStyleId").justified();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": [
|
||||
{"w:jc": [{_attr: {"w:val": "both"}}]},
|
||||
]},
|
||||
{"w:rPr": []},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:pPr": [{ "w:jc": [{ _attr: { "w:val": "both" } }] }],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#thematicBreak", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.thematicBreak();
|
||||
const style = new ParagraphStyle("myStyleId").thematicBreak();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": [
|
||||
{"w:pBdr": [{"w:bottom": [{_attr: {
|
||||
"w:color": "auto",
|
||||
"w:space": "1",
|
||||
"w:val": "single",
|
||||
"w:sz": "6",
|
||||
}}]}]},
|
||||
]},
|
||||
{"w:rPr": []},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:pPr": [
|
||||
{
|
||||
"w:pBdr": [
|
||||
{
|
||||
"w:bottom": [
|
||||
{
|
||||
_attr: {
|
||||
"w:color": "auto",
|
||||
"w:space": "1",
|
||||
"w:val": "single",
|
||||
"w:sz": "6",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#leftTabStop", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.leftTabStop(1200);
|
||||
const style = new ParagraphStyle("myStyleId").leftTabStop(1200);
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": [
|
||||
{"w:tabs": [
|
||||
{"w:tab": [{_attr: {"w:val": "left", "w:pos": 1200}}]},
|
||||
]},
|
||||
]},
|
||||
{"w:rPr": []},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:pPr": [
|
||||
{
|
||||
"w:tabs": [{ "w:tab": [{ _attr: { "w:val": "left", "w:pos": 1200 } }] }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#maxRightTabStop", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.maxRightTabStop();
|
||||
const style = new ParagraphStyle("myStyleId").maxRightTabStop();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": [
|
||||
{"w:tabs": [
|
||||
{"w:tab": [{_attr: {"w:val": "right", "w:pos": 9026}}]},
|
||||
]},
|
||||
]},
|
||||
{"w:rPr": []},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:pPr": [
|
||||
{
|
||||
"w:tabs": [{ "w:tab": [{ _attr: { "w:val": "right", "w:pos": 9026 } }] }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#keepLines", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.keepLines();
|
||||
const style = new ParagraphStyle("myStyleId").keepLines();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": [{"w:keepLines": []}]},
|
||||
{"w:rPr": []},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [{ "w:keepLines": [] }] },
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#keepNext", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.keepNext();
|
||||
const style = new ParagraphStyle("myStyleId").keepNext();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": [{"w:keepNext": []}]},
|
||||
{"w:rPr": []},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [{ "w:keepNext": [] }] },
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -356,211 +355,197 @@ describe("ParagraphStyle", () => {
|
||||
|
||||
describe("formatting methods: run properties", () => {
|
||||
it("#size", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.size(24);
|
||||
const style = new ParagraphStyle("myStyleId").size(24);
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": [
|
||||
{"w:sz": [{_attr: {"w:val": 24}}]},
|
||||
]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:sz": [{ _attr: { "w:val": 24 } }] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#smallCaps", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.smallCaps();
|
||||
const style = new ParagraphStyle("myStyleId").smallCaps();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": [
|
||||
{"w:smallCaps": [{_attr: {"w:val": true}}]},
|
||||
]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:smallCaps": [{ _attr: { "w:val": true } }] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#allCaps", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.allCaps();
|
||||
const style = new ParagraphStyle("myStyleId").allCaps();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": [
|
||||
{"w:caps": [{_attr: {"w:val": true}}]},
|
||||
]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:caps": [{ _attr: { "w:val": true } }] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#strike", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.strike();
|
||||
const style = new ParagraphStyle("myStyleId").strike();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": [
|
||||
{"w:strike": [{_attr: {"w:val": true}}]},
|
||||
]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:strike": [{ _attr: { "w:val": true } }] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#doubleStrike", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.doubleStrike();
|
||||
const style = new ParagraphStyle("myStyleId").doubleStrike();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": [
|
||||
{"w:dstrike": [{_attr: {"w:val": true}}]},
|
||||
]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:dstrike": [{ _attr: { "w:val": true } }] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#subScript", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.subScript();
|
||||
const style = new ParagraphStyle("myStyleId").subScript();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": [
|
||||
{"w:vertAlign": [{_attr: {"w:val": "subscript"}}]},
|
||||
]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:vertAlign": [{ _attr: { "w:val": "subscript" } }] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#superScript", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.superScript();
|
||||
const style = new ParagraphStyle("myStyleId").superScript();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": [
|
||||
{"w:vertAlign": [{_attr: {"w:val": "superscript"}}]},
|
||||
]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:vertAlign": [{ _attr: { "w:val": "superscript" } }] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#font", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.font("Times");
|
||||
const style = new ParagraphStyle("myStyleId").font("Times");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": [{"w:rFonts": [{_attr: {"w:ascii": "Times", "w:hAnsi": "Times"}}]}]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [{ "w:rFonts": [{ _attr: { "w:ascii": "Times", "w:hAnsi": "Times" } }] }] },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#bold", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.bold();
|
||||
const style = new ParagraphStyle("myStyleId").bold();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": [
|
||||
{"w:b": [{_attr: {"w:val": true}}]},
|
||||
]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:b": [{ _attr: { "w:val": true } }] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("#italics", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.italics();
|
||||
const style = new ParagraphStyle("myStyleId").italics();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": [
|
||||
{"w:i": [{_attr: {"w:val": true}}]},
|
||||
]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:i": [{ _attr: { "w:val": true } }] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
describe("#underline", () => {
|
||||
it("should set underline to 'single' if no arguments are given", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.underline();
|
||||
const style = new ParagraphStyle("myStyleId").underline();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": [
|
||||
{"w:u": [{_attr: {"w:val": "single"}}]},
|
||||
]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:u": [{ _attr: { "w:val": "single" } }] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("should set the style if given", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.underline("double");
|
||||
const style = new ParagraphStyle("myStyleId").underline("double");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": [
|
||||
{"w:u": [{_attr: {"w:val": "double"}}]},
|
||||
]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:u": [{ _attr: { "w:val": "double" } }] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("should set the style and color if given", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.underline("double", "005599");
|
||||
const style = new ParagraphStyle("myStyleId").underline("double", "005599");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": [
|
||||
{"w:u": [{_attr: {"w:val": "double", "w:color": "005599"}}]},
|
||||
]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:u": [{ _attr: { "w:val": "double", "w:color": "005599" } }] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("#color", () => {
|
||||
const style = new ParagraphStyle("myStyleId")
|
||||
.color("123456");
|
||||
const style = new ParagraphStyle("myStyleId").color("123456");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{_attr: {"w:type": "paragraph", "w:styleId": "myStyleId"}},
|
||||
{"w:pPr": []},
|
||||
{"w:rPr": [
|
||||
{"w:color": [{_attr: {"w:val": "123456"}}]},
|
||||
]},
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:color": [{ _attr: { "w:val": "123456" } }] }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user