From 030fb997bcef4be558cd001ce3b78f5d1dc0986a Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sat, 12 Jun 2021 11:30:27 +0100 Subject: [PATCH] Fix image display for Gutenberg in SW mode Former-commit-id: 747b8193312c14aaaf722d1f2bcea4990d69b23a [formerly 5b75942a1827883754193d28ba152748fe07274f [formerly 155207bf97755bdffa42c4912df74a90cf536602]] Former-commit-id: 3bf2d7bfee30a093285b56292d18859546f9c850 Former-commit-id: a974dfb5b80347da589130afd45b1412286b73fd --- www/js/app.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index 9d4ffc8e..54ab5775 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -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 && /]*>/.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; }