Skip to content

Commit

Permalink
Add support for OpenDocument graphics and templates (#718)
Browse files Browse the repository at this point in the history
  • Loading branch information
sly7-7 authored Jan 6, 2025
1 parent 1fe621a commit 4db407d
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 @@ -39,16 +39,41 @@ function getFileTypeFromMimeType(mimeType) {
ext: 'odt',
mime: 'application/vnd.oasis.opendocument.text',
};
case 'application/vnd.oasis.opendocument.text-template':
return {
ext: 'ott',
mime: 'application/vnd.oasis.opendocument.text-template',
};
case 'application/vnd.oasis.opendocument.spreadsheet':
return {
ext: 'ods',
mime: 'application/vnd.oasis.opendocument.spreadsheet',
};
case 'application/vnd.oasis.opendocument.spreadsheet-template':
return {
ext: 'ots',
mime: 'application/vnd.oasis.opendocument.spreadsheet-template',
};
case 'application/vnd.oasis.opendocument.presentation':
return {
ext: 'odp',
mime: 'application/vnd.oasis.opendocument.presentation',
};
case 'application/vnd.oasis.opendocument.presentation-template':
return {
ext: 'otp',
mime: 'application/vnd.oasis.opendocument.presentation-template',
};
case 'application/vnd.oasis.opendocument.graphics':
return {
ext: 'odg',
mime: 'application/vnd.oasis.opendocument.graphics',
};
case 'application/vnd.oasis.opendocument.graphics-template':
return {
ext: 'otg',
mime: 'application/vnd.oasis.opendocument.graphics-template',
};
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
return {
ext: 'xlsx',
Expand Down
Binary file added fixture/fixture.odg
Binary file not shown.
Binary file added fixture/fixture.otg
Binary file not shown.
Binary file added fixture/fixture.otp
Binary file not shown.
Binary file added fixture/fixture.ots
Binary file not shown.
Binary file added fixture/fixture.ott
Binary file not shown.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@
"potx",
"xltx",
"dotx",
"xltm"
"xltm",
"ots",
"odg",
"otg",
"otp",
"ott"
],
"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 @@ -514,6 +514,7 @@ abortController.abort(); // Abort file-type reading from the Blob stream.
- [`mxf`](https://en.wikipedia.org/wiki/Material_Exchange_Format) - Material Exchange Format
- [`nef`](https://www.nikonusa.com/en/learn-and-explore/a/products-and-innovation/nikon-electronic-format-nef.html) - Nikon Electronic Format image file
- [`nes`](https://fileinfo.com/extension/nes) - Nintendo NES ROM
- [`odg`](https://en.wikipedia.org/wiki/OpenDocument) - OpenDocument for drawing
- [`odp`](https://en.wikipedia.org/wiki/OpenDocument) - OpenDocument for presentations
- [`ods`](https://en.wikipedia.org/wiki/OpenDocument) - OpenDocument for spreadsheets
- [`odt`](https://en.wikipedia.org/wiki/OpenDocument) - OpenDocument for word processing
Expand All @@ -525,6 +526,10 @@ abortController.abort(); // Abort file-type reading from the Blob stream.
- [`opus`](https://en.wikipedia.org/wiki/Opus_(audio_format)) - Audio file
- [`orf`](https://en.wikipedia.org/wiki/ORF_format) - Olympus Raw image file
- [`otf`](https://en.wikipedia.org/wiki/OpenType) - OpenType font
- [`otg`](https://en.wikipedia.org/wiki/OpenDocument_technical_specification#Templates) - OpenDocument template for drawing
- [`otp`](https://en.wikipedia.org/wiki/OpenDocument_technical_specification#Templates) - OpenDocument template for presentations
- [`ots`](https://en.wikipedia.org/wiki/OpenDocument_technical_specification#Templates) - OpenDocument template for spreadsheets
- [`ott`](https://en.wikipedia.org/wiki/OpenDocument_technical_specification#Templates) - OpenDocument template for word processing
- [`parquet`](https://en.wikipedia.org/wiki/Apache_Parquet) - Apache Parquet
- [`pcap`](https://wiki.wireshark.org/Development/LibpcapFileFormat) - Libpcap File Format
- [`pdf`](https://en.wikipedia.org/wiki/Portable_Document_Format) - Portable Document Format
Expand Down
10 changes: 10 additions & 0 deletions supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ export const extensions = [
'xltx',
'dotx',
'xltm',
'ott',
'ots',
'otp',
'odg',
'otg',
];

export const mimeTypes = [
Expand Down Expand Up @@ -319,4 +324,9 @@ export const mimeTypes = [
'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
'application/vnd.ms-excel.template.macroenabled.12',
'application/vnd.oasis.opendocument.text-template',
'application/vnd.oasis.opendocument.spreadsheet-template',
'application/vnd.oasis.opendocument.presentation-template',
'application/vnd.oasis.opendocument.graphics',
'application/vnd.oasis.opendocument.graphics-template',
];

0 comments on commit 4db407d

Please sign in to comment.