]> _ Git - fluidbook-toolbox.git/commitdiff
wait #7782 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 13 Oct 2025 10:21:20 +0000 (12:21 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 13 Oct 2025 10:21:20 +0000 (12:21 +0200)
app/Fluidbook/SearchIndex.php
app/Http/Controllers/Admin/Operations/FluidbookPublication/LinksOperation.php
app/Models/FluidbookPublication.php
resources/views/fluidbook_publication/link_editor.blade.php
resources/views/fluidbook_publication/link_editor_icons.blade.php

index 819c1ba2e78e6c041749c9835b925691399c933f..25008be4e858764faa104517c4cb5b2162e88941 100644 (file)
@@ -71,7 +71,7 @@ class SearchIndex
      * @param $compiler Compiler|FluidbookPublication
      * @return array
      */
-    public static function makeHighlightIndex($compiler): array
+    public static function makeHighlightIndex($compiler, $ignoreSeparators = ''): array
     {
 
         if ($compiler instanceof Compiler) {
@@ -80,13 +80,13 @@ class SearchIndex
         } else if ($compiler instanceof FluidbookPublication) {
             $fluidbook = $compiler;
             $pages = $fluidbook->getComposition();
-        }else{
+        } else {
             return [];
         }
 
         $res = [];
         foreach ($pages as $page => $infos) {
-            $fby = $fluidbook->getHightlightFile($page);
+            $fby = $fluidbook->getHightlightFile($page, $ignoreSeparators);
             $words = json_decode(Gzip::file_get_contents($fby), true);
 
             if (is_array($words)) {
index 90a5af34cdb0b30e6482eaefaeca1649e0f651d7..ea9a0a5227eb565db70714fc752830245b6da374 100644 (file)
@@ -291,8 +291,10 @@ trait LinksOperation
         $toPrefix = '';
         $toSuffix = '';
         $skipFirst = true;
-        $vPadding = 0;
-        $hPadding = 0;
+        $vPadding = 2;
+        $hPadding = 2;
+        $tooltip = '';
+        $ignoreSeparators = '';
         switch ($rules) {
             case 'cart':
                 $type = \Fluidbook\Tools\Links\Link::CART;
@@ -300,8 +302,7 @@ trait LinksOperation
             case 'steelite':
                 $toSuffix = '?embed';
                 $target = '_popupiframe';
-                $hPadding = 2;
-                $vPadding = 4;
+                $ignoreSeparators = '-';
             case 'web':
             default:
                 break;
@@ -311,8 +312,7 @@ trait LinksOperation
         $excel = ExcelToArray::excelToArrayKeyVal($uploadedFile->getPathname());
         /** @var FluidbookPublication $fluidbook */
         $fluidbook = FluidbookPublication::withoutGlobalScopes()->find($fluidbook_id);
-        $highlights = $fluidbook->getHightlightData();
-        $links = [];
+        $highlights = $fluidbook->getHightlightData($ignoreSeparators);
 
         foreach ($excel as $search => $url) {
             if ($skipFirst) {
@@ -324,7 +324,7 @@ trait LinksOperation
 
             if (isset($highlights[$search])) {
                 foreach ($highlights[$search] as $o) {
-                    $uid = LinksData::generateUID();
+                    $uid = 'a_' . substr(sha1($type . '//' . json_encode($o)), 0, 10);
                     $links[$uid] = [
                         'uid' => $uid,
                         'page' => $o['page'],
@@ -335,12 +335,13 @@ trait LinksOperation
                         'type' => $type,
                         'target' => $target,
                         'to' => $toPrefix . $url . $toSuffix,
+                        'tooltip' => $tooltip,
                     ];
                 }
             }
         }
 
-        LinksData::saveLinksInFile($fluidbook_id, backpack_user()->id, __("Ajouter des liens automatiques à partir du fichier :file (règles :rule)", ['file' => $uploadedFile->getClientOriginalName(),'rule'=>$rules]) . ' ', $links, $rulers, [], []);
+        LinksData::saveLinksInFile($fluidbook_id, backpack_user()->id, __("Ajouter des liens automatiques à partir du fichier :file (règles :rule)", ['file' => $uploadedFile->getClientOriginalName(), 'rule' => $rules]) . ' ', $links, $rulers, [], []);
         return response()->json(['success' => 'ok']);
     }
 
index 89b73061f7c3a661ec1316f75cb1049f18904693..3bf058f7ea80b5a2a1a16d81d21ef83dcd5b2311 100644 (file)
@@ -457,15 +457,15 @@ class FluidbookPublication extends ToolboxStatusModel
         return self::_getDocument($compo[0])->getTextFile($compo[1], $type, $mode ?? $this->search_mode ?: 'standard', $this->textExtraction, $this->ignoreSearchSeparators);
     }
 
-    public function getHightlightData(): array
+    public function getHightlightData($ignoreSeparators = null): array
     {
-        return SearchIndex::makeHighlightIndex($this);
+        return SearchIndex::makeHighlightIndex($this,$ignoreSeparators);
     }
 
-    public function getHightlightFile($page)
+    public function getHightlightFile($page, $ignoreSeparators = null)
     {
         $compo = $this->getComposition()[$page];
-        return self::_getDocument($compo[0])->getHightlightFile($compo[1], $this->search_mode ?: 'standard', $this->ignoreSearchSeparators);
+        return self::_getDocument($compo[0])->getHightlightFile($compo[1], $this->search_mode ?: 'standard', $ignoreSeparators ?? $this->ignoreSearchSeparators);
     }
 
     public function getAccessibleFile($page, $format = 'md')
index d1e08186dbd1d80c44cbbbef38789ab342fd3f6c..b4538d798d67a563a41dd99278a610fb953e4fdf 100644 (file)
                     </div>
                     <a href="#" data-icon="import-links-pdf" data-action="links.importFromPDF"
                        data-tooltip="{{__('Importer les liens du PDF')}}"></a>
-                    <div data-icon="automatic-links"
+                    <div data-icon="auto-links"
                          data-tooltip="{{__('Ajouter automatique des liens à partir d\'un excel')}}">
                         <form class="importExcel"
                               data-save-before-submit="{{__("Sauvegarde avant l'ajout automatique à partir d'un excel")}}"
index b8ace8a399b5b8e6bbe223553ca465d5a2867f4d..904f9c0417cdf717035f32533bfd02a0dd7d58b1 100644 (file)
@@ -107,7 +107,9 @@ Edit here : https://toolbox.fluidbook.com/tool-sprite/3/edit
             <line class="st0" x1="28.9" y1="10.6" x2="24.3" y2="12.6"/>
             <line class="st0" x1="25.9" y1="6.1" x2="22.4" y2="9.6"/>
             <line class="st0" x1="21.4" y1="3.1" x2="19.4" y2="7.7"/>
-        </symbol><symbol id="linkeditor-import-markdown" viewBox="0 0 19.97 19.91"><path d="m.45 0-.23.02-.04.13c-.06.19-.1 2.2-.1 5.07 0 2.54.04 4.1.11 4.25.07.14.2.18.57.18.42 0 .57-.05.65-.23.05-.11.06-.34.07-1.76v-1.64s.47-.02.47-.02c.7-.03 1.4-.21 1.83-.46.28-.16.71-.6.83-.85.22-.43.3-.82.33-1.48.06-1.26-.29-2.13-1.07-2.69-.35-.25-.79-.45-1.06-.48-.33-.03-2.06-.06-2.36-.04m5.69.05c-.11.14-.12.28-.14 2.04-.01.97-.03 3.02-.03 4.56v2.79s.16.12.16.12c.25.18.4.22.93.24.78.03 1.73-.09 2.2-.26.65-.24 1.22-.88 1.45-1.61.12-.41.15-.98.15-3.07 0-2.24-.03-2.66-.18-3.13-.15-.44-.29-.67-.6-.97-.23-.22-.34-.3-.63-.44-.19-.09-.41-.19-.48-.21-.3-.09-2.75-.14-2.81-.06m6.25-.01c-.18.03-.23.08-.26.29-.04.24-.07 7.4-.03 8.24.05 1.05.05 1.06.57 1.1.31.02.48-.02.66-.17l.14-.12v-3.95h1.06c1.26-.03 1.27-.03 1.36-.31.06-.22.06-.33 0-.48-.09-.23-.3-.26-1.64-.3l-.77-.02v-3.11h.94c1.26 0 1.91-.04 2.02-.13.13-.1.18-.23.18-.51s-.05-.48-.14-.52c-.07-.03-3.87-.05-4.09-.02m-10.04 1.27c.44.07.82.33.99.66.08.16.08.19.1 1.02l.02.86-.11.2c-.22.41-.41.56-.86.68-.14.04-.44.08-.65.09l-.39.02v-3.62l.33.02c.18.01.44.04.58.07m5.81-.01c.45.06.77.27 1.05.69l.17.26-.02 2.53c-.01 2.52-.01 2.54-.09 2.75-.22.64-.71.9-1.69.9h-.24v-7.22l.29.02c.16.01.4.04.52.05m-7.7 9.56c-.15.07-.36.27-.43.4-.1.22-.05.88.13 1.5.29 1.03 1.11 2.01 2.07 2.47.37.18.64.27.94.32.28.04 1.41.1 2.26.1.35 0 .73.01.85.03l.22.02-.49.52c-.57.6-.78.86-.81 1-.06.28.11.59.39.72q.39.18 1.96-1.38c.85-.85 1.35-1.37 1.39-1.46.09-.17.09-.31 0-.47-.12-.23-1.89-2.05-2.52-2.58-.34-.29-.48-.36-.65-.34-.26.05-.56.32-.61.57-.05.23.14.49 1.02 1.39l.48.5-1.57-.02c-.86-.01-1.65-.04-1.75-.05-.38-.07-.92-.42-1.29-.84-.27-.31-.42-.64-.56-1.28-.19-.88-.22-.93-.48-1.07-.15-.08-.43-.1-.56-.04" fill-rule="evenodd" fill="currentColor"/><path fill="currentColor" d="m14.12 17.19-.95-3.78v4.09c0 .23-.05.4-.15.51s-.24.17-.4.17-.29-.06-.4-.17c-.1-.11-.15-.28-.15-.51v-4.69c0-.26.07-.43.2-.52s.32-.14.55-.14h.37c.22 0 .39.02.49.06s.18.11.22.22c.05.11.1.28.17.51l.86 3.25.86-3.25c.06-.24.12-.41.17-.51s.12-.18.22-.22.26-.06.49-.06h.37c.23 0 .41.04.54.14.13.09.2.26.2.52v4.69c0 .23-.05.4-.15.51s-.24.17-.41.17c-.16 0-.29-.06-.39-.17s-.15-.28-.15-.51v-4.09l-.95 3.78c-.06.25-.11.42-.15.54-.04.11-.11.22-.22.31s-.25.14-.44.14c-.14 0-.26-.03-.36-.09s-.17-.14-.23-.23c-.05-.09-.1-.2-.13-.31s-.06-.23-.09-.36z"/><rect fill="none" height="8.8" rx="1.03" stroke="currentColor" stroke-miterlimit="10" stroke-width=".5" width="9.76" x="9.97" y="10.85"/></symbol></svg></div>
+        </symbol><symbol id="linkeditor-import-markdown" viewBox="0 0 19.97 19.91"><path d="m.45 0-.23.02-.04.13c-.06.19-.1 2.2-.1 5.07 0 2.54.04 4.1.11 4.25.07.14.2.18.57.18.42 0 .57-.05.65-.23.05-.11.06-.34.07-1.76v-1.64s.47-.02.47-.02c.7-.03 1.4-.21 1.83-.46.28-.16.71-.6.83-.85.22-.43.3-.82.33-1.48.06-1.26-.29-2.13-1.07-2.69-.35-.25-.79-.45-1.06-.48-.33-.03-2.06-.06-2.36-.04m5.69.05c-.11.14-.12.28-.14 2.04-.01.97-.03 3.02-.03 4.56v2.79s.16.12.16.12c.25.18.4.22.93.24.78.03 1.73-.09 2.2-.26.65-.24 1.22-.88 1.45-1.61.12-.41.15-.98.15-3.07 0-2.24-.03-2.66-.18-3.13-.15-.44-.29-.67-.6-.97-.23-.22-.34-.3-.63-.44-.19-.09-.41-.19-.48-.21-.3-.09-2.75-.14-2.81-.06m6.25-.01c-.18.03-.23.08-.26.29-.04.24-.07 7.4-.03 8.24.05 1.05.05 1.06.57 1.1.31.02.48-.02.66-.17l.14-.12v-3.95h1.06c1.26-.03 1.27-.03 1.36-.31.06-.22.06-.33 0-.48-.09-.23-.3-.26-1.64-.3l-.77-.02v-3.11h.94c1.26 0 1.91-.04 2.02-.13.13-.1.18-.23.18-.51s-.05-.48-.14-.52c-.07-.03-3.87-.05-4.09-.02m-10.04 1.27c.44.07.82.33.99.66.08.16.08.19.1 1.02l.02.86-.11.2c-.22.41-.41.56-.86.68-.14.04-.44.08-.65.09l-.39.02v-3.62l.33.02c.18.01.44.04.58.07m5.81-.01c.45.06.77.27 1.05.69l.17.26-.02 2.53c-.01 2.52-.01 2.54-.09 2.75-.22.64-.71.9-1.69.9h-.24v-7.22l.29.02c.16.01.4.04.52.05m-7.7 9.56c-.15.07-.36.27-.43.4-.1.22-.05.88.13 1.5.29 1.03 1.11 2.01 2.07 2.47.37.18.64.27.94.32.28.04 1.41.1 2.26.1.35 0 .73.01.85.03l.22.02-.49.52c-.57.6-.78.86-.81 1-.06.28.11.59.39.72q.39.18 1.96-1.38c.85-.85 1.35-1.37 1.39-1.46.09-.17.09-.31 0-.47-.12-.23-1.89-2.05-2.52-2.58-.34-.29-.48-.36-.65-.34-.26.05-.56.32-.61.57-.05.23.14.49 1.02 1.39l.48.5-1.57-.02c-.86-.01-1.65-.04-1.75-.05-.38-.07-.92-.42-1.29-.84-.27-.31-.42-.64-.56-1.28-.19-.88-.22-.93-.48-1.07-.15-.08-.43-.1-.56-.04" fill-rule="evenodd" fill="currentColor"/><path fill="currentColor" d="m14.12 17.19-.95-3.78v4.09c0 .23-.05.4-.15.51s-.24.17-.4.17-.29-.06-.4-.17c-.1-.11-.15-.28-.15-.51v-4.69c0-.26.07-.43.2-.52s.32-.14.55-.14h.37c.22 0 .39.02.49.06s.18.11.22.22c.05.11.1.28.17.51l.86 3.25.86-3.25c.06-.24.12-.41.17-.51s.12-.18.22-.22.26-.06.49-.06h.37c.23 0 .41.04.54.14.13.09.2.26.2.52v4.69c0 .23-.05.4-.15.51s-.24.17-.41.17c-.16 0-.29-.06-.39-.17s-.15-.28-.15-.51v-4.09l-.95 3.78c-.06.25-.11.42-.15.54-.04.11-.11.22-.22.31s-.25.14-.44.14c-.14 0-.26-.03-.36-.09s-.17-.14-.23-.23c-.05-.09-.1-.2-.13-.31s-.06-.23-.09-.36z"/><rect fill="none" height="8.8" rx="1.03" stroke="currentColor" stroke-miterlimit="10" stroke-width=".5" width="9.76" x="9.97" y="10.85"/></symbol><symbol id="linkeditor-auto-links" viewBox="0 0 20 20">
+            <path fill="currentColor" d="M16.4,11.3c0,0-.2,0-.3.2-.3.2-1.5,1.4-1.8,1.7-.2.3-.2.4,0,.6.1.1.3.2.4.2s.5-.3,1.4-1.2l.6-.6.4.3c.2.2.4.4.6.5l.2.2-.6.6c-.8.8-1.1,1.1-1.1,1.3,0,.1,0,.1,0,.3,0,.2.2.3.3.3.2,0,.4,0,.5,0,0,0,1.1-1.1,1.5-1.5.3-.4.4-.5.4-.9,0-.4,0-.5-.8-1.3-.7-.7-.9-.8-1.4-.9-.3,0-.2,0-.4,0M4,12c-.1,0-.3.2-.3.3,0,.2,0,.7,0,1.2.2.8.9,1.5,1.6,1.9.3.1.5.2.7.2.2,0,1.1,0,1.7,0,.3,0,.6,0,.7,0h.2s-.4.4-.4.4c-.4.5-.6.7-.6.8,0,.2,0,.5.3.6q.3.1,1.5-1.1c.7-.7,1-1.1,1.1-1.1,0-.1,0-.2,0-.4,0-.2-1.5-1.6-1.9-2-.3-.2-.4-.3-.5-.3-.2,0-.4.2-.5.4,0,.2.1.4.8,1.1l.4.4h-1.2c-.7,0-1.3,0-1.3,0-.3,0-.7-.3-1-.6-.2-.2-.3-.5-.4-1-.1-.7-.2-.7-.4-.8-.1,0-.3,0-.4,0M15.8,13.7c-.2.1-.6.5-1.2,1.1-.9.9-1.1,1.1-1,1.4,0,.2.4.4.6.4.1,0,.4-.2,1.3-1.1.9-.9,1.1-1.1,1.1-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