Просмотр исходного кода

fix(pdf): incorrect area highlight logic for file graph

charlie 8 месяцев назад
Родитель
Сommit
099c5eb358

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

@@ -127,6 +127,7 @@
             (println "[existed ref block]" ref-block)
             ref-block)
           (let [text (:text content)
+                area? (not (nil? (:image content)))
                 wrap-props #(if-let [stamp (:image content)]
                               (assoc %
                                 :hl-type :area
@@ -139,10 +140,11 @@
                 properties (wrap-props props)]
             (when (string? text)
               (editor-handler/api-insert-new-block!
-               text (merge {:page        (:block/name ref-page)
-                            :custom-uuid id
-                            :properties properties}
-                           insert-opts)))))))))
+                text (merge {:page (:block/name ref-page)
+                             :custom-uuid id
+                             :edit-block? (not area?)
+                             :properties properties}
+                       insert-opts)))))))))
 
 (defn db-based-ensure-ref-block!
   [pdf-current {:keys [id content page properties] :as hl} insert-opts]

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

@@ -572,10 +572,11 @@
                                         (pdf-utils/scaled-to-vw-pos viewer (:position hl)))]
                         (-> (p/let [result (pdf-assets/persist-hl-area-image$ viewer (:pdf/current @state/state)
                                              hl nil (:bounding vw-pos))]
-                              (when (de/entity? result)
+                              (if (de/entity? result)
                                 (let [hl' (assoc-in hl [:content :image] (:db/id result))]
                                   (set-highlights! (map (fn [hl] (if (= (:id hl) (:id hl')) hl' hl)) highlights'))
-                                  hl')))
+                                  hl')
+                                hl))
                           (p/catch (fn [e] (js/console.error e))))
                         hl))))
         upd-hl! (fn [hl]