mirror of
https://github.com/penpot/penpot.git
synced 2025-05-20 03:26:11 +02:00
🐛 Fixes image upload position when uploading from left sidebar
This commit is contained in:
parent
7378089f4a
commit
b7cbe49cb2
2 changed files with 9 additions and 3 deletions
|
@ -493,7 +493,7 @@
|
||||||
(rx/map #(assoc (first %) :name (.-name (second %))))
|
(rx/map #(assoc (first %) :name (.-name (second %))))
|
||||||
(rx/do on-svg)))))
|
(rx/do on-svg)))))
|
||||||
|
|
||||||
(defn upload-media-objects
|
(defn- upload-media-objects
|
||||||
[{:keys [file-id local? data name uris mtype svg-as-images] :as params}]
|
[{:keys [file-id local? data name uris mtype svg-as-images] :as params}]
|
||||||
(us/assert ::upload-media-objects params)
|
(us/assert ::upload-media-objects params)
|
||||||
(ptk/reify ::upload-media-objects
|
(ptk/reify ::upload-media-objects
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
(ns app.main.ui.workspace.left-toolbar
|
(ns app.main.ui.workspace.left-toolbar
|
||||||
(:require
|
(:require
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
|
[app.common.math :as mth]
|
||||||
[app.common.media :as cm]
|
[app.common.media :as cm]
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.data.workspace.shortcuts :as sc]
|
[app.main.data.workspace.shortcuts :as sc]
|
||||||
|
@ -36,8 +37,13 @@
|
||||||
(mf/deps file)
|
(mf/deps file)
|
||||||
(fn [blobs]
|
(fn [blobs]
|
||||||
(let [params {:file-id (:id file)
|
(let [params {:file-id (:id file)
|
||||||
:data (seq blobs)}]
|
:data (seq blobs)}
|
||||||
(st/emit! (dw/upload-media-workspace params (gpt/point 0 0))))))]
|
;; We don't want to add a ref because that redraws the component
|
||||||
|
;; for everychange. Better direct access on the callback
|
||||||
|
vbox (get-in @st/state [:workspace-local :vbox])
|
||||||
|
x (mth/round (+ (:x vbox) (/ (:width vbox) 2)))
|
||||||
|
y (mth/round (+ (:y vbox) (/ (:height vbox) 2)))]
|
||||||
|
(st/emit! (dw/upload-media-workspace params (gpt/point x y))))))]
|
||||||
|
|
||||||
[:li.tooltip.tooltip-right
|
[:li.tooltip.tooltip-right
|
||||||
{:alt (tr "workspace.toolbar.image")
|
{:alt (tr "workspace.toolbar.image")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue