From 3e3b220b2ecdb2e7efd87b7cfd162118bef36801 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 7 Jul 2023 18:34:21 +0200 Subject: [PATCH] wait #6120 @1.5 --- app/Fluidbook/Compiler/Compiler.php | 33 ++++++++------------- app/Fluidbook/Link/LinksData.php | 13 +++++++- resources/linkeditor/js/linkeditor.form.js | 15 ++++++++-- resources/linkeditor/js/linkeditor.links.js | 11 +++++-- 4 files changed, 44 insertions(+), 28 deletions(-) diff --git a/app/Fluidbook/Compiler/Compiler.php b/app/Fluidbook/Compiler/Compiler.php index 5c2641ecb..d466ad9bc 100644 --- a/app/Fluidbook/Compiler/Compiler.php +++ b/app/Fluidbook/Compiler/Compiler.php @@ -49,6 +49,7 @@ class Compiler extends Base implements CompilerInterface use Favicon; use Secure; use Images; + use Sound; protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', ''); @@ -666,7 +667,7 @@ class Compiler extends Base implements CompilerInterface public function handle() { $this->log('Preprocess images'); - FluidbookImagesPreprocess::dispatchSync($this->book_id); + (new FluidbookImagesPreprocess($this->book_id))->handle(); $this->log('Start compile process'); // Raw copy of some directories @@ -855,18 +856,6 @@ class Compiler extends Base implements CompilerInterface } } - /** - * @throws \Exception - */ - protected function writeSounds() - { - if (!$this->fluidbookSettings->soundTheme || $this->fluidbookSettings->soundTheme === 'none') { - return; - } - $dir = resource_path('fluidbookpublication/sounds/' . $this->fluidbookSettings->soundTheme); - $this->setSetting('simpleSoundTheme', file_exists($dir . '/flip.mp3')); - $this->vdir->copyDirectory($dir, 'data/sounds'); - } protected function writeAccessibility() { @@ -1836,14 +1825,14 @@ class Compiler extends Base implements CompilerInterface return $this->config->get($k); } - public function getWidth() + public function getWidth($page = 1) { - return $this->getPageDimension(1)[0]; + return $this->getPageDimension($page)[0]; } - public function getHeight() + public function getHeight($page = 1) { - return $this->getPageDimension(1)[1]; + return $this->getPageDimension($page)[1]; } @@ -2896,14 +2885,14 @@ class Compiler extends Base implements CompilerInterface return $this->getFluidbook()->getPDFSplitSource($page); } - public function getWidthForLinks() + public function getWidthForLinks($page = 1) { - return $this->getWidth() / $this->getLinkScale(); + return $this->getWidth($page) / $this->getLinkScale(); } - public function getHeightForLinks() + public function getHeightForLinks($page = 1) { - return $this->getHeight() / $this->getLinkScale(); + return $this->getHeight($page) / $this->getLinkScale(); } /** @@ -2934,3 +2923,5 @@ class Compiler extends Base implements CompilerInterface return (int)$this->config->JPEGQuality; } } + + diff --git a/app/Fluidbook/Link/LinksData.php b/app/Fluidbook/Link/LinksData.php index c8bd8ac18..31afdb7eb 100644 --- a/app/Fluidbook/Link/LinksData.php +++ b/app/Fluidbook/Link/LinksData.php @@ -263,8 +263,19 @@ class LinksData self::_fixMultimedia($links); self::_fixCloseButton($links); self::_fixColors($links); + self::_fixInline($links); } + protected static function _fixInline(&$links) + { + foreach ($links as $k => $link) { + if (isset($link['inline'])) { + $links[$k]['inline'] = Link::normalizeInlineIntegration($link['inline']); + } + } + } + + protected static function _fixColors(&$links) { foreach ($links as $k => $link) { @@ -604,7 +615,7 @@ class LinksData } $link = []; - $cols = array('page' => '', 'left' => '', 'top' => '', 'width' => '', 'height' => '', 'type' => '', 'to' => '', 'target' => '_blank', 'video_loop' => true, 'video_auto_start' => true, 'video_controls' => true, 'video_sound_on' => true, 'tooltip' => '', 'numerotation' => 'physical', "inline" => true, 'pdfjs' => 'normal'); + $cols = array('page' => '', 'left' => '', 'top' => '', 'width' => '', 'height' => '', 'type' => '', 'to' => '', 'target' => '_blank', 'video_loop' => true, 'video_auto_start' => true, 'video_controls' => true, 'video_sound_on' => true, 'tooltip' => '', 'numerotation' => 'physical', "inline" => 'inline', 'pdfjs' => 'normal'); $k = 0; foreach ($cols as $col => $default) { if (isset($line[$k])) { diff --git a/resources/linkeditor/js/linkeditor.form.js b/resources/linkeditor/js/linkeditor.form.js index cec7d1aa2..08169686d 100644 --- a/resources/linkeditor/js/linkeditor.form.js +++ b/resources/linkeditor/js/linkeditor.form.js @@ -36,8 +36,17 @@ LinkeditorForm.prototype = { }); + setInterval(function () { + if ($(document.activeElement).is('.sp-input')) { + var v = $(document.activeElement).val(); + let main = $(document.activeElement).closest('.form-group').find('.colorpicker'); + $(main).val(v); + $(main).trigger('change'); - $(document).on('change', "#linkeditor-panel-form input,#linkeditor-panel-form select,#linkeditor-panel-form textarea", function () { + } + }, 250); + + $(document).on('change keyup', "#linkeditor-panel-form input,#linkeditor-panel-form select,#linkeditor-panel-form textarea", function () { if ($this._maskChangeEvent) { return; } @@ -163,7 +172,7 @@ LinkeditorForm.prototype = { if (f.length === 0) { return; } - if(!f.is('input,textarea')){ + if (!f.is('input,textarea')) { return; } f = f.get(0); @@ -280,7 +289,7 @@ LinkeditorForm.prototype = { initSpectrum: function () { $("#linkeditor-panel-form .colorpicker:not(.init)").each(function () { var t = $(this); - $(this).spectrum({ + let s = $(this).spectrum({ preferredFormat: 'hex3', showAlpha: true, allowEmpty: false, diff --git a/resources/linkeditor/js/linkeditor.links.js b/resources/linkeditor/js/linkeditor.links.js index c7baa03f3..b65edbc43 100644 --- a/resources/linkeditor/js/linkeditor.links.js +++ b/resources/linkeditor/js/linkeditor.links.js @@ -1050,7 +1050,7 @@ LinkeditorLinks.prototype = { let zindex = ((calcDepth + 1) * 10000) - Math.min(9999, Math.max(1, Math.round(9999 * ((linkWidth * linkHeight) / $this.linkeditor.bookSurface)))); if (isNaN(zindex) || isNaN(calcDepth)) { - console.warn('error defining depth of link ' + $(this).attr('fb-uid'), calcDepth, linkWidth, linkHeight, $this.linkeditor.bookSurface); + console.warn('error defining depth of link ' + $(this).attr('fb-uid'), calcDepth, $this.findDefaultLinkDepth($(this)), linkWidth, linkHeight, $this.linkeditor.bookSurface); } $(this).attr('fb-calc-depth', calcDepth); @@ -1066,7 +1066,7 @@ LinkeditorLinks.prototype = { $.each(conf, function (k, v) { let val = $(link).attr('fb-' + k); if (k === 'alternative' || k === 'to') { - if (key === 6) { + if (key == 6) { let e = val.split('.'); let ext = e.pop().toLowerCase(); val = (['png', 'jpg', 'jpeg', 'gif', 'webp', 'avif', 'svg'].indexOf(ext) >= 0) ? 'file.jpg' : 'file.zip'; @@ -1077,7 +1077,12 @@ LinkeditorLinks.prototype = { if (settings.length > 0) { key += '/' + settings.join(','); } - return DEPTH.depths[key]; + + let res = DEPTH.depths[key]; + if (res === undefined) { + console.log('undefined depth key ', key); + } + return res; }, clear: function () { -- 2.39.5