You've already forked joplin
							
							
				mirror of
				https://github.com/laurent22/joplin.git
				synced 2025-10-31 00:07:48 +02:00 
			
		
		
		
	Desktop: Fixed export to HTML, PDF and printing
This commit is contained in:
		| @@ -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> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user