Ver código fonte

fix: can't update highlight color

Tienson Qin 1 ano atrás
pai
commit
b74fcd57e7

+ 4 - 9
src/main/frontend/extensions/pdf/assets.cljs

@@ -279,15 +279,10 @@
 
 (defn update-hl-block!
   [highlight]
-  (let [db-based? (config/db-based-graph?)]
-    (when-let [block (db-model/get-block-by-uuid (:id highlight))]
-      (doseq [[k v] {(if db-based? :logseq.property.pdf/hl-image :hl-stamp)
-                     (if (area-highlight? highlight)
-                       (get-in highlight [:content :image])
-                       (js/Date.now))
-                     (pu/get-pid :logseq.property/hl-color)
-                     (get-in highlight [:properties :color])}]
-        (property-handler/set-block-property! (state/get-current-repo) (:block/uuid block) k v)))))
+  (when-let [block (db-model/get-block-by-uuid (:id highlight))]
+    (when-let [color (get-in highlight [:properties :color])]
+      (let [k (pu/get-pid :logseq.property/hl-color)]
+        (property-handler/set-block-property! (state/get-current-repo) (:block/uuid block) k color)))))
 
 (defn unlink-hl-area-image$
   [^js _viewer current hl]

+ 4 - 3
src/main/frontend/extensions/pdf/core.cljs

@@ -565,8 +565,8 @@
                           highlights' (conj highlights hl)]
                       (set-highlights! highlights')
 
-                      (when-let [vw-pos (and (pdf-assets/area-highlight? hl)
-                                             (pdf-utils/scaled-to-vw-pos viewer (:position hl)))]
+                      (if-let [vw-pos (and (pdf-assets/area-highlight? hl)
+                                           (pdf-utils/scaled-to-vw-pos viewer (:position hl)))]
                         ;; exceptions
                         (->
                          (p/let [result (pdf-assets/persist-hl-area-image$ viewer (:pdf/current @state/state)
@@ -576,7 +576,8 @@
                                (set-highlights! (map (fn [hl] (if (= (:id hl) (:id hl')) hl' hl)) highlights'))
                                hl')))
                          (p/catch (fn [e]
-                                    (js/console.error e))))))))
+                                    (js/console.error e))))
+                        hl))))
         upd-hl! (fn [hl]
                   (let [highlights (pdf-utils/fix-nested-js highlights)]
                     (when-let [[target-idx] (medley/find-first