Using a better demo naming system
This commit is contained in:
@ -1,3 +1,5 @@
|
|||||||
|
// Highlighting text
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, Header, Packer, Paragraph, TextRun } from "../build";
|
import { AlignmentType, Document, Header, Packer, Paragraph, TextRun } from "../build";
|
||||||
|
|
@ -1,3 +1,5 @@
|
|||||||
|
// Shading text
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, Header, Packer, Paragraph, ShadingType, TextRun } from "../build";
|
import { AlignmentType, Document, Header, Packer, Paragraph, ShadingType, TextRun } from "../build";
|
||||||
|
|
||||||
@ -18,7 +20,7 @@ doc.addSection({
|
|||||||
font: {
|
font: {
|
||||||
name: "Garamond",
|
name: "Garamond",
|
||||||
},
|
},
|
||||||
shadow: {
|
shading: {
|
||||||
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
|
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
|
||||||
color: "00FFFF",
|
color: "00FFFF",
|
||||||
fill: "FF0000",
|
fill: "FF0000",
|
@ -19,13 +19,16 @@ prompt.start();
|
|||||||
|
|
||||||
prompt.get(schema, (_, result) => {
|
prompt.get(schema, (_, result) => {
|
||||||
const demoNumber = result.number;
|
const demoNumber = result.number;
|
||||||
const filePath = `./demo/demo${demoNumber}.ts`;
|
const files = fs.readdirSync("./demo").filter((fn) => fn.startsWith(demoNumber));
|
||||||
|
|
||||||
if (!fs.existsSync(filePath)) {
|
if (files.length === 0) {
|
||||||
console.error(`demo${demoNumber} does not exist: ${filePath}`);
|
console.error(`demo number ${demoNumber} does not exist`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(`Running demo ${demoNumber}`);
|
|
||||||
|
const filePath = `./demo/${files[0]}`;
|
||||||
|
|
||||||
|
console.log(`Running demo ${demoNumber}: ${files[0]}`);
|
||||||
if (shelljs.exec(`npm run ts-node -- ${filePath}`).code === 0) {
|
if (shelljs.exec(`npm run ts-node -- ${filePath}`).code === 0) {
|
||||||
console.log("Document created successfully");
|
console.log("Document created successfully");
|
||||||
} else {
|
} else {
|
||||||
|
@ -205,7 +205,7 @@ export class LevelBase extends XmlComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public shadow(value: string, fill: string, color: string): Level {
|
public shadow(value: string, fill: string, color: string): Level {
|
||||||
this.addRunProperty(new formatting.Shadow(value, fill, color));
|
this.addRunProperty(new formatting.Shading(value, fill, color));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
// --------------------- Paragraph formatting ------------------------ //
|
// --------------------- Paragraph formatting ------------------------ //
|
||||||
|
@ -201,7 +201,7 @@ export class HighlightComplexScript extends XmlComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Shadow extends XmlComponent {
|
export class Shading extends XmlComponent {
|
||||||
constructor(value: string, fill: string, color: string) {
|
constructor(value: string, fill: string, color: string) {
|
||||||
super("w:shd");
|
super("w:shd");
|
||||||
this.root.push(
|
this.root.push(
|
||||||
|
@ -158,7 +158,7 @@ describe("Run", () => {
|
|||||||
describe("#shadow()", () => {
|
describe("#shadow()", () => {
|
||||||
it("it should add shadow to the properties", () => {
|
it("it should add shadow to the properties", () => {
|
||||||
const run = new Run({
|
const run = new Run({
|
||||||
shadow: {
|
shading: {
|
||||||
type: ShadingType.PERCENT_10,
|
type: ShadingType.PERCENT_10,
|
||||||
fill: "00FFFF",
|
fill: "00FFFF",
|
||||||
color: "FF0000",
|
color: "FF0000",
|
||||||
|
@ -15,7 +15,7 @@ import {
|
|||||||
Italics,
|
Italics,
|
||||||
ItalicsComplexScript,
|
ItalicsComplexScript,
|
||||||
RightToLeft,
|
RightToLeft,
|
||||||
Shadow,
|
Shading,
|
||||||
ShadowComplexScript,
|
ShadowComplexScript,
|
||||||
Size,
|
Size,
|
||||||
SizeComplexScript,
|
SizeComplexScript,
|
||||||
@ -51,7 +51,7 @@ export interface IRunOptions {
|
|||||||
readonly hint?: string;
|
readonly hint?: string;
|
||||||
};
|
};
|
||||||
readonly highlight?: string;
|
readonly highlight?: string;
|
||||||
readonly shadow?: {
|
readonly shading?: {
|
||||||
readonly type: ShadingType;
|
readonly type: ShadingType;
|
||||||
readonly fill: string;
|
readonly fill: string;
|
||||||
readonly color: string;
|
readonly color: string;
|
||||||
@ -130,9 +130,9 @@ export class Run extends XmlComponent {
|
|||||||
this.properties.push(new HighlightComplexScript(options.highlight));
|
this.properties.push(new HighlightComplexScript(options.highlight));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.shadow) {
|
if (options.shading) {
|
||||||
this.properties.push(new Shadow(options.shadow.type, options.shadow.fill, options.shadow.color));
|
this.properties.push(new Shading(options.shading.type, options.shading.fill, options.shading.color));
|
||||||
this.properties.push(new ShadowComplexScript(options.shadow.type, options.shadow.fill, options.shadow.color));
|
this.properties.push(new ShadowComplexScript(options.shading.type, options.shading.fill, options.shading.color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +64,6 @@ export class CharacterStyle extends Style {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public shadow(value: string, fill: string, color: string): CharacterStyle {
|
public shadow(value: string, fill: string, color: string): CharacterStyle {
|
||||||
return this.addRunProperty(new formatting.Shadow(value, fill, color));
|
return this.addRunProperty(new formatting.Shading(value, fill, color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ export class ParagraphStyle extends Style {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public shadow(value: string, fill: string, color: string): ParagraphStyle {
|
public shadow(value: string, fill: string, color: string): ParagraphStyle {
|
||||||
return this.addRunProperty(new formatting.Shadow(value, fill, color));
|
return this.addRunProperty(new formatting.Shading(value, fill, color));
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------- Paragraph formatting ------------------------ //
|
// --------------------- Paragraph formatting ------------------------ //
|
||||||
|
Reference in New Issue
Block a user