From 0acb9cf7a9896509c45be40bf6415d674980f07e Mon Sep 17 00:00:00 2001 From: Dolan Miu Date: Sun, 19 Jun 2022 02:01:54 +0100 Subject: [PATCH] Format demo --- demo/72-comment.ts | 36 ------------------------------------ demo/73-comment.ts | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 36 deletions(-) delete mode 100644 demo/72-comment.ts create mode 100644 demo/73-comment.ts diff --git a/demo/72-comment.ts b/demo/72-comment.ts deleted file mode 100644 index 0b2d1f4952..0000000000 --- a/demo/72-comment.ts +++ /dev/null @@ -1,36 +0,0 @@ -// 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 { Document, Packer, Paragraph, TextRun, CommentRangeStart, CommentRangeEnd, Comments, Comment, CommentReference, PrettityType } from "../build"; - -const doc = new Document({ - comments: new Comments([new Comment({ id: '0', author: 'Ray Chen', date: new Date().toISOString() }, 'comment text content')]), - sections: [ - { - properties: {}, - children: [ - new Paragraph({ - children: [ - new TextRun("Hello World"), - new CommentRangeStart({ id: "0" }), - new TextRun({ - text: "Foo Bar", - bold: true, - }), - new CommentRangeEnd({ id: "0" }), - new TextRun({ - children: [ - new CommentReference({ id: "0" }) - ], - bold: true, - }), - ], - }), - ], - }, - ], -}, -); -Packer.toBuffer(doc, PrettityType.WITH_2_BLANKS).then((buffer) => { - fs.writeFileSync("document-comments.docx", buffer); -}); diff --git a/demo/73-comment.ts b/demo/73-comment.ts new file mode 100644 index 0000000000..d0f3b08005 --- /dev/null +++ b/demo/73-comment.ts @@ -0,0 +1,34 @@ +// 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"; + +const doc = new Document({ + comments: new Comments([new Comment({ id: "0", author: "Ray Chen", date: new Date().toISOString() }, "comment text content")]), + sections: [ + { + properties: {}, + children: [ + new Paragraph({ + children: [ + new TextRun("Hello World"), + new CommentRangeStart({ id: "0" }), + new TextRun({ + text: "Foo Bar", + bold: true, + }), + new CommentRangeEnd({ id: "0" }), + new TextRun({ + children: [new CommentReference({ id: "0" })], + bold: true, + }), + ], + }), + ], + }, + ], +}); + +Packer.toBuffer(doc).then((buffer) => { + fs.writeFileSync("document-comments.docx", buffer); +});