1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-08 05:57:02 +09:00

fix export to html

This commit is contained in:
Andrew Simachev 2022-01-28 13:22:28 +03:00
parent 8409fa6a64
commit 4decf51a53
4 changed files with 16 additions and 7 deletions

View file

@ -869,7 +869,19 @@ function exit (relaunch) {
function savePage (name) {
name = String(name || 'untitled').replace(/[^a-z0-9]/gi, '-').toLowerCase();
win.webContents.savePage(path.join(exportPath, name + '.html'), 'HTMLComplete').then(() => {
let p = path.join(exportPath, name + '_files');
let fp = path.join(exportPath, name + '.html');
win.webContents.savePage(fp, 'HTMLComplete').then(() => {
let f = fs.readFileSync(fp, 'utf8');
f = f.replace(`<script src="./${name}_files/run.js" type="text/javascript"></script>`, '');
f = f.replace(`<script src="./${name}_files/main.js" type="text/javascript"></script>`, '');
fs.writeFileSync(fp, f);
fs.unlinkSync(path.join(p, 'main.js'));
fs.unlinkSync(path.join(p, 'run.js'));
shell.openPath(exportPath);
send('command', 'saveAsHTMLSuccess');
}).catch(err => {