Fix image display for Gutenberg in SW mode

Former-commit-id: 747b8193312c14aaaf722d1f2bcea4990d69b23a [formerly 5b75942a1827883754193d28ba152748fe07274f [formerly 155207bf97755bdffa42c4912df74a90cf536602]]
Former-commit-id: 3bf2d7bfee30a093285b56292d18859546f9c850
Former-commit-id: a974dfb5b80347da589130afd45b1412286b73fd
This commit is contained in:
Jaifroid 2021-06-12 11:30:27 +01:00
parent 65d265945a
commit 030fb997bc

View File

@ -3190,6 +3190,10 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
// UWP apps with windows need to allow all images in all throughput
if (/UWP/.test(params.appType) && (appstate.target === 'window' || appstate.messageChannelWaiting) &&
params.imageDisplay) { imageDisplayMode = 'all'; }
// We need to do the same for Gutenberg and PHET ZIMs
if (/gutenberg|phet/i.test(appstate.selectedArchive._file._files[0].name)) {
imageDisplayMode = 'all';
}
if (/\bhtml\b/i.test(mimetype)) {
// Intercept files of type html and apply transformations
var message = {
@ -3204,10 +3208,14 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
var postTransformedHTML = function() {
clearTimeout(timer);
if (params.transformedHTML && /<html[^>]*>/.test(params.transformedHTML)) {
// Because UWP app window can only be controlled from the Service Worker, we have to allow all images
// to be called from any external windows
if (/UWP/.test(params.appType) && (appstate.target === 'window' || appstate.messageChannelWaiting) &&
params.imageDisplay) { imageDisplayMode = 'all'; }
// // Because UWP app window can only be controlled from the Service Worker, we have to allow all images
// // to be called from any external windows
// if (/UWP/.test(params.appType) && (appstate.target === 'window' || appstate.messageChannelWaiting) &&
// params.imageDisplay) { imageDisplayMode = 'all'; }
// // We need to do the same for Gutenberg and PHET ZIMs
// if (/gutenberg|phet/i.test(appstate.selectedArchive._file._files[0].name)) {
// imageDisplayMode = 'all';
// }
appstate.messageChannelWaiting = false;
// Let's send the content to the ServiceWorker
thisMessage.content = params.transformedHTML;
@ -4351,7 +4359,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
if (params.preloadingAllImages !== true) {
$('#searchingArticles').show();
params.preloadingAllImages = true;
if (params.imageDisplay) params.contentInjectionMode == 'jquery' ?
if (params.imageDisplay) params.contentInjectionMode === 'jquery' ?
images.prepareImagesJQuery(articleWindow, true) : images.prepareImagesServiceWorker(articleWindow, true);
return;
}