devexpress-richedit
Version:
DevExpress Rich Text Editor is an advanced word-processing tool designed for working with rich text documents.
47 lines (46 loc) • 1.27 kB
JavaScript
import * as JSZip from 'jszip';
import { XmlReader } from './xml-reader';
const JSZip2 = JSZip.default ?? JSZip;
export class ArchiveData {
entryMap;
options;
constructor(options) {
this.options = options;
this.entryMap = {};
}
async init(blob) {
const that = this;
try {
const zip = await JSZip2.loadAsync(blob, {});
zip.forEach((relativePath, zipEntry) => {
that.entryMap[relativePath] = zipEntry;
});
}
catch (err) {
console.log(`Cannot open file: ${err}`);
}
}
async getXmlReader(filePath) {
const entry = this.entryMap[filePath];
if (!entry)
return null;
try {
return new XmlReader(await entry.async('text'), this.options, filePath);
}
catch (err) {
return null;
}
}
async getBase64(filePath) {
const entry = this.entryMap[filePath];
if (!entry)
return null;
try {
return await entry.async('base64');
}
catch (err) {
console.log(`Cannot get base46: ${err}`);
return null;
}
}
}