added styles
This commit is contained in:
17
ts/styles/defaults/index.ts
Normal file
17
ts/styles/defaults/index.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import {XmlComponent} from "../../docx/xml-components";
|
||||
import {ParagraphPropertiesDefaults} from "./paragraph-properties";
|
||||
import {RunPropertiesDefaults} from "./run-properties";
|
||||
|
||||
export class DocumentDefaults implements XmlComponent {
|
||||
private docDefaults: Array<XmlComponent>;
|
||||
|
||||
xmlKeys = {
|
||||
docDefaults: "w:docDefaults"
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.docDefaults = new Array<XmlComponent>();
|
||||
this.docDefaults.push(new RunPropertiesDefaults());
|
||||
this.docDefaults.push(new ParagraphPropertiesDefaults());
|
||||
}
|
||||
}
|
15
ts/styles/defaults/paragraph-properties.ts
Normal file
15
ts/styles/defaults/paragraph-properties.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import {XmlComponent} from "../../docx/xml-components";
|
||||
import {ParagraphProperties} from "../../docx/paragraph/properties";
|
||||
|
||||
export class ParagraphPropertiesDefaults implements XmlComponent {
|
||||
private pPrDefault: Array<XmlComponent>;
|
||||
|
||||
xmlKeys = {
|
||||
pPrDefault: "w:pPrDefault"
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.pPrDefault = new Array<XmlComponent>();
|
||||
this.pPrDefault.push(new ParagraphProperties());
|
||||
}
|
||||
}
|
15
ts/styles/defaults/run-properties.ts
Normal file
15
ts/styles/defaults/run-properties.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import {XmlComponent} from "../../docx/xml-components";
|
||||
import {RunProperties} from "../../docx/run/properties";
|
||||
|
||||
export class RunPropertiesDefaults implements XmlComponent {
|
||||
private rPrDefault: Array<XmlComponent>;
|
||||
|
||||
xmlKeys = {
|
||||
rPrDefault: "w:rPrDefault"
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.rPrDefault = new Array<XmlComponent>();
|
||||
this.rPrDefault.push(new RunProperties());
|
||||
}
|
||||
}
|
36
ts/styles/index.ts
Normal file
36
ts/styles/index.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import {XmlComponent} from "../docx/xml-components";
|
||||
import {DocumentAttributes} from "../docx/xml-components/document-attributes"
|
||||
import {DocumentDefaults} from "./defaults";
|
||||
import {LatentStyles} from "./latent-styles";
|
||||
import {LatentStyleException} from "./latent-styles/exceptions";
|
||||
import {LatentStyleExceptionAttributes} from "./latent-styles/exceptions/attributes";
|
||||
|
||||
export class Style implements XmlComponent {
|
||||
private styles: Array<XmlComponent>;
|
||||
|
||||
xmlKeys = {
|
||||
styles: 'w:styles'
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.styles = new Array<XmlComponent>();
|
||||
this.styles.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.styles.push(new DocumentDefaults());
|
||||
var latentStyles = new LatentStyles();
|
||||
//latentStyles.push(new LatentStyleException(new LatentStyleExceptionAttributes({
|
||||
// name: "Normal"
|
||||
//})));
|
||||
this.styles.push(latentStyles);
|
||||
}
|
||||
|
||||
push(style: XmlComponent): void {
|
||||
this.styles.push(style);
|
||||
}
|
||||
}
|
30
ts/styles/latent-styles/exceptions/attributes.ts
Normal file
30
ts/styles/latent-styles/exceptions/attributes.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import {XmlComponent} from "../../../docx/xml-components";
|
||||
|
||||
interface LatentStyleExceptionAttributesProperties {
|
||||
name?: string;
|
||||
uiPriority?: string,
|
||||
qFormat?: string,
|
||||
semiHidden?: string,
|
||||
unhideWhenUsed?: string
|
||||
}
|
||||
|
||||
export class LatentStyleExceptionAttributes implements XmlComponent {
|
||||
private _attr: Object;
|
||||
|
||||
xmlKeys = {
|
||||
name: "w:name",
|
||||
uiPriority: "w:uiPriority",
|
||||
qFormat: "w:qFormat",
|
||||
semiHidden: "w:semiHidden",
|
||||
unhideWhenUsed: "w:unhideWhenUsed"
|
||||
};
|
||||
|
||||
constructor(properties?: LatentStyleExceptionAttributesProperties) {
|
||||
this._attr = properties
|
||||
|
||||
if (!properties) {
|
||||
this._attr = {};
|
||||
}
|
||||
this._attr["xmlKeys"] = this.xmlKeys;
|
||||
}
|
||||
}
|
15
ts/styles/latent-styles/exceptions/index.ts
Normal file
15
ts/styles/latent-styles/exceptions/index.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import {XmlComponent} from "../../../docx/xml-components";
|
||||
import {LatentStyleExceptionAttributes} from "./attributes";
|
||||
|
||||
export class LatentStyleException implements XmlComponent {
|
||||
private lsdException: Array<XmlComponent>;
|
||||
|
||||
xmlKeys = {
|
||||
lsdException: "w:lsdException"
|
||||
}
|
||||
|
||||
constructor(attributes: LatentStyleExceptionAttributes) {
|
||||
this.lsdException = new Array<XmlComponent>();
|
||||
this.lsdException.push(attributes);
|
||||
}
|
||||
}
|
18
ts/styles/latent-styles/index.ts
Normal file
18
ts/styles/latent-styles/index.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import {XmlComponent} from "../../docx/xml-components";
|
||||
import {LatentStyleException} from "./exceptions";
|
||||
|
||||
export class LatentStyles implements XmlComponent {
|
||||
private latentStyles: Array<XmlComponent>;
|
||||
|
||||
xmlKeys = {
|
||||
latentStyles: "w:latentStyles"
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.latentStyles = new Array<XmlComponent>();
|
||||
}
|
||||
|
||||
push(latentException: LatentStyleException): void {
|
||||
this.latentStyles.push(latentException);
|
||||
}
|
||||
}
|
150
ts/styles/sample/index.ts
Normal file
150
ts/styles/sample/index.ts
Normal file
@ -0,0 +1,150 @@
|
||||
function createLsdException(name, uiPriority, qFormat?, semiHidden?, unhideWhenUsed?) {
|
||||
'use strict';
|
||||
|
||||
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': [{
|
||||
_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)
|
||||
}, {
|
||||
'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;
|
||||
};
|
Reference in New Issue
Block a user