From ba731d3c8a9408b9d33deb63e0492b54298169c5 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 3 Jul 2016 19:43:00 +0100 Subject: Read author name and initials for each comment --- lib/documents.js | 4 +++- lib/docx/comments-reader.js | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/documents.js b/lib/documents.js index a8312e9..1869dab 100644 --- a/lib/documents.js +++ b/lib/documents.js @@ -117,7 +117,9 @@ function comment(options) { return { type: types.comment, commentId: options.commentId, - body: options.body + body: options.body, + authorName: options.authorName, + authorInitials: options.authorInitials }; } diff --git a/lib/docx/comments-reader.js b/lib/docx/comments-reader.js index be98bac..41bf8f6 100644 --- a/lib/docx/comments-reader.js +++ b/lib/docx/comments-reader.js @@ -9,9 +9,19 @@ function createCommentsReader(bodyReader) { function readCommentElement(element) { var id = element.attributes["w:id"]; + + function readOptionalAttribute(name) { + return (element.attributes[name] || "").trim() || null; + } + return bodyReader.readXmlElements(element.children) .map(function(body) { - return documents.comment({commentId: id, body: body}); + return documents.comment({ + commentId: id, + body: body, + authorName: readOptionalAttribute("w:author"), + authorInitials: readOptionalAttribute("w:initials") + }); }); } -- cgit v1.2.3