You've already forked joplin
							
							
				mirror of
				https://github.com/laurent22/joplin.git
				synced 2025-10-31 00:07:48 +02:00 
			
		
		
		
	Clipper: Generate better HTML so that it loads faster in text editor
This commit is contained in:
		
							
								
								
									
										5
									
								
								ElectronClient/app/package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										5
									
								
								ElectronClient/app/package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -6654,6 +6654,11 @@ | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "uglifycss": { | ||||
|       "version": "0.0.29", | ||||
|       "resolved": "https://registry.npmjs.org/uglifycss/-/uglifycss-0.0.29.tgz", | ||||
|       "integrity": "sha512-J2SQ2QLjiknNGbNdScaNZsXgmMGI0kYNrXaDlr4obnPW9ni1jljb1NeEVWAiTgZ8z+EBWP2ozfT9vpy03rjlMQ==" | ||||
|     }, | ||||
|     "uid-safe": { | ||||
|       "version": "2.1.5", | ||||
|       "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz", | ||||
|   | ||||
| @@ -150,6 +150,7 @@ | ||||
|     "syswide-cas": "^5.1.0", | ||||
|     "tar": "^4.4.4", | ||||
|     "tcp-port-used": "^0.1.2", | ||||
|     "uglifycss": "0.0.29", | ||||
|     "url-parse": "^1.4.3", | ||||
|     "uuid": "^3.2.1", | ||||
|     "valid-url": "^1.0.9", | ||||
|   | ||||
| @@ -440,9 +440,7 @@ class Api { | ||||
| 				const style = await this.buildNoteStyleSheet_(requestNote.stylesheets); | ||||
| 				const minify = require('html-minifier').minify; | ||||
|  | ||||
| 				const styleTag = style.length ? '<style>' + style.join('\n') + '</style>' + '\n' : ''; | ||||
|  | ||||
| 				output.body = minify(styleTag + requestNote.body_html, { | ||||
| 				const minifyOptions = { | ||||
| 					// Remove all spaces and, especially, newlines from tag attributes, as that would | ||||
| 					// break the rendering. | ||||
| 					customAttrCollapse: /.*/, | ||||
| @@ -450,7 +448,18 @@ class Api { | ||||
| 					// means a code block in Markdown. | ||||
| 					collapseWhitespace: true, | ||||
| 					minifyCSS: true, | ||||
| 					maxLineLength: 300, | ||||
| 				}; | ||||
|  | ||||
| 				const uglifycss = require('uglifycss'); | ||||
| 				const styleString = uglifycss.processString(style.join('\n'), { | ||||
| 					// Need to set a max length because Ace Editor takes forever | ||||
| 					// to display notes with long lines. | ||||
| 					maxLineLen: 200, | ||||
| 				}); | ||||
|  | ||||
| 				const styleTag = style.length ? '<style>' + styleString + '</style>' + '\n' : ''; | ||||
| 				output.body = styleTag + minify(requestNote.body_html, minifyOptions); | ||||
| 				output.body = htmlUtils.prependBaseUrl(output.body, baseUrl); | ||||
| 				output.markup_language = Note.MARKUP_LANGUAGE_HTML; | ||||
| 			} else { // Convert to Markdown  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user