mirror of
https://github.com/penpot/penpot.git
synced 2025-06-05 07:31:38 +02:00
commit
b1d99232a9
4 changed files with 46 additions and 26 deletions
|
@ -13,6 +13,7 @@
|
||||||
:clj [clojure.core :as c])
|
:clj [clojure.core :as c])
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
|
[app.common.exceptions :as ex]
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
|
@ -62,7 +63,7 @@
|
||||||
(map->Point v)
|
(map->Point v)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(throw (ex-info "Invalid arguments" {:v v}))))
|
(ex/raise :hint "invalid arguments (on pointer constructor)" :value v)))
|
||||||
([x y]
|
([x y]
|
||||||
(Point. x y)))
|
(Point. x y)))
|
||||||
|
|
||||||
|
|
|
@ -216,14 +216,16 @@
|
||||||
[file-id {:keys [revn changes] :as params}]
|
[file-id {:keys [revn changes] :as params}]
|
||||||
(us/verify! ::us/uuid file-id)
|
(us/verify! ::us/uuid file-id)
|
||||||
(us/verify! ::shapes-changes-persisted params)
|
(us/verify! ::shapes-changes-persisted params)
|
||||||
(ptk/reify ::changes-persisted
|
(ptk/reify ::shapes-changes-persisted
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
;; NOTE: we don't set the file features context here because
|
;; NOTE: we don't set the file features context here because
|
||||||
;; there are no useful context for code that need to be executed
|
;; there are no useful context for code that need to be executed
|
||||||
;; on the frontend side
|
;; on the frontend side
|
||||||
|
|
||||||
|
(if-let [current-file-id (:current-file-id state)]
|
||||||
|
(if (= file-id current-file-id)
|
||||||
(let [changes (group-by :page-id changes)]
|
(let [changes (group-by :page-id changes)]
|
||||||
(if (= file-id (:current-file-id state))
|
|
||||||
(-> state
|
(-> state
|
||||||
(update-in [:workspace-file :revn] max revn)
|
(update-in [:workspace-file :revn] max revn)
|
||||||
(update :workspace-data (fn [file]
|
(update :workspace-data (fn [file]
|
||||||
|
@ -234,11 +236,12 @@
|
||||||
(cp/process-changes changes)
|
(cp/process-changes changes)
|
||||||
(ctst/update-object-indices page-id))
|
(ctst/update-object-indices page-id))
|
||||||
(rest entries))
|
(rest entries))
|
||||||
fdata)))))
|
fdata))))))
|
||||||
(-> state
|
(-> state
|
||||||
(update-in [:workspace-libraries file-id :revn] max revn)
|
(update-in [:workspace-libraries file-id :revn] max revn)
|
||||||
(update-in [:workspace-libraries file-id :data]
|
(update-in [:workspace-libraries file-id :data] cp/process-changes changes)))
|
||||||
cp/process-changes changes)))))))
|
|
||||||
|
state))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
[app.main.data.workspace.collapse :as dwc]
|
[app.main.data.workspace.collapse :as dwc]
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[app.main.data.workspace.thumbnails :as dwt]
|
[app.main.data.workspace.thumbnails :as dwt]
|
||||||
|
[app.main.data.workspace.undo :as dwu]
|
||||||
[app.main.data.workspace.zoom :as dwz]
|
[app.main.data.workspace.zoom :as dwz]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.streams :as ms]
|
[app.main.streams :as ms]
|
||||||
|
@ -502,8 +503,11 @@
|
||||||
[obj state objects]
|
[obj state objects]
|
||||||
(let [{:keys [id-original id-duplicated]}
|
(let [{:keys [id-original id-duplicated]}
|
||||||
(get-in state [:workspace-local :duplicated])]
|
(get-in state [:workspace-local :duplicated])]
|
||||||
(if (and (not= id-original (:id obj))
|
(if (or (and (not= id-original (:id obj))
|
||||||
(not= id-duplicated (:id obj)))
|
(not= id-duplicated (:id obj)))
|
||||||
|
;; As we can remove duplicated elements may be we can still caching a deleted id
|
||||||
|
(not (contains? objects id-original))
|
||||||
|
(not (contains? objects id-duplicated)))
|
||||||
|
|
||||||
;; The default is leave normal shapes in place, but put
|
;; The default is leave normal shapes in place, but put
|
||||||
;; new frames to the right of the original.
|
;; new frames to the right of the original.
|
||||||
|
@ -556,16 +560,21 @@
|
||||||
|
|
||||||
frames (into #{}
|
frames (into #{}
|
||||||
(map #(get-in objects [% :frame-id]))
|
(map #(get-in objects [% :frame-id]))
|
||||||
selected)]
|
selected)
|
||||||
|
undo-id (uuid/next)]
|
||||||
|
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(->> (rx/from dup-frames)
|
(->> (rx/from dup-frames)
|
||||||
(rx/map (fn [[old-id new-id]] (dwt/duplicate-thumbnail old-id new-id))))
|
(rx/map (fn [[old-id new-id]] (dwt/duplicate-thumbnail old-id new-id))))
|
||||||
|
|
||||||
;; Warning: This order is important for the focus mode.
|
;; Warning: This order is important for the focus mode.
|
||||||
(rx/of (dch/commit-changes changes)
|
(rx/of
|
||||||
|
(dwu/start-undo-transaction undo-id)
|
||||||
|
(dch/commit-changes changes)
|
||||||
(select-shapes new-selected)
|
(select-shapes new-selected)
|
||||||
(ptk/data-event :layout/update frames)
|
(ptk/data-event :layout/update frames)
|
||||||
(memorize-duplicated id-original id-duplicated))))))))))
|
(memorize-duplicated id-original id-duplicated)
|
||||||
|
(dwu/commit-undo-transaction undo-id))))))))))
|
||||||
|
|
||||||
(defn change-hover-state
|
(defn change-hover-state
|
||||||
[id value]
|
[id value]
|
||||||
|
|
|
@ -30,7 +30,14 @@
|
||||||
[error]
|
[error]
|
||||||
(cond
|
(cond
|
||||||
(instance? ExceptionInfo error)
|
(instance? ExceptionInfo error)
|
||||||
(-> error ex-data ptk/handle-error)
|
(let [data (ex-data error)]
|
||||||
|
(if (contains? data :type)
|
||||||
|
(ptk/handle-error data)
|
||||||
|
(let [hint (str/ffmt "Unexpected error: '%'" (ex-message error))]
|
||||||
|
(ts/schedule #(st/emit! (rt/assign-exception error)))
|
||||||
|
(js/console.group hint)
|
||||||
|
(js/console.log (.-stack error))
|
||||||
|
(js/console.groupEnd hint))))
|
||||||
|
|
||||||
(map? error)
|
(map? error)
|
||||||
(ptk/handle-error error)
|
(ptk/handle-error error)
|
||||||
|
@ -49,7 +56,7 @@
|
||||||
|
|
||||||
(defmethod ptk/handle-error :default
|
(defmethod ptk/handle-error :default
|
||||||
[error]
|
[error]
|
||||||
(let [hint (str/concat "Unexpected error: " (:hint error))]
|
(let [hint (str/ffmt "Unhandled error: '%'" (:hint error "[no hint]"))]
|
||||||
(ts/schedule #(st/emit! (rt/assign-exception error)))
|
(ts/schedule #(st/emit! (rt/assign-exception error)))
|
||||||
(js/console.group hint)
|
(js/console.group hint)
|
||||||
(ex/ignoring (js/console.error (pr-str error)))
|
(ex/ignoring (js/console.error (pr-str error)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue