Преглед изворни кода

fix: improve search precision

Tienson Qin пре 4 година
родитељ
комит
4f80bb6139
3 измењених фајлова са 11 додато и 8 уклоњено
  1. 8 6
      resources/css/common.css
  2. 2 1
      src/main/frontend/components/search.cljs
  3. 1 1
      src/main/frontend/search.cljs

+ 8 - 6
resources/css/common.css

@@ -225,12 +225,6 @@ pre.code {
 
 
 }
 }
 
 
-mark {
-  background: #fef3ac;
-  color: #262626;
-  padding: 0 1px;
-}
-
 dl {
 dl {
   margin: 1rem 0;
   margin: 1rem 0;
 }
 }
@@ -735,11 +729,19 @@ a.navigation {
 /* text mark/highlight */
 /* text mark/highlight */
 
 
 mark {
 mark {
+    background: #fef3ac;
+    color: #262626;
     padding: 2px 4px;
     padding: 2px 4px;
     border-radius: 3px;
     border-radius: 3px;
     font-size: 14px;
     font-size: 14px;
 }
 }
 
 
+/* search results */
+.search-results mark {
+    padding: 0;
+    border-radius: 0;
+}
+
 /* page reference */
 /* page reference */
 
 
 .page-reference {
 .page-reference {

+ 2 - 1
src/main/frontend/components/search.cljs

@@ -152,7 +152,8 @@
                  :width 500})}
                  :width 500})}
        (ui/auto-complete
        (ui/auto-complete
         result
         result
-        {:on-chosen (fn [{:keys [type data]}]
+        {:class "search-results"
+         :on-chosen (fn [{:keys [type data]}]
                       (search-handler/clear-search!)
                       (search-handler/clear-search!)
                       (leave-focus)
                       (leave-focus)
                       (case type
                       (case type

+ 1 - 1
src/main/frontend/search.cljs

@@ -39,7 +39,7 @@
                         (clj->js {:keys ["uuid" "content"]
                         (clj->js {:keys ["uuid" "content"]
                                   :shouldSort true
                                   :shouldSort true
                                   :minMatchCharLength 2
                                   :minMatchCharLength 2
-                                  :threshold 0.4}))]
+                                  :threshold 0.2}))]
       (swap! indices assoc-in [repo :blocks] indice)
       (swap! indices assoc-in [repo :blocks] indice)
       indice)))
       indice)))