|
495 | 495 | (rum/local nil ::src) |
496 | 496 | [state config title href metadata full_text] |
497 | 497 | (let [src (::src state) |
498 | | - ^js js-url (:link-js-url config) |
499 | 498 | href (cond-> href |
500 | | - (nil? js-url) |
501 | | - (config/get-local-asset-absolute-path))] |
| 499 | + (common-config/local-relative-asset? href) |
| 500 | + (config/get-local-asset-absolute-path)) |
| 501 | + ^js js-url (or (:link-js-url config) |
| 502 | + (when (path/protocol-url? href) |
| 503 | + (try |
| 504 | + (js/URL. href) |
| 505 | + (catch :default _ nil))))] |
502 | 506 | (when (nil? @src) |
503 | 507 | (-> (assets-handler/<make-asset-url href js-url) |
504 | 508 | (p/then (fn [url] |
|
562 | 566 | {:on-click (fn [e] |
563 | 567 | (util/stop e) |
564 | 568 | (let [repo-dir (config/get-repo-dir repo) |
565 | | - ext-url (:logseq.property.asset/external-url asset-block) |
566 | | - local-ext-url? (and (not (string/blank? ext-url)) |
567 | | - (common-config/local-relative-asset? ext-url)) |
568 | | - file-fpath (if local-ext-url? |
569 | | - ;; Plugin-sourced asset stored under assets/storages/<plugin-id>/... |
570 | | - (path/path-join repo-dir (string/replace ext-url #"^[./]+" "")) |
571 | | - (path/path-join repo-dir (str "assets/" (:block/uuid asset-block) "." (name ext))))] |
572 | | - (js/window.apis.openPath file-fpath)))} |
| 569 | + ext-url (:logseq.property.asset/external-url asset-block) |
| 570 | + remote-ext-url? (and (not (string/blank? ext-url)) |
| 571 | + (path/protocol-url? ext-url) |
| 572 | + (not (common-config/local-protocol-asset? ext-url))) |
| 573 | + local-ext-url? (and (not (string/blank? ext-url)) |
| 574 | + (common-config/local-relative-asset? ext-url)) |
| 575 | + file-fpath (if local-ext-url? |
| 576 | + ;; Plugin-sourced asset stored under assets/storages/<plugin-id>/... |
| 577 | + (path/path-join repo-dir (string/replace ext-url #"^[./]+" "")) |
| 578 | + (path/path-join repo-dir (str "assets/" (:block/uuid asset-block) "." (name ext))))] |
| 579 | + (if remote-ext-url? |
| 580 | + (js/window.apis.openExternal ext-url) |
| 581 | + (js/window.apis.openPath file-fpath))))} |
573 | 582 | file-name]) |
574 | 583 |
|
575 | 584 | :else |
|
0 commit comments