Write tests, improve API, create documentation

This commit is contained in:
Dolan Miu
2022-06-22 23:35:46 +01:00
parent 5b7c62685d
commit 9827ed30bb
10 changed files with 355 additions and 103 deletions

View File

@ -1,10 +1,12 @@
// 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 { Document, Packer, Paragraph, TextRun, CommentRangeStart, CommentRangeEnd, Comments, Comment, CommentReference } from "../build";
import { Document, Packer, Paragraph, TextRun, CommentRangeStart, CommentRangeEnd, CommentReference } from "../build";
const doc = new Document({
comments: new Comments([new Comment({ id: "0", author: "Ray Chen", date: new Date().toISOString() }, "comment text content")]),
comments: {
children: [{ id: 0, author: "Ray Chen", date: new Date(), text: "comment text content" }],
},
sections: [
{
properties: {},
@ -12,14 +14,14 @@ const doc = new Document({
new Paragraph({
children: [
new TextRun("Hello World"),
new CommentRangeStart({ id: "0" }),
new CommentRangeStart(0),
new TextRun({
text: "Foo Bar",
bold: true,
}),
new CommentRangeEnd({ id: "0" }),
new CommentRangeEnd(0),
new TextRun({
children: [new CommentReference({ id: "0" })],
children: [new CommentReference(0)],
bold: true,
}),
],