MAD support
This commit is contained in:
parent
efbc7e64c9
commit
926d6a4df4
@ -1,5 +1,5 @@
|
||||
# cfb-editor
|
||||
|
||||
Archive (ZIP/CFB) Editor
|
||||
Archive (ZIP/CFB/MAD) Editor
|
||||
|
||||
See <https://sheetjs.com/cfb-editor/> for a live instance
|
||||
See <https://oss.sheetjs.com/cfb-editor/> for a live instance
|
||||
|
@ -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",
|
||||
|
@ -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(",");
|
||||
|
@ -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;
|
||||
|
@ -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 + " ";
|
||||
|
@ -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)) : "";
|
||||
|
Loading…
Reference in New Issue
Block a user