docxmlater 11.0.4 → 11.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +410 -637
- package/dist/core/DocumentParser.d.ts.map +1 -1
- package/dist/core/DocumentParser.js +3 -0
- package/dist/core/DocumentParser.js.map +1 -1
- package/dist/elements/ImageRun.d.ts.map +1 -1
- package/dist/elements/ImageRun.js +6 -1
- package/dist/elements/ImageRun.js.map +1 -1
- package/dist/esm/core/DocumentParser.js +3 -0
- package/dist/esm/core/DocumentParser.js.map +1 -1
- package/dist/esm/elements/ImageRun.js +6 -1
- package/dist/esm/elements/ImageRun.js.map +1 -1
- package/package.json +16 -5
- package/src/core/DocumentParser.ts +7 -0
- package/src/elements/ImageRun.ts +10 -1
|
@@ -20,9 +20,14 @@ export class ImageRun extends Run {
|
|
|
20
20
|
return { name: '__rawXml', rawXml: this._rawRunXml };
|
|
21
21
|
}
|
|
22
22
|
const drawing = this.imageElement.toXML();
|
|
23
|
+
const children = [];
|
|
24
|
+
const rPr = Run.generateRunPropertiesXML(this.getFormatting());
|
|
25
|
+
if (rPr)
|
|
26
|
+
children.push(rPr);
|
|
27
|
+
children.push(drawing);
|
|
23
28
|
return {
|
|
24
29
|
name: 'w:r',
|
|
25
|
-
children
|
|
30
|
+
children,
|
|
26
31
|
};
|
|
27
32
|
}
|
|
28
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageRun.js","sourceRoot":"","sources":["../../../src/elements/ImageRun.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAgB/B,MAAM,OAAO,QAAS,SAAQ,GAAG;IACvB,YAAY,CAAQ;IACpB,UAAU,CAAU;IAM5B,YAAY,KAAY;QAGtB,KAAK,CAAC,EAAE,CAAC,CAAC;QACV,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED,YAAY,CAAC,GAAW;QACt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AE,CAAC,CAAC;QAC/D,IAAI,GAAG;YAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5B,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,OAAO;YACL,IAAI,EAAE,KAAK;YACX,QAAQ;SACT,CAAC;IACJ,CAAC;CACF","sourcesContent":["/**\n * ImageRun - A run that contains an image (drawing)\n * Extends Run class for type-safe paragraph content\n *\n * This is a specialized Run that contains a drawing instead of text.\n * It generates proper w:r (run) XML with w:drawing child element.\n */\n\nimport { Run } from './Run.js';\nimport { Image } from './Image.js';\nimport { XMLElement } from '../xml/XMLBuilder.js';\n\n/**\n * ImageRun - A run containing an embedded image\n *\n * In WordprocessingML, images are embedded in runs as drawing elements:\n * <w:r>\n * <w:drawing>\n * <wp:inline>\n * ... image data ...\n * </wp:inline>\n * </w:drawing>\n * </w:r>\n */\nexport class ImageRun extends Run {\n private imageElement: Image;\n private _rawRunXml?: string;\n\n /**\n * Creates a new image run\n * @param image The image to embed in this run\n */\n constructor(image: Image) {\n // Call parent constructor with empty text\n // The text is irrelevant for image runs\n super('');\n this.imageElement = image;\n }\n\n setRawRunXml(xml: string): void {\n this._rawRunXml = xml;\n }\n\n getRawRunXml(): string | undefined {\n return this._rawRunXml;\n }\n\n /**\n * Gets the image element\n * @returns Image instance\n */\n getImageElement(): Image {\n return this.imageElement;\n }\n\n /**\n * Override toXML to generate image-specific XML\n * Generates a w:r element containing w:drawing instead of w:t\n * @returns XMLElement with w:r containing w:drawing\n */\n toXML(): XMLElement {\n if (this._rawRunXml) {\n return { name: '__rawXml', rawXml: this._rawRunXml };\n }\n const drawing = this.imageElement.toXML();\n const children: XMLElement[] = [];\n // Per ECMA-376 §17.3.2.28, w:rPr (if present) must precede the run's\n // content. For runs containing an inline drawing, the rPr's w:rFonts\n // affects line metrics in Word; dropping it shifts the baseline and\n // can let images (with shadow effectExtent) overflow their containing\n // cell. Emit rPr whenever the run carries formatting.\n const rPr = Run.generateRunPropertiesXML(this.getFormatting());\n if (rPr) children.push(rPr);\n children.push(drawing);\n return {\n name: 'w:r',\n children,\n };\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docxmlater",
|
|
3
|
-
"version": "11.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "11.0.6",
|
|
4
|
+
"description": "TypeScript library for editing existing Word documents with full tracked-changes, comment, and bookmark fidelity. Round-trip safe DOCX modification.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -52,18 +52,29 @@
|
|
|
52
52
|
"document",
|
|
53
53
|
"office",
|
|
54
54
|
"openxml",
|
|
55
|
+
"ooxml",
|
|
56
|
+
"ecma-376",
|
|
55
57
|
"xml",
|
|
56
58
|
"wordprocessingml",
|
|
57
59
|
"microsoft-word",
|
|
58
|
-
"document-generation",
|
|
59
60
|
"docx-editor",
|
|
60
|
-
"
|
|
61
|
+
"edit-docx",
|
|
62
|
+
"modify-docx",
|
|
63
|
+
"docx-typescript",
|
|
64
|
+
"tracked-changes",
|
|
65
|
+
"track-changes",
|
|
66
|
+
"revisions",
|
|
67
|
+
"comments",
|
|
68
|
+
"bookmarks",
|
|
69
|
+
"round-trip",
|
|
70
|
+
"openxml-sdk",
|
|
71
|
+
"docxtemplater-alternative"
|
|
61
72
|
],
|
|
62
73
|
"author": "DiaTech",
|
|
63
74
|
"license": "MIT",
|
|
64
75
|
"repository": {
|
|
65
76
|
"type": "git",
|
|
66
|
-
"url": "https://github.com/ItMeDiaTech/docXMLater.git"
|
|
77
|
+
"url": "git+https://github.com/ItMeDiaTech/docXMLater.git"
|
|
67
78
|
},
|
|
68
79
|
"bugs": {
|
|
69
80
|
"url": "https://github.com/ItMeDiaTech/docXMLater/issues"
|
|
@@ -1349,6 +1349,11 @@ export class DocumentParser {
|
|
|
1349
1349
|
imageManager
|
|
1350
1350
|
);
|
|
1351
1351
|
if (imageRun) {
|
|
1352
|
+
// Preserve the parent run's w:rPr (rFonts, noProof, b, etc.)
|
|
1353
|
+
// — without this, ImageRun.toXML() emits <w:r><w:drawing/></w:r>
|
|
1354
|
+
// and Word recalculates line height with the default font,
|
|
1355
|
+
// shifting the image and clipping it into adjacent cells.
|
|
1356
|
+
this.parseRunPropertiesFromObject(runObj['w:rPr'], imageRun);
|
|
1352
1357
|
paragraph.addRun(imageRun);
|
|
1353
1358
|
}
|
|
1354
1359
|
}
|
|
@@ -2123,6 +2128,7 @@ export class DocumentParser {
|
|
|
2123
2128
|
imageManager
|
|
2124
2129
|
);
|
|
2125
2130
|
if (imageRun) {
|
|
2131
|
+
this.parseRunPropertiesFromObject(child['w:rPr'], imageRun);
|
|
2126
2132
|
paragraph.addRun(imageRun);
|
|
2127
2133
|
}
|
|
2128
2134
|
}
|
|
@@ -2184,6 +2190,7 @@ export class DocumentParser {
|
|
|
2184
2190
|
imageManager
|
|
2185
2191
|
);
|
|
2186
2192
|
if (imageRun) {
|
|
2193
|
+
this.parseRunPropertiesFromObject(child['w:rPr'], imageRun);
|
|
2187
2194
|
paragraph.addRun(imageRun);
|
|
2188
2195
|
}
|
|
2189
2196
|
}
|
package/src/elements/ImageRun.ts
CHANGED
|
@@ -63,9 +63,18 @@ export class ImageRun extends Run {
|
|
|
63
63
|
return { name: '__rawXml', rawXml: this._rawRunXml };
|
|
64
64
|
}
|
|
65
65
|
const drawing = this.imageElement.toXML();
|
|
66
|
+
const children: XMLElement[] = [];
|
|
67
|
+
// Per ECMA-376 §17.3.2.28, w:rPr (if present) must precede the run's
|
|
68
|
+
// content. For runs containing an inline drawing, the rPr's w:rFonts
|
|
69
|
+
// affects line metrics in Word; dropping it shifts the baseline and
|
|
70
|
+
// can let images (with shadow effectExtent) overflow their containing
|
|
71
|
+
// cell. Emit rPr whenever the run carries formatting.
|
|
72
|
+
const rPr = Run.generateRunPropertiesXML(this.getFormatting());
|
|
73
|
+
if (rPr) children.push(rPr);
|
|
74
|
+
children.push(drawing);
|
|
66
75
|
return {
|
|
67
76
|
name: 'w:r',
|
|
68
|
-
children
|
|
77
|
+
children,
|
|
69
78
|
};
|
|
70
79
|
}
|
|
71
80
|
}
|