diff --git a/README.md b/README.md index 393e4c4..a3fcd36 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # cfb-editor -Archive (ZIP/CFB) Editor +Archive (ZIP/CFB/MAD) Editor -See for a live instance +See for a live instance diff --git a/package.json b/package.json index 2f05417..0b48b16 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cfb-editor", - "version": "0.1.1", + "version": "0.1.2", "description": "CFB / ZIP editor", "private": true, "homepage": "https://sheetjs.com/cfb-editor", @@ -13,7 +13,7 @@ "test:watch": "nwb test-react --server" }, "dependencies": { - "cfb": "^1.1.4", + "cfb": "^1.2.0", "crc-32": "^1.2.0", "file-saver": "^1.3.3", "printj": "^1.1.2", diff --git a/src/consts.js b/src/consts.js index ffaefe9..5dba737 100644 --- a/src/consts.js +++ b/src/consts.js @@ -6,6 +6,7 @@ export const SheetJSFT = [ "application/zip", "application/octet-stream" ].join(",") + [ + "mht", "mhtml", "zip", "xlsx", "xlsb", "xlsm", "ods", "cfb", "xls", "qpw", "wb3", "ppt", "doc" ].map(function(x) { return "." + x; }).join(","); diff --git a/src/state.js b/src/state.js index 1c3eed8..afcd5a5 100644 --- a/src/state.js +++ b/src/state.js @@ -36,6 +36,7 @@ export default easyStore({ this.loading = true; setTimeout(() => {try { switch(bstr.slice(0,4)) { + case "MIME": case "\xD0\xCF\x11\xE0": this.type = "CFB"; this.file = CFB.read(bstr, {type: "binary"}); break; case "PK\x03\x04": case "PK\x05\x06": this.type = "ZIP"; this.file = new JSZIP(bstr, {base64: false}); break; default: throw new Error(`Invalid file (magic ${bstr.slice(0,4).split("").map(x => x.charCodeAt(0).toString(16).padStart(2,"0"))})`); @@ -103,7 +104,8 @@ export default easyStore({ setTimeout(() => {try { this.dirty = false; let o; - if(this.isCFB()) o = SaveBString(CFB.write(this.file, {type:"binary"}), this.fname || "SheetJS.cfb"); + var fType = /\.mht(?:ml)?$/.test(this.fname||"") ? "mad" : ""; + if(this.isCFB()) o = SaveBString(CFB.write(this.file, {type:"binary", fileType: fType}), this.fname || "SheetJS.cfb"); if(this.isZIP()) o = SaveBString(this.file.generate({type:"string", compression:"DEFLATE"}), this.fname || "SheetJS.zip"); this.loading = false; return o; diff --git a/src/utils/misc.js b/src/utils/misc.js index 9e434d2..1107137 100644 --- a/src/utils/misc.js +++ b/src/utils/misc.js @@ -1,5 +1,4 @@ /* cfb-editor (C) 2017-present SheetJS -- http://sheetjs.com */ -/* global Uint8Array */ import { sprintf, vsprintf } from 'printj'; const X = "%02hhx", Y = X + X + " "; diff --git a/src/views/FileView.js b/src/views/FileView.js index df8a151..656b86c 100644 --- a/src/views/FileView.js +++ b/src/views/FileView.js @@ -52,6 +52,8 @@ class FileView extends PureComponent { if(!props.mode || props.mode == "full") { const hdr = store.getContentSliceByEntry(FI,0,16); if(hdr[0] == 0xFF && hdr[1] == 0xD8 && hdr[2] == 0xFF) show_link = "imag"; + if(hdr[0] == 0x89 && hdr[1] == 0x50 && hdr[2] == 0x4E) show_link = "imag"; + if(hdr[0] == 0x47 && hdr[1] == 0x49 && hdr[2] == 0x46 && hdr[3] == 0x38) show_link = "imag"; } const show_imag = this.props.mode == "imag", I = show_imag ? "data:image/jpeg;base64," + btoa(store.getTextByEntry(FI)) : "";