aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-11-20 15:16:07 +0000
committerMichael Williamson <mike@zwobble.org>2025-11-20 15:16:07 +0000
commit5b8d20f1cdca33a08cd0cb72af5b13c22653cea3 (patch)
treea6d3b52fd0d709327a28e4ffe0be8eb89246af5e /lib
parent3261fbb689a2d54c151d6be7fa653553735e5861 (diff)
Handle hyperlinked wp:anchor and wp:inline elements
Diffstat (limited to 'lib')
-rw-r--r--lib/docx/body-reader.js18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js
index 826424b..febbbc2 100644
--- a/lib/docx/body-reader.js
+++ b/lib/docx/body-reader.js
@@ -586,14 +586,26 @@ function BodyReader(options) {
}
function readBlip(element, blip) {
- var properties = element.first("wp:docPr").attributes;
+ var propertiesElement = element.firstOrEmpty("wp:docPr");
+ var properties = propertiesElement.attributes;
+
var altText = isBlank(properties.descr) ? properties.title : properties.descr;
+
var blipImageFile = findBlipImageFile(blip);
if (blipImageFile === null) {
return emptyResultWithMessages([warning("Could not find image file for a:blip element")]);
- } else {
- return readImage(blipImageFile, altText);
}
+
+ return readImage(blipImageFile, altText).map(function(imageElement) {
+ var hlinkClickElement = propertiesElement.firstOrEmpty("a:hlinkClick");
+ var relationshipId = hlinkClickElement.attributes["r:id"];
+ if (relationshipId) {
+ var href = relationships.findTargetByRelationshipId(relationshipId);
+ return new documents.Hyperlink([imageElement], {href: href});
+ } else {
+ return imageElement;
+ }
+ });
}
function isBlank(value) {