Porting tests over to vitest

This commit is contained in:
Dolan Miu
2023-06-05 00:33:43 +01:00
parent a89919397d
commit e69b063687
256 changed files with 1557 additions and 612 deletions

View File

@ -1,5 +1,5 @@
// Simple example to add text to a document // Simple example to add text to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, Tab, TextRun } from "docx"; import { Document, Packer, Paragraph, Tab, TextRun } from "docx";

View File

@ -1,7 +1,7 @@
// Generate a CV // Generate a CV
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { AlignmentType, Document, HeadingLevel, Packer, Paragraph, Tab, TabStopPosition, TabStopType, TextRun } from "../build"; import { AlignmentType, Document, HeadingLevel, Packer, Paragraph, Tab, TabStopPosition, TabStopType, TextRun } from "docx";
// tslint:disable:no-shadowed-variable // tslint:disable:no-shadowed-variable

View File

@ -1,5 +1,5 @@
// Setting styles with JavaScript configuration // Setting styles with JavaScript configuration
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { import {
AlignmentType, AlignmentType,
@ -16,7 +16,7 @@ import {
TabStopPosition, TabStopPosition,
UnderlineType, UnderlineType,
LevelFormat, LevelFormat,
} from "../build"; } from "docx";
const table = new Table({ const table = new Table({
rows: [ rows: [

View File

@ -1,7 +1,7 @@
// Scaling images // Scaling images
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, ImageRun, Packer, Paragraph } from "../build"; import { Document, ImageRun, Packer, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// This example shows 3 styles using XML styles // This example shows 3 styles using XML styles
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph } from "../build"; import { Document, HeadingLevel, Packer, Paragraph } from "docx";
const styles = fs.readFileSync("./demo/assets/custom-styles.xml", "utf-8"); const styles = fs.readFileSync("./demo/assets/custom-styles.xml", "utf-8");
const doc = new Document({ const doc = new Document({

View File

@ -1,7 +1,7 @@
// Page numbers // Page numbers
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, Paragraph, TextRun } from "../build"; import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, Paragraph, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Page break before example // Page break before example
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph } from "../build"; import { Document, Packer, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Multiple sections and headers // Multiple sections and headers
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Footer, Header, Packer, PageNumber, NumberFormat, PageOrientation, Paragraph, TextRun } from "../build"; import { Document, Footer, Header, Packer, PageNumber, NumberFormat, PageOrientation, Paragraph, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Footnotes // Footnotes
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, FootnoteReferenceRun, Packer, Paragraph, TextRun } from "../build"; import { Document, FootnoteReferenceRun, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
footnotes: { footnotes: {

View File

@ -1,7 +1,7 @@
// Insert image from a buffer // Insert image from a buffer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, ImageRun, Packer, Paragraph } from "../build"; import { Document, ImageRun, Packer, Paragraph } from "docx";
const imageBase64Data = `iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAACzVBMVEUAAAAAAAAAAAAAAAA/A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S2phHTWn9lDkIhBTqWqxQZ+IsRvtdHY9AvI2VX2hW68nfqGmuQsCEl3JdjfCF8OW1bPdtwhQ0gm2mQzfRE3a7KCYj0BNZJs8+Kxf/r6WtTEI2FIqlsMfFgRB5A6KUnSe/vUkX0AnuvUIt8SjM1m6wWQymUwmk8lkMgXRf5vi8rLQxtUhAAAAAElFTkSuQmCC`;

View File

@ -1,7 +1,7 @@
// Export to base64 string - Useful in a browser environment. // Export to base64 string - Useful in a browser environment.
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, Tab, TextRun } from "../build"; import { Document, Packer, Paragraph, Tab, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,5 +1,5 @@
// Example on how to customize the look at feel using Styles // Example on how to customize the look at feel using Styles
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph, TextRun, UnderlineType } from "docx"; import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph, TextRun, UnderlineType } from "docx";

View File

@ -1,7 +1,7 @@
// Add custom borders to table cell // Add custom borders to table cell
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { BorderStyle, Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build"; import { BorderStyle, Document, Packer, Paragraph, Table, TableCell, TableRow } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,18 +1,7 @@
// This demo shows how to create bookmarks then link to them with internal hyperlinks // This demo shows how to create bookmarks then link to them with internal hyperlinks
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { import { Bookmark, Document, Footer, HeadingLevel, InternalHyperlink, Packer, PageBreak, Paragraph, TextRun, PageReference } from "docx";
Bookmark,
Document,
Footer,
HeadingLevel,
InternalHyperlink,
Packer,
PageBreak,
Paragraph,
TextRun,
PageReference,
} from "../build";
const LOREM_IPSUM = const LOREM_IPSUM =
/* cspell:disable-next-line */ /* cspell:disable-next-line */

View File

@ -1,7 +1,7 @@
// This demo shows right to left for special languages // This demo shows right to left for special languages
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, Table, TableCell, TableRow, TextRun } from "../build"; import { Document, Packer, Paragraph, Table, TableCell, TableRow, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// This demo adds an image to the Media cache, and then insert to the document afterwards // This demo adds an image to the Media cache, and then insert to the document afterwards
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, ImageRun, Packer, Paragraph, TextRun } from "../build"; import { Document, ImageRun, Packer, Paragraph, TextRun } from "docx";
const imageBase64Data = `iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAACzVBMVEUAAAAAAAAAAAAAAAA/AD8zMzMqKiokJCQfHx8cHBwZGRkuFxcqFSonJyckJCQiIiIfHx8eHh4cHBwoGhomGSYkJCQhISEfHx8eHh4nHR0lHBwkGyQjIyMiIiIgICAfHx8mHh4lHh4kHR0jHCMiGyIhISEgICAfHx8lHx8kHh4jHR0hHCEhISEgICAlHx8kHx8jHh4jHh4iHSIhHCEhISElICAkHx8jHx8jHh4iHh4iHSIhHSElICAkICAjHx8jHx8iHh4iHh4hHiEhHSEkICAjHx8iHx8iHx8hHh4hHiEkHSEjHSAjHx8iHx8iHx8hHh4kHiEkHiEjHSAiHx8hHx8hHh4kHiEjHiAjHSAiHx8iHx8hHx8kHh4jHiEjHiAjHiAiICAiHx8kHx8jHh4jHiEjHiAiHiAiHSAiHx8jHx8jHx8jHiAiHiAiHiAiHSAiHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8iHx8i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xxmXssOfxnvDVcxRTod9FxyhqLoAqis5aPhwTDp9spRgEH2Q6KLbYoKqlaKTm6Isp0C/sJMnjFvhiERXPQvUNRe9p29lhR04CdBpC8Sl8YiuncIxEuzUUg4Dkgj+paVozygY9plPMh28SaymO9kabAopREGF3vt9MzeFFl8G7lRSZ8FFGK8XX4VA8QjEd7XrM3M0OXz8YCy+qKBLgq3wqnofiTorF0Ax56Rg1J1elW+BBAsVe+My6iYq7IK6keBdOIseV2qn5Pb8f3MqkWAXf9ThM8c8lAOIotuFsF875lRrH5klRcG0+xcPwQ1oLxfeRAP4heQTnGL78X2rqlw2DK59SXAV/zKaiGMAuko5InCt68mcOan5+ohf+z1pP8lQY/GHZQMV4YD3FpXDp4qerqbF/lBWBswyi+AL+ia+maLgcRRQj4IYlY/UpauqKBsPJAxQF8NM1TRQ/RudSPAD34rK3scOuR8/HGcspxsJfOVS8NZbiGXiUtPgINU3v3WFDmx8pEuG3EiqKKVbCC1vm2iZqap5LAtCtleQf8F9sFYWDohzeJczYyQ4V2bEZFGsQgJRGqqqhS2phHTWn9lDkIhBTqWqxQZ+IsRvtdHY9AvI2VX2hW68nfqGmuQsCEl3JdjfCF8OW1bPdtwhQ0gm2mQzfRE3a7KCYj0BNZJs8+Kxf/r6WtTEI2FIqlsMfFgRB5A6KUnSe/vUkX0AnuvUIt8SjM1m6wWQymUwmk8lkMgXRf5vi8rLQxtUhAAAAAElFTkSuQmCC`;

View File

@ -1,7 +1,7 @@
// Add image to table cell // Add image to table cell
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "../build"; import { Document, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Example of how you would create a table and add data to it // Example of how you would create a table and add data to it
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "../build"; import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "docx";
const styles = fs.readFileSync("./demo/assets/custom-styles.xml", "utf-8"); const styles = fs.readFileSync("./demo/assets/custom-styles.xml", "utf-8");

View File

@ -1,7 +1,7 @@
// Creates two paragraphs, one with a border and one without // Creates two paragraphs, one with a border and one without
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { BorderStyle, Document, Packer, Paragraph, TextRun } from "../build"; import { BorderStyle, Document, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Custom styles using JavaScript configuration // Custom styles using JavaScript configuration
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, convertInchesToTwip, HeadingLevel, Packer, Paragraph, UnderlineType } from "../build"; import { Document, convertInchesToTwip, HeadingLevel, Packer, Paragraph, UnderlineType } from "docx";
const doc = new Document({ const doc = new Document({
styles: { styles: {

View File

@ -1,7 +1,7 @@
// Table of contents // Table of contents
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { File, HeadingLevel, Packer, Paragraph, StyleLevel, TableOfContents } from "../build"; import { File, HeadingLevel, Packer, Paragraph, StyleLevel, TableOfContents } from "docx";
// WordprocessingML docs for TableOfContents can be found here: // WordprocessingML docs for TableOfContents can be found here:
// http://officeopenxml.com/WPtableOfContents.php // http://officeopenxml.com/WPtableOfContents.php

View File

@ -1,8 +1,8 @@
// Numbered lists // Numbered lists
// The lists can also be restarted by specifying the instance number // The lists can also be restarted by specifying the instance number
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build"; import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
numbering: { numbering: {

View File

@ -1,7 +1,7 @@
// Numbering and bullet points example // Numbering and bullet points example
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { AlignmentType, convertInchesToTwip, Document, Footer, Header, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build"; import { AlignmentType, convertInchesToTwip, Document, Footer, Header, HeadingLevel, LevelFormat, Packer, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
numbering: { numbering: {

View File

@ -1,7 +1,7 @@
// Example of how you would create a table and add data to it // Example of how you would create a table and add data to it
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign, TextDirection } from "../build"; import { Document, HeadingLevel, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign, TextDirection } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,6 +1,6 @@
// Example of how you would merge cells together (Rows and Columns) and apply shading // Example of how you would merge cells together (Rows and Columns) and apply shading
// Also includes an example on how to center tables // Also includes an example on how to center tables
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { import {
AlignmentType, AlignmentType,
@ -15,7 +15,7 @@ import {
TableCell, TableCell,
TableRow, TableRow,
WidthType, WidthType,
} from "../build"; } from "docx";
const table = new Table({ const table = new Table({
rows: [ rows: [

View File

@ -1,7 +1,7 @@
// Sequential Captions // Sequential Captions
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, SequentialIdentifier, TextRun } from "../build"; import { Document, Packer, Paragraph, SequentialIdentifier, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,5 +1,5 @@
// Example of how you would create a table with float positions // Example of how you would create a table with float positions
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { import {
Document, Document,
@ -14,7 +14,7 @@ import {
TableLayoutType, TableLayoutType,
TableRow, TableRow,
WidthType, WidthType,
} from "../build"; } from "docx";
const table = new Table({ const table = new Table({
rows: [ rows: [

View File

@ -1,7 +1,7 @@
// Example on how to add hyperlinks to websites // Example on how to add hyperlinks to websites
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, ExternalHyperlink, Footer, FootnoteReferenceRun, ImageRun, Packer, Paragraph, TextRun } from "../build"; import { Document, ExternalHyperlink, Footer, FootnoteReferenceRun, ImageRun, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
footnotes: { footnotes: {

View File

@ -1,7 +1,7 @@
// Add image to table cell in a header and body // Add image to table cell in a header and body
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Header, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "../build"; import { Document, Header, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "docx";
const table = new Table({ const table = new Table({
rows: [ rows: [

View File

@ -1,7 +1,7 @@
// Add images to header and footer // Add images to header and footer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Header, ImageRun, Packer, Paragraph } from "../build"; import { Document, Header, ImageRun, Packer, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,8 +1,8 @@
// Example of how to "wrap" text around an image // Example of how to "wrap" text around an image
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
// import { Document, Packer, Paragraph } from "../build"; // import { Document, Packer, Paragraph } from "docx";
import { Document, ImageRun, Packer, Paragraph, TextWrappingSide, TextWrappingType } from "../build"; import { Document, ImageRun, Packer, Paragraph, TextWrappingSide, TextWrappingType } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Example how to display page numbers // Example how to display page numbers
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, NumberFormat, Paragraph, TextRun } from "../build"; import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, NumberFormat, Paragraph, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Example of how you would create a table and add data to it // Example of how you would create a table and add data to it
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "../build"; import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "docx";
const table = new Table({ const table = new Table({
columnWidths: [3505, 5505], columnWidths: [3505, 5505],

View File

@ -1,7 +1,7 @@
// Example demonstrating line numbers. // Example demonstrating line numbers.
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "../build"; import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Multiple cells merging in the same table - Rows and Columns // Multiple cells merging in the same table - Rows and Columns
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build"; import { Document, Packer, Paragraph, Table, TableCell, TableRow } from "docx";
const table = new Table({ const table = new Table({
rows: [ rows: [

View File

@ -1,7 +1,7 @@
// Page numbers - Start from 0 on a new section // Page numbers - Start from 0 on a new section
// 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, PageBreak, PageNumber, PageNumberSeparator, Paragraph, TextRun } from "../build"; import { AlignmentType, Document, Header, Packer, PageBreak, PageNumber, PageNumberSeparator, Paragraph, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Add image to table cell // Add image to table cell
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, ImageRun, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "../build"; import { Document, ImageRun, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "docx";
const imageBase64Data = `iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAACzVBMVEUAAAAAAAAAAAAAAAA/AD8zMzMqKiokJCQfHx8cHBwZGRkuFxcqFSonJyckJCQiIiIfHx8eHh4cHBwoGhomGSYkJCQhISEfHx8eHh4nHR0lHBwkGyQjIyMiIiIgICAfHx8mHh4lHh4kHR0jHCMiGyIhISEgICAfHx8lHx8kHh4jHR0hHCEhISEgICAlHx8kHx8jHh4jHh4iHSIhHCEhISElICAkHx8jHx8jHh4iHh4iHSIhHSElICAkICAjHx8jHx8iHh4iHh4hHiEhHSEkICAjHx8iHx8iHx8hHh4hHiEkHSEjHSAjHx8iHx8iHx8hHh4kHiEkHiEjHSAiHx8hHx8hHh4kHiEjHiAjHSAiHx8iHx8hHx8kHh4jHiEjHiAjHiAiICAiHx8kHx8jHh4jHiEjHiAiHiAiHSAiHx8jHx8jHx8jHiAiHiAiHiAiHSAiHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8iHx8iHSAiHiAjHiAjHx8jHx8hHx8iHx8iHyAiHiAjHiAjHiAjHh4hHx8iHx8iHx8iHyAjHSAjHiAjHiAjHh4hHx8iHx8iHx8jHyAjHiAhHh4iHx8iHx8jHyAjHSAjHSAhHiAhHh4iHx8iHx8jHx8jHyAjHSAjHSAiHh4iHh4jHx8jHx8jHyAjHyAhHSAhHSAiHh4iHh4jHx8jHx8jHyAhHyAhHSAiHSAiHh4jHh4jHx8jHx8jHyAhHyAhHSAiHSAjHR4jHh4jHx8jHx8hHyAhHyAiHS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RrH5klRcG0+xcPwQ1oLxfeRAP4heQTnGL78X2rqlw2DK59SXAV/zKaiGMAuko5InCt68mcOan5+ohf+z1pP8lQY/GHZQMV4YD3FpXDp4qerqbF/lBWBswyi+AL+ia+maLgcRRQj4IYlY/UpauqKBsPJAxQF8NM1TRQ/RudSPAD34rK3scOuR8/HGcspxsJfOVS8NZbiGXiUtPgINU3v3WFDmx8pEuG3EiqKKVbCC1vm2iZqap5LAtCtleQf8F9sFYWDohzeJczYyQ4V2bEZFGsQgJRGqqqhS2phHTWn9lDkIhBTqWqxQZ+IsRvtdHY9AvI2VX2hW68nfqGmuQsCEl3JdjfCF8OW1bPdtwhQ0gm2mQzfRE3a7KCYj0BNZJs8+Kxf/r6WtTEI2FIqlsMfFgRB5A6KUnSe/vUkX0AnuvUIt8SjM1m6wWQymUwmk8lkMgXRf5vi8rLQxtUhAAAAAElFTkSuQmCC`;

View File

@ -1,7 +1,7 @@
// Sections with multiple columns // Sections with multiple columns
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph } from "../build"; import { Document, Packer, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Highlighting text // 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 "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Shading text // 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 "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Multiple sections with total number of pages in each section // Multiple sections with total number of pages in each section
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, NumberFormat, Paragraph, TextRun } from "../build"; import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, NumberFormat, Paragraph, TextRun } from "docx";
const header = new Header({ const header = new Header({
children: [ children: [

View File

@ -1,7 +1,7 @@
// Example of making content of section vertically aligned // Example of making content of section vertically aligned
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, VerticalAlign, TextRun, Tab } from "../build"; import { Document, Packer, Paragraph, VerticalAlign, TextRun, Tab } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,5 +1,5 @@
// Add custom borders and no-borders to the table itself // Add custom borders and no-borders to the table itself
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { import {
BorderStyle, BorderStyle,
@ -13,7 +13,7 @@ import {
TableRow, TableRow,
TextDirection, TextDirection,
VerticalAlign, VerticalAlign,
} from "../build"; } from "docx";
const table = new Table({ const table = new Table({
rows: [ rows: [

View File

@ -1,5 +1,5 @@
// Example of how to add images to the document - You can use Buffers, UInt8Arrays or Base64 strings // Example of how to add images to the document - You can use Buffers, UInt8Arrays or Base64 strings
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { import {
Document, Document,
@ -10,7 +10,7 @@ import {
Paragraph, Paragraph,
VerticalPositionAlign, VerticalPositionAlign,
VerticalPositionRelativeFrom, VerticalPositionRelativeFrom,
} from "../build"; } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// The demo on the README.md // The demo on the README.md
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, HeadingLevel, ImageRun, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign } from "../build"; import { Document, HeadingLevel, ImageRun, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign } from "docx";
const table = new Table({ const table = new Table({
rows: [ rows: [

View File

@ -1,7 +1,7 @@
// Custom character styles using JavaScript configuration // Custom character styles using JavaScript configuration
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun } from "../build"; import { Document, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
styles: { styles: {

View File

@ -1,7 +1,7 @@
// Japanese text - Need to use a Japanese font // Japanese text - Need to use a Japanese font
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph } from "../build"; import { Document, HeadingLevel, Packer, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
styles: { styles: {

View File

@ -5,9 +5,8 @@
// Note that if the OS have not install `KaiTi` font, this demo doesn't work. // Note that if the OS have not install `KaiTi` font, this demo doesn't work.
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph, TextRun } from "../build"; import { Document, HeadingLevel, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
styles: { styles: {

View File

@ -3,9 +3,8 @@
// to the document in Word after the document has been generated. Standard properties (such as creator, title // to the document in Word after the document has been generated. Standard properties (such as creator, title
// and subject) cover typical use cases, but sometimes custom properties are required. // and subject) cover typical use cases, but sometimes custom properties are required.
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer } from "../build"; import { Document, Packer } from "docx";
const doc = new Document( const doc = new Document(
// Standard properties // Standard properties

View File

@ -1,5 +1,5 @@
// Simple example to add text to a document // Simple example to add text to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { import {
Document, Document,
@ -21,7 +21,7 @@ import {
Packer, Packer,
Paragraph, Paragraph,
TextRun, TextRun,
} from "../build"; } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Change background colour of whole document // Change background colour of whole document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, Tab, TextRun } from "../build"; import { Document, Packer, Paragraph, Tab, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
background: { background: {

View File

@ -1,7 +1,7 @@
// Numbered lists - Add parent number in sub number // Numbered lists - Add parent number in sub number
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build"; import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
numbering: { numbering: {

View File

@ -1,7 +1,7 @@
// Usage of different Section Types // Usage of different Section Types
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun, SectionType } from "../build"; import { Document, Packer, Paragraph, TextRun, SectionType } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Move + offset header and footer // Move + offset header and footer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Footer, Header, Packer, Paragraph } from "../build"; import { Document, Footer, Header, Packer, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Example of how to change page borders // Example of how to change page borders
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph, Tab, TextRun } from "../build"; import { Document, HeadingLevel, Packer, Paragraph, Tab, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,5 +1,5 @@
// Track Revisions aka. "Track Changes" // Track Revisions aka. "Track Changes"
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { import {
AlignmentType, AlignmentType,
@ -14,7 +14,7 @@ import {
ShadingType, ShadingType,
Tab, Tab,
TextRun, TextRun,
} from "../build"; } from "docx";
/* /*
For reference, see For reference, see

View File

@ -1,5 +1,5 @@
// Text Frame (Text Box) example // Text Frame (Text Box) example
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { import {
BorderStyle, BorderStyle,

View File

@ -1,7 +1,7 @@
// Simple example to add text to a document // Simple example to add text to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, LineRuleType, Packer, Paragraph, TextRun } from "../build"; import { Document, LineRuleType, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Move + offset header and footer // Move + offset header and footer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Footer, Header, Packer, PageBreak, Paragraph, TextRun } from "../build"; import { Document, Footer, Header, Packer, PageBreak, Paragraph, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
evenAndOddHeaderAndFooters: true, evenAndOddHeaderAndFooters: true,

View File

@ -1,7 +1,7 @@
// Numbered lists - With complex number text // Numbered lists - With complex number text
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, LevelFormat } from "../build"; import { Document, Packer, Paragraph, LevelFormat } from "docx";
const doc = new Document({ const doc = new Document({
numbering: { numbering: {

View File

@ -1,8 +1,8 @@
// Example of how to set the document page sizes // Example of how to set the document page sizes
// Reference from https://papersizes.io/a/a3 // Reference from https://papersizes.io/a/a3
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { convertMillimetersToTwip, Document, Packer, PageOrientation, Paragraph } from "../build"; import { convertMillimetersToTwip, Document, Packer, PageOrientation, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Use fields to include dynamic text // Use fields to include dynamic text
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Bookmark, Document, Packer, Paragraph, SimpleField, TextRun } from "../build"; import { Bookmark, Document, Packer, Paragraph, SimpleField, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
creator: "Me", creator: "Me",

View File

@ -1,7 +1,7 @@
// Section with 2 columns including a column break // Section with 2 columns including a column break
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, ColumnBreak, TextRun } from "../build"; import { Document, Packer, Paragraph, ColumnBreak, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,5 +1,5 @@
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, LevelFormat } from "../build"; import { Document, Packer, Paragraph, LevelFormat } from "docx";
const doc = new Document({ const doc = new Document({
numbering: { numbering: {

View File

@ -1,7 +1,7 @@
// Sections with multiple columns // Sections with multiple columns
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Column, Document, Packer, Paragraph } from "../build"; import { Column, Document, Packer, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Example of how to set the document to landscape // Example of how to set the document to landscape
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, PageOrientation, Paragraph } from "../build"; import { Document, Packer, PageOrientation, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Example demonstrating line numbers with suppression. // Example demonstrating line numbers with suppression.
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "../build"; import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Example demonstrating page borders with style, colors and size // Example demonstrating page borders with style, colors and size
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, TextRun, Paragraph, BorderStyle, PageBorderDisplay, PageBorderOffsetFrom, PageBorderZOrder } from "../build"; import { Document, Packer, TextRun, Paragraph, BorderStyle, PageBorderDisplay, PageBorderOffsetFrom, PageBorderZOrder } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Example on how to preserve word wrap text. Works with all languages. // Example on how to preserve word wrap text. Works with all languages.
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun, SpaceType } from "../build"; import { Document, Packer, Paragraph, TextRun, SpaceType } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Simple example to add comments to a document // Simple example to add comments to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun, CommentRangeStart, CommentRangeEnd, CommentReference } from "../build"; import { Document, Packer, Paragraph, TextRun, CommentRangeStart, CommentRangeEnd, CommentReference } from "docx";
const doc = new Document({ const doc = new Document({
comments: { comments: {

View File

@ -1,5 +1,5 @@
// Exporting the document as a stream // Exporting the document as a stream
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, Tab, TextRun } from "docx"; import { Document, Packer, Paragraph, Tab, TextRun } from "docx";

View File

@ -1,5 +1,5 @@
// Example of using tab stops // Example of using tab stops
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph, TabStopPosition, TabStopType, TextRun } from "docx"; import { Document, HeadingLevel, Packer, Paragraph, TabStopPosition, TabStopType, TextRun } from "docx";

View File

@ -1,7 +1,7 @@
// Add compatibility options // Add compatibility options
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun } from "../build"; import { Document, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
compatibility: { compatibility: {

View File

@ -1,7 +1,7 @@
// Exporting the document as a stream // Exporting the document as a stream
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, Table, TableBorders, TableCell, TableRow, WidthType } from "../build"; import { Document, Packer, Paragraph, Table, TableBorders, TableCell, TableRow, WidthType } from "docx";
const table1 = new Table({ const table1 = new Table({
columnWidths: [3505, 5505], columnWidths: [3505, 5505],

View File

@ -1,7 +1,7 @@
// Simple example to add text to a document // Simple example to add text to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { AlignmentType, Document, Packer, Paragraph, TextRun } from "../build"; import { AlignmentType, Document, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,5 +1,5 @@
// Example of how you would create a table and add data to it from a data source // Example of how you would create a table and add data to it from a data source
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { import {
Document, Document,
@ -13,7 +13,7 @@ import {
TextDirection, TextDirection,
TextRun, TextRun,
WidthType, WidthType,
} from "../build"; } from "docx";
interface StockPrice { interface StockPrice {
readonly date: Date; readonly date: Date;

View File

@ -1,7 +1,7 @@
// Add text to header and footer // Add text to header and footer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Footer, Header, Packer, Paragraph } from "../build"; import { Document, Footer, Header, Packer, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Simple example to add text to a document // Simple example to add text to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { AlignmentType, convertMillimetersToTwip, Document, Packer, Paragraph, TextRun } from "../build"; import { AlignmentType, convertMillimetersToTwip, Document, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
styles: { styles: {

View File

@ -1,7 +1,7 @@
// Example of a continuous header // Example of a continuous header
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Footer, Header, Packer, Paragraph, SectionType, Tab, TextRun } from "../build"; import { Document, Footer, Header, Packer, Paragraph, SectionType, Tab, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
creator: "Creator", creator: "Creator",

View File

@ -1,7 +1,7 @@
// Example of using headers and footers in a new section // Example of using headers and footers in a new section
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Footer, Header, Packer, Paragraph, SectionType, Tab, TextRun } from "../build"; import { Document, Footer, Header, Packer, Paragraph, SectionType, Tab, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
creator: "Creator", creator: "Creator",

View File

@ -1,7 +1,7 @@
// Simple example to add text to a document // Simple example to add text to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph } from "../build"; import { Document, Packer, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
styles: { styles: {

View File

@ -1,5 +1,5 @@
// Simple example apply positional tabs to a document // Simple example apply positional tabs to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { import {
Document, Document,
@ -11,7 +11,7 @@ import {
PositionalTabAlignment, PositionalTabAlignment,
PositionalTabRelativeTo, PositionalTabRelativeTo,
PositionalTabLeader, PositionalTabLeader,
} from "../build"; } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,5 +1,5 @@
// Patch a document with patches // Patch a document with patches
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { import {
ExternalHyperlink, ExternalHyperlink,
@ -14,7 +14,7 @@ import {
TextDirection, TextDirection,
TextRun, TextRun,
VerticalAlign, VerticalAlign,
} from "../build"; } from "docx";
patchDocument(fs.readFileSync("demo/assets/simple-template.docx"), { patchDocument(fs.readFileSync("demo/assets/simple-template.docx"), {
patches: { patches: {

View File

@ -1,7 +1,7 @@
// Generate a template document // Generate a template document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun } from "../build"; import { Document, Packer, Paragraph, TextRun } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

View File

@ -1,7 +1,7 @@
// Patch a document with patches // Patch a document with patches
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { patchDocument, PatchType, TextRun } from "../build"; import { patchDocument, PatchType, TextRun } from "docx";
patchDocument(fs.readFileSync("demo/assets/simple-template-2.docx"), { patchDocument(fs.readFileSync("demo/assets/simple-template-2.docx"), {
patches: { patches: {

View File

@ -1,7 +1,7 @@
// Patch a document with patches // Patch a document with patches
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { IPatch, patchDocument, PatchType, TextRun } from "../build"; import { IPatch, patchDocument, PatchType, TextRun } from "docx";
export const font = "Trebuchet MS"; export const font = "Trebuchet MS";
export const getPatches = (fields: { [key: string]: string }) => { export const getPatches = (fields: { [key: string]: string }) => {

View File

@ -1,7 +1,7 @@
// Patch a document with patches // Patch a document with patches
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { IPatch, patchDocument, PatchType, TextRun } from "../build"; import { IPatch, patchDocument, PatchType, TextRun } from "docx";
export const font = "Trebuchet MS"; export const font = "Trebuchet MS";
export const getPatches = (fields: { [key: string]: string }) => { export const getPatches = (fields: { [key: string]: string }) => {

View File

@ -1,7 +1,7 @@
// Add images to header and footer // Add images to header and footer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs"; import * as fs from "fs";
import { Document, Footer, Header, ImageRun, Packer, Paragraph } from "../build"; import { Document, Footer, Header, ImageRun, Packer, Paragraph } from "docx";
const doc = new Document({ const doc = new Document({
sections: [ sections: [

999
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -22,8 +22,7 @@
], ],
"scripts": { "scripts": {
"build": "tsc && vite build", "build": "tsc && vite build",
"pretest": "rimraf ./build", "test": "vitest",
"test": "mocha --config=.mocharc.json",
"test.coverage": "nyc npm test", "test.coverage": "nyc npm test",
"test.watch": "npm test -- --watch", "test.watch": "npm test -- --watch",
"prepublishOnly": "npm run build --omit=dev", "prepublishOnly": "npm run build --omit=dev",
@ -124,6 +123,7 @@
"vite-plugin-dts": "^2.3.0", "vite-plugin-dts": "^2.3.0",
"vite-plugin-node-polyfills": "^0.8.2", "vite-plugin-node-polyfills": "^0.8.2",
"vite-tsconfig-paths": "^4.2.0", "vite-tsconfig-paths": "^4.2.0",
"vitest": "^0.31.4",
"webpack": "^5.28.0", "webpack": "^5.28.0",
"webpack-cli": "^5.0.0" "webpack-cli": "^5.0.0"
}, },

View File

@ -1,4 +1,4 @@
import { assert, expect } from "chai"; import { assert, beforeEach, describe, expect, it } from "vitest";
import * as sinon from "sinon"; import * as sinon from "sinon";
import { Formatter } from "@export/formatter"; import { Formatter } from "@export/formatter";

View File

@ -1,4 +1,4 @@
import { expect } from "chai"; import { describe, expect, it } from "vitest";
import { Media } from "@file/media"; import { Media } from "@file/media";

View File

@ -1,180 +1,189 @@
// /* tslint:disable:typedef space-before-function-paren */ /* tslint:disable:typedef space-before-function-paren */
// import { expect } from "chai"; import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
// import * as sinon from "sinon"; import * as sinon from "sinon";
// import { File } from "@file/file"; import { File } from "@file/file";
// import { Footer, Header } from "@file/header"; import { Footer, Header } from "@file/header";
// import { ImageRun, Paragraph } from "@file/paragraph"; import { ImageRun, Paragraph } from "@file/paragraph";
// import * as convenienceFunctions from "@util/convenience-functions"; import * as convenienceFunctions from "@util/convenience-functions";
// import { Compiler } from "./next-compiler"; import { Compiler } from "./next-compiler";
// describe("Compiler", () => { describe("Compiler", () => {
// let compiler: Compiler; let compiler: Compiler;
// beforeEach(() => { beforeEach(() => {
// compiler = new Compiler(); compiler = new Compiler();
// }); });
// before(() => { beforeAll(() => {
// sinon.stub(convenienceFunctions, "uniqueId").callsFake(() => "test"); vi.spyOn(convenienceFunctions, "uniqueId").mockReturnValue("test");
// }); });
// after(() => { afterAll(() => {
// (convenienceFunctions.uniqueId as sinon.SinonStub).restore(); vi.resetAllMocks();
// }); });
// describe("#compile()", () => { describe("#compile()", () => {
// it("should pack all the content", async function () { it(
// this.timeout(99999999); "should pack all the content",
// const file = new File({ async () => {
// sections: [], const file = new File({
// comments: { sections: [],
// children: [], comments: {
// }, children: [],
// }); },
// const zipFile = await compiler.compile(file); });
// const fileNames = Object.keys(zipFile.files).map((f) => zipFile.files[f].name); const zipFile = await compiler.compile(file);
const fileNames = Object.keys(zipFile.files).map((f) => zipFile.files[f].name);
// expect(fileNames).is.an.instanceof(Array); expect(fileNames).is.an.instanceof(Array);
// expect(fileNames).has.length(17); expect(fileNames).has.length(17);
// expect(fileNames).to.include("word/document.xml"); expect(fileNames).to.include("word/document.xml");
// expect(fileNames).to.include("word/styles.xml"); expect(fileNames).to.include("word/styles.xml");
// expect(fileNames).to.include("docProps/core.xml"); expect(fileNames).to.include("docProps/core.xml");
// expect(fileNames).to.include("docProps/custom.xml"); expect(fileNames).to.include("docProps/custom.xml");
// expect(fileNames).to.include("docProps/app.xml"); expect(fileNames).to.include("docProps/app.xml");
// expect(fileNames).to.include("word/numbering.xml"); expect(fileNames).to.include("word/numbering.xml");
// expect(fileNames).to.include("word/footnotes.xml"); expect(fileNames).to.include("word/footnotes.xml");
// expect(fileNames).to.include("word/_rels/footnotes.xml.rels"); expect(fileNames).to.include("word/_rels/footnotes.xml.rels");
// expect(fileNames).to.include("word/settings.xml"); expect(fileNames).to.include("word/settings.xml");
// expect(fileNames).to.include("word/comments.xml"); expect(fileNames).to.include("word/comments.xml");
// expect(fileNames).to.include("word/_rels/document.xml.rels"); expect(fileNames).to.include("word/_rels/document.xml.rels");
// expect(fileNames).to.include("[Content_Types].xml"); expect(fileNames).to.include("[Content_Types].xml");
// expect(fileNames).to.include("_rels/.rels"); expect(fileNames).to.include("_rels/.rels");
// }); },
{
timeout: 99999999,
},
);
// it("should pack all additional headers and footers", function () { it(
// const file = new File({ "should pack all additional headers and footers",
// sections: [ () => {
// { const file = new File({
// headers: { sections: [
// default: new Header({ {
// children: [new Paragraph("test")], headers: {
// }), default: new Header({
// }, children: [new Paragraph("test")],
// footers: { }),
// default: new Footer({ },
// children: [new Paragraph("test")], footers: {
// }), default: new Footer({
// }, children: [new Paragraph("test")],
// children: [], }),
// }, },
// { children: [],
// headers: { },
// default: new Header({ {
// children: [new Paragraph("test")], headers: {
// }), default: new Header({
// }, children: [new Paragraph("test")],
// footers: { }),
// default: new Footer({ },
// children: [new Paragraph("test")], footers: {
// }), default: new Footer({
// }, children: [new Paragraph("test")],
// children: [], }),
// }, },
// ], children: [],
// }); },
],
});
// this.timeout(99999999); const zipFile = compiler.compile(file);
const fileNames = Object.keys(zipFile.files).map((f) => zipFile.files[f].name);
// const zipFile = compiler.compile(file); expect(fileNames).is.an.instanceof(Array);
// const fileNames = Object.keys(zipFile.files).map((f) => zipFile.files[f].name); expect(fileNames).has.length(25);
// expect(fileNames).is.an.instanceof(Array); expect(fileNames).to.include("word/header1.xml");
// expect(fileNames).has.length(25); expect(fileNames).to.include("word/_rels/header1.xml.rels");
expect(fileNames).to.include("word/header2.xml");
expect(fileNames).to.include("word/_rels/header2.xml.rels");
expect(fileNames).to.include("word/footer1.xml");
expect(fileNames).to.include("word/_rels/footer1.xml.rels");
expect(fileNames).to.include("word/footer2.xml");
expect(fileNames).to.include("word/_rels/footer2.xml.rels");
},
{
timeout: 99999999,
},
);
// expect(fileNames).to.include("word/header1.xml"); it("should call the format method X times equalling X files to be formatted", () => {
// expect(fileNames).to.include("word/_rels/header1.xml.rels"); // This test is required because before, there was a case where Document was formatted twice, which was inefficient
// expect(fileNames).to.include("word/header2.xml"); // This also caused issues such as running prepForXml multiple times as format() was ran multiple times.
// expect(fileNames).to.include("word/_rels/header2.xml.rels"); const paragraph = new Paragraph("");
// expect(fileNames).to.include("word/footer1.xml"); const file = new File({
// expect(fileNames).to.include("word/_rels/footer1.xml.rels"); sections: [
// expect(fileNames).to.include("word/footer2.xml"); {
// expect(fileNames).to.include("word/_rels/footer2.xml.rels"); properties: {},
// }); children: [paragraph],
},
],
});
// it("should call the format method X times equalling X files to be formatted", () => { // tslint:disable-next-line: no-string-literal
// // This test is required because before, there was a case where Document was formatted twice, which was inefficient const spy = sinon.spy(compiler["formatter"], "format");
// // This also caused issues such as running prepForXml multiple times as format() was ran multiple times.
// const paragraph = new Paragraph("");
// const file = new File({
// sections: [
// {
// properties: {},
// children: [paragraph],
// },
// ],
// });
// // tslint:disable-next-line: no-string-literal compiler.compile(file);
// const spy = sinon.spy(compiler["formatter"], "format"); expect(spy.callCount).to.equal(13);
});
// compiler.compile(file); it("should work with media datas", () => {
// expect(spy.callCount).to.equal(13); // This test is required because before, there was a case where Document was formatted twice, which was inefficient
// }); // This also caused issues such as running prepForXml multiple times as format() was ran multiple times.
const file = new File({
sections: [
{
headers: {
default: new Header({
children: [new Paragraph("test")],
}),
},
footers: {
default: new Footer({
children: [new Paragraph("test")],
}),
},
children: [
new Paragraph({
children: [
new ImageRun({
data: Buffer.from("", "base64"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
],
},
],
});
// it("should work with media datas", () => { // tslint:disable-next-line: no-string-literal
// // This test is required because before, there was a case where Document was formatted twice, which was inefficient sinon.stub(compiler["imageReplacer"], "getMediaData").returns([
// // This also caused issues such as running prepForXml multiple times as format() was ran multiple times. {
// const file = new File({ stream: Buffer.from(""),
// sections: [ fileName: "test",
// { transformation: {
// headers: { pixels: {
// default: new Header({ x: 100,
// children: [new Paragraph("test")], y: 100,
// }), },
// }, emus: {
// footers: { x: 100,
// default: new Footer({ y: 100,
// children: [new Paragraph("test")], },
// }), },
// }, },
// children: [ ]);
// new Paragraph({
// children: [
// new ImageRun({
// data: Buffer.from("", "base64"),
// transformation: {
// width: 100,
// height: 100,
// },
// }),
// ],
// }),
// ],
// },
// ],
// });
// // tslint:disable-next-line: no-string-literal compiler.compile(file);
// sinon.stub(compiler["imageReplacer"], "getMediaData").returns([ });
// { });
// stream: Buffer.from(""), });
// fileName: "test",
// transformation: {
// pixels: {
// x: 100,
// y: 100,
// },
// emus: {
// x: 100,
// y: 100,
// },
// },
// },
// ]);
// compiler.compile(file);
// });
// });
// });

View File

@ -1,6 +1,4 @@
/* tslint:disable:typedef space-before-function-paren */ import { afterEach, assert, beforeEach, describe, expect, it, vi } from "vitest";
import { assert } from "chai";
import { mock, stub } from "sinon";
import { File } from "@file/file"; import { File } from "@file/file";
import { HeadingLevel, Paragraph } from "@file/paragraph"; import { HeadingLevel, Paragraph } from "@file/paragraph";
@ -46,62 +44,71 @@ describe("Packer", () => {
}); });
describe("#toBuffer()", () => { describe("#toBuffer()", () => {
it("should create a standard docx file", async function () { it(
this.timeout(99999999); "should create a standard docx file",
async () => {
const buffer = await Packer.toBuffer(file); const buffer = await Packer.toBuffer(file);
assert.isDefined(buffer); assert.isDefined(buffer);
assert.isTrue(buffer.byteLength > 0); assert.isTrue(buffer.byteLength > 0);
}); },
{
timeout: 99999999,
},
);
it("should handle exception if it throws any", () => { it("should handle exception if it throws any", () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const compiler = stub((Packer as any).compiler, "compile"); vi.spyOn((Packer as any).compiler, "compile").mockImplementation(() => {
throw new Error();
});
compiler.throwsException();
return Packer.toBuffer(file).catch((error) => { return Packer.toBuffer(file).catch((error) => {
assert.isDefined(error); assert.isDefined(error);
}); });
}); });
after(() => { afterEach(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any vi.restoreAllMocks();
(Packer as any).compiler.compile.restore();
}); });
}); });
describe("#toBase64String()", () => { describe("#toBase64String()", () => {
it("should create a standard docx file", async function () { it(
this.timeout(99999999); "should create a standard docx file",
async () => {
const str = await Packer.toBase64String(file); const str = await Packer.toBase64String(file);
expect(str).toBeDefined();
assert.isDefined(str); expect(str.length).toBeGreaterThan(0);
assert.isTrue(str.length > 0); },
}); {
timeout: 99999999,
},
);
it("should handle exception if it throws any", () => { it("should handle exception if it throws any", () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const compiler = stub((Packer as any).compiler, "compile"); vi.spyOn((Packer as any).compiler, "compile").mockImplementation(() => {
throw new Error();
});
compiler.throwsException();
return Packer.toBase64String(file).catch((error) => { return Packer.toBase64String(file).catch((error) => {
assert.isDefined(error); assert.isDefined(error);
}); });
}); });
after(() => { afterEach(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any vi.resetAllMocks();
(Packer as any).compiler.compile.restore();
}); });
}); });
describe("#toBlob()", () => { describe("#toBlob()", () => {
it("should create a standard docx file", async () => { it("should create a standard docx file", async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
stub((Packer as any).compiler, "compile").callsFake(() => ({ vi.spyOn((Packer as any).compiler, "compile").mockReturnValue({
// tslint:disable-next-line: no-empty // tslint:disable-next-line: no-empty
generateAsync: () => mock({}), generateAsync: () => vi.fn(),
})); });
const str = await Packer.toBlob(file); const str = await Packer.toBlob(file);
assert.isDefined(str); assert.isDefined(str);
@ -109,35 +116,27 @@ describe("Packer", () => {
it("should handle exception if it throws any", () => { it("should handle exception if it throws any", () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const compiler = stub((Packer as any).compiler, "compile"); vi.spyOn((Packer as any).compiler, "compile").mockImplementation(() => {
throw new Error();
});
compiler.throwsException();
return Packer.toBlob(file).catch((error) => { return Packer.toBlob(file).catch((error) => {
assert.isDefined(error); assert.isDefined(error);
}); });
}); });
afterEach(() => { afterEach(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any vi.resetAllMocks();
(Packer as any).compiler.compile.restore();
}); });
}); });
describe("#toStream()", () => { describe("#toStream()", () => {
it("should create a standard docx file", async () => { it("should create a standard docx file", async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
stub((Packer as any).compiler, "compile").callsFake(() => ({ vi.spyOn((Packer as any).compiler, "compile").mockReturnValue(Promise.resolve(new Uint8Array(255)));
// tslint:disable-next-line: no-empty const stream = Packer.toStream(file);
generateNodeStream: () => ({
on: (event: string, cb: () => void) => { const p = new Promise<void>((resolve, reject) => {
if (event === "end") {
cb();
}
},
}),
}));
const stream = await Packer.toStream(file);
return new Promise((resolve, reject) => {
stream.on("error", () => { stream.on("error", () => {
reject(new Error()); reject(new Error());
}); });
@ -146,20 +145,15 @@ describe("Packer", () => {
resolve(); resolve();
}); });
}); });
await p;
}); });
it("should handle exception if it throws any", () => { it("should handle exception if it throws any", () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const compiler = stub((Packer as any).compiler, "compile").callsFake(() => ({ vi.spyOn((Packer as any).compiler, "compile").mockImplementation(() => {
// tslint:disable-next-line: no-empty throw new Error();
on: (event: string, cb: () => void) => { });
if (event === "error") {
cb();
}
},
}));
compiler.throwsException();
try { try {
Packer.toStream(file); Packer.toStream(file);
} catch (error) { } catch (error) {
@ -168,8 +162,7 @@ describe("Packer", () => {
}); });
afterEach(() => { afterEach(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any vi.resetAllMocks();
(Packer as any).compiler.compile.restore();
}); });
}); });
}); });

View File

@ -51,15 +51,12 @@ export class Packer {
public static toStream(file: File, prettify?: boolean | PrettifyType): Stream { public static toStream(file: File, prettify?: boolean | PrettifyType): Stream {
const zip = this.compiler.compile(file, prettify === true ? PrettifyType.WITH_2_BLANKS : prettify === false ? undefined : prettify); const zip = this.compiler.compile(file, prettify === true ? PrettifyType.WITH_2_BLANKS : prettify === false ? undefined : prettify);
const stream = new Stream(); const stream = new Stream();
// eslint-disable-next-line functional/immutable-data
stream.pipe = (dest) => {
zip.then((z) => { zip.then((z) => {
dest.write(z); stream.emit("data", z);
stream.emit("end");
}); });
return dest;
};
return stream; return stream;
} }

View File

@ -1,4 +1,4 @@
import { expect } from "chai"; import { describe, expect, it } from "vitest";
import { Formatter } from "@export/formatter"; import { Formatter } from "@export/formatter";
import { BorderStyle } from "@file/border"; import { BorderStyle } from "@file/border";

View File

@ -1,6 +1,6 @@
// tslint:disable:no-string-literal // tslint:disable:no-string-literal
import { expect } from "chai"; import { beforeEach, describe, expect, it } from "vitest";
import { Formatter } from "@export/formatter"; import { Formatter } from "@export/formatter";

View File

@ -1,4 +1,4 @@
import { expect } from "chai"; import { describe, expect, it } from "vitest";
import { Formatter } from "@export/formatter"; import { Formatter } from "@export/formatter";

View File

@ -1,4 +1,4 @@
import { expect } from "chai"; import { describe, expect, it } from "vitest";
import { Formatter } from "@export/formatter"; import { Formatter } from "@export/formatter";

View File

@ -1,4 +1,4 @@
import { expect } from "chai"; import { describe, expect, it } from "vitest";
import { DocumentWrapper } from "./document-wrapper"; import { DocumentWrapper } from "./document-wrapper";

Some files were not shown because too many files have changed in this diff Show More