1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Desktop: Fixed export to HTML, PDF and printing

This commit is contained in:
Laurent Cozic 2019-12-30 20:44:15 +01:00
parent 193978a8be
commit 8d7d70bc13
4 changed files with 26 additions and 1 deletions

View File

@ -37,7 +37,7 @@ class InteropServiceHelper {
htmlFile = await this.exportNoteToHtmlFile(noteId); htmlFile = await this.exportNoteToHtmlFile(noteId);
const windowOptions = { const windowOptions = {
show: true, show: false,
}; };
win = bridge().newBrowserWindow(windowOptions); win = bridge().newBrowserWindow(windowOptions);

View File

@ -66,6 +66,8 @@
} }
})); }));
// TODO: The joplin-renderer package should take care of creating the <link> and <script> tags to reduce duplicate code
// Calling app would then ensure that the CSS files, etc. are in the correct location.
const loadedPluginAssets_ = {} const loadedPluginAssets_ = {}
function loadPluginAssets(assets) { function loadPluginAssets(assets) {
if (!assets) return; if (!assets) return;

View File

@ -92,6 +92,8 @@ class NoteBodyViewer extends Component {
}, 10); }, 10);
`); `);
// TODO: The joplin-renderer package should take care of creating the <link> and <script> tags to reduce duplicate code
// Calling app would then ensure that the CSS files, etc. are in the correct location.
const headers = []; const headers = [];
for (let i = 0; i < result.pluginAssets.length; i++) { for (let i = 0; i < result.pluginAssets.length; i++) {
const asset = result.pluginAssets[i]; const asset = result.pluginAssets[i];

View File

@ -108,11 +108,32 @@ class InteropService_Exporter_Html extends InteropService_Exporter_Base {
if (item.title) noteContent.push(`<div class="exported-note-title">${escapeHtml(item.title)}</div>`); if (item.title) noteContent.push(`<div class="exported-note-title">${escapeHtml(item.title)}</div>`);
if (result.html) noteContent.push(result.html); if (result.html) noteContent.push(result.html);
// We need to export all the plugin assets too and refer them from the header
// The source path is a bit hard-coded but shouldn't change.
// TODO: The joplin-renderer package should take care of creating the <link> and <script> tags to reduce duplicate code
// Calling app would then ensure that the CSS files, etc. are in the correct location.
const headers = [];
for (let i = 0; i < result.pluginAssets.length; i++) {
const asset = result.pluginAssets[i];
const filePath = `${dirname(dirname(__dirname))}/gui/note-viewer/pluginAssets/${asset.name}`;
const destPath = `${dirname(noteFilePath)}/pluginAssets/${asset.name}`;
await shim.fsDriver().mkdir(dirname(destPath));
await shim.fsDriver().copy(filePath, destPath);
if (asset.mime === 'text/css') {
headers.push(`<link rel="stylesheet" href="pluginAssets/${asset.name}">`);
} else if (asset.mime === 'application/javascript') {
// NOT TESTED!!
headers.push(`<script type="application/javascript" src="pluginAssets/${asset.name}"></script>`);
}
}
const fullHtml = ` const fullHtml = `
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
${headers.join('\n')}
<title>${escapeHtml(item.title)}</title> <title>${escapeHtml(item.title)}</title>
</head> </head>
<body> <body>