mirror of
https://github.com/penpot/penpot.git
synced 2025-03-17 10:11:22 -05:00
Merge remote-tracking branch 'origin/staging' into develop
This commit is contained in:
commit
d268ff2952
7 changed files with 92 additions and 55 deletions
|
@ -98,6 +98,7 @@
|
|||
- Fix undo when updating several texts [Taiga #5197](https://tree.taiga.io/project/penpot/issue/5197)
|
||||
- Fix assets right click button for multiple selection [Taiga #5545](https://tree.taiga.io/project/penpot/issue/5545)
|
||||
- Fix problem with precision in resizes [Taiga #5623](https://tree.taiga.io/project/penpot/issue/5623)
|
||||
- Fix absolute positioned layouts not showing flex properties [Taiga #5630](https://tree.taiga.io/project/penpot/issue/5630)
|
||||
|
||||
### :arrow_up: Deps updates
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
|
||||
(defn update-shapes
|
||||
([ids update-fn] (update-shapes ids update-fn nil))
|
||||
([ids update-fn {:keys [reg-objects? save-undo? stack-undo? attrs ignore-tree page-id ignore-remote? ignore-touched]
|
||||
([ids update-fn {:keys [reg-objects? save-undo? stack-undo? attrs ignore-tree page-id ignore-remote? ignore-touched undo-group]
|
||||
:or {reg-objects? false save-undo? true stack-undo? false ignore-remote? false ignore-touched false}}]
|
||||
(dm/assert! (sm/coll-of-uuid? ids))
|
||||
(dm/assert! (fn? update-fn))
|
||||
|
@ -78,7 +78,9 @@
|
|||
(-> (pcb/empty-changes it page-id)
|
||||
(pcb/set-save-undo? save-undo?)
|
||||
(pcb/set-stack-undo? stack-undo?)
|
||||
(pcb/with-objects objects))
|
||||
(pcb/with-objects objects)
|
||||
(cond-> undo-group
|
||||
(pcb/set-undo-group undo-group)))
|
||||
ids)
|
||||
changes (pcb/reorder-grid-children changes ids)
|
||||
changes (add-undo-group changes state)]
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
|
||||
;; Add & select the created shape to the workspace
|
||||
(rx/concat
|
||||
(if (or (cph/text-shape? shape) (cph/frame-shape? shape))
|
||||
(if (cph/frame-shape? shape)
|
||||
(rx/of (dwu/start-undo-transaction (:id shape)))
|
||||
(rx/empty))
|
||||
|
||||
|
|
|
@ -77,6 +77,10 @@
|
|||
(pcb/with-objects objects)
|
||||
(prepare-add-shape shape objects selected))
|
||||
|
||||
changes (cond-> changes
|
||||
(cph/text-shape? shape)
|
||||
(pcb/set-undo-group (:id shape)))
|
||||
|
||||
undo-id (js/Symbol)]
|
||||
|
||||
(rx/concat
|
||||
|
|
|
@ -156,8 +156,8 @@
|
|||
(cond-> new-shape?
|
||||
(assoc :name text))
|
||||
(cond-> (or (some? width) (some? height))
|
||||
(gsh/transform-shape (ctm/change-size shape width height)))))))
|
||||
(dwu/commit-undo-transaction (:id shape))))))
|
||||
(gsh/transform-shape (ctm/change-size shape width height))))))
|
||||
{:undo-group (when new-shape? id)})))))
|
||||
|
||||
(when (some? id)
|
||||
(rx/of (dws/deselect-shape id)
|
||||
|
|
|
@ -11,8 +11,12 @@
|
|||
[app.common.logging :as log]
|
||||
[app.common.pages.changes :as cpc]
|
||||
[app.common.schema :as sm]
|
||||
[app.util.time :as dt]
|
||||
[beicon.core :as rx]
|
||||
[potok.core :as ptk]))
|
||||
|
||||
(def discard-transaction-time-millis (* 20 1000))
|
||||
|
||||
;; Change this to :info :debug or :trace to debug this module
|
||||
(log/set-level! :warn)
|
||||
|
||||
|
@ -107,10 +111,18 @@
|
|||
(def empty-tx
|
||||
{:undo-changes [] :redo-changes []})
|
||||
|
||||
(declare check-open-transactions)
|
||||
|
||||
(defn start-undo-transaction
|
||||
"Start a transaction, so that every changes inside are added together in a single undo entry."
|
||||
[id]
|
||||
(ptk/reify ::start-undo-transaction
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(->> (rx/of (check-open-transactions))
|
||||
;; Wait the configured time
|
||||
(rx/delay discard-transaction-time-millis)))
|
||||
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(log/info :msg "start-undo-transaction")
|
||||
|
@ -120,21 +132,24 @@
|
|||
(cond-> state
|
||||
(nil? current-tx) (assoc-in [:workspace-undo :transaction] empty-tx)
|
||||
(nil? pending-tx) (assoc-in [:workspace-undo :transactions-pending] #{id})
|
||||
(some? pending-tx) (update-in [:workspace-undo :transactions-pending] conj id))))))
|
||||
(some? pending-tx) (update-in [:workspace-undo :transactions-pending] conj id)
|
||||
:always (update-in [:workspace-undo :transactions-pending-ts] assoc id (dt/now)))))))
|
||||
|
||||
(defn discard-undo-transaction []
|
||||
(ptk/reify ::discard-undo-transaction
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(log/info :msg "discard-undo-transaction")
|
||||
(update state :workspace-undo dissoc :transaction :transactions-pending))))
|
||||
(update state :workspace-undo dissoc :transaction :transactions-pending :transactions-pending-ts))))
|
||||
|
||||
(defn commit-undo-transaction [id]
|
||||
(ptk/reify ::commit-undo-transaction
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(log/info :msg "commit-undo-transaction")
|
||||
(let [state (update-in state [:workspace-undo :transactions-pending] disj id)]
|
||||
(let [state (-> state
|
||||
(update-in [:workspace-undo :transactions-pending] disj id)
|
||||
(update-in [:workspace-undo :transactions-pending-ts] dissoc id))]
|
||||
(if (empty? (get-in state [:workspace-undo :transactions-pending]))
|
||||
(-> state
|
||||
(add-undo-entry (get-in state [:workspace-undo :transaction]))
|
||||
|
@ -147,3 +162,17 @@
|
|||
(update [_ state]
|
||||
(assoc state :workspace-undo {}))))
|
||||
|
||||
(defn check-open-transactions
|
||||
[]
|
||||
(ptk/reify ::check-open-transactions
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(log/info :msg "check-open-transactions")
|
||||
(let [pending-ts (-> (dm/get-in state [:workspace-undo :transactions-pending-ts])
|
||||
(update-vals #(.toMillis (dt/diff (dt/now) %))))]
|
||||
(->> pending-ts
|
||||
(filter (fn [[_ ts]] (>= ts discard-transaction-time-millis)))
|
||||
(rx/from)
|
||||
(rx/tap #(js/console.warn (dm/str "FORCE COMMIT TRANSACTION AFTER " (second %) "MS")))
|
||||
(rx/map first)
|
||||
(rx/map commit-undo-transaction))))))
|
||||
|
|
|
@ -231,7 +231,9 @@
|
|||
|
||||
on-change-z-index
|
||||
(fn [value]
|
||||
(st/emit! (dwsl/update-layout-child ids {:layout-item-z-index value})))]
|
||||
(st/emit! (dwsl/update-layout-child ids {:layout-item-z-index value})))
|
||||
|
||||
is-layout-child? (and is-layout-child? (not is-absolute?))]
|
||||
|
||||
[:div.element-set
|
||||
[:div.element-set-title
|
||||
|
@ -249,7 +251,7 @@
|
|||
"Layout element")]]
|
||||
|
||||
[:div.element-set-content.layout-item-menu
|
||||
(when is-layout-child?
|
||||
(when (or is-layout-child? is-absolute?)
|
||||
[:div.layout-row
|
||||
[:div.row-title.sizing "Position"]
|
||||
[:div.btn-wrapper
|
||||
|
@ -275,53 +277,52 @@
|
|||
:disabled (not is-absolute?)
|
||||
:value (:layout-item-z-index values)}]]]])
|
||||
|
||||
(when (not (:layout-item-absolute values))
|
||||
[:*
|
||||
[:*
|
||||
[:div.layout-row
|
||||
[:div.row-title.sizing "Sizing"]
|
||||
[:& element-behavior {:is-layout-child? is-layout-child?
|
||||
:is-layout-container? is-layout-container?
|
||||
:layout-item-v-sizing (or (:layout-item-v-sizing values) :fix)
|
||||
:layout-item-h-sizing (or (:layout-item-h-sizing values) :fix)
|
||||
:on-change-behavior on-change-behavior}]]
|
||||
|
||||
(when is-layout-child?
|
||||
[:div.layout-row
|
||||
[:div.row-title.sizing "Sizing"]
|
||||
[:& element-behavior {:is-layout-child? is-layout-child?
|
||||
:is-layout-container? is-layout-container?
|
||||
:layout-item-v-sizing (or (:layout-item-v-sizing values) :fix)
|
||||
:layout-item-h-sizing (or (:layout-item-h-sizing values) :fix)
|
||||
:on-change-behavior on-change-behavior}]]
|
||||
[:div.row-title "Align"]
|
||||
[:div.btn-wrapper
|
||||
[:& align-self-row {:is-col? is-col?
|
||||
:align-self align-self
|
||||
:set-align-self set-align-self}]]])
|
||||
|
||||
(when (and is-layout-child? is-flex-parent?)
|
||||
[:div.layout-row
|
||||
[:div.row-title "Align"]
|
||||
[:div.btn-wrapper
|
||||
[:& align-self-row {:is-col? is-col?
|
||||
:align-self align-self
|
||||
:set-align-self set-align-self}]]])
|
||||
(when is-layout-child?
|
||||
[:& margin-section {:values values
|
||||
:change-margin-style change-margin-style
|
||||
:on-margin-change on-margin-change}])
|
||||
|
||||
(when is-layout-child?
|
||||
[:& margin-section {:values values
|
||||
:change-margin-style change-margin-style
|
||||
:on-margin-change on-margin-change}])
|
||||
[:div.advanced-ops-body
|
||||
[:div.input-wrapper
|
||||
(for [item (cond-> []
|
||||
(= (:layout-item-h-sizing values) :fill)
|
||||
(conj :layout-item-min-w :layout-item-max-w)
|
||||
|
||||
[:div.advanced-ops-body
|
||||
[:div.input-wrapper
|
||||
(for [item (cond-> []
|
||||
(= (:layout-item-h-sizing values) :fill)
|
||||
(conj :layout-item-min-w :layout-item-max-w)
|
||||
(= (:layout-item-v-sizing values) :fill)
|
||||
(conj :layout-item-min-h :layout-item-max-h))]
|
||||
|
||||
(= (:layout-item-v-sizing values) :fill)
|
||||
(conj :layout-item-min-h :layout-item-max-h))]
|
||||
|
||||
[:div.tooltip.tooltip-bottom
|
||||
{:key (d/name item)
|
||||
:alt (tr (dm/str "workspace.options.layout-item.title." (d/name item)))
|
||||
:class (dom/classnames "maxH" (= item :layout-item-max-h)
|
||||
"minH" (= item :layout-item-min-h)
|
||||
"maxW" (= item :layout-item-max-w)
|
||||
"minW" (= item :layout-item-min-w))}
|
||||
[:div.input-element
|
||||
{:alt (tr (dm/str "workspace.options.layout-item." (d/name item)))}
|
||||
[:> numeric-input
|
||||
{:no-validate true
|
||||
:min 0
|
||||
:data-wrap true
|
||||
:placeholder "--"
|
||||
:on-focus #(dom/select-target %)
|
||||
:on-change (partial on-size-change item)
|
||||
:value (get values item)
|
||||
:nillable true}]]])]]])]]))
|
||||
[:div.tooltip.tooltip-bottom
|
||||
{:key (d/name item)
|
||||
:alt (tr (dm/str "workspace.options.layout-item.title." (d/name item)))
|
||||
:class (dom/classnames "maxH" (= item :layout-item-max-h)
|
||||
"minH" (= item :layout-item-min-h)
|
||||
"maxW" (= item :layout-item-max-w)
|
||||
"minW" (= item :layout-item-min-w))}
|
||||
[:div.input-element
|
||||
{:alt (tr (dm/str "workspace.options.layout-item." (d/name item)))}
|
||||
[:> numeric-input
|
||||
{:no-validate true
|
||||
:min 0
|
||||
:data-wrap true
|
||||
:placeholder "--"
|
||||
:on-focus #(dom/select-target %)
|
||||
:on-change (partial on-size-change item)
|
||||
:value (get values item)
|
||||
:nillable true}]]])]]]]]))
|
||||
|
|
Loading…
Add table
Reference in a new issue