瀏覽代碼

fix(pdf): incorrect styles for the external window pdf viewer

charlie 9 月之前
父節點
當前提交
4d0fbe11be

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

@@ -146,7 +146,8 @@
         action-fn! (fn [action clear?]
                      (when-let [action (and action (name action))]
                        (let [highlight (if (fn? highlight) (highlight) highlight)
-                             content (:content highlight)]
+                             content (:content highlight)
+                             ^js owner-win (pdf-windows/resolve-own-window viewer)]
                          (case action
                            "ref"
                            (pdf-assets/copy-hl-ref! highlight viewer)
@@ -155,7 +156,7 @@
                            (do
                              (util/copy-to-clipboard!
                               (or (:text content) (pdf-utils/fix-selection-text-breakline (.toString selection)))
-                              :owner-window (pdf-windows/resolve-own-window viewer))
+                              :owner-window owner-win)
                              (pdf-utils/clear-all-selection))
 
                            "link"
@@ -178,7 +179,7 @@
                                                       {:id         (pdf-utils/gen-uuid)
                                                        :properties properties})]
                                  (p/let [highlight' (add-hl! highlight)]
-                                   (pdf-utils/clear-all-selection)
+                                   (pdf-utils/clear-all-selection owner-win)
                                    (pdf-assets/copy-hl-ref! highlight' viewer)))
 
 ;; update highlight

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

@@ -105,8 +105,9 @@
           (js/console.error e)))))))
 
 (defn clear-all-selection
-  []
-  (.removeAllRanges (js/window.getSelection)))
+  ([] (clear-all-selection js/window))
+  ([^js win]
+   (some-> win (.getSelection) (.removeAllRanges))))
 
 (def adjust-viewer-size!
   (util/debounce

+ 1 - 0
src/main/frontend/extensions/pdf/windows.cljs

@@ -93,6 +93,7 @@
                   (.appendChild (.-head doc) base)
                   (set! (.-title doc) (or (:filename pdf-current) "Logseq"))
                   (set! (.-dataset doc-el) -theme (str theme-mode))
+                  (set! (.-dataset doc-el) -color (or (some-> (state/sub :ui/radix-color) (name)) "logseq"))
                   (resolve-classes! doc)
                   (resolve-styles! doc)
                   (.appendChild (.-body doc) main)