From f75b6e05e296af2c888bfb01b89ade2bf00f424a Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 5 Apr 2023 18:39:01 +0200 Subject: [PATCH] wip #5844 @6 --- .gitignore | 5 +---- app/Console/Commands/UpdatePDFJSLibrary.php | 6 ++++-- app/Jobs/FluidbookCompiler.php | 10 ++++++---- app/Models/FluidbookPublication.php | 1 - resources/pdfjs/custom/custom.js | 3 --- 5 files changed, 11 insertions(+), 14 deletions(-) delete mode 100644 resources/pdfjs/custom/custom.js diff --git a/.gitignore b/.gitignore index 7fea67e6e..d14f395a2 100644 --- a/.gitignore +++ b/.gitignore @@ -17,10 +17,7 @@ yarn-error.log .DS_Store /resources/cubedesigners-oxygene/ /resources/css/ -/resources/pdfjs/dist/ -/resources/pdfjs/legacy/ -/resources/pdfjs/dist-min/ -/resources/pdfjs/legacy-min/ +/resources/pdfjs/ /resources/fluidbookpublication/player/ /resources/elearningpackage/dist/ /resources/quiz/dist/ diff --git a/app/Console/Commands/UpdatePDFJSLibrary.php b/app/Console/Commands/UpdatePDFJSLibrary.php index e1e2623af..3036ac36e 100644 --- a/app/Console/Commands/UpdatePDFJSLibrary.php +++ b/app/Console/Commands/UpdatePDFJSLibrary.php @@ -36,12 +36,14 @@ class UpdatePDFJSLibrary extends CubistCommand Zip::extract($tmp, $path); unlink($tmp); copy('https://code.jquery.com/jquery-3.6.4.min.js', $path . '/web/jquery.min.js'); - copy(resource_path('pdfjs/custom/custom.js'), $path . '/web/custom.js'); + touch($path . '/web/custom.js'); $html = file_get_contents($path . '/web/viewer.html'); - $html = str_replace('', '', $html); + $html = str_replace('', '', $html); file_put_contents($path . '/web/viewer.html', $html); + Files::str_replace('function _isValidProtocol(url) {', 'function _isValidProtocol(url) {return true;', [$path . '/build/pdf.js', $path . '/build/pdf.worker.js']); + `cp -r $path $minpath`; `/application/scripts/terser_path $minpath`; } diff --git a/app/Jobs/FluidbookCompiler.php b/app/Jobs/FluidbookCompiler.php index 216e3a542..42844d725 100644 --- a/app/Jobs/FluidbookCompiler.php +++ b/app/Jobs/FluidbookCompiler.php @@ -2694,11 +2694,13 @@ height="0" width="0" style="display:none;visibility:hidden"> $resource = resource_path('pdfjs/legacy-min'); } $this->vdir->copyDirectory($resource, 'pdfjs'); + $this->vdir->copy($this->assets . '/js/libs/pdfjs/custom.js', 'pdfjs/web/custom.js'); - $css = '.article #sidebarContainer, .article .toolbar {display:none !important;}'; - $css .= '.article .pdfViewer{padding:0 !important;}'; - $css .= '.article #viewerContainer{top:0 !important;overflow:visible !important;}'; - $css .= '.article{--page-border:0;--page-margin:0;--body-bg-color:transparent;}'; + + $css = '.seamless #sidebarContainer, .seamless .toolbar {display:none !important;}'; + $css .= '.seamless .pdfViewer{padding:0 !important;}'; + $css .= '.seamless #viewerContainer{top:0 !important;overflow:visible !important;}'; + $css .= '.seamless{--page-border:0;--page-margin:0;--body-bg-color:transparent;}'; $css .= '.openFile,.rotateCw,.rotateCcw,.rotateCcw + .horizontalToolbarSeparator{display:none !important;}' . $this->fluidbookSettings->PDFJSCSS; $this->vdir->file_put_contents('pdfjs/web/viewer.css', file_get_contents($resource . '/web/viewer.css') . $css); } diff --git a/app/Models/FluidbookPublication.php b/app/Models/FluidbookPublication.php index f3069174d..e05f3e2c4 100644 --- a/app/Models/FluidbookPublication.php +++ b/app/Models/FluidbookPublication.php @@ -223,7 +223,6 @@ class FluidbookPublication extends ToolboxSettingsModel $this->setComposedAttributes(); $this->checkHash(); if ($this->_compositionUpdated) { - Links::addLinksFromPDF($this->id); FluidbookImagesPreprocess::dispatch($this->id); } return parent::onSaved(); diff --git a/resources/pdfjs/custom/custom.js b/resources/pdfjs/custom/custom.js deleted file mode 100644 index 12b480981..000000000 --- a/resources/pdfjs/custom/custom.js +++ /dev/null @@ -1,3 +0,0 @@ -$(function () { - PDFViewerApplication.preferences.set("externalLinkTarget", 2); -}); -- 2.39.5