0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-04 13:50:12 -05:00

Shareable link pointing to a specific board

This commit is contained in:
Marina López 2024-12-09 12:22:35 +01:00 committed by Alonso Torres
parent ea43a999e9
commit b18ee859b1
8 changed files with 562 additions and 455 deletions

View file

@ -11,6 +11,7 @@
### :sparkles: New features
- New gradients UI with multi-stop support.
- Shareable link pointing to an specific board.
### :bug: Bugs fixed

View file

@ -254,6 +254,22 @@
(dwsl/initialize-shape-layout)
(fetch-libraries file-id))))))
(defn zoom-to-frame
[]
(ptk/reify ::zoom-to-frame
ptk/WatchEvent
(watch [_ state _]
(let [params (rt/get-params state)
board-id (get params :board-id)
board-id (cond
(vector? board-id) board-id
(string? board-id) [board-id])
frames-id (->> board-id
(map uuid/uuid)
(into (d/ordered-set)))]
(rx/of (dws/select-shapes frames-id)
dwz/zoom-to-selected-shape)))))
(defn- fetch-bundle
"Multi-stage file bundle fetch coordinator"
[file-id]
@ -290,7 +306,6 @@
:features features
:thumbnails thumbnails})))))
(rx/map bundle-fetched)))
(rx/take-until stopper-s))))))
(defn initialize-workspace
@ -334,6 +349,13 @@
(rx/take 1)
(rx/map #(dwl/go-to-local-component :id component-id))))
(when (:board-id rparams)
(->> stream
(rx/filter (ptk/type? ::workspace-initialized))
(rx/observe-on :async)
(rx/take 1)
(rx/map zoom-to-frame)))
(->> stream
(rx/filter dch/commit?)
(rx/map deref)
@ -1913,6 +1935,13 @@
(update [_ state]
(assoc-in state [:workspace-global :show-distances?] value))))
(defn copy-link-to-clipboard
[]
(ptk/reify ::copy-link-to-clipboard
ptk/WatchEvent
(watch [_ _ _]
(wapi/write-to-clipboard (rt/get-current-href)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Interactions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View file

@ -26,6 +26,7 @@
[app.main.data.workspace.undo :as dwu]
[app.main.data.workspace.zoom :as dwz]
[app.main.refs :as refs]
[app.main.router :as rt]
[app.main.streams :as ms]
[app.main.worker :as uw]
[app.util.mouse :as mse]
@ -138,12 +139,25 @@
ptk/WatchEvent
(watch [_ state _]
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)]
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
selected-id (wsh/lookup-selected state)
selected (wsh/lookup-shapes state selected-id)
frame-ids (map (fn [item] (let [parent (cfh/get-frame objects (:id item))]
(:id parent))) selected)
params-without-board (-> (rt/get-params state)
(dissoc :board-id))
params-board (-> (rt/get-params state)
(assoc :board-id frame-ids))]
(rx/of
(dwc/expand-all-parents [id] objects)
:interrupt
::dwsp/interrupt))))))
::dwsp/interrupt)
(if (some #(= % uuid/zero) frame-ids)
(rx/of (rt/nav :workspace params-without-board {::rt/replace true}))
(rx/of (rt/nav :workspace params-board {::rt/replace true}))))))))
(defn select-prev-shape
([]

View file

@ -85,6 +85,11 @@
:subsections [:edit]
:fn #(st/emit! (dw/copy-selected))}
:copy-link {:tooltip (ds/meta (ds/alt "C"))
:command (ds/c-mod "alt+c")
:subsections [:edit]
:fn #(st/emit! (dw/copy-link-to-clipboard))}
:cut {:tooltip (ds/meta "X")
:command (ds/c-mod "x")
:subsections [:edit]

View file

@ -138,6 +138,8 @@
::mf/private true}
[]
(let [do-copy #(st/emit! (dw/copy-selected))
do-copy-link #(st/emit! (dw/copy-link-to-clipboard))
do-cut #(st/emit! (dw/copy-selected)
(dw/delete-selected))
do-paste #(st/emit! (dw/paste-from-clipboard))
@ -146,6 +148,9 @@
[:> menu-entry* {:title (tr "workspace.shape.menu.copy")
:shortcut (sc/get-tooltip :copy)
:on-click do-copy}]
[:> menu-entry* {:title (tr "workspace.shape.menu.copy_link")
:shortcut (sc/get-tooltip :copy-link)
:on-click do-copy-link}]
[:> menu-entry* {:title (tr "workspace.shape.menu.cut")
:shortcut (sc/get-tooltip :cut)
:on-click do-cut}]

View file

@ -91,6 +91,7 @@
(tr "shortcuts.bring-front")
(tr "shortcuts.clear-undo")
(tr "shortcuts.copy")
(tr "shortcuts.copy-link")
(tr "shortcuts.create-component")
(tr "shortcuts.create-new-project")
(tr "shortcuts.cut")

File diff suppressed because it is too large Load diff

View file

@ -3341,6 +3341,9 @@ msgstr "Limpiar historial"
msgid "shortcuts.copy"
msgstr "Copiar"
msgid "shortcuts.copy-link"
msgstr "Copiar enlace al portapapeles"
#: src/app/main/ui/workspace/sidebar/shortcuts.cljs:94
msgid "shortcuts.create-component"
msgstr "Crear componente"
@ -5940,6 +5943,9 @@ msgstr "Enviar atrás"
msgid "workspace.shape.menu.copy"
msgstr "Copiar"
msgid "workspace.shape.menu.copy_link"
msgstr "Copiar enlace al portapapeles"
#: src/app/main/ui/workspace/sidebar/assets/common.cljs:427
msgid "workspace.shape.menu.create-annotation"
msgstr "Crear una nota"