feat(comments): Support comment pictures (#3032)

* feat(comments): Support comment pictures

* fix(demo): Fix the image path to load the image correctly

* fix(test): Update the number of files asserted in the compiler test case

* feat(comments): Support comment pictures

* fix(demo): Fix the image path to load the image correctly

* fix(test): Update the number of files asserted in the compiler test case

* style(src): Format the code and remove extra blank lines

---------

Co-authored-by: Dolan <dolan_miu@hotmail.com>
This commit is contained in:
Terry Sargent
2025-04-16 15:45:36 +08:00
committed by GitHub
parent 5af1045a59
commit b19025881b
4 changed files with 77 additions and 19 deletions

View File

@ -1,7 +1,7 @@
// Simple example to add comments to a document
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun, CommentRangeStart, CommentRangeEnd, CommentReference } from "docx";
import { Document, Packer, Paragraph, TextRun, CommentRangeStart, CommentRangeEnd, CommentReference, ImageRun } from "docx";
const doc = new Document({
comments: {
@ -20,6 +20,14 @@ const doc = new Document({
}),
new Paragraph({
children: [
new ImageRun({
type: "jpg",
data: fs.readFileSync("./demo/images/cat.jpg"),
transformation: {
width: 100,
height: 100,
},
}),
new TextRun({
text: "comment text content",
}),