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

2
dist/index.html vendored
View file

@ -3,8 +3,6 @@
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Anytype</title>
<script src="./polyfill.js" type="text/javascript"></script>
</head>
<body>
<div id="root"></div>

4
dist/index.web.html vendored
View file

@ -8,14 +8,14 @@
window.isWebVersion = true;
window.serverAddr = 'http://127.0.0.1:50397'
let onload = function () {
document.body.onload = function () {
RendererEvents.dataPath(null, '/');
};
</script>
<script src="./polyfill.js" type="text/javascript"></script>
</head>
<body onload="onload();">
<body>
<div id="root"></div>
<script src="./run.js" type="text/javascript"></script>
</body>

3
dist/run.js vendored
View file

@ -1,6 +1,5 @@
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = './main.js?' + Math.random();
s.async = true;
s.type = 'text/javascript';
document.body.appendChild(s);

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 => {