Closed gwozt closed 2 years ago
Hello, your suggestion is allow de lib works in the server and browser. Its an improvement and now i don
t have enough time to do it, but i will think.
I just removed the ocurrences of fs in the file rtf.class.js
. Then I was able to use this lib in the browser.
What else should I do?
//const fs = require('fs');
//....
saveRtfInFile(path, value) {
// fs.writeFile(path, value, (err) => {
// if (err) throw err;
console.log('The file has been saved!');
// });
}
to save the rtf from the browser, i did this:
const htmlToRtf = require('html-to-rtf');
const rtf = htmlToRtf.convertHtmlToRtf(this.editor.getData());
const blob = new Blob([rtf], {type: "application/rtf;charset=utf-8"});
const link=window.URL.createObjectURL(blob);
window.location=link;
and I was able to download a valid RTF.
I sent a package update v2.0.0 to work in the browser and the server.
You would be a lifesaver if you would modify the code to have it also work without fs module. Or create an angular wrapper for it. I only need the part where you do the conversion. It would also be very helpful if you would update the code so that it also works with VanillaJS.