mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05:00
🎉 Add open url action
This commit is contained in:
parent
4697a1904a
commit
57245dd77e
8 changed files with 56 additions and 13 deletions
|
@ -204,6 +204,12 @@
|
|||
shape
|
||||
objects
|
||||
:center))))
|
||||
(defn set-url
|
||||
[interaction url]
|
||||
(us/verify ::interaction interaction)
|
||||
(us/verify ::url url)
|
||||
(assert (= (:action-type interaction) :open-url))
|
||||
(assoc interaction :url url))
|
||||
|
||||
(defn set-overlay-pos-type
|
||||
[interaction overlay-pos-type shape objects]
|
||||
|
@ -217,7 +223,6 @@
|
|||
shape
|
||||
objects
|
||||
overlay-pos-type)))
|
||||
|
||||
(defn toggle-overlay-pos-type
|
||||
[interaction overlay-pos-type shape objects]
|
||||
(us/verify ::interaction interaction)
|
||||
|
@ -233,7 +238,6 @@
|
|||
shape
|
||||
objects
|
||||
new-pos-type))))
|
||||
|
||||
(defn set-overlay-position
|
||||
[interaction overlay-position]
|
||||
(us/verify ::interaction interaction)
|
||||
|
|
|
@ -67,8 +67,10 @@
|
|||
(st/emit! (dv/close-overlay frame-id)))
|
||||
|
||||
:prev-screen
|
||||
(do
|
||||
(st/emit! (rt/nav-back-local)))
|
||||
(st/emit! (rt/nav-back-local))
|
||||
|
||||
:open-url
|
||||
(st/emit! (dom/open-new-window (:url interaction)))
|
||||
|
||||
nil))
|
||||
|
||||
|
|
|
@ -39,7 +39,8 @@
|
|||
:open-overlay (tr "workspace.options.interaction-open-overlay")
|
||||
:toggle-overlay (tr "workspace.options.interaction-toggle-overlay")
|
||||
:close-overlay (tr "workspace.options.interaction-close-overlay")
|
||||
:prev-screen (tr "workspace.options.interaction-prev-screen")})
|
||||
:prev-screen (tr "workspace.options.interaction-prev-screen")
|
||||
:open-url (tr "workspace.options.interaction-open-url")})
|
||||
|
||||
(defn- action-summary
|
||||
[interaction destination]
|
||||
|
@ -53,6 +54,7 @@
|
|||
:close-overlay (tr "workspace.options.interaction-close-overlay-dest"
|
||||
(get destination :name (tr "workspace.options.interaction-self")))
|
||||
:prev-screen (tr "workspace.options.interaction-prev-screen")
|
||||
:open-url (tr "workspace.options.interaction-open-url")
|
||||
"--"))
|
||||
|
||||
(defn- overlay-pos-type-names
|
||||
|
@ -106,6 +108,11 @@
|
|||
value (when (not= value "") (uuid/uuid value))]
|
||||
(update-interaction index #(cti/set-destination % value shape objects))))
|
||||
|
||||
change-url
|
||||
(fn [event]
|
||||
(let [value (-> event dom/get-target dom/get-value)]
|
||||
(update-interaction index #(cti/set-url % value))))
|
||||
|
||||
change-overlay-pos-type
|
||||
(fn [event]
|
||||
(let [value (-> event dom/get-target dom/get-value d/read-string)]
|
||||
|
@ -186,6 +193,13 @@
|
|||
(not= (:id frame) (:frame-id shape))) ; nor a shape to its container frame
|
||||
[:option {:value (str (:id frame))} (:name frame)]))]])
|
||||
|
||||
; URL
|
||||
(when (= action-type :open-url)
|
||||
[:div.interactions-element
|
||||
[:span.element-set-subtitle.wide (tr "workspace.options.interaction-url")]
|
||||
[:input.input-text {:default-value (str (:url interaction))
|
||||
:on-blur change-url}]])
|
||||
|
||||
(when (or (= action-type :open-overlay)
|
||||
(= action-type :toggle-overlay))
|
||||
[:*
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
goog.provide("app.util.browser_history");
|
||||
goog.require("goog.history.Html5History");
|
||||
|
||||
|
||||
goog.scope(function() {
|
||||
const self = app.util.browser_history;
|
||||
const Html5History = goog.history.Html5History;
|
||||
|
|
|
@ -394,3 +394,14 @@
|
|||
(defn left-mouse? [bevent]
|
||||
(let [event (.-nativeEvent ^js bevent)]
|
||||
(= 1 (.-which event))))
|
||||
|
||||
(defn open-new-window
|
||||
([uri]
|
||||
(open-new-window uri "_blank"))
|
||||
([uri name]
|
||||
(js/window.open (str uri) name)))
|
||||
|
||||
(defn browser-back
|
||||
[]
|
||||
(.back (.-history js/window)))
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
[app.common.uri :as u]
|
||||
[app.config :as cfg]
|
||||
[app.util.browser-history :as bhistory]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.timers :as ts]
|
||||
[beicon.core :as rx]
|
||||
[goog.events :as e]
|
||||
|
@ -110,14 +111,13 @@
|
|||
uri (-> (u/uri cfg/public-uri)
|
||||
(assoc :fragment path))
|
||||
name (str (name id) "-" (:file-id params))]
|
||||
(js/window.open (str uri) name))))
|
||||
(dom/open-new-window (str uri) name))))
|
||||
|
||||
(defn nav-new-window
|
||||
([id] (nav-new-window id nil nil))
|
||||
([id params] (nav-new-window id params nil))
|
||||
([id params qparams] (NavigateNewWindow. id params qparams)))
|
||||
|
||||
|
||||
(defn nav-new-window*
|
||||
[{:keys [rname path-params query-params name]}]
|
||||
(ptk/reify ::nav-new-window
|
||||
|
@ -127,17 +127,14 @@
|
|||
path (resolve router rname path-params query-params)
|
||||
uri (-> (u/uri cfg/public-uri)
|
||||
(assoc :fragment path))]
|
||||
|
||||
|
||||
|
||||
(js/window.open (str uri) name)))))
|
||||
(dom/open-new-window (str uri) name)))))
|
||||
|
||||
(defn nav-back
|
||||
[]
|
||||
(ptk/reify ::nav-back
|
||||
ptk/EffectEvent
|
||||
(effect [_ _ _]
|
||||
(ts/asap #(.back (.-history js/window))))))
|
||||
(ts/asap dom/browser-back))))
|
||||
|
||||
(defn nav-back-local
|
||||
"Navigate back only if the previous page is in penpot app."
|
||||
|
|
|
@ -2465,6 +2465,10 @@ msgstr "On Click"
|
|||
msgid "workspace.options.interaction-open-overlay"
|
||||
msgstr "Open overlay"
|
||||
|
||||
#: src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs
|
||||
msgid "workspace.options.interaction-open-url"
|
||||
msgstr "Open url"
|
||||
|
||||
#: src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs
|
||||
msgid "workspace.options.interaction-prev-screen"
|
||||
msgstr "Previous screen"
|
||||
|
@ -2481,6 +2485,10 @@ msgstr "Open overlay: %s"
|
|||
msgid "workspace.options.interaction-toggle-overlay-dest"
|
||||
msgstr "Toggle overlay: %s"
|
||||
|
||||
#: src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs
|
||||
msgid "workspace.options.interaction-url"
|
||||
msgstr "URL"
|
||||
|
||||
#: src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs
|
||||
msgid "workspace.options.interaction-pos-manual"
|
||||
msgstr "Manual"
|
||||
|
|
|
@ -2348,6 +2348,10 @@ msgstr "En click"
|
|||
msgid "workspace.options.interaction-open-overlay"
|
||||
msgstr "Superposición"
|
||||
|
||||
#: src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs
|
||||
msgid "workspace.options.interaction-open-url"
|
||||
msgstr "Abrir url"
|
||||
|
||||
#: src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs
|
||||
msgid "workspace.options.interaction-prev-screen"
|
||||
msgstr "Pantalla anterior"
|
||||
|
@ -2364,6 +2368,10 @@ msgstr "Superposición: %s"
|
|||
msgid "workspace.options.interaction-toggle-overlay-dest"
|
||||
msgstr "Alternar superpos.: %s"
|
||||
|
||||
#: src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs
|
||||
msgid "workspace.options.interaction-url"
|
||||
msgstr "URL"
|
||||
|
||||
#: src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs
|
||||
msgid "workspace.options.interaction-pos-manual"
|
||||
msgstr "Manual"
|
||||
|
|
Loading…
Add table
Reference in a new issue