mirror of
https://github.com/penpot/penpot.git
synced 2025-03-25 22:21:44 -05:00
commit
b1d99232a9
4 changed files with 46 additions and 26 deletions
common/src/app/common/geom
frontend/src/app/main
|
@ -13,6 +13,7 @@
|
|||
:clj [clojure.core :as c])
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.math :as mth]
|
||||
[app.common.spec :as us]
|
||||
[clojure.spec.alpha :as s]
|
||||
|
@ -62,7 +63,7 @@
|
|||
(map->Point v)
|
||||
|
||||
:else
|
||||
(throw (ex-info "Invalid arguments" {:v v}))))
|
||||
(ex/raise :hint "invalid arguments (on pointer constructor)" :value v)))
|
||||
([x y]
|
||||
(Point. x y)))
|
||||
|
||||
|
|
|
@ -216,29 +216,32 @@
|
|||
[file-id {:keys [revn changes] :as params}]
|
||||
(us/verify! ::us/uuid file-id)
|
||||
(us/verify! ::shapes-changes-persisted params)
|
||||
(ptk/reify ::changes-persisted
|
||||
(ptk/reify ::shapes-changes-persisted
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
;; NOTE: we don't set the file features context here because
|
||||
;; there are no useful context for code that need to be executed
|
||||
;; on the frontend side
|
||||
(let [changes (group-by :page-id changes)]
|
||||
(if (= file-id (:current-file-id state))
|
||||
(-> state
|
||||
(update-in [:workspace-file :revn] max revn)
|
||||
(update :workspace-data (fn [file]
|
||||
(loop [fdata file
|
||||
entries (seq changes)]
|
||||
(if-let [[page-id changes] (first entries)]
|
||||
(recur (-> fdata
|
||||
(cp/process-changes changes)
|
||||
(ctst/update-object-indices page-id))
|
||||
(rest entries))
|
||||
fdata)))))
|
||||
|
||||
(if-let [current-file-id (:current-file-id state)]
|
||||
(if (= file-id current-file-id)
|
||||
(let [changes (group-by :page-id changes)]
|
||||
(-> state
|
||||
(update-in [:workspace-file :revn] max revn)
|
||||
(update :workspace-data (fn [file]
|
||||
(loop [fdata file
|
||||
entries (seq changes)]
|
||||
(if-let [[page-id changes] (first entries)]
|
||||
(recur (-> fdata
|
||||
(cp/process-changes changes)
|
||||
(ctst/update-object-indices page-id))
|
||||
(rest entries))
|
||||
fdata))))))
|
||||
(-> state
|
||||
(update-in [:workspace-libraries file-id :revn] max revn)
|
||||
(update-in [:workspace-libraries file-id :data]
|
||||
cp/process-changes changes)))))))
|
||||
(update-in [:workspace-libraries file-id :data] cp/process-changes changes)))
|
||||
|
||||
state))))
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
[app.main.data.workspace.collapse :as dwc]
|
||||
[app.main.data.workspace.state-helpers :as wsh]
|
||||
[app.main.data.workspace.thumbnails :as dwt]
|
||||
[app.main.data.workspace.undo :as dwu]
|
||||
[app.main.data.workspace.zoom :as dwz]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.streams :as ms]
|
||||
|
@ -502,8 +503,11 @@
|
|||
[obj state objects]
|
||||
(let [{:keys [id-original id-duplicated]}
|
||||
(get-in state [:workspace-local :duplicated])]
|
||||
(if (and (not= id-original (:id obj))
|
||||
(not= id-duplicated (:id obj)))
|
||||
(if (or (and (not= id-original (: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
|
||||
;; new frames to the right of the original.
|
||||
|
@ -556,16 +560,21 @@
|
|||
|
||||
frames (into #{}
|
||||
(map #(get-in objects [% :frame-id]))
|
||||
selected)]
|
||||
selected)
|
||||
undo-id (uuid/next)]
|
||||
|
||||
(rx/concat
|
||||
(->> (rx/from dup-frames)
|
||||
(rx/map (fn [[old-id new-id]] (dwt/duplicate-thumbnail old-id new-id))))
|
||||
|
||||
;; Warning: This order is important for the focus mode.
|
||||
(rx/of (dch/commit-changes changes)
|
||||
(select-shapes new-selected)
|
||||
(ptk/data-event :layout/update frames)
|
||||
(memorize-duplicated id-original id-duplicated))))))))))
|
||||
(rx/of
|
||||
(dwu/start-undo-transaction undo-id)
|
||||
(dch/commit-changes changes)
|
||||
(select-shapes new-selected)
|
||||
(ptk/data-event :layout/update frames)
|
||||
(memorize-duplicated id-original id-duplicated)
|
||||
(dwu/commit-undo-transaction undo-id))))))))))
|
||||
|
||||
(defn change-hover-state
|
||||
[id value]
|
||||
|
|
|
@ -30,7 +30,14 @@
|
|||
[error]
|
||||
(cond
|
||||
(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)
|
||||
(ptk/handle-error error)
|
||||
|
@ -49,7 +56,7 @@
|
|||
|
||||
(defmethod ptk/handle-error :default
|
||||
[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)))
|
||||
(js/console.group hint)
|
||||
(ex/ignoring (js/console.error (pr-str error)))
|
||||
|
|
Loading…
Add table
Reference in a new issue