Skip to content

Commit

Permalink
Add support for MSOffice macro-enabled docs and templates (#720)
Browse files Browse the repository at this point in the history
  • Loading branch information
sly7-7 authored Jan 9, 2025
1 parent 356bce8 commit 7fe5667
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 1 deletion.
25 changes: 25 additions & 0 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ function getFileTypeFromMimeType(mimeType) {
ext: 'xlsx',
mime: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
};
case 'application/vnd.ms-excel.sheet.macroEnabled':
return {
ext: 'xlsm',
mime: 'application/vnd.ms-excel.sheet.macroEnabled.12',
};
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.template':
return {
ext: 'xltx',
Expand All @@ -94,21 +99,41 @@ function getFileTypeFromMimeType(mimeType) {
ext: 'docx',
mime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
};
case 'application/vnd.ms-word.document.macroEnabled':
return {
ext: 'docm',
mime: 'application/vnd.ms-word.document.macroEnabled.12',
};
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.template':
return {
ext: 'dotx',
mime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
};
case 'application/vnd.ms-word.template.macroEnabledTemplate':
return {
ext: 'dotm',
mime: 'application/vnd.ms-word.template.macroEnabled.12',
};
case 'application/vnd.openxmlformats-officedocument.presentationml.template':
return {
ext: 'potx',
mime: 'application/vnd.openxmlformats-officedocument.presentationml.template',
};
case 'application/vnd.ms-powerpoint.template.macroEnabled':
return {
ext: 'potm',
mime: 'application/vnd.ms-powerpoint.template.macroEnabled.12',
};
case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
return {
ext: 'pptx',
mime: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
};
case 'application/vnd.ms-powerpoint.presentation.macroEnabled':
return {
ext: 'pptm',
mime: 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
};
case 'application/vnd.ms-visio.drawing':
return {
ext: 'vsdx',
Expand Down
Binary file added fixture/fixture.docm
Binary file not shown.
Binary file added fixture/fixture.dotm
Binary file not shown.
Binary file added fixture/fixture.potm
Binary file not shown.
Binary file added fixture/fixture.pptm
Binary file not shown.
Binary file added fixture/fixture.xlsm
Binary file not shown.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,12 @@
"odg",
"otg",
"otp",
"ott"
"ott",
"xlsm",
"docm",
"dotm",
"potm",
"pptm"
],
"dependencies": {
"@tokenizer/inflate": "^0.2.6",
Expand Down
5 changes: 5 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,9 @@ abortController.abort(); // Abort file-type reading from the Blob stream.
- [`deb`](https://en.wikipedia.org/wiki/Deb_(file_format)) - Debian package
- [`dmg`](https://en.wikipedia.org/wiki/Apple_Disk_Image) - Apple Disk Image
- [`dng`](https://en.wikipedia.org/wiki/Digital_Negative) - Adobe Digital Negative image file
- [`docm`](https://en.wikipedia.org/wiki/List_of_Microsoft_Office_filename_extensions) - Microsoft Word macro-enabled document
- [`docx`](https://en.wikipedia.org/wiki/Office_Open_XML) - Microsoft Word document
- [`dotm`](https://en.wikipedia.org/wiki/List_of_Microsoft_Office_filename_extensions) - Microsoft Word macro-enabled template
- [`dotx`](https://en.wikipedia.org/wiki/List_of_Microsoft_Office_filename_extensions) - Microsoft Word template
- [`drc`](https://en.wikipedia.org/wiki/Zstandard) - Google's Draco 3D Data Compression
- [`dsf`](https://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf) - Sony DSD Stream File (DSF)
Expand Down Expand Up @@ -536,7 +538,9 @@ abortController.abort(); // Abort file-type reading from the Blob stream.
- [`pdf`](https://en.wikipedia.org/wiki/Portable_Document_Format) - Portable Document Format
- [`pgp`](https://en.wikipedia.org/wiki/Pretty_Good_Privacy) - Pretty Good Privacy
- [`png`](https://en.wikipedia.org/wiki/Portable_Network_Graphics) - Portable Network Graphics
- [`potm`](https://en.wikipedia.org/wiki/List_of_Microsoft_Office_filename_extensions) - Microsoft PowerPoint macro-enabled template
- [`potx`](https://en.wikipedia.org/wiki/List_of_Microsoft_Office_filename_extensions) - Microsoft PowerPoint template
- [`pptm`](https://en.wikipedia.org/wiki/List_of_Microsoft_Office_filename_extensions) - Microsoft PowerPoint macro-enabled document
- [`pptx`](https://en.wikipedia.org/wiki/Office_Open_XML) - Microsoft PowerPoint document
- [`ps`](https://en.wikipedia.org/wiki/Postscript) - Postscript
- [`psd`](https://en.wikipedia.org/wiki/Adobe_Photoshop#File_format) - Adobe Photoshop document
Expand Down Expand Up @@ -569,6 +573,7 @@ abortController.abort(); // Abort file-type reading from the Blob stream.
- [`woff2`](https://en.wikipedia.org/wiki/Web_Open_Font_Format) - Web Open Font Format
- [`wv`](https://en.wikipedia.org/wiki/WavPack) - WavPack
- [`xcf`](https://en.wikipedia.org/wiki/XCF_(file_format)) - eXperimental Computing Facility
- [`xlsm`](https://en.wikipedia.org/wiki/List_of_Microsoft_Office_filename_extensions) - Microsoft Excel macro-enabled document
- [`xlsx`](https://en.wikipedia.org/wiki/Office_Open_XML) - Microsoft Excel document
- [`xltm`](https://en.wikipedia.org/wiki/List_of_Microsoft_Office_filename_extensions) - Microsoft Excel macro-enabled template
- [`xltx`](https://en.wikipedia.org/wiki/List_of_Microsoft_Office_filename_extensions) - Microsoft Excel template
Expand Down
10 changes: 10 additions & 0 deletions supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ export const extensions = [
'otp',
'odg',
'otg',
'xlsm',
'docm',
'dotm',
'potm',
'pptm',
];

export const mimeTypes = [
Expand Down Expand Up @@ -329,4 +334,9 @@ export const mimeTypes = [
'application/vnd.oasis.opendocument.presentation-template',
'application/vnd.oasis.opendocument.graphics',
'application/vnd.oasis.opendocument.graphics-template',
'application/vnd.ms-excel.sheet.macroEnabled.12',
'application/vnd.ms-word.document.macroEnabled.12',
'application/vnd.ms-word.template.macroEnabled.12',
'application/vnd.ms-powerpoint.template.macroEnabled.12',
'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
];

0 comments on commit 7fe5667

Please sign in to comment.