feat: open image in browser if external

This commit is contained in:
Konstantinos Kaloutas
2022-09-01 17:31:34 +03:00
committed by Andelf
parent e4cf242b84
commit fcbb09f240
2 changed files with 19 additions and 18 deletions

View File

@@ -282,15 +282,17 @@
:title title}
metadata)]
[:.asset-overlay]
[:.asset-action-bar
(when (and (util/electron?) local?)
[:button.asset-action-btn.text-left
{:title "Show item in folder"
:on-mouse-down util/stop
:on-click (fn [e]
((util/stop e)
(js/window.apis.showItemInFolder (string/replace src #"^assets://" ""))))}
title])
(let [image-src (string/replace src #"^assets://" "")]
[:.asset-action-bar
[:button.asset-action-btn.text-left
{:title (if local? "Show item in folder" "Open image")
:on-mouse-down util/stop
:on-click (fn [e]
(util/stop e)
(if (and (util/electron?) local?)
(js/window.apis.showItemInFolder image-src)
(js/window.apis.openExternal src)))}
image-src]
[:.flex
[:button.asset-action-btn
{:title "Delete image"
@@ -320,13 +322,12 @@
{:title "Copy image"
:on-mouse-down util/stop
:on-click (fn [e]
(let [image-src (string/replace src #"^assets://" "")]
(util/stop e)
(-> (js/fetch image-src)
(.then (fn [data]
(-> (.blob data)
(.then (fn [blob]
(js/navigator.clipboard.write (clj->js [(js/ClipboardItem. (clj->js {(.-type blob) blob}))]))))))))))}
(util/stop e)
(-> (js/fetch image-src)
(.then (fn [data]
(-> (.blob data)
(.then (fn [blob]
(js/navigator.clipboard.write (clj->js [(js/ClipboardItem. (clj->js {(.-type blob) blob}))])))))))))}
(ui/icon "copy")]
[:button.asset-action-btn
@@ -350,7 +351,7 @@
(when (seq images)
(lightbox/preview-images! images))))}
(ui/icon "maximize")]]]]))))
(ui/icon "maximize")]]])]))))
(rum/defc audio-cp [src]
[:audio {:src src

View File

@@ -58,7 +58,7 @@
}
.asset-action-btn {
@apply m-1 p-1 rounded;
@apply m-1 p-1 rounded truncate;
opacity: 0.8;
user-select: none;