ts/styles linter warnings
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
import {XmlComponent} from "../../docx/xml-components";
|
import { XmlComponent } from "../../docx/xml-components";
|
||||||
import {ParagraphPropertiesDefaults} from "./paragraph-properties";
|
import { ParagraphPropertiesDefaults } from "./paragraph-properties";
|
||||||
import {RunPropertiesDefaults} from "./run-properties";
|
import { RunPropertiesDefaults } from "./run-properties";
|
||||||
|
|
||||||
export class DocumentDefaults extends XmlComponent {
|
export class DocumentDefaults extends XmlComponent {
|
||||||
|
|
||||||
@ -15,10 +15,10 @@ export class DocumentDefaults extends XmlComponent {
|
|||||||
this.root.push(this.paragraphPropertiesDefaults);
|
this.root.push(this.paragraphPropertiesDefaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearVariables(): void {
|
public clearVariables(): void {
|
||||||
this.runPropertiesDefaults.clearVariables();
|
this.runPropertiesDefaults.clearVariables();
|
||||||
this.paragraphPropertiesDefaults.clearVariables();
|
this.paragraphPropertiesDefaults.clearVariables();
|
||||||
delete this.runPropertiesDefaults;
|
delete this.runPropertiesDefaults;
|
||||||
delete this.paragraphPropertiesDefaults;
|
delete this.paragraphPropertiesDefaults;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {XmlComponent} from "../../docx/xml-components";
|
import { ParagraphProperties } from "../../docx/paragraph/properties";
|
||||||
import {ParagraphProperties} from "../../docx/paragraph/properties";
|
import { XmlComponent } from "../../docx/xml-components";
|
||||||
|
|
||||||
export class ParagraphPropertiesDefaults extends XmlComponent {
|
export class ParagraphPropertiesDefaults extends XmlComponent {
|
||||||
|
|
||||||
@ -7,4 +7,4 @@ export class ParagraphPropertiesDefaults extends XmlComponent {
|
|||||||
super("w:pPrDefault");
|
super("w:pPrDefault");
|
||||||
this.root.push(new ParagraphProperties());
|
this.root.push(new ParagraphProperties());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {XmlComponent} from "../../docx/xml-components";
|
import { RunProperties } from "../../docx/run/properties";
|
||||||
import {RunProperties} from "../../docx/run/properties";
|
import { XmlComponent } from "../../docx/xml-components";
|
||||||
|
|
||||||
export class RunPropertiesDefaults extends XmlComponent {
|
export class RunPropertiesDefaults extends XmlComponent {
|
||||||
|
|
||||||
@ -7,4 +7,4 @@ export class RunPropertiesDefaults extends XmlComponent {
|
|||||||
super("w:rPrDefault");
|
super("w:rPrDefault");
|
||||||
this.root.push(new RunProperties());
|
this.root.push(new RunProperties());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,56 +1,60 @@
|
|||||||
import {Styles} from "./";
|
import { ParagraphProperties } from "../docx/paragraph/properties";
|
||||||
import {DocumentDefaults} from "./defaults";
|
import { Color, Italics, Size } from "../docx/run/formatting";
|
||||||
import {ParagraphPropertiesDefaults} from "./defaults/paragraph-properties";
|
import { RunProperties } from "../docx/run/properties";
|
||||||
import {RunPropertiesDefaults} from "./defaults/run-properties";
|
|
||||||
import {Heading1Style, Heading2Style, TitleStyle, Heading3Style, Heading4Style, Heading5Style, Heading6Style, ListParagraph} from "./style";
|
import { Styles } from "./";
|
||||||
// import {StyleAttributes} from "./style/attributes";
|
import { DocumentDefaults } from "./defaults";
|
||||||
import {ParagraphProperties} from "../docx/paragraph/properties";
|
import { ParagraphPropertiesDefaults } from "./defaults/paragraph-properties";
|
||||||
import {RunProperties} from "../docx/run/properties";
|
import { RunPropertiesDefaults } from "./defaults/run-properties";
|
||||||
import {Color, Size, Italics} from "../docx/run/formatting";
|
import {
|
||||||
|
Heading1Style, Heading2Style, Heading3Style, Heading4Style, Heading5Style, Heading6Style,
|
||||||
|
ListParagraph, TitleStyle,
|
||||||
|
} from "./style";
|
||||||
|
// import { StyleAttributes } from "./style/attributes";
|
||||||
|
|
||||||
export class DefaultStylesFactory {
|
export class DefaultStylesFactory {
|
||||||
|
|
||||||
newInstance(): Styles {
|
public newInstance(): Styles {
|
||||||
let styles = new Styles();
|
const styles = new Styles();
|
||||||
styles.push(new DocumentDefaults());
|
styles.push(new DocumentDefaults());
|
||||||
|
|
||||||
let titleStyle = new TitleStyle();
|
const titleStyle = new TitleStyle();
|
||||||
titleStyle.addRunProperty(new Size(56));
|
titleStyle.addRunProperty(new Size(56));
|
||||||
styles.push(titleStyle);
|
styles.push(titleStyle);
|
||||||
|
|
||||||
let heading1Style = new Heading1Style();
|
const heading1Style = new Heading1Style();
|
||||||
heading1Style.addRunProperty(new Color("2E74B5"));
|
heading1Style.addRunProperty(new Color("2E74B5"));
|
||||||
heading1Style.addRunProperty(new Size(32));
|
heading1Style.addRunProperty(new Size(32));
|
||||||
styles.push(heading1Style);
|
styles.push(heading1Style);
|
||||||
|
|
||||||
let heading2Style = new Heading2Style();
|
const heading2Style = new Heading2Style();
|
||||||
heading2Style.addRunProperty(new Color("2E74B5"));
|
heading2Style.addRunProperty(new Color("2E74B5"));
|
||||||
heading2Style.addRunProperty(new Size(26));
|
heading2Style.addRunProperty(new Size(26));
|
||||||
styles.push(heading2Style);
|
styles.push(heading2Style);
|
||||||
|
|
||||||
let heading3Style = new Heading3Style();
|
const heading3Style = new Heading3Style();
|
||||||
heading3Style.addRunProperty(new Color("1F4D78"));
|
heading3Style.addRunProperty(new Color("1F4D78"));
|
||||||
heading3Style.addRunProperty(new Size(24));
|
heading3Style.addRunProperty(new Size(24));
|
||||||
styles.push(heading3Style);
|
styles.push(heading3Style);
|
||||||
|
|
||||||
let heading4Style = new Heading4Style();
|
const heading4Style = new Heading4Style();
|
||||||
heading4Style.addRunProperty(new Color("2E74B5"));
|
heading4Style.addRunProperty(new Color("2E74B5"));
|
||||||
heading4Style.addRunProperty(new Italics());
|
heading4Style.addRunProperty(new Italics());
|
||||||
styles.push(heading4Style);
|
styles.push(heading4Style);
|
||||||
|
|
||||||
let heading5Style = new Heading5Style();
|
const heading5Style = new Heading5Style();
|
||||||
heading5Style.addRunProperty(new Color("2E74B5"));
|
heading5Style.addRunProperty(new Color("2E74B5"));
|
||||||
styles.push(heading5Style);
|
styles.push(heading5Style);
|
||||||
|
|
||||||
let heading6Style = new Heading6Style();
|
const heading6Style = new Heading6Style();
|
||||||
heading6Style.addRunProperty(new Color("1F4D78"));
|
heading6Style.addRunProperty(new Color("1F4D78"));
|
||||||
styles.push(heading6Style);
|
styles.push(heading6Style);
|
||||||
|
|
||||||
let listParagraph = new ListParagraph();
|
const listParagraph = new ListParagraph();
|
||||||
// listParagraph.addParagraphProperty();
|
// listParagraph.addParagraphProperty();
|
||||||
styles.push(listParagraph);
|
styles.push(listParagraph);
|
||||||
|
|
||||||
// console.log(JSON.stringify(styles, null, " "));
|
// console.log(JSON.stringify(styles, null, " "));
|
||||||
return styles;
|
return styles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import {XmlComponent} from "../docx/xml-components";
|
import { DocumentAttributes } from "../docx/document/document-attributes";
|
||||||
import {DocumentAttributes} from "../docx/document/document-attributes";
|
import { XmlComponent } from "../docx/xml-components";
|
||||||
import {DocumentDefaults} from "./defaults";
|
import { DocumentDefaults } from "./defaults";
|
||||||
import {LatentStyles} from "./latent-styles";
|
import { LatentStyles } from "./latent-styles";
|
||||||
import {LatentStyleException} from "./latent-styles/exceptions";
|
import { LatentStyleException } from "./latent-styles/exceptions";
|
||||||
import {LatentStyleExceptionAttributes} from "./latent-styles/exceptions/attributes";
|
import { LatentStyleExceptionAttributes } from "./latent-styles/exceptions/attributes";
|
||||||
|
|
||||||
export class Styles extends XmlComponent {
|
export class Styles extends XmlComponent {
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ export class Styles extends XmlComponent {
|
|||||||
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
||||||
w14: "http://schemas.microsoft.com/office/word/2010/wordml",
|
w14: "http://schemas.microsoft.com/office/word/2010/wordml",
|
||||||
w15: "http://schemas.microsoft.com/office/word/2012/wordml",
|
w15: "http://schemas.microsoft.com/office/word/2012/wordml",
|
||||||
Ignorable: "w14 w15"
|
Ignorable: "w14 w15",
|
||||||
}));
|
}));
|
||||||
// let latentStyles = new LatentStyles();
|
// let latentStyles = new LatentStyles();
|
||||||
// latentStyles.push(new LatentStyleException(new LatentStyleExceptionAttributes({
|
// latentStyles.push(new LatentStyleException(new LatentStyleExceptionAttributes({
|
||||||
@ -24,13 +24,14 @@ export class Styles extends XmlComponent {
|
|||||||
// this.root.push(latentStyles);
|
// this.root.push(latentStyles);
|
||||||
}
|
}
|
||||||
|
|
||||||
push(style: XmlComponent): void {
|
public push(style: XmlComponent): Styles {
|
||||||
this.root.push(style);
|
this.root.push(style);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearVariables() {
|
public clearVariables(): void {
|
||||||
this.root.forEach(element => {
|
this.root.forEach((element) => {
|
||||||
element.clearVariables();
|
element.clearVariables();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import {XmlComponent} from "../../../docx/xml-components";
|
import {XmlComponent} from "../../../docx/xml-components";
|
||||||
|
|
||||||
interface LatentStyleExceptionAttributesProperties {
|
interface ILatentStyleExceptionAttributesProperties {
|
||||||
name?: string;
|
name?: string;
|
||||||
uiPriority?: string;
|
uiPriority?: string;
|
||||||
qFormat?: string;
|
qFormat?: string;
|
||||||
@ -9,23 +9,23 @@ interface LatentStyleExceptionAttributesProperties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class LatentStyleExceptionAttributes extends XmlComponent {
|
export class LatentStyleExceptionAttributes extends XmlComponent {
|
||||||
private _attr: Object;
|
private _attr: ILatentStyleExceptionAttributesProperties;
|
||||||
|
|
||||||
xmlKeys = {
|
private xmlKeys = {
|
||||||
name: "w:name",
|
name: "w:name",
|
||||||
uiPriority: "w:uiPriority",
|
uiPriority: "w:uiPriority",
|
||||||
qFormat: "w:qFormat",
|
qFormat: "w:qFormat",
|
||||||
semiHidden: "w:semiHidden",
|
semiHidden: "w:semiHidden",
|
||||||
unhideWhenUsed: "w:unhideWhenUsed"
|
unhideWhenUsed: "w:unhideWhenUsed",
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(properties?: LatentStyleExceptionAttributesProperties) {
|
constructor(properties?: ILatentStyleExceptionAttributesProperties) {
|
||||||
super("_attr");
|
super("_attr");
|
||||||
this._attr = properties;
|
this._attr = properties;
|
||||||
|
|
||||||
if (!properties) {
|
if (!properties) {
|
||||||
this._attr = {};
|
this._attr = {};
|
||||||
}
|
}
|
||||||
this._attr["xmlKeys"] = this.xmlKeys;
|
//this._attr.xmlKeys = this.xmlKeys;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {XmlComponent} from "../../../docx/xml-components";
|
import { XmlComponent } from "../../../docx/xml-components";
|
||||||
import {LatentStyleExceptionAttributes} from "./attributes";
|
import { LatentStyleExceptionAttributes } from "./attributes";
|
||||||
|
|
||||||
export class LatentStyleException extends XmlComponent {
|
export class LatentStyleException extends XmlComponent {
|
||||||
|
|
||||||
@ -7,4 +7,4 @@ export class LatentStyleException extends XmlComponent {
|
|||||||
super("w:lsdException");
|
super("w:lsdException");
|
||||||
this.root.push(attributes);
|
this.root.push(attributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {XmlComponent} from "../../docx/xml-components";
|
import { XmlComponent } from "../../docx/xml-components";
|
||||||
import {LatentStyleException} from "./exceptions";
|
import { LatentStyleException } from "./exceptions";
|
||||||
|
|
||||||
export class LatentStyles extends XmlComponent {
|
export class LatentStyles extends XmlComponent {
|
||||||
|
|
||||||
@ -7,7 +7,7 @@ export class LatentStyles extends XmlComponent {
|
|||||||
super("w:latentStyles");
|
super("w:latentStyles");
|
||||||
}
|
}
|
||||||
|
|
||||||
push(latentException: LatentStyleException): void {
|
public push(latentException: LatentStyleException): void {
|
||||||
this.root.push(latentException);
|
this.root.push(latentException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import {XmlComponent} from "../../docx/xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "../../docx/xml-components";
|
||||||
import {XmlAttributeComponent} from "../../docx/xml-components";
|
|
||||||
|
|
||||||
interface StyleAttributesProperties {
|
interface IStyleAttributesProperties {
|
||||||
type?: string;
|
type?: string;
|
||||||
styleId?: string;
|
styleId?: string;
|
||||||
default?: string;
|
default?: string;
|
||||||
@ -10,15 +9,15 @@ interface StyleAttributesProperties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class StyleAttributes extends XmlAttributeComponent {
|
export class StyleAttributes extends XmlAttributeComponent {
|
||||||
private _attr: Object;
|
private _attr: IStyleAttributesProperties;
|
||||||
|
|
||||||
constructor(properties: StyleAttributesProperties) {
|
constructor(properties: IStyleAttributesProperties) {
|
||||||
super({
|
super({
|
||||||
type: "w:type",
|
type: "w:type",
|
||||||
styleId: "w:styleId",
|
styleId: "w:styleId",
|
||||||
default: "w:default",
|
default: "w:default",
|
||||||
customStyle: "w:customStyle",
|
customStyle: "w:customStyle",
|
||||||
val: "w:val"
|
val: "w:val",
|
||||||
}, properties);
|
}, properties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import {XmlComponent} from "../../docx/xml-components";
|
import { XmlComponent } from "../../docx/xml-components";
|
||||||
import {StyleAttributes} from "./attributes";
|
import { StyleAttributes } from "./attributes";
|
||||||
|
|
||||||
export class Name extends XmlComponent {
|
export class Name extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:name");
|
super("w:name");
|
||||||
this.root.push(new StyleAttributes({
|
this.root.push(new StyleAttributes({
|
||||||
val: value
|
val: value,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -16,7 +16,7 @@ export class BasedOn extends XmlComponent {
|
|||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:basedOn");
|
super("w:basedOn");
|
||||||
this.root.push(new StyleAttributes({
|
this.root.push(new StyleAttributes({
|
||||||
val: value
|
val: value,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -27,7 +27,7 @@ export class Next extends XmlComponent {
|
|||||||
super("w:next");
|
super("w:next");
|
||||||
this.root.push(new StyleAttributes({
|
this.root.push(new StyleAttributes({
|
||||||
styleId: "1",
|
styleId: "1",
|
||||||
val: value
|
val: value,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ export class Link extends XmlComponent {
|
|||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:link");
|
super("w:link");
|
||||||
this.root.push(new StyleAttributes({
|
this.root.push(new StyleAttributes({
|
||||||
val: value
|
val: value,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ export class UiPriority extends XmlComponent {
|
|||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:uiPriority");
|
super("w:uiPriority");
|
||||||
this.root.push(new StyleAttributes({
|
this.root.push(new StyleAttributes({
|
||||||
val: value
|
val: value,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,4 +73,4 @@ export class RsId extends XmlComponent {
|
|||||||
|
|
||||||
export class SemiHidden extends XmlComponent {
|
export class SemiHidden extends XmlComponent {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import {XmlComponent} from "../../docx/xml-components";
|
import { ParagraphProperties } from "../../docx/paragraph/properties";
|
||||||
import {StyleAttributes} from "./attributes";
|
import { RunProperties } from "../../docx/run/properties";
|
||||||
import {ParagraphProperties} from "../../docx/paragraph/properties";
|
import { XmlComponent } from "../../docx/xml-components";
|
||||||
import {RunProperties} from "../../docx/run/properties";
|
|
||||||
import {Name, BasedOn, Next, QuickFormat} from "./components";
|
import { StyleAttributes } from "./attributes";
|
||||||
|
import { BasedOn, Name, Next, QuickFormat } from "./components";
|
||||||
|
|
||||||
export class Style extends XmlComponent {
|
export class Style extends XmlComponent {
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ export class Style extends XmlComponent {
|
|||||||
this.root.push(attributes);
|
this.root.push(attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
push(styleSegment: XmlComponent): void {
|
public push(styleSegment: XmlComponent): void {
|
||||||
this.root.push(styleSegment);
|
this.root.push(styleSegment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -23,9 +24,9 @@ export class ParagraphStyle extends Style {
|
|||||||
|
|
||||||
constructor(styleId: string) {
|
constructor(styleId: string) {
|
||||||
|
|
||||||
let attributes = new StyleAttributes({
|
const attributes = new StyleAttributes({
|
||||||
type: "paragraph",
|
type: "paragraph",
|
||||||
styleId: styleId
|
styleId: styleId,
|
||||||
});
|
});
|
||||||
super(attributes);
|
super(attributes);
|
||||||
this.paragraphProperties = new ParagraphProperties();
|
this.paragraphProperties = new ParagraphProperties();
|
||||||
@ -34,18 +35,18 @@ export class ParagraphStyle extends Style {
|
|||||||
this.root.push(this.runProperties);
|
this.root.push(this.runProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearVariables(): void {
|
public clearVariables(): void {
|
||||||
this.paragraphProperties.clearVariables();
|
this.paragraphProperties.clearVariables();
|
||||||
this.runProperties.clearVariables();
|
this.runProperties.clearVariables();
|
||||||
delete this.paragraphProperties;
|
delete this.paragraphProperties;
|
||||||
delete this.runProperties;
|
delete this.runProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
addParagraphProperty(property: XmlComponent): void {
|
public addParagraphProperty(property: XmlComponent): void {
|
||||||
this.paragraphProperties.push(property);
|
this.paragraphProperties.push(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
addRunProperty(property: XmlComponent): void {
|
public addRunProperty(property: XmlComponent): void {
|
||||||
this.runProperties.push(property);
|
this.runProperties.push(property);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,4 +119,4 @@ export class ListParagraph extends ParagraphStyle {
|
|||||||
this.root.push(new BasedOn("Normal"));
|
this.root.push(new BasedOn("Normal"));
|
||||||
this.root.push(new QuickFormat());
|
this.root.push(new QuickFormat());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Styles } from "../styles";
|
|
||||||
import { assert } from "chai";
|
import { assert } from "chai";
|
||||||
|
import { Styles } from "../styles";
|
||||||
|
|
||||||
describe("Styles", () => {
|
describe("Styles", () => {
|
||||||
let styles: Styles;
|
let styles: Styles;
|
||||||
@ -11,11 +11,8 @@ describe("Styles", () => {
|
|||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
|
|
||||||
it("should create styles with correct rootKey", () => {
|
it("should create styles with correct rootKey", () => {
|
||||||
let styles = new Styles();
|
const newJson = JSON.parse(JSON.stringify(styles));
|
||||||
let stringifiedJson = JSON.stringify(styles);
|
|
||||||
let newJson = JSON.parse(stringifiedJson);
|
|
||||||
|
|
||||||
assert.equal(newJson.rootKey, "w:styles");
|
assert.equal(newJson.rootKey, "w:styles");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user