Skip to content

Commit a974876

Browse files
authored
Merge pull request #726 from Harbour-Enterprises/feat/export-fixes
fix: null values in w:line spacing, invalid content types at export
2 parents 03ca19b + d4cf9c3 commit a974876

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

packages/super-editor/src/core/DocxZipper.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,20 @@ class DocxZipper {
7777
}
7878

7979
getFileExtension(fileName) {
80-
return fileName.split('.').pop();
80+
const fileSplit = fileName.split('.');
81+
if (fileSplit.length < 2) return null;
82+
return fileSplit[fileSplit.length - 1];
8183
}
8284

8385
/**
8486
* Update [Content_Types].xml with extensions of new Image annotations
8587
*/
8688
async updateContentTypes(docx, media, fromJson) {
87-
const newMediaTypes = Object.keys(media).map((name) => {
88-
return this.getFileExtension(name);
89-
});
89+
const newMediaTypes = Object.keys(media)
90+
.map((name) => {
91+
return this.getFileExtension(name);
92+
})
93+
.filter(Boolean);
9094

9195
const contentTypesPath = '[Content_Types].xml';
9296
let contentTypesXml;

packages/super-editor/src/core/super-converter/exporter.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,9 @@ function generateParagraphProperties(node) {
226226
if (lineSpaceBefore >= 0) attributes['w:before'] = pixelsToTwips(lineSpaceBefore);
227227
if (lineSpaceAfter >= 0) attributes['w:after'] = pixelsToTwips(lineSpaceAfter);
228228

229-
if (lineRule === 'exact') {
230-
if (lineHeight) attributes['w:line'] = ptToTwips(parseFloat(lineHeight));
231-
} else {
232-
if (lineHeight) attributes['w:line'] = linesToTwips(lineHeight);
229+
if (lineHeight && !Number.isNaN(parseFloat(lineHeight))) {
230+
if (lineRule === 'exact') attributes['w:line'] = ptToTwips(parseFloat(lineHeight));
231+
else attributes['w:line'] = linesToTwips(lineHeight);
233232
}
234233

235234
attributes['w:lineRule'] = lineRule || 'auto';
@@ -1838,7 +1837,6 @@ function translateImageNode(params, imageSize) {
18381837
}
18391838

18401839
const imageUrl = `media/${imageName}_${attrs.hash}.${type}`;
1841-
18421840
imageId = addNewImageRelationship(params, imageUrl);
18431841
params.media[`${imageName}_${attrs.hash}.${type}`] = src;
18441842
}

0 commit comments

Comments
 (0)