Merge branch 'staging' into develop

This commit is contained in:
Andrey Antukh 2022-01-26 12:16:50 +01:00
commit e1a88ae899
9 changed files with 110 additions and 51 deletions

View file

@ -1247,7 +1247,7 @@
(defn update-shape-flags
[ids {:keys [blocked hidden] :as flags}]
(us/verify (s/coll-of ::us/uuid) ids)
(s/assert ::shape-attrs flags)
(us/assert ::shape-attrs flags)
(ptk/reify ::update-shape-flags
ptk/WatchEvent
(watch [_ state _]
@ -1449,7 +1449,6 @@
(defn show-shape-context-menu
[{:keys [shape] :as params}]
(us/verify (s/nilable ::cp/minimal-shape) shape)
(ptk/reify ::show-shape-context-menu
ptk/WatchEvent
(watch [_ state _]
@ -1858,7 +1857,7 @@
(defn paste-text
[text]
(s/assert string? text)
(us/assert string? text)
(ptk/reify ::paste-text
ptk/WatchEvent
(watch [_ state _]
@ -1887,7 +1886,7 @@
(defn- paste-svg
[text]
(s/assert string? text)
(us/assert string? text)
(ptk/reify ::paste-svg
ptk/WatchEvent
(watch [_ state _]

View file

@ -16,6 +16,7 @@
[app.main.ui.icons :as i]
[app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]]
[cuerdas.core :as str]
[rumext.alpha :as mf]))
(mf/defc header
@ -63,9 +64,11 @@
(if (:edition @local)
[:& inline-edition {:content (:name project)
:on-end (fn [name]
(st/emit! (-> (dd/rename-project (assoc project :name name))
(with-meta {::ev/origin "project"})))
(swap! local assoc :edition false))}]
(let [name (str/trim name)]
(when-not (str/empty? name)
(st/emit! (-> (dd/rename-project (assoc project :name name))
(with-meta {::ev/origin "project"}))))
(swap! local assoc :edition false)))}]
[:div.dashboard-title
[:h1 {:on-double-click on-edit}
(:name project)]]))

View file

@ -18,6 +18,7 @@
[app.util.i18n :as i18n :refer [tr]]
[app.util.router :as rt]
[app.util.time :as dt]
[cuerdas.core :as str]
[okulary.core :as l]
[rumext.alpha :as mf]))
@ -73,9 +74,11 @@
(mf/use-callback
(mf/deps project)
(fn [name]
(st/emit! (-> (dd/rename-project (assoc project :name name))
(with-meta {::ev/origin "dashboard"})))
(swap! local assoc :edition? false)))
(let [name (str/trim name)]
(when-not (str/empty? name)
(st/emit! (-> (dd/rename-project (assoc project :name name))
(with-meta {::ev/origin "dashboard"}))))
(swap! local assoc :edition? false))))
on-file-created
(mf/use-callback

View file

@ -46,8 +46,8 @@
(on-stop-edit)
(swap! local assoc :edition false)
(st/emit! (dw/end-rename-shape)
(when-not (str/empty? name)
(dw/update-shape (:id shape) {:name name})))))
(when-not (str/empty? (str/trim name))
(dw/update-shape (:id shape) {:name (str/trim name)})))))
cancel-edit (fn []
(on-stop-edit)

View file

@ -18,6 +18,7 @@
[app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd]
[cuerdas.core :as str]
[okulary.core :as l]
[rumext.alpha :as mf]))
@ -66,8 +67,9 @@
(mf/use-callback
(fn [event]
(let [target (dom/event->target event)
name (dom/get-value target)]
(st/emit! (dw/rename-page id name))
name (str/trim (dom/get-value target))]
(when-not (str/empty? name)
(st/emit! (dw/rename-page id name)))
(swap! local assoc :edition false))))
on-key-down

View file

@ -316,6 +316,11 @@
(->> (rx/of node)
(rx/observe-on :async))))
(defn media-node? [node]
(and (cip/shape? node)
(cip/has-image? node)
(not (cip/close? node))))
(defn import-page
[context file [page-id page-name content]]
(let [nodes (->> content cip/node-seq)
@ -326,18 +331,29 @@
(assoc :id (resolve page-id)))
flows (->> (get-in page-data [:options :flows])
(mapv #(update % :starting-frame resolve)))
guides (->> (get-in page-data [:options :guides])
(d/mapm #(update %2 :frame-id resolve)))
page-data (d/assoc-in-when page-data [:options :flows] flows)
file (-> file (fb/add-page page-data))
page-data (-> page-data
(d/assoc-in-when [:options :flows] flows)
(d/assoc-in-when [:options :guides] guides))
file (-> file (fb/add-page page-data))]
(->> (rx/from nodes)
(rx/filter cip/shape?)
(rx/merge-map (partial resolve-media context file-id))
(rx/reduce (partial process-import-node context) file)
(rx/map (comp fb/close-page setup-interactions)))))
;; Preprocess nodes to parallel upload the images. Store the result in a table
;; old-node => node with image
;; that will be used in the second pass immediately
pre-process-images
(->> (rx/from nodes)
(rx/filter media-node?)
(rx/merge-map
(fn [node]
(->> (resolve-media context file-id node)
(rx/map (fn [result] [node result])))))
(rx/reduce conj {}))]
(->> pre-process-images
(rx/flat-map
(fn [pre-proc]
(->> (rx/from nodes)
(rx/filter cip/shape?)
(rx/map (fn [node] (or (get pre-proc node) node)))
(rx/reduce (partial process-import-node context) file)
(rx/map (comp fb/close-page setup-interactions))))))))
(defn import-component [context file node]
(let [resolve (:resolve context)
@ -357,7 +373,7 @@
(rx/filter cip/shape?)
(rx/skip 1)
(rx/skip-last 1)
(rx/merge-map (partial resolve-media context file-id))
(rx/mapcat (partial resolve-media context file-id))
(rx/reduce (partial process-import-node context) file)
(rx/map fb/finish-component))))
@ -377,7 +393,6 @@
(fn [[page-id page-name]]
(->> (get-file context :page page-id)
(rx/map (fn [page-data] [page-id page-name page-data])))))
(rx/concat-reduce (partial import-page context) file))))
(defn process-library-colors
@ -416,7 +431,7 @@
(let [resolve (:resolve context)]
(->> (get-file context :media-list)
(rx/flat-map (comp d/kebab-keys cip/string->uuid))
(rx/merge-map
(rx/mapcat
(fn [[id media]]
(let [media (assoc media :id (resolve id))]
(->> (get-file context :media id media)