Browse Source

electron: create url window

charlie 3 years ago
parent
commit
df107f1e2e
1 changed files with 21 additions and 0 deletions
  1. 21 0
      src/electron/electron/window.cljs

+ 21 - 0
src/electron/electron/window.cljs

@@ -94,6 +94,27 @@
   []
   (.getAllWindows BrowserWindow))
 
+(defn create-url-window! [url opts]
+  (let [win-opts (merge
+                   {:width                600
+                    :height               400
+                    :frame                true
+                    :trafficLightPosition {:x 16 :y 16}
+                    :autoHideMenuBar      (not utils/mac?)
+                    :webPreferences
+                    {:plugins                 true          ; pdf
+                     :nodeIntegration         false
+                     :nodeIntegrationInWorker false
+                     :webSecurity             true
+                     :contextIsolation        true
+                     :spellcheck              ((fnil identity true) (cfgs/get-item :spell-check))
+                     ;; Remove OverlayScrollbars and transition `.scrollbar-spacing`
+                     ;; to use `scollbar-gutter` after the feature is implemented in browsers.
+                     :enableBlinkFeatures     'OverlayScrollbars'}}
+                   opts)
+        ^js win (BrowserWindow. (clj->js win-opts))]
+    (.loadURL win url)))
+
 (defn get-graph-all-windows
   [graph-path] ;; graph-path == dir
   (->> (group-by second (:window/graph @state/state))