]> _ Git - fluidbook-html5.git/commitdiff
wip #6188 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 14 Sep 2023 13:13:46 +0000 (15:13 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 14 Sep 2023 13:13:46 +0000 (15:13 +0200)
js/libs/fluidbook/fluidbook.search.js
style/fluidbook.less
style/mixins.less

index 9e7b006c64f38020f9f50e11da6c1a72a06cc41e..96b17fae0dc64bbd1e1bb1f5702826b1badf940a 100644 (file)
@@ -357,6 +357,7 @@ FluidbookSearch.prototype = {
     },
 
     _find: function (q, callback) {
+        this.resultPages = [];
         if (this.robust) {
             return this._findRobust(q, callback);
         }
@@ -370,7 +371,7 @@ FluidbookSearch.prototype = {
         var terms = [];
         var total = 0;
         var doublePages = [];
-        this.resultPages = [];
+
 
         var matchedWord, indexWord, searchTerm, term, page;
         var maxPage = this.fluidbook.contentlock.getMaxPage();
@@ -560,9 +561,41 @@ FluidbookSearch.prototype = {
 
     setRobustHighlightTerms: function (terms) {
         let term = terms.join('');
-        let firstLetter = term.split('')[0];
-        var h = {occurences: HIGHLIGHTS[firstLetter], color: 0, word: firstLetter, term: term};
-        this.highlights.push(h);
+        let letters = term.split('');
+
+        let occurences = [];
+
+        for (let i = 0; i < letters.length; i++) {
+            let letter = letters[i];
+            if (i === 0) {
+                occurences = HIGHLIGHTS[letter];
+            } else {
+                let filteredOccurences = [];
+                for (let j in occurences) {
+                    let o = occurences[j];
+                    for (let k in HIGHLIGHTS[letter]) {
+                        if (HIGHLIGHTS[letter][k].o === o.o + i) {
+                            if (o.next === undefined) {
+                                o.next = [];
+                            }
+                            o.next.push(HIGHLIGHTS[letter][k]);
+                            filteredOccurences.push(o);
+                        }
+                    }
+                }
+                occurences = filteredOccurences;
+            }
+        }
+
+        if (!occurences.length) {
+            return;
+        }
+
+        for (let i in occurences) {
+            let o = occurences[i];
+            this.highlights.push({occurences: [o], color: 0, word: term, term: term});
+            this.highlights.push({occurences: o.next, color: 0, word: term, term: term});
+        }
     },
 
     clearHighlights: function () {
@@ -660,9 +693,6 @@ FluidbookSearch.prototype = {
             width: (width + 2 * padding) * z,
             height: (position.height + padding * 3) * z
         };
-        if (this.robust) {
-            coords.width = coords.height;
-        }
         var transform = {};
         if (position.rotation) {
             transform.rotate = -position.rotation + 'deg';
index bdc5b86a42d4496b5c341cf2114242bd6e146884..f8b13ce8bb6dbfbd49e6ca6123ad0aeacd031e43 100644 (file)
@@ -656,6 +656,7 @@ body, html {
   left: 0px;
   z-index: 6;
   pointer-events: none;
+  opacity: 0.3;
 
   .highlight {
     position: absolute;
@@ -665,11 +666,11 @@ body, html {
 
     transform-origin: 0 0;
 
-    &.robust {
-      border-radius: 50% 50%;
-      animation: pulse 1s infinite alternate linear;
-      transform-origin: 50% 50%;
-    }
+    //&.robust {
+    //  border-radius: 50% 50%;
+    //  animation: pulse 1s infinite alternate linear;
+    //  transform-origin: 50% 50%;
+    //}
 
     &[data-color="0"], &[data-color="5"], &[data-color="10"] {
       .highlight-area(#00ff00);
index 43c011050e231cd17d8283a4c079371d0ee3f7b2..127faf94f22956c4c85a0ef116b8d195426e4caf 100644 (file)
@@ -10,9 +10,9 @@
 
 .highlight-area(@color) {
   border-color: @color;
-  background-color: fade(@color, 30%);
-  &.robust{
-    border-color: fade(@color, 35%);
+  background-color: @color;
+  &.robust {
+    border: 0;
   }
 }