Tienson Qin 4 лет назад
Родитель
Сommit
de7c6584fb
3 измененных файлов с 19 добавлено и 13 удалено
  1. 13 6
      src/main/frontend/components/block.cljs
  2. 2 3
      src/main/frontend/extensions/pdf/pdf.css
  3. 4 4
      yarn.lock

+ 13 - 6
src/main/frontend/components/block.cljs

@@ -437,12 +437,18 @@
         inner))))
 
 (rum/defc asset-reference
-  [title path]
+  [config title path]
   (let [repo-path (config/get-repo-dir (state/get-current-repo))
         full-path (.. util/node-path (join repo-path (config/get-local-asset-absolute-path path)))
         ext-name (util/get-file-ext full-path)
-        ext-name (and ext-name (string/lower-case ext-name))]
-
+        ext-name (and ext-name (string/lower-case ext-name))
+        title-or-path (cond
+                        (string? title)
+                        title
+                        (seq title)
+                        (->elem :span (map-inline config title))
+                        :else
+                        path)]
     [:div.asset-ref-wrap
      {:data-ext ext-name}
 
@@ -454,8 +460,9 @@
                      (when-let [current (pdf-assets/inflate-asset (util/node-path.basename full-path))]
                        (state/set-state! :pdf/current current)
                        (.preventDefault e)))}
-        (or title path)]
-       [:a.asset-ref {:target "_blank" :href full-path} (or title path)])
+        title-or-path]
+       [:a.asset-ref {:target "_blank" :href full-path}
+        title-or-path])
 
      (case ext-name
        ;; https://en.wikipedia.org/wiki/HTML5_video
@@ -843,7 +850,7 @@
 
           (and (util/electron?)
                (show-link? config metadata s full_text))
-          (asset-reference (second (first label)) s)
+          (asset-reference config label s)
 
           ;; open file externally if s is "../assets/<...>"
           (and (util/electron?)

+ 2 - 3
src/main/frontend/extensions/pdf/pdf.css

@@ -503,8 +503,9 @@
 .asset-ref {
   &.is-pdf {
     &:before {
-      content: "[[📙";
+      content: "[[📚";
       opacity: .4;
+      margin-right: 4px;
     }
 
     &:after {
@@ -654,5 +655,3 @@ body.is-pdf-active {
   mix-blend-mode: multiply;
   color: unset;
 }
-
-

+ 4 - 4
yarn.lock

@@ -6165,10 +6165,10 @@ mkdirp@^0.5.0, mkdirp@^0.5.4, mkdirp@~0.5.1:
   dependencies:
     minimist "^1.2.5"
 
[email protected].4:
-  version "0.9.4"
-  resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-0.9.4.tgz#80dd027e06a297ef4bbbabd28793a40f64bcb451"
-  integrity sha512-Pt994A4XGG1rDdU5tvR8quk1WdlD0eTmo+UWo37qndLaHFxt++lTT7UK8WX3cj0HamJlx8WiYWQO3gOWIzL+dw==
[email protected].5:
+  version "0.9.5"
+  resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-0.9.5.tgz#e030977a48033b286752b8aeaa7b75505c22a8fa"
+  integrity sha512-5KqxnXmMhVt4nT0xp3SH22FLPWfRDArUbuU/+gTuDUbFa89Adr9q2HyaVtXmUypcg39RIKH8xn/c1jRx1IViag==
   dependencies:
     yargs "^12.0.2"