Prechádzať zdrojové kódy

fix(pdf): support the raw path under win32 that included backslash for pdf local resource

charlie 4 rokov pred
rodič
commit
e62e2d8ed6

+ 1 - 0
src/main/frontend/extensions/pdf/pdf.css

@@ -673,6 +673,7 @@ body.is-pdf-active {
 
   #sidebar-nav-wrapper {
     border: none !important;
+    display: none;
   }
 
   #head {

+ 1 - 2
src/main/frontend/util.cljc

@@ -15,7 +15,6 @@
             [goog.object :as gobj]
             [goog.string :as gstring]
             [goog.userAgent]
-            ["path" :as nodePath]
             [promesa.core :as p]))
   (:require
    [clojure.core.async :as async]
@@ -33,7 +32,7 @@
      (-pr-writer [sym writer _]
        (-write writer (str "\"" (.toString sym) "\"")))))
 
-#?(:cljs (defonce ^js node-path nodePath))
+#?(:cljs (defonce ^js node-path utils/nodePath))
 #?(:cljs (defn app-scroll-container-node []
            (gdom/getElement "main-container")))
 

+ 14 - 1
src/main/frontend/utils.js

@@ -1,3 +1,5 @@
+import path from 'path'
+
 if (typeof window === 'undefined') {
   global.window = {}
 }
@@ -265,4 +267,15 @@ export const writeClipboard = (text, isHtml) => {
       })
     }
   })
-}
+}
+
+export const toPosixPath = (input) => {
+  return input && input.replace(/\\+/g, '/')
+}
+
+export const nodePath = Object.assign({}, path, {
+  basename (input) {
+    input = toPosixPath(input)
+    return path.basename(input)
+  }
+})