0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-14 08:41:48 -05:00

Merge remote-tracking branch 'origin/staging' into develop

This commit is contained in:
Alejandro Alonso 2023-01-12 13:14:25 +01:00
commit c39c58198d
34 changed files with 295 additions and 200 deletions

View file

@ -54,6 +54,7 @@
- Fix problem with SVG imports with style [#2605](https://github.com/penpot/penpot/issues/2605) - Fix problem with SVG imports with style [#2605](https://github.com/penpot/penpot/issues/2605)
- Fix ghost shapes after sync groups in components [Taiga #4649](https://tree.taiga.io/project/penpot/issue/4649) - Fix ghost shapes after sync groups in components [Taiga #4649](https://tree.taiga.io/project/penpot/issue/4649)
- Fix layer orders messed up on move, group, reparent and undo [Github #2672](https://github.com/penpot/penpot/issues/2672) - Fix layer orders messed up on move, group, reparent and undo [Github #2672](https://github.com/penpot/penpot/issues/2672)
- Fix max height in library dialog [Github #2335](https://github.com/penpot/penpot/issues/2335)
## 1.16.2-beta ## 1.16.2-beta

View file

@ -962,7 +962,8 @@
[{:keys [pool] :as cfg} {:keys [::rpc/profile-id file-id] :as params}] [{:keys [pool] :as cfg} {:keys [::rpc/profile-id file-id] :as params}]
(db/with-atomic [conn pool] (db/with-atomic [conn pool]
(check-edition-permissions! conn profile-id file-id) (check-edition-permissions! conn profile-id file-id)
(ignore-sync conn params))) (-> (ignore-sync conn params)
(update :features db/decode-pgarray #{}))))
;; --- MUTATION COMMAND: upsert-file-object-thumbnail ;; --- MUTATION COMMAND: upsert-file-object-thumbnail

View file

@ -19,7 +19,6 @@
(def precision 6) (def precision 6)
;; --- Matrix Impl ;; --- Matrix Impl
(defrecord Matrix [^double a (defrecord Matrix [^double a
^double b ^double b
^double c ^double c
@ -28,13 +27,23 @@
^double f] ^double f]
Object Object
(toString [_] (toString [_]
(str "matrix(" #?(:clj
(mth/precision a precision) "," (dm/fmt "matrix(%, %, %, %, %, %)"
(mth/precision b precision) "," (mth/precision a precision)
(mth/precision c precision) "," (mth/precision b precision)
(mth/precision d precision) "," (mth/precision c precision)
(mth/precision e precision) "," (mth/precision d precision)
(mth/precision f precision) ")"))) (mth/precision e precision)
(mth/precision f precision))
:cljs
(dm/fmt "matrix(%, %, %, %, %, %)"
(.toFixed a precision)
(.toFixed b precision)
(.toFixed c precision)
(.toFixed d precision)
(.toFixed e precision)
(.toFixed f precision)))))
(defn matrix? (defn matrix?
"Return true if `v` is Matrix instance." "Return true if `v` is Matrix instance."

View file

@ -41,7 +41,7 @@
(:width parent-rect) (:width parent-rect)
:else :else
(+ box-width (- box-x prev-x) (/ layout-gap-row 2))) (+ box-width (- box-x prev-x) (/ layout-gap-col 2)))
height height
(cond (cond
@ -52,7 +52,7 @@
(:height parent-rect) (:height parent-rect)
:else :else
(+ box-height (- box-y prev-y) (/ layout-gap-col 2)))] (+ box-height (- box-y prev-y) (/ layout-gap-row 2)))]
(if row? (if row?
(let [half-point-width (+ (- box-x x) (/ box-width 2))] (let [half-point-width (+ (- box-x x) (/ box-width 2))]
@ -87,14 +87,14 @@
(if row? (if row?
(:width frame) (:width frame)
(+ line-width margin-x (+ line-width margin-x
(if row? (* layout-gap-row (dec num-children)) 0))) (if row? (* layout-gap-col (dec num-children)) 0)))
line-height line-height
(if col? (if col?
(:height frame) (:height frame)
(+ line-height margin-y (+ line-height margin-y
(if col? (if col?
(* layout-gap-col (dec num-children)) (* layout-gap-row (dec num-children))
0))) 0)))
box-x box-x
@ -122,7 +122,7 @@
(:width frame) (:width frame)
:else :else
(+ line-width (- box-x prev-x) (/ layout-gap-row 2))) (+ line-width (- box-x prev-x) (/ layout-gap-col 2)))
height (cond height (cond
(and row? last?) (and row? last?)
@ -132,7 +132,7 @@
(:height frame) (:height frame)
:else :else
(+ line-height (- box-y prev-y) (/ layout-gap-col 2)))] (+ line-height (- box-y prev-y) (/ layout-gap-row 2)))]
(gsr/make-rect x y width height))) (gsr/make-rect x y width height)))
(defn layout-drop-areas (defn layout-drop-areas

View file

@ -77,8 +77,8 @@
next-max-width (+ child-margin-width (if fill-width? child-max-width child-width)) next-max-width (+ child-margin-width (if fill-width? child-max-width child-width))
next-max-height (+ child-margin-height (if fill-height? child-max-height child-height)) next-max-height (+ child-margin-height (if fill-height? child-max-height child-height))
next-line-min-width (+ line-min-width next-min-width (* layout-gap-row num-children)) next-line-min-width (+ line-min-width next-min-width (* layout-gap-col num-children))
next-line-min-height (+ line-min-height next-min-height (* layout-gap-col num-children))] next-line-min-height (+ line-min-height next-min-height (* layout-gap-row num-children))]
(if (and (some? line-data) (if (and (some? line-data)
(or (not wrap?) (or (not wrap?)
@ -168,20 +168,20 @@
(let [[total-min-width total-min-height total-max-width total-max-height] (let [[total-min-width total-min-height total-max-width total-max-height]
(->> layout-lines (reduce add-ranges [0 0 0 0])) (->> layout-lines (reduce add-ranges [0 0 0 0]))
get-layout-width (fn [{:keys [num-children]}] (- layout-width (* layout-gap-row (dec num-children)))) get-layout-width (fn [{:keys [num-children]}] (- layout-width (* layout-gap-col (dec num-children))))
get-layout-height (fn [{:keys [num-children]}] (- layout-height (* layout-gap-col (dec num-children)))) get-layout-height (fn [{:keys [num-children]}] (- layout-height (* layout-gap-row (dec num-children))))
num-lines (count layout-lines) num-lines (count layout-lines)
;; When align-items is stretch we need to adjust the main axis size to grow for the full content ;; When align-items is stretch we need to adjust the main axis size to grow for the full content
stretch-width-fix stretch-width-fix
(if (and col? (ctl/content-stretch? parent)) (if (and col? (ctl/content-stretch? parent))
(/ (- layout-width (* layout-gap-row (dec num-lines)) total-max-width) num-lines) (/ (- layout-width (* layout-gap-col (dec num-lines)) total-max-width) num-lines)
0) 0)
stretch-height-fix stretch-height-fix
(if (and row? (ctl/content-stretch? parent)) (if (and row? (ctl/content-stretch? parent))
(/ (- layout-height (* layout-gap-col (dec num-lines)) total-max-height) num-lines) (/ (- layout-height (* layout-gap-row (dec num-lines)) total-max-height) num-lines)
0) 0)
;; Distributes the space between the layout lines based on its max/min constraints ;; Distributes the space between the layout lines based on its max/min constraints
@ -200,7 +200,7 @@
(map #(assoc % :line-height (+ (:line-max-height %) stretch-height-fix))) (map #(assoc % :line-height (+ (:line-max-height %) stretch-height-fix)))
(and row? (< total-min-height layout-height total-max-height)) (and row? (< total-min-height layout-height total-max-height))
(distribute-space :line-height :line-min-height :line-max-height total-min-height (- layout-height (* (dec num-lines) layout-gap-col))) (distribute-space :line-height :line-min-height :line-max-height total-min-height (- layout-height (* (dec num-lines) layout-gap-row)))
(and col? (>= total-min-width layout-width)) (and col? (>= total-min-width layout-width))
(map #(assoc % :line-width (:line-min-width %))) (map #(assoc % :line-width (:line-min-width %)))
@ -209,7 +209,7 @@
(map #(assoc % :line-width (+ (:line-max-width %) stretch-width-fix))) (map #(assoc % :line-width (+ (:line-max-width %) stretch-width-fix)))
(and col? (< total-min-width layout-width total-max-width)) (and col? (< total-min-width layout-width total-max-width))
(distribute-space :line-width :line-min-width :line-max-width total-min-width (- layout-width (* (dec num-lines) layout-gap-row)))) (distribute-space :line-width :line-min-width :line-max-width total-min-width (- layout-width (* (dec num-lines) layout-gap-col))))
[total-width total-height] (->> layout-lines (reduce add-lines [0 0])) [total-width total-height] (->> layout-lines (reduce add-lines [0 0]))
@ -231,7 +231,7 @@
[layout-gap-row layout-gap-col] (ctl/gaps shape) [layout-gap-row layout-gap-col] (ctl/gaps shape)
layout-gap-row layout-gap-col
(cond (and row? space-around?) (cond (and row? space-around?)
0 0
@ -239,9 +239,9 @@
(/ (- width line-width) (dec num-children)) (/ (- width line-width) (dec num-children))
:else :else
layout-gap-row) layout-gap-col)
layout-gap-col layout-gap-row
(cond (and col? space-around?) (cond (and col? space-around?)
0 0
@ -249,7 +249,7 @@
(/ (- height line-height) (dec num-children)) (/ (- height line-height) (dec num-children))
:else :else
layout-gap-col) layout-gap-row)
margin-x margin-x
(if (and row? space-around?) (if (and row? space-around?)

View file

@ -29,8 +29,8 @@
lines-gap-row (* (dec num-lines) layout-gap-row) lines-gap-row (* (dec num-lines) layout-gap-row)
lines-gap-col (* (dec num-lines) layout-gap-col) lines-gap-col (* (dec num-lines) layout-gap-col)
free-width-gap (- layout-width total-width lines-gap-row) free-width-gap (- layout-width total-width lines-gap-col)
free-height-gap (- layout-height total-height lines-gap-col) free-height-gap (- layout-height total-height lines-gap-row)
free-width (- layout-width total-width) free-width (- layout-width total-width)
free-height (- layout-height total-height)] free-height (- layout-height total-height)]
@ -87,7 +87,7 @@
(/ free-width (inc num-lines)) (/ free-width (inc num-lines))
:else :else
layout-gap-row) layout-gap-col)
line-gap-col line-gap-col
(cond (cond
@ -101,14 +101,14 @@
(/ free-height (inc num-lines)) (/ free-height (inc num-lines))
:else :else
layout-gap-col)] layout-gap-row)]
(cond-> base-p (cond-> base-p
row? row?
(gpt/add (vv (+ line-height (max layout-gap-col line-gap-col)))) (gpt/add (vv (+ line-height (max layout-gap-row line-gap-col))))
col? col?
(gpt/add (hv (+ line-width (max layout-gap-row line-gap-row))))))) (gpt/add (hv (+ line-width (max layout-gap-col line-gap-row)))))))
(defn get-start-line (defn get-start-line
"Cross axis line. It's position is fixed along the different lines" "Cross axis line. It's position is fixed along the different lines"
@ -128,8 +128,8 @@
content-stretch? (ctl/content-stretch? parent) content-stretch? (ctl/content-stretch? parent)
hv (partial gpo/start-hv layout-bounds) hv (partial gpo/start-hv layout-bounds)
vv (partial gpo/start-vv layout-bounds) vv (partial gpo/start-vv layout-bounds)
children-gap-width (* layout-gap-row (dec num-children)) children-gap-width (* layout-gap-col (dec num-children))
children-gap-height (* layout-gap-col (dec num-children)) children-gap-height (* layout-gap-row (dec num-children))
line-height line-height
(if (and row? content-stretch?) (if (and row? content-stretch?)
@ -257,12 +257,12 @@
next-p next-p
(cond-> start-p (cond-> start-p
row? row?
(-> (gpt/add (hv (+ child-width layout-gap-row))) (-> (gpt/add (hv (+ child-width layout-gap-col)))
(gpt/add (hv (+ margin-left margin-right)))) (gpt/add (hv (+ margin-left margin-right))))
col? col?
(-> (gpt/add (vv (+ margin-top margin-bottom))) (-> (gpt/add (vv (+ margin-top margin-bottom)))
(gpt/add (vv (+ child-height layout-gap-col)))) (gpt/add (vv (+ child-height layout-gap-row))))
(some? margin-x) (some? margin-x)
(gpt/add (hv margin-x)) (gpt/add (hv margin-x))

View file

@ -148,11 +148,9 @@
(or (= :row layout-flex-dir) (= :reverse-row layout-flex-dir))) (or (= :row layout-flex-dir) (= :reverse-row layout-flex-dir)))
(defn gaps (defn gaps
[{:keys [layout-gap layout-gap-type]}] [{:keys [layout-gap]}]
(let [layout-gap-row (or (-> layout-gap :row-gap) 0) (let [layout-gap-row (or (-> layout-gap :row-gap) 0)
layout-gap-col (if (= layout-gap-type :simple) layout-gap-col (or (-> layout-gap :column-gap) 0)]
layout-gap-row
(or (-> layout-gap :column-gap) 0))]
[layout-gap-row layout-gap-col])) [layout-gap-row layout-gap-col]))
(defn child-min-width (defn child-min-width

View file

@ -626,6 +626,7 @@
border-radius: $br-medium; border-radius: $br-medium;
height: 664px; height: 664px;
width: 920px; width: 920px;
max-height: 100%;
.modal-content { .modal-content {
display: flex; display: flex;

View file

@ -119,6 +119,19 @@
} }
} }
} }
& .view-only-mode {
color: $color-primary;
border: 1px solid $color-primary;
border-radius: 3px;
font-size: 10px;
text-transform: uppercase;
display: flex;
align-items: center;
justify-content: center;
margin-left: auto;
padding: 0.25rem;
}
} }
& .focus-title { & .focus-title {

View file

@ -76,6 +76,11 @@
display: none; display: none;
} }
} }
&:hover {
svg {
fill: $color-gray-20;
}
}
} }
.view-options { .view-options {

View file

@ -812,11 +812,14 @@
layouts-to-update layouts-to-update
(into #{} (into #{}
(filter (partial ctl/layout? objects)) (filter (partial ctl/layout? objects))
(concat [parent-id] (cph/get-parent-ids objects parent-id)))] (concat [parent-id] (cph/get-parent-ids objects parent-id)))
undo-id (js/Symbol)]
(rx/of (dch/commit-changes changes) (rx/of (dwu/start-undo-transaction undo-id)
(dch/commit-changes changes)
(dwco/expand-collapse parent-id) (dwco/expand-collapse parent-id)
(ptk/data-event :layout/update layouts-to-update)))))) (ptk/data-event :layout/update layouts-to-update)
(dwu/commit-undo-transaction undo-id))))))
(defn relocate-selected-shapes (defn relocate-selected-shapes
[parent-id to-index] [parent-id to-index]
@ -1558,11 +1561,14 @@
(filter #(= (:type %) :add-obj)) (filter #(= (:type %) :add-obj))
(filter #(selected (:old-id %))) (filter #(selected (:old-id %)))
(map #(get-in % [:obj :id])) (map #(get-in % [:obj :id]))
(into (d/ordered-set)))] (into (d/ordered-set)))
undo-id (js/Symbol)]
(rx/of (dch/commit-changes changes) (rx/of (dwu/start-undo-transaction undo-id)
(dch/commit-changes changes)
(dws/select-shapes selected) (dws/select-shapes selected)
(ptk/data-event :layout/update [frame-id]))))] (ptk/data-event :layout/update [frame-id])
(dwu/commit-undo-transaction undo-id))))]
(ptk/reify ::paste-shape (ptk/reify ::paste-shape
ptk/WatchEvent ptk/WatchEvent
@ -1582,8 +1588,10 @@
(map str/trim) (map str/trim)
(mapv #(hash-map :type "paragraph" (mapv #(hash-map :type "paragraph"
:children [(merge txt/default-text-attrs {:text %})])))] :children [(merge txt/default-text-attrs {:text %})])))]
{:type "root" ;; if text is composed only by line breaks paragraphs is an empty list and should be nil
:children [{:type "paragraph-set" :children paragraphs}]})) (when (d/not-empty? paragraphs)
{:type "root"
:children [{:type "paragraph-set" :children paragraphs}]})))
(defn calculate-paste-position [state] (defn calculate-paste-position [state]
(cond (cond
@ -1618,7 +1626,7 @@
:height height :height height
:grow-type (if (> (count text) 100) :auto-height :auto-width) :grow-type (if (> (count text) 100) :auto-height :auto-width)
:content (as-content text)} :content (as-content text)}
undo-id (uuid/next)] undo-id (js/Symbol)]
(rx/of (dwu/start-undo-transaction undo-id) (rx/of (dwu/start-undo-transaction undo-id)
(dwsh/create-and-add-shape :text x y shape) (dwsh/create-and-add-shape :text x y shape)

View file

@ -16,6 +16,7 @@
[app.main.data.workspace.changes :as dch] [app.main.data.workspace.changes :as dch]
[app.main.data.workspace.selection :as dws] [app.main.data.workspace.selection :as dws]
[app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.state-helpers :as wsh]
[app.main.data.workspace.undo :as dwu]
[beicon.core :as rx] [beicon.core :as rx]
[potok.core :as ptk])) [potok.core :as ptk]))
@ -188,10 +189,13 @@
changes {:redo-changes (vec (mapcat :redo-changes changes-list)) changes {:redo-changes (vec (mapcat :redo-changes changes-list))
:undo-changes (vec (mapcat :undo-changes changes-list)) :undo-changes (vec (mapcat :undo-changes changes-list))
:origin it}] :origin it}
undo-id (js/Symbol)]
(rx/of (dch/commit-changes changes) (rx/of (dwu/start-undo-transaction undo-id)
(ptk/data-event :layout/update parents)))))) (dch/commit-changes changes)
(ptk/data-event :layout/update parents)
(dwu/commit-undo-transaction undo-id))))))
(def mask-group (def mask-group
(ptk/reify ::mask-group (ptk/reify ::mask-group

View file

@ -246,7 +246,7 @@
:always :always
(ctsi/set-destination (:id target-frame)))) (ctsi/set-destination (:id target-frame))))
undo-id (uuid/next)] undo-id (js/Symbol)]
(rx/of (rx/of
(dwu/start-undo-transaction undo-id) (dwu/start-undo-transaction undo-id)

View file

@ -154,7 +154,7 @@
(pcb/with-library-data data) (pcb/with-library-data data)
(pcb/update-color color)) (pcb/update-color color))
undo-id (uuid/next)] undo-id (js/Symbol)]
(rx/of (dwu/start-undo-transaction undo-id) (rx/of (dwu/start-undo-transaction undo-id)
(dch/commit-changes changes) (dch/commit-changes changes)
(sync-file (:current-file-id state) file-id :colors (:id color)) (sync-file (:current-file-id state) file-id :colors (:id color))
@ -259,7 +259,7 @@
changes (-> (pcb/empty-changes it) changes (-> (pcb/empty-changes it)
(pcb/with-library-data data) (pcb/with-library-data data)
(pcb/update-typography typography)) (pcb/update-typography typography))
undo-id (uuid/next)] undo-id (js/Symbol)]
(rx/of (dwu/start-undo-transaction undo-id) (rx/of (dwu/start-undo-transaction undo-id)
(dch/commit-changes changes) (dch/commit-changes changes)
(sync-file (:current-file-id state) file-id :typographies (:id typography)) (sync-file (:current-file-id state) file-id :typographies (:id typography))
@ -650,7 +650,7 @@
(let [current-file-id (:current-file-id state) (let [current-file-id (:current-file-id state)
page (wsh/lookup-page state) page (wsh/lookup-page state)
shape (ctn/get-shape page shape-id) shape (ctn/get-shape page shape-id)
undo-id (uuid/next)] undo-id (js/Symbol)]
(rx/of (rx/of
(dwu/start-undo-transaction undo-id) (dwu/start-undo-transaction undo-id)
(update-component shape-id) (update-component shape-id)
@ -664,7 +664,7 @@
(ptk/reify ::update-component-in-bulk (ptk/reify ::update-component-in-bulk
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(rx/concat (rx/concat
(rx/of (dwu/start-undo-transaction undo-id)) (rx/of (dwu/start-undo-transaction undo-id))
(rx/map #(update-component-sync (:id %) file-id) (rx/from shapes)) (rx/map #(update-component-sync (:id %) file-id) (rx/from shapes))

View file

@ -18,7 +18,6 @@
[app.common.types.modifiers :as ctm] [app.common.types.modifiers :as ctm]
[app.common.types.shape :as cts] [app.common.types.shape :as cts]
[app.common.types.shape.layout :as ctl] [app.common.types.shape.layout :as ctl]
[app.common.uuid :as uuid]
[app.main.data.workspace.changes :as dch] [app.main.data.workspace.changes :as dch]
[app.main.data.workspace.comments :as-alias dwcm] [app.main.data.workspace.comments :as-alias dwcm]
[app.main.data.workspace.guides :as-alias dwg] [app.main.data.workspace.guides :as-alias dwg]
@ -343,7 +342,7 @@
shapes (map (d/getf objects) ids) shapes (map (d/getf objects) ids)
ignore-tree (->> (map #(get-ignore-tree object-modifiers objects %) shapes) ignore-tree (->> (map #(get-ignore-tree object-modifiers objects %) shapes)
(reduce merge {})) (reduce merge {}))
undo-id (uuid/next)] undo-id (js/Symbol)]
(rx/concat (rx/concat
(if undo-transation? (if undo-transation?

View file

@ -561,7 +561,7 @@
frames (into #{} frames (into #{}
(map #(get-in objects [% :frame-id])) (map #(get-in objects [% :frame-id]))
selected) selected)
undo-id (uuid/next)] undo-id (js/Symbol)]
(rx/concat (rx/concat
(->> (rx/from dup-frames) (->> (rx/from dup-frames)

View file

@ -67,10 +67,13 @@
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [_ state _]
(let [objects (wsh/lookup-page-objects state) (let [objects (wsh/lookup-page-objects state)
children-ids (into [] (mapcat #(get-in objects [% :shapes])) ids)] children-ids (into [] (mapcat #(get-in objects [% :shapes])) ids)
(rx/of (dwc/update-shapes ids (get-layout-initializer type)) undo-id (js/Symbol)]
(rx/of (dwu/start-undo-transaction undo-id)
(dwc/update-shapes ids (get-layout-initializer type))
(ptk/data-event :layout/update ids) (ptk/data-event :layout/update ids)
(dwc/update-shapes children-ids #(dissoc % :constraints-h :constraints-v))))))) (dwc/update-shapes children-ids #(dissoc % :constraints-h :constraints-v))
(dwu/commit-undo-transaction undo-id))))))
;; Never call this directly but through the data-event `:layout/update` ;; Never call this directly but through the data-event `:layout/update`
@ -155,7 +158,7 @@
parent-id (:parent-id (first selected-shapes)) parent-id (:parent-id (first selected-shapes))
shapes-ids (:shapes (first selected-shapes)) shapes-ids (:shapes (first selected-shapes))
ordered-ids (into (d/ordered-set) shapes-ids) ordered-ids (into (d/ordered-set) shapes-ids)
undo-id (uuid/next)] undo-id (js/Symbol)]
(rx/of (rx/of
(dwu/start-undo-transaction undo-id) (dwu/start-undo-transaction undo-id)
(dwse/select-shapes ordered-ids) (dwse/select-shapes ordered-ids)
@ -175,7 +178,7 @@
(dwu/commit-undo-transaction undo-id))) (dwu/commit-undo-transaction undo-id)))
(let [new-shape-id (uuid/next) (let [new-shape-id (uuid/next)
undo-id (uuid/next) undo-id (js/Symbol)
flex-params (shapes->flex-params objects selected-shapes)] flex-params (shapes->flex-params objects selected-shapes)]
(rx/of (rx/of
(dwu/start-undo-transaction undo-id) (dwu/start-undo-transaction undo-id)
@ -199,7 +202,7 @@
(ptk/reify ::remove-layout (ptk/reify ::remove-layout
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(rx/of (rx/of
(dwu/start-undo-transaction undo-id) (dwu/start-undo-transaction undo-id)
(dwc/update-shapes ids #(apply dissoc % layout-keys)) (dwc/update-shapes ids #(apply dissoc % layout-keys))
@ -217,7 +220,7 @@
selected-shapes (map (d/getf objects) selected) selected-shapes (map (d/getf objects) selected)
single? (= (count selected-shapes) 1) single? (= (count selected-shapes) 1)
is-frame? (= :frame (:type (first selected-shapes))) is-frame? (= :frame (:type (first selected-shapes)))
undo-id (uuid/next)] undo-id (js/Symbol)]
(if (and single? is-frame?) (if (and single? is-frame?)
(rx/of (rx/of
@ -251,8 +254,11 @@
(ptk/reify ::update-layout (ptk/reify ::update-layout
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]
(rx/of (dwc/update-shapes ids #(d/deep-merge % changes)) (let [undo-id (js/Symbol)]
(ptk/data-event :layout/update ids))))) (rx/of (dwu/start-undo-transaction undo-id)
(dwc/update-shapes ids #(d/deep-merge % changes))
(ptk/data-event :layout/update ids)
(dwu/commit-undo-transaction undo-id))))))
(defn update-layout-child (defn update-layout-child
[ids changes] [ids changes]
@ -261,6 +267,9 @@
(watch [_ state _] (watch [_ state _]
(let [objects (wsh/lookup-page-objects state) (let [objects (wsh/lookup-page-objects state)
parent-ids (->> ids (map #(cph/get-parent-id objects %))) parent-ids (->> ids (map #(cph/get-parent-id objects %)))
layout-ids (->> ids (filter (comp ctl/layout? (d/getf objects))))] layout-ids (->> ids (filter (comp ctl/layout? (d/getf objects))))
(rx/of (dwc/update-shapes ids #(d/deep-merge (or % {}) changes)) undo-id (js/Symbol)]
(ptk/data-event :layout/update (d/concat-vec layout-ids parent-ids))))))) (rx/of (dwu/start-undo-transaction undo-id)
(dwc/update-shapes ids #(d/deep-merge (or % {}) changes))
(ptk/data-event :layout/update (d/concat-vec layout-ids parent-ids))
(dwu/commit-undo-transaction undo-id))))))

View file

@ -92,21 +92,27 @@
(ctst/generate-unique-name (:name attrs))) (ctst/generate-unique-name (:name attrs)))
shape (make-new-shape shape (make-new-shape
(assoc attrs :id id :name name) (assoc attrs :id id :name name)
objects objects
selected) selected)
changes (-> (pcb/empty-changes it page-id) changes (-> (pcb/empty-changes it page-id)
(pcb/with-objects objects) (pcb/with-objects objects)
(pcb/add-object shape) (cond-> (some? (:index (meta attrs)))
(pcb/add-object shape {:index (:index (meta attrs))}))
(cond-> (nil? (:index (meta attrs)))
(pcb/add-object shape))
(cond-> (some? (:parent-id attrs)) (cond-> (some? (:parent-id attrs))
(pcb/change-parent (:parent-id attrs) [shape])))] (pcb/change-parent (:parent-id attrs) [shape])))
undo-id (js/Symbol)]
(rx/concat (rx/concat
(rx/of (dch/commit-changes changes) (rx/of (dwu/start-undo-transaction undo-id)
(dch/commit-changes changes)
(ptk/data-event :layout/update [(:parent-id shape)]) (ptk/data-event :layout/update [(:parent-id shape)])
(when-not no-select? (when-not no-select?
(dws/select-shapes (d/ordered-set id)))) (dws/select-shapes (d/ordered-set id)))
(dwu/commit-undo-transaction undo-id))
(when (= :text (:type attrs)) (when (= :text (:type attrs))
(->> (rx/of (dwe/start-edition-mode id)) (->> (rx/of (dwe/start-edition-mode id))
(rx/observe-on :async))))))))) (rx/observe-on :async)))))))))
@ -304,12 +310,15 @@
(cond-> (seq starting-flows) (cond-> (seq starting-flows)
(pcb/update-page-option :flows (fn [flows] (pcb/update-page-option :flows (fn [flows]
(->> (map :id starting-flows) (->> (map :id starting-flows)
(reduce ctp/remove-flow flows))))))] (reduce ctp/remove-flow flows))))))
undo-id (js/Symbol)]
(rx/of (dc/detach-comment-thread ids) (rx/of (dwu/start-undo-transaction undo-id)
(dc/detach-comment-thread ids)
(ptk/data-event :layout/update all-parents) (ptk/data-event :layout/update all-parents)
(dch/commit-changes changes) (dch/commit-changes changes)
(ptk/data-event :layout/update layout-ids)))) (ptk/data-event :layout/update layout-ids)
(dwu/commit-undo-transaction undo-id))))
(defn create-and-add-shape (defn create-and-add-shape
[type frame-x frame-y data] [type frame-x frame-y data]
@ -357,7 +366,13 @@
(let [page-id (:current-page-id state) (let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id) objects (wsh/lookup-page-objects state page-id)
selected (wsh/lookup-selected state) selected (wsh/lookup-selected state)
selected-objs (map #(get objects %) selected)] selected (cph/clean-loops objects selected)
selected-objs (map #(get objects %) selected)
new-index (->> selected
(cph/order-by-indexed-shapes objects)
first
(cph/get-position-on-parent objects)
inc)]
(when (d/not-empty? selected) (when (d/not-empty? selected)
(let [srect (gsh/selection-rect selected-objs) (let [srect (gsh/selection-rect selected-objs)
frame-id (get-in objects [(first selected) :frame-id]) frame-id (get-in objects [(first selected) :frame-id])
@ -367,10 +382,11 @@
(cond-> id (cond-> id
(assoc :id id)) (assoc :id id))
(assoc :frame-id frame-id :parent-id parent-id) (assoc :frame-id frame-id :parent-id parent-id)
(with-meta {:index new-index})
(cond-> (not= frame-id uuid/zero) (cond-> (not= frame-id uuid/zero)
(assoc :fills [] :hide-in-viewer true)) (assoc :fills [] :hide-in-viewer true))
(cts/setup-rect-selrect)) (cts/setup-rect-selrect))
undo-id (uuid/next)] undo-id (js/Symbol)]
(rx/of (rx/of
(dwu/start-undo-transaction undo-id) (dwu/start-undo-transaction undo-id)
(add-shape shape) (add-shape shape)

View file

@ -323,7 +323,8 @@
(ptk/reify ::resize-text (ptk/reify ::resize-text
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [_ state _]
(let [shape (wsh/lookup-shape state id)] (let [shape (wsh/lookup-shape state id)
undo-id (js/Symbol)]
(letfn [(update-fn [shape] (letfn [(update-fn [shape]
(let [{:keys [selrect grow-type]} shape (let [{:keys [selrect grow-type]} shape
{shape-width :width shape-height :height} selrect {shape-width :width shape-height :height} selrect
@ -335,17 +336,19 @@
shape shape
(cond-> shape (cond-> shape
(and (not-changed? shape-height new-height) (and (not-changed? shape-height new-height)
(or (= grow-type :auto-height) (= grow-type :auto-width))) (or (= grow-type :auto-height) (= grow-type :auto-width)))
(gsh/transform-shape (ctm/change-dimensions-modifiers shape :height new-height {:ignore-lock? true})))] (gsh/transform-shape (ctm/change-dimensions-modifiers shape :height new-height {:ignore-lock? true})))]
shape))] shape))]
(when (or (and (not-changed? (:width shape) new-width) (= (:grow-type shape) :auto-width)) (when (or (and (not-changed? (:width shape) new-width) (= (:grow-type shape) :auto-width))
(and (not-changed? (:height shape) new-height) (and (not-changed? (:height shape) new-height)
(or (= (:grow-type shape) :auto-height) (= (:grow-type shape) :auto-width)))) (or (= (:grow-type shape) :auto-height) (= (:grow-type shape) :auto-width))))
(rx/of (dch/update-shapes [id] update-fn {:reg-objects? true :save-undo? true}) (rx/of (dwu/start-undo-transaction undo-id)
(ptk/data-event :layout/update [id])))))))) (dch/update-shapes [id] update-fn {:reg-objects? true :save-undo? true})
(ptk/data-event :layout/update [id])
(dwu/commit-undo-transaction undo-id))))))))
(defn save-font (defn save-font

View file

@ -20,7 +20,6 @@
[app.common.types.modifiers :as ctm] [app.common.types.modifiers :as ctm]
[app.common.types.shape-tree :as ctst] [app.common.types.shape-tree :as ctst]
[app.common.types.shape.layout :as ctl] [app.common.types.shape.layout :as ctl]
[app.common.uuid :as uuid]
[app.main.data.workspace.changes :as dch] [app.main.data.workspace.changes :as dch]
[app.main.data.workspace.collapse :as dwc] [app.main.data.workspace.collapse :as dwc]
[app.main.data.workspace.modifiers :as dwm] [app.main.data.workspace.modifiers :as dwm]
@ -509,7 +508,7 @@
(rx/last) (rx/last)
(rx/mapcat (rx/mapcat
(fn [[_ target-frame drop-index]] (fn [[_ target-frame drop-index]]
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(rx/of (dwu/start-undo-transaction undo-id) (rx/of (dwu/start-undo-transaction undo-id)
(move-shapes-to-frame ids target-frame drop-index) (move-shapes-to-frame ids target-frame drop-index)
(dwm/apply-modifiers {:undo-transation? false}) (dwm/apply-modifiers {:undo-transation? false})
@ -571,10 +570,14 @@
index)) index))
changes))) changes)))
(-> (pcb/empty-changes it page-id) (-> (pcb/empty-changes it page-id)
(pcb/with-objects objects))))] (pcb/with-objects objects))))
undo-id (js/Symbol)]
(rx/of (dch/commit-changes changes) (rx/of
(ptk/data-event :layout/update selected)))))) (dwu/start-undo-transaction undo-id)
(dch/commit-changes changes)
(ptk/data-event :layout/update selected)
(dwu/commit-undo-transaction undo-id))))))
(defn nudge-selected-shapes (defn nudge-selected-shapes
"Move shapes a fixed increment in one direction, from a keyboard action." "Move shapes a fixed increment in one direction, from a keyboard action."

View file

@ -113,9 +113,10 @@
{::mf/wrap-props false} {::mf/wrap-props false}
[props] [props]
(let [childs (unchecked-get props "childs")] (let [childs (unchecked-get props "childs")]
[:> frame-container props [:> frame-container props
[:g.frame-children [:g.frame-children
(for [item childs] (for [item childs]
[:& shape-wrapper {:key (dm/str (:id item)) :shape item}])]]))) [:& shape-wrapper {:key (dm/str (:id item)) :shape item}]
)]])))

View file

@ -118,7 +118,7 @@
i/full-screen)] i/full-screen)]
(when (:is-admin permissions) (when (:is-admin permissions)
[:span.btn-primary {:on-click open-share-dialog} i/export [:span (tr "labels.share-prototype")]]) [:span.btn-primary.tooltip.tooltip-bottom-left {:on-click open-share-dialog :alt (tr "labels.share-prototype")} i/export [:span (tr "labels.share-prototype")]])
(when (:can-edit permissions) (when (:can-edit permissions)
[:span.btn-text-dark {:on-click go-to-workspace} (tr "labels.edit-file")]) [:span.btn-text-dark {:on-click go-to-workspace} (tr "labels.edit-file")])

View file

@ -39,7 +39,7 @@
type (if (= (count shapes) 1) (-> shapes first :type) :multiple) type (if (= (count shapes) 1) (-> shapes first :type) :multiple)
options (type->options type)] options (type->options type)]
[:div.element-options [:div.element-options
(for [option options] (for [[idx option] (map-indexed vector options)]
[:> (case option [:> (case option
:layout layout-panel :layout layout-panel
:layout-flex layout-flex-panel :layout-flex layout-flex-panel
@ -51,7 +51,8 @@
:image image-panel :image image-panel
:text text-panel :text text-panel
:svg svg-panel) :svg svg-panel)
{:shapes shapes {:key idx
:shapes shapes
:frame frame :frame frame
:from from}]) :from from}])
[:& exports [:& exports

View file

@ -106,9 +106,9 @@
[:& copy-button {:data (copy-style-data style)}]]) [:& copy-button {:data (copy-style-data style)}]])
(when (:fills style) (when (:fills style)
(for [fill (:fills style)] (for [[idx fill] (map-indexed vector (:fills style))]
[:& color-row {:key idx
[:& color-row {:format @color-format :format @color-format
:color (shape->color fill) :color (shape->color fill)
:copy-data (copy-style-data fill :fill-color :fill-color-gradient) :copy-data (copy-style-data fill :fill-color :fill-color-gradient)
:on-change-format #(reset! color-format %)}])) :on-change-format #(reset! color-format %)}]))
@ -175,8 +175,9 @@
(remove (fn [[_ text]] (str/empty? (str/trim text)))) (remove (fn [[_ text]] (str/empty? (str/trim text))))
(mapv (fn [[style text]] (vector (merge txt/default-text-attrs style) text))))] (mapv (fn [[style text]] (vector (merge txt/default-text-attrs style) text))))]
(for [[_ [full-style text]] (map-indexed vector style-text-blocks)] (for [[idx [full-style text]] (map-indexed vector style-text-blocks)]
[:& typography-block {:shape shape [:& typography-block {:key idx
:shape shape
:style full-style :style full-style
:text text}]))) :text text}])))

View file

@ -60,7 +60,7 @@
(reset! expanded false) (reset! expanded false)
(reset! section %) (reset! section %)
(when (= from :workspace) (when (= from :workspace)
(dw/set-inspect-expanded false))) (st/emit! (dw/set-inspect-expanded false))))
:selected @section} :selected @section}
[:& tab-element {:id :info :title (tr "inspect.tabs.info")} [:& tab-element {:id :info :title (tr "inspect.tabs.info")}
[:& attributes {:page-id page-id [:& attributes {:page-id page-id

View file

@ -80,17 +80,33 @@
{::mf/wrap-props false {::mf/wrap-props false
::mf/wrap [mf/memo]} ::mf/wrap [mf/memo]}
[props] [props]
(let [layout (obj/get props "layout") (let [layout (obj/get props "layout")
drawing-tool (:tool (mf/deref refs/workspace-drawing)) section (obj/get props "section")
expanded (mf/deref refs/inspect-expanded)] drawing-tool (:tool (mf/deref refs/workspace-drawing))
[:aside.settings-bar.settings-bar-right {:class (when expanded "expanded")} is-comments? (= drawing-tool :comments)
is-history? (contains? layout :document-history)
is-inspect? (= section :inspect)
expanded? (mf/deref refs/inspect-expanded)
can-be-expanded? (and
(not is-comments?)
(not is-history?)
is-inspect?)]
(mf/use-effect
(mf/deps can-be-expanded?)
(fn []
(when (not can-be-expanded?)
(st/emit! (dw/set-inspect-expanded false)))))
[:aside.settings-bar.settings-bar-right {:class (when (and can-be-expanded? expanded?) "expanded")}
[:div.settings-bar-inside [:div.settings-bar-inside
(cond (cond
(= drawing-tool :comments) is-comments?
[:& comments-sidebar] [:& comments-sidebar]
(contains? layout :document-history) is-history?
[:& history-toolbox] [:& history-toolbox]
:else :else

View file

@ -12,7 +12,6 @@
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.text :as txt] [app.common.text :as txt]
[app.common.uuid :as uuid]
[app.config :as cf] [app.config :as cf]
[app.main.data.events :as ev] [app.main.data.events :as ev]
[app.main.data.modal :as modal] [app.main.data.modal :as modal]
@ -182,7 +181,7 @@
(defn- create-assets-group (defn- create-assets-group
[rename components-to-group group-name] [rename components-to-group group-name]
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(st/emit! (dwu/start-undo-transaction undo-id)) (st/emit! (dwu/start-undo-transaction undo-id))
(apply st/emit! (apply st/emit!
(->> components-to-group (->> components-to-group
@ -594,7 +593,7 @@
(mf/use-fn (mf/use-fn
(mf/deps @state) (mf/deps @state)
(fn [] (fn []
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(if (empty? selected-components) (if (empty? selected-components)
(st/emit! (dwl/duplicate-component {:id (:component-id @state)})) (st/emit! (dwl/duplicate-component {:id (:component-id @state)}))
(do (do
@ -606,7 +605,7 @@
(mf/use-fn (mf/use-fn
(mf/deps @state file-id multi-components? multi-assets?) (mf/deps @state file-id multi-components? multi-assets?)
(fn [] (fn []
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(if (or multi-components? multi-assets?) (if (or multi-components? multi-assets?)
(on-assets-delete) (on-assets-delete)
(st/emit! (dwu/start-undo-transaction undo-id) (st/emit! (dwu/start-undo-transaction undo-id)
@ -653,7 +652,7 @@
(mf/deps components selected-components on-clear-selection) (mf/deps components selected-components on-clear-selection)
(fn [group-name] (fn [group-name]
(on-clear-selection) (on-clear-selection)
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(st/emit! (dwu/start-undo-transaction undo-id)) (st/emit! (dwu/start-undo-transaction undo-id))
(apply st/emit! (apply st/emit!
(->> components (->> components
@ -670,7 +669,7 @@
(mf/deps components) (mf/deps components)
(fn [path last-path] (fn [path last-path]
(on-clear-selection) (on-clear-selection)
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(st/emit! (dwu/start-undo-transaction undo-id)) (st/emit! (dwu/start-undo-transaction undo-id))
(apply st/emit! (apply st/emit!
(->> components (->> components
@ -701,7 +700,7 @@
(mf/deps components) (mf/deps components)
(fn [path] (fn [path]
(on-clear-selection) (on-clear-selection)
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(st/emit! (dwu/start-undo-transaction undo-id)) (st/emit! (dwu/start-undo-transaction undo-id))
(apply st/emit! (apply st/emit!
(->> components (->> components
@ -1029,7 +1028,7 @@
(mf/deps objects selected-objects on-clear-selection) (mf/deps objects selected-objects on-clear-selection)
(fn [group-name] (fn [group-name]
(on-clear-selection) (on-clear-selection)
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(st/emit! (dwu/start-undo-transaction undo-id)) (st/emit! (dwu/start-undo-transaction undo-id))
(apply st/emit! (apply st/emit!
(->> objects (->> objects
@ -1046,7 +1045,7 @@
(mf/deps objects) (mf/deps objects)
(fn [path last-path] (fn [path last-path]
(on-clear-selection) (on-clear-selection)
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(st/emit! (dwu/start-undo-transaction undo-id)) (st/emit! (dwu/start-undo-transaction undo-id))
(apply st/emit! (apply st/emit!
(->> objects (->> objects
@ -1076,7 +1075,7 @@
(mf/deps objects) (mf/deps objects)
(fn [path] (fn [path]
(on-clear-selection) (on-clear-selection)
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(st/emit! (dwu/start-undo-transaction undo-id)) (st/emit! (dwu/start-undo-transaction undo-id))
(apply st/emit! (apply st/emit!
(->> objects (->> objects
@ -1193,7 +1192,7 @@
(fn [] (fn []
(if (or multi-colors? multi-assets?) (if (or multi-colors? multi-assets?)
(on-assets-delete) (on-assets-delete)
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(st/emit! (dwu/start-undo-transaction undo-id) (st/emit! (dwu/start-undo-transaction undo-id)
(dwl/delete-color color) (dwl/delete-color color)
(dwl/sync-file file-id file-id :colors (:id color)) (dwl/sync-file file-id file-id :colors (:id color))
@ -1458,7 +1457,7 @@
(fn [color-id] (fn [color-id]
(fn [group-name] (fn [group-name]
(on-clear-selection) (on-clear-selection)
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(st/emit! (dwu/start-undo-transaction undo-id)) (st/emit! (dwu/start-undo-transaction undo-id))
(apply st/emit! (apply st/emit!
(->> colors (->> colors
@ -1476,7 +1475,7 @@
(mf/deps colors) (mf/deps colors)
(fn [path last-path] (fn [path last-path]
(on-clear-selection) (on-clear-selection)
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(st/emit! (dwu/start-undo-transaction undo-id)) (st/emit! (dwu/start-undo-transaction undo-id))
(apply st/emit! (apply st/emit!
(->> colors (->> colors
@ -1508,7 +1507,7 @@
(mf/deps colors) (mf/deps colors)
(fn [path] (fn [path]
(on-clear-selection) (on-clear-selection)
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(st/emit! (dwu/start-undo-transaction undo-id)) (st/emit! (dwu/start-undo-transaction undo-id))
(apply st/emit! (apply st/emit!
(->> colors (->> colors
@ -1757,7 +1756,7 @@
(mf/deps typographies selected-typographies on-clear-selection file-id) (mf/deps typographies selected-typographies on-clear-selection file-id)
(fn [group-name] (fn [group-name]
(on-clear-selection) (on-clear-selection)
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(st/emit! (dwu/start-undo-transaction undo-id)) (st/emit! (dwu/start-undo-transaction undo-id))
(apply st/emit! (apply st/emit!
(->> typographies (->> typographies
@ -1775,7 +1774,7 @@
(mf/deps typographies) (mf/deps typographies)
(fn [path last-path] (fn [path last-path]
(on-clear-selection) (on-clear-selection)
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(st/emit! (dwu/start-undo-transaction undo-id)) (st/emit! (dwu/start-undo-transaction undo-id))
(apply st/emit! (apply st/emit!
(->> typographies (->> typographies
@ -1806,7 +1805,7 @@
(mf/deps typographies) (mf/deps typographies)
(fn [path] (fn [path]
(on-clear-selection) (on-clear-selection)
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(st/emit! (dwu/start-undo-transaction undo-id)) (st/emit! (dwu/start-undo-transaction undo-id))
(apply st/emit! (apply st/emit!
(->> typographies (->> typographies
@ -1844,7 +1843,7 @@
(mf/use-fn (mf/use-fn
(mf/deps @state multi-typographies? multi-assets?) (mf/deps @state multi-typographies? multi-assets?)
(fn [] (fn []
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(if (or multi-typographies? multi-assets?) (if (or multi-typographies? multi-assets?)
(on-assets-delete) (on-assets-delete)
(st/emit! (dwu/start-undo-transaction undo-id) (st/emit! (dwu/start-undo-transaction undo-id)
@ -2088,7 +2087,7 @@
(mf/use-fn (mf/use-fn
(mf/deps selected-assets) (mf/deps selected-assets)
(fn [] (fn []
(let [undo-id (uuid/next)] (let [undo-id (js/Symbol)]
(st/emit! (dwu/start-undo-transaction undo-id)) (st/emit! (dwu/start-undo-transaction undo-id))
(apply st/emit! (map #(dwl/delete-component {:id %}) (apply st/emit! (map #(dwl/delete-component {:id %})
(:components selected-assets))) (:components selected-assets)))

View file

@ -582,7 +582,6 @@
[:button.back-button i/arrow-slide] [:button.back-button i/arrow-slide]
[:div.focus-name (or title (tr "workspace.focus.selection"))] [:div.focus-name (or title (tr "workspace.focus.selection"))]
[:div.focus-mode (tr "workspace.focus.focus-mode")]]] [:div.focus-mode (tr "workspace.focus.focus-mode")]]]
filter-component) filter-component)
(if (some? filtered-objects) (if (some? filtered-objects)
@ -599,8 +598,8 @@
:key (dm/str (:id page)) :key (dm/str (:id page))
:filtered? true}]]] :filtered? true}]]]
[:div.tool-window-content {:on-scroll on-scroll [:div.tool-window-content {:on-scroll on-scroll
:style {:display (when (some? filtered-objects) "none")}} :style {:display (when (some? filtered-objects) "none")}}
[:& layers-tree {:objects objects [:& layers-tree {:objects objects
:key (dm/str (:id page)) :key (dm/str (:id page))
:filtered? false}]])])) :filtered? false}]])]))

View file

@ -72,7 +72,8 @@
shape-parent-frame (cph/get-frame objects (:frame-id first-selected-shape)) shape-parent-frame (cph/get-frame objects (:frame-id first-selected-shape))
on-change-tab on-change-tab
(fn [options-mode] (fn [options-mode]
(st/emit! (udw/set-options-mode options-mode)) (st/emit! (udw/set-options-mode options-mode)
(udw/set-inspect-expanded false))
(if (= options-mode :inspect) ;;TODO maybe move this logic to set-options-mode (if (= options-mode :inspect) ;;TODO maybe move this logic to set-options-mode
(st/emit! :interrupt (udw/set-workspace-read-only true)) (st/emit! :interrupt (udw/set-workspace-read-only true))
(st/emit! :interrupt (udw/set-workspace-read-only false))))] (st/emit! :interrupt (udw/set-workspace-read-only false))))]

View file

@ -250,12 +250,12 @@
[:> numeric-input {:no-validate true [:> numeric-input {:no-validate true
:placeholder "--" :placeholder "--"
:on-click (fn [event] :on-click (fn [event]
(reset! gap-selected? :row-gap) (reset! gap-selected? :column-gap)
(dom/select-target event)) (dom/select-target event))
:on-change (partial set-gap (= :no-wrap wrap-type) :row-gap) :on-change (partial set-gap (= :no-wrap wrap-type) :column-gap)
:on-blur #(reset! gap-selected? :none) :on-blur #(reset! gap-selected? :none)
:value (:row-gap gap-value) :value (:column-gap gap-value)
:disabled (and (= :no-wrap wrap-type) (not is-col?))}]] :disabled (and (= :no-wrap wrap-type) is-col?)}]]
[:div.gap-row.tooltip.tooltip-bottom-left [:div.gap-row.tooltip.tooltip-bottom-left
{:alt "Row gap"} {:alt "Row gap"}
@ -264,12 +264,12 @@
[:> numeric-input {:no-validate true [:> numeric-input {:no-validate true
:placeholder "--" :placeholder "--"
:on-click (fn [event] :on-click (fn [event]
(reset! gap-selected? :column-gap) (reset! gap-selected? :row-gap)
(dom/select-target event)) (dom/select-target event))
:on-change (partial set-gap (= :no-wrap wrap-type) :column-gap) :on-change (partial set-gap (= :no-wrap wrap-type) :row-gap)
:on-blur #(reset! gap-selected? :none) :on-blur #(reset! gap-selected? :none)
:value (:column-gap gap-value) :value (:row-gap gap-value)
:disabled (and (= :no-wrap wrap-type) is-col?)}]]]]) :disabled (and (= :no-wrap wrap-type) (not is-col?))}]]]])
(mf/defc layout-container-menu (mf/defc layout-container-menu
{::mf/wrap [#(mf/memo' % (mf/check-props ["ids" "values" "type" "multiple"]))]} {::mf/wrap [#(mf/memo' % (mf/check-props ["ids" "values" "type" "multiple"]))]}
@ -364,67 +364,68 @@
[:div.element-set-title [:div.element-set-title
[:* [:*
[:span "Layout"] [:span "Layout"]
(if (and (not multiple)(:layout values)) (if (and (not multiple) (:layout values))
[:div.title-actions [:div.title-actions
#_[:div.layout-btns #_[:div.layout-btns
[:button {:on-click set-flex [:button {:on-click set-flex
:class (dom/classnames :class (dom/classnames
:active (= :flex layout-type))} "Flex"] :active (= :flex layout-type))} "Flex"]
[:button {:on-click set-grid [:button {:on-click set-grid
:class (dom/classnames :class (dom/classnames
:active (= :grid layout-type))} "Grid"]] :active (= :grid layout-type))} "Grid"]]
[:button.remove-layout {:on-click on-remove-layout} i/minus]] [:button.remove-layout {:on-click on-remove-layout} i/minus]]
[:button.add-page {:on-click on-add-layout} i/close])]] [:button.add-page {:on-click on-add-layout} i/close])]]
(when (:layout values) (when (:layout values)
(if (= :flex layout-type) (when (not= :multiple layout-type)
[:div.element-set-content.layout-menu (if (= :flex layout-type)
[:div.layout-row [:div.element-set-content.layout-menu
[:div.direction-wrap.row-title "Direction"]
[:div.btn-wrapper
[:div.direction
[:*
(for [dir [:row :reverse-row :column :reverse-column]]
[:& direction-btn {:key (d/name dir)
:dir dir
:saved-dir saved-dir
:set-direction set-direction}])]]
[:div.wrap-type
[:& wrap-row {:wrap-type wrap-type
:set-wrap set-wrap}]]]]
(when (= :wrap wrap-type)
[:div.layout-row [:div.layout-row
[:div.align-content.row-title "Content"] [:div.direction-wrap.row-title "Direction"]
[:div.btn-wrapper [:div.btn-wrapper
[:& align-content-row {:is-col? is-col? [:div.direction
:align-content align-content [:*
:set-align-content set-align-content}]]]) (for [dir [:row :reverse-row :column :reverse-column]]
[:& direction-btn {:key (d/name dir)
:dir dir
:saved-dir saved-dir
:set-direction set-direction}])]]
[:div.layout-row [:div.wrap-type
[:div.align-items.row-title "Align"] [:& wrap-row {:wrap-type wrap-type
[:div.btn-wrapper :set-wrap set-wrap}]]]]
[:& align-row {:is-col? is-col?
:align-items align-items
:set-align set-align-items}]]]
[:div.layout-row (when (= :wrap wrap-type)
[:div.justify-content.row-title "Justify"] [:div.layout-row
[:div.btn-wrapper.justify-content [:div.align-content.row-title "Content"]
[:& justify-content-row {:is-col? is-col? [:div.btn-wrapper
:justify-content justify-content [:& align-content-row {:is-col? is-col?
:set-justify set-justify-content}]]] :align-content align-content
[:& gap-section {:is-col? is-col? :set-align-content set-align-content}]]])
:wrap-type wrap-type
:gap-selected? gap-selected? [:div.layout-row
:set-gap set-gap [:div.align-items.row-title "Align"]
:gap-value (:layout-gap values)}] [:div.btn-wrapper
[:& align-row {:is-col? is-col?
:align-items align-items
:set-align set-align-items}]]]
[:div.layout-row
[:div.justify-content.row-title "Justify"]
[:div.btn-wrapper.justify-content
[:& justify-content-row {:is-col? is-col?
:justify-content justify-content
:set-justify set-justify-content}]]]
[:& gap-section {:is-col? is-col?
:wrap-type wrap-type
:gap-selected? gap-selected?
:set-gap set-gap
:gap-value (:layout-gap values)}]
[:& padding-section {:values values [:& padding-section {:values values
:on-change-style change-padding-type :on-change-style change-padding-type
:on-change on-padding-change}]] :on-change on-padding-change}]]
[:div "GRID TO COME"]))])) [:div "GRID TO COME"])))]))

View file

@ -10,7 +10,6 @@
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.common.types.shape.layout :as ctl] [app.common.types.shape.layout :as ctl]
[app.common.types.shape.radius :as ctsr] [app.common.types.shape.radius :as ctsr]
[app.common.uuid :as uuid]
[app.main.constants :refer [size-presets]] [app.main.constants :refer [size-presets]]
[app.main.data.workspace :as udw] [app.main.data.workspace :as udw]
[app.main.data.workspace.changes :as dch] [app.main.data.workspace.changes :as dch]
@ -250,7 +249,7 @@
(mf/deps ids) (mf/deps ids)
(fn [event] (fn [event]
(let [value (-> event dom/get-target dom/checked?) (let [value (-> event dom/get-target dom/checked?)
undo-id (uuid/next)] undo-id (js/Symbol)]
(do (do
(st/emit! (dwu/start-undo-transaction undo-id) (st/emit! (dwu/start-undo-transaction undo-id)
(dch/update-shapes ids (fn [shape] (assoc shape :hide-in-viewer (not value))))) (dch/update-shapes ids (fn [shape] (assoc shape :hide-in-viewer (not value)))))

View file

@ -222,7 +222,8 @@
:style #js {"--height" (str size "px")}} :style #js {"--height" (str size "px")}}
[:div.tool-window-bar [:div.tool-window-bar
[:span (tr "workspace.sidebar.sitemap")] [:span (tr "workspace.sidebar.sitemap")]
(when-not workspace-read-only? (if workspace-read-only?
[:div.view-only-mode (tr "labels.view-only")]
[:div.add-page {:on-click create} i/close]) [:div.add-page {:on-click create} i/close])
[:div.collapse-pages {:on-click toggle-pages [:div.collapse-pages {:on-click toggle-pages
:style {:transform (when (not @show-pages?) "rotate(-90deg)")}} i/arrow-slide]] :style {:transform (when (not @show-pages?) "rotate(-90deg)")}} i/arrow-slide]]

View file

@ -1549,6 +1549,9 @@ msgstr "Active"
msgid "labels.inactive" msgid "labels.inactive"
msgstr "Inactive" msgstr "Inactive"
msgid "labels.view-only"
msgstr "VIEW ONLY"
#: src/app/main/data/workspace/persistence.cljs, src/app/main/data/workspace/persistence.cljs, src/app/main/data/media.cljs #: src/app/main/data/workspace/persistence.cljs, src/app/main/data/workspace/persistence.cljs, src/app/main/data/media.cljs
msgid "media.loading" msgid "media.loading"
msgstr "Loading image…" msgstr "Loading image…"

View file

@ -1742,6 +1742,9 @@ msgstr "Activo"
msgid "labels.inactive" msgid "labels.inactive"
msgstr "Inactivo" msgstr "Inactivo"
msgid "labels.view-only"
msgstr "SOLO LECTURA"
#: src/app/main/data/workspace/persistence.cljs, src/app/main/data/media.cljs #: src/app/main/data/workspace/persistence.cljs, src/app/main/data/media.cljs
msgid "media.loading" msgid "media.loading"
msgstr "Cargando imagen…" msgstr "Cargando imagen…"