Merge pull request #68 from citizenos/master
Updated bullet list creating
This commit is contained in:
@ -311,4 +311,4 @@ const doc = documentCreator.create([experiences, education, skills, achievements
|
|||||||
var exporter = new docx.LocalPacker(doc);
|
var exporter = new docx.LocalPacker(doc);
|
||||||
exporter.pack("Dolan Miu CV");
|
exporter.pack("Dolan Miu CV");
|
||||||
|
|
||||||
console.log('Document created successfully at project root!');
|
console.log('Document created successfully at project root!');
|
@ -29,6 +29,16 @@ doc.addParagraph(subP);
|
|||||||
doc.addParagraph(secondSubP);
|
doc.addParagraph(secondSubP);
|
||||||
doc.addParagraph(subSubP);
|
doc.addParagraph(subSubP);
|
||||||
|
|
||||||
|
var bullet1 = new docx.Paragraph("Hey you").bullet();
|
||||||
|
var bullet2 = new docx.Paragraph("What's up fam").bullet(1);
|
||||||
|
var bullet3 = new docx.Paragraph("Hello World 2").bullet(2);
|
||||||
|
var bullet4 = new docx.Paragraph("Yeah boi").bullet(3);
|
||||||
|
|
||||||
|
doc.addParagraph(bullet1);
|
||||||
|
doc.addParagraph(bullet2);
|
||||||
|
doc.addParagraph(bullet3);
|
||||||
|
doc.addParagraph(bullet4);
|
||||||
|
|
||||||
var exporter = new docx.LocalPacker(doc);
|
var exporter = new docx.LocalPacker(doc);
|
||||||
exporter.pack('My Document');
|
exporter.pack('My Document');
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
"webpack": "rimraf ./build && webpack",
|
"webpack": "rimraf ./build && webpack",
|
||||||
"demo": "npm run build && node ./demo",
|
"demo": "npm run build && node ./demo",
|
||||||
"typedoc": "typedoc --out docs/ src/ --module commonjs --target ES6 --disableOutputCheck --excludePrivate --externalPattern \"**/*.spec.ts\"",
|
"typedoc": "typedoc --out docs/ src/ --module commonjs --target ES6 --disableOutputCheck --excludePrivate --externalPattern \"**/*.spec.ts\"",
|
||||||
"style": "prettier -l \"src/**/*.ts\"",
|
"style": "prettier --debug-check \"src/**/*.ts\"",
|
||||||
"fix-types": "node types-absolute-fixer.js"
|
"fix-types": "node types-absolute-fixer.js"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { XmlComponent } from "file/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
import { DocumentAttributes } from "../document/document-attributes";
|
import { DocumentAttributes } from "../document/document-attributes";
|
||||||
import { Indent } from "../paragraph/formatting";
|
import { Indent } from "../paragraph/formatting";
|
||||||
import { RunFonts } from "../paragraph/run/run-fonts";
|
|
||||||
import { AbstractNumbering } from "./abstract-numbering";
|
import { AbstractNumbering } from "./abstract-numbering";
|
||||||
import { Num } from "./num";
|
import { Num } from "./num";
|
||||||
|
|
||||||
@ -37,49 +36,40 @@ export class Numbering extends XmlComponent {
|
|||||||
const abstractNumbering = this.createAbstractNumbering();
|
const abstractNumbering = this.createAbstractNumbering();
|
||||||
|
|
||||||
abstractNumbering
|
abstractNumbering
|
||||||
.createLevel(0, "bullet", "•", "left")
|
.createLevel(0, "bullet", "\u25CF", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 720, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 720, hanging: 360 }));
|
||||||
.addRunProperty(new RunFonts("Symbol", "default"));
|
|
||||||
|
|
||||||
abstractNumbering
|
abstractNumbering
|
||||||
.createLevel(1, "bullet", "o", "left")
|
.createLevel(1, "bullet", "\u25CB", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 1440, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 1440, hanging: 360 }));
|
||||||
.addRunProperty(new RunFonts("Courier New", "default"));
|
|
||||||
|
|
||||||
abstractNumbering
|
abstractNumbering
|
||||||
.createLevel(2, "bullet", "•", "left")
|
.createLevel(2, "bullet", "\u25A0", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 2160, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 2160, hanging: 360 }));
|
||||||
.addRunProperty(new RunFonts("Wingdings", "default"));
|
|
||||||
|
|
||||||
abstractNumbering
|
abstractNumbering
|
||||||
.createLevel(3, "bullet", "•", "left")
|
.createLevel(3, "bullet", "\u25CF", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 2880, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 2880, hanging: 360 }));
|
||||||
.addRunProperty(new RunFonts("Symbol", "default"));
|
|
||||||
|
|
||||||
abstractNumbering
|
abstractNumbering
|
||||||
.createLevel(4, "bullet", "o", "left")
|
.createLevel(4, "bullet", "\u25CB", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 3600, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 3600, hanging: 360 }));
|
||||||
.addRunProperty(new RunFonts("Courier New", "default"));
|
|
||||||
|
|
||||||
abstractNumbering
|
abstractNumbering
|
||||||
.createLevel(5, "bullet", "•", "left")
|
.createLevel(5, "bullet", "\u25A0", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 4320, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 4320, hanging: 360 }));
|
||||||
.addRunProperty(new RunFonts("Wingdings", "default"));
|
|
||||||
|
|
||||||
abstractNumbering
|
abstractNumbering
|
||||||
.createLevel(6, "bullet", "•", "left")
|
.createLevel(6, "bullet", "\u25CF", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 5040, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 5040, hanging: 360 }));
|
||||||
.addRunProperty(new RunFonts("Symbol", "default"));
|
|
||||||
|
|
||||||
abstractNumbering
|
abstractNumbering
|
||||||
.createLevel(7, "bullet", "o", "left")
|
.createLevel(7, "bullet", "\u25CB", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 5760, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 5760, hanging: 360 }));
|
||||||
.addRunProperty(new RunFonts("Courier New", "default"));
|
|
||||||
|
|
||||||
abstractNumbering
|
abstractNumbering
|
||||||
.createLevel(8, "bullet", "•", "left")
|
.createLevel(8, "bullet", "\u25A0", "left")
|
||||||
.addParagraphProperty(new Indent({ left: 6480, hanging: 360 }))
|
.addParagraphProperty(new Indent({ left: 6480, hanging: 360 }));
|
||||||
.addRunProperty(new RunFonts("Wingdings", "default"));
|
|
||||||
|
|
||||||
this.createConcreteNumbering(abstractNumbering);
|
this.createConcreteNumbering(abstractNumbering);
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ describe("Paragraph", () => {
|
|||||||
|
|
||||||
describe("#bullet()", () => {
|
describe("#bullet()", () => {
|
||||||
it("should add list paragraph style to JSON", () => {
|
it("should add list paragraph style to JSON", () => {
|
||||||
paragraph.bullet();
|
paragraph.bullet(0);
|
||||||
const tree = new Formatter().format(paragraph);
|
const tree = new Formatter().format(paragraph);
|
||||||
expect(tree)
|
expect(tree)
|
||||||
.to.have.property("w:p")
|
.to.have.property("w:p")
|
||||||
@ -179,7 +179,7 @@ describe("Paragraph", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("it should add numbered properties", () => {
|
it("it should add numbered properties", () => {
|
||||||
paragraph.bullet();
|
paragraph.bullet(1);
|
||||||
const tree = new Formatter().format(paragraph);
|
const tree = new Formatter().format(paragraph);
|
||||||
expect(tree)
|
expect(tree)
|
||||||
.to.have.property("w:p")
|
.to.have.property("w:p")
|
||||||
@ -190,7 +190,7 @@ describe("Paragraph", () => {
|
|||||||
.which.is.an("array")
|
.which.is.an("array")
|
||||||
.which.has.length.at.least(2);
|
.which.has.length.at.least(2);
|
||||||
expect(tree["w:p"][0]["w:pPr"][1]).to.deep.equal({
|
expect(tree["w:p"][0]["w:pPr"][1]).to.deep.equal({
|
||||||
"w:numPr": [{ "w:ilvl": [{ _attr: { "w:val": 0 } }] }, { "w:numId": [{ _attr: { "w:val": 1 } }] }],
|
"w:numPr": [{ "w:ilvl": [{ _attr: { "w:val": 1 } }] }, { "w:numId": [{ _attr: { "w:val": 1 } }] }],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -129,9 +129,10 @@ export class Paragraph extends XmlComponent {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bullet(): Paragraph {
|
public bullet(indentLevel: number): Paragraph {
|
||||||
|
indentLevel = indentLevel || 0;
|
||||||
this.properties.push(new Style("ListParagraph"));
|
this.properties.push(new Style("ListParagraph"));
|
||||||
this.properties.push(new NumberProperties(1, 0));
|
this.properties.push(new NumberProperties(1, indentLevel));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user