]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5844 @6
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 5 Apr 2023 16:39:01 +0000 (18:39 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 5 Apr 2023 16:39:01 +0000 (18:39 +0200)
.gitignore
app/Console/Commands/UpdatePDFJSLibrary.php
app/Jobs/FluidbookCompiler.php
app/Models/FluidbookPublication.php
resources/pdfjs/custom/custom.js [deleted file]

index 7fea67e6e09421de84d721c138170e6b12b8decb..d14f395a276fcbd3acf14d67aa413740ad44f406 100644 (file)
@@ -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/
index e1e2623af1fe533f7a141b5f18cd8e63e0c8299a..3036ac36eb1105873f2a64fb8d00b584dd26089f 100644 (file)
@@ -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('<script src="viewer.js"></script>', '<script src="jquery.min.js"></script><script src="custom.js"></script><script src="viewer.js"></script>', $html);
+        $html = str_replace('<script src="../build/pdf.js"></script>', '<script src="jquery.min.js"></script><script src="custom.js"></script><script src="../build/pdf.js"></script>', $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`;
     }
index 216e3a5426a1739b54076af577fe0d671b809e1a..42844d7259ef887108df2eff4ab051bc4eef2bf4 100644 (file)
@@ -2694,11 +2694,13 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
             $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);
     }
index f3069174da56af37f4c9cff57ce823d6c906d630..e05f3e2c456dbf662392ee528b332fac3acfda23 100644 (file)
@@ -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 (file)
index 12b4809..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-$(function () {
-    PDFViewerApplication.preferences.set("externalLinkTarget", 2);
-});