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:
parent
193978a8be
commit
8d7d70bc13
@ -37,7 +37,7 @@ class InteropServiceHelper {
|
||||
htmlFile = await this.exportNoteToHtmlFile(noteId);
|
||||
|
||||
const windowOptions = {
|
||||
show: true,
|
||||
show: false,
|
||||
};
|
||||
|
||||
win = bridge().newBrowserWindow(windowOptions);
|
||||
|
@ -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_ = {}
|
||||
function loadPluginAssets(assets) {
|
||||
if (!assets) return;
|
||||
|
@ -92,6 +92,8 @@ class NoteBodyViewer extends Component {
|
||||
}, 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 = [];
|
||||
for (let i = 0; i < result.pluginAssets.length; i++) {
|
||||
const asset = result.pluginAssets[i];
|
||||
|
@ -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 (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 = `
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
${headers.join('\n')}
|
||||
<title>${escapeHtml(item.title)}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
Loading…
Reference in New Issue
Block a user