1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-27 08:21:03 +02:00

Clipper: Fixes #2034: Better handling of HTML minifying error with fallback to non-minified HTML

This commit is contained in:
Laurent Cozic 2019-11-07 20:32:11 +00:00
parent 3da32f007e
commit 4e72a8f3a5
4 changed files with 35 additions and 13 deletions

View File

@ -8,7 +8,7 @@
overflow: hidden;
}
#content {
#joplin-container-content {
/* Needs this in case the content contains elements with absolute positioning */
/* Without this they would just stay at a fixed position when scrolling */
position: relative;
@ -36,10 +36,10 @@
</style>
</head>
<body id="body">
<div id="styleContainer"></div>
<div id="markScriptContainer"></div>
<div id="content" ondragstart="return false;" ondrop="return false;"></div>
<body id="joplin-container-body">
<div id="joplin-container-styleContainer"></div>
<div id="joplin-container-markScriptContainer"></div>
<div id="joplin-container-content" ondragstart="return false;" ondrop="return false;"></div>
<script src="./lib.js"></script>
<script>
@ -48,7 +48,7 @@
}
try {
const contentElement = document.getElementById('content');
const contentElement = document.getElementById('joplin-container-content');
const ipc = {};
@ -74,7 +74,7 @@
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = f;
document.getElementById('styleContainer').appendChild(link);
document.getElementById('joplin-container-styleContainer').appendChild(link);
}
}
@ -205,7 +205,7 @@
// TODO: Add support for scriptType on mobile and CLI
if (!mark_) {
mark_ = new Mark(document.getElementById('content'), {
mark_ = new Mark(document.getElementById('joplin-container-content'), {
exclude: ['img'],
acrossElements: true,
});
@ -270,7 +270,7 @@
};
script.src = '../../node_modules/mark.js/dist/mark.min.js';
document.getElementById('markScriptContainer').appendChild(script);
document.getElementById('joplin-container-markScriptContainer').appendChild(script);
markLoaded_ = true;
} else {
setMarkers(keywords, options);
@ -283,8 +283,8 @@
// The body element needs to have a fixed height for the content to be scrollable
function updateBodyHeight() {
document.getElementById('body').style.height = window.innerHeight + 'px';
document.getElementById('content').style.height = window.innerHeight + 'px';
document.getElementById('joplin-container-body').style.height = window.innerHeight + 'px';
document.getElementById('joplin-container-content').style.height = window.innerHeight + 'px';
}
function currentPercentScroll() {

View File

@ -3289,6 +3289,11 @@
}
}
},
"font-awesome-filetypes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/font-awesome-filetypes/-/font-awesome-filetypes-2.1.0.tgz",
"integrity": "sha512-U6hi14GRjfZFIWsTNyVmCBuHyPhiizWEKVbaQqHipKQv3rA1l1PNvmKulzpqxonFnQMToty5ZhfWbc/0IjLDGA=="
},
"for-in": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
@ -4403,6 +4408,11 @@
"resolved": "https://registry.npmjs.org/markdown-it-abbr/-/markdown-it-abbr-1.0.4.tgz",
"integrity": "sha1-1mtTZFIcuz3Yqlna37ovtoZcj9g="
},
"markdown-it-anchor": {
"version": "5.2.5",
"resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-5.2.5.tgz",
"integrity": "sha512-xLIjLQmtym3QpoY9llBgApknl7pxAcN3WDRc2d3rwpl+/YvDZHPmKscGs+L6E05xf2KrCXPBvosWt7MZukwSpQ=="
},
"markdown-it-deflist": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/markdown-it-deflist/-/markdown-it-deflist-2.0.3.tgz",
@ -4478,6 +4488,11 @@
"resolved": "https://registry.npmjs.org/markdown-it-sup/-/markdown-it-sup-1.0.0.tgz",
"integrity": "sha1-y5yf+RpSVawI8/09YyhuFd8KH8M="
},
"markdown-it-toc-done-right": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/markdown-it-toc-done-right/-/markdown-it-toc-done-right-4.1.0.tgz",
"integrity": "sha512-UhD2Oj6cZV3ycYPoelt4hTkwKIK3zbPP1wjjdpCq7UGtWQOFalDFDv1s2zBYV6aR2gMs/X8kpJcOYsQmUbiXDw=="
},
"match-at": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/match-at/-/match-at-0.1.1.tgz",

View File

@ -254,7 +254,7 @@ module.exports = function(style, options) {
border: 1px solid #CBCBCB;
}
#content {
#joplin-container-content {
/* The height of the content is set dynamically by JavaScript (in updateBodyHeight) to go
around various issues related to scrolling. However when printing we don't want this
fixed size as that would crop the content. So we set it to auto here. "important" is

View File

@ -482,7 +482,14 @@ class Api {
});
const styleTag = style.length ? `<style>${styleString}</style>` + '\n' : '';
output.body = styleTag + minify(requestNote.body_html, minifyOptions);
let minifiedHtml = '';
try {
minifiedHtml = minify(requestNote.body_html, minifyOptions);
} catch (error) {
console.warn('Could not minify HTML - using non-minified HTML instead', error);
minifiedHtml = requestNote.body_html;
}
output.body = styleTag + minifiedHtml;
output.body = htmlUtils.prependBaseUrl(output.body, baseUrl);
output.markup_language = Note.MARKUP_LANGUAGE_HTML;
} else {