mirror of
https://github.com/penpot/penpot.git
synced 2025-06-05 14:21:40 +02:00
✨ Fix comments for nested frames
This commit is contained in:
parent
79a46efa35
commit
0bb0063be4
8 changed files with 60 additions and 51 deletions
|
@ -333,15 +333,20 @@
|
|||
(let [page-id (:current-page-id state)
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
|
||||
to-move-shapes (into []
|
||||
(map (d/getf objects))
|
||||
(reverse (cph/sort-z-index objects shapes)))
|
||||
to-move-shapes
|
||||
(into []
|
||||
(map (d/getf objects))
|
||||
(reverse (cph/sort-z-index objects shapes)))
|
||||
|
||||
changes (-> (pcb/empty-changes it page-id)
|
||||
(pcb/with-objects objects)
|
||||
(pcb/change-parent frame-id to-move-shapes 0))]
|
||||
changes
|
||||
(when (d/not-empty? to-move-shapes)
|
||||
(-> (pcb/empty-changes it page-id)
|
||||
(pcb/with-objects objects)
|
||||
(pcb/change-parent frame-id to-move-shapes 0)))]
|
||||
|
||||
(rx/of (dch/commit-changes changes))))))
|
||||
(if (some? changes)
|
||||
(rx/of (dch/commit-changes changes))
|
||||
(rx/empty))))))
|
||||
|
||||
(s/def ::set-of-uuid
|
||||
(s/every ::us/uuid :kind set?))
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.math :as mth]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.main.data.workspace.common :as dwc]
|
||||
[app.main.data.workspace.state-helpers :as wsh]
|
||||
[app.main.data.workspace.undo :as dwu]
|
||||
[app.main.worker :as uw]
|
||||
[beicon.core :as rx]
|
||||
|
@ -29,7 +31,8 @@
|
|||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [tool (get-in state [:workspace-drawing :tool])
|
||||
shape (get-in state [:workspace-drawing :object])]
|
||||
shape (get-in state [:workspace-drawing :object])
|
||||
objects (wsh/lookup-page-objects state)]
|
||||
(rx/concat
|
||||
(when (:initialized? shape)
|
||||
(let [page-id (:current-page-id state)
|
||||
|
@ -68,7 +71,10 @@
|
|||
(if (= :frame (:type shape))
|
||||
(->> (uw/ask! {:cmd :selection/query
|
||||
:page-id page-id
|
||||
:rect (:selrect shape)})
|
||||
:rect (:selrect shape)
|
||||
:include-frames? true
|
||||
:full-frame? true})
|
||||
(rx/map #(cph/clean-loops objects %))
|
||||
(rx/map #(dwc/move-shapes-into-frame (:id shape) %)))
|
||||
(rx/empty)))))
|
||||
|
||||
|
|
|
@ -208,8 +208,8 @@
|
|||
|
||||
;; TOOLS
|
||||
|
||||
:draw-frame {:tooltip "A"
|
||||
:command "a"
|
||||
:draw-frame {:tooltip "B"
|
||||
:command ["b" "a"]
|
||||
:subsections [:tools :basics]
|
||||
:fn #(st/emit! (dwd/select-for-drawing :frame))}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
(ns app.main.ui.viewer.comments
|
||||
(:require
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.geom.matrix :as gmt]
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.main.data.comments :as dcm]
|
||||
|
@ -75,13 +76,6 @@
|
|||
[:span.label (tr "labels.show-comments-list")]]]]]))
|
||||
|
||||
|
||||
(defn- frame-contains?
|
||||
[{:keys [x y width height]} {px :x py :y}]
|
||||
(let [x2 (+ x width)
|
||||
y2 (+ y height)]
|
||||
(and (<= x px x2)
|
||||
(<= y py y2))))
|
||||
|
||||
(def threads-ref
|
||||
(l/derived :comment-threads st/state))
|
||||
|
||||
|
@ -93,11 +87,11 @@
|
|||
(let [profile (mf/deref refs/profile)
|
||||
threads-map (mf/deref threads-ref)
|
||||
|
||||
modifier1 (-> (gpt/point (:x frame) (:y frame))
|
||||
(gpt/negate)
|
||||
(gmt/translate-matrix))
|
||||
frame-corner (-> frame :points gsh/points->selrect gpt/point)
|
||||
modifier1 (-> (gmt/matrix)
|
||||
(gmt/translate (gpt/negate frame-corner)))
|
||||
|
||||
modifier2 (-> (gpt/point (:x frame) (:y frame))
|
||||
modifier2 (-> (gpt/point frame-corner)
|
||||
(gmt/translate-matrix))
|
||||
|
||||
cstate (mf/deref refs/comments-local)
|
||||
|
@ -105,7 +99,7 @@
|
|||
threads (->> (vals threads-map)
|
||||
(dcm/apply-filters cstate profile)
|
||||
(filter (fn [{:keys [position]}]
|
||||
(frame-contains? frame position))))
|
||||
(gsh/has-point? frame position))))
|
||||
|
||||
on-bubble-click
|
||||
(mf/use-callback
|
||||
|
|
|
@ -140,9 +140,9 @@
|
|||
|
||||
(when (not (:hidden frame))
|
||||
[:g {:id (dm/str "frame-title-" (:id frame))
|
||||
:transform frame-transform}
|
||||
}
|
||||
(when (:use-for-thumbnail? frame)
|
||||
[:g {:transform (dm/str (text-transform label-pos zoom))}
|
||||
[:g {:transform (dm/str frame-transform " " (text-transform label-pos zoom))}
|
||||
[:svg {:x 0
|
||||
:y -9
|
||||
:width 12
|
||||
|
@ -156,7 +156,7 @@
|
|||
:width width
|
||||
:height 20
|
||||
:class "workspace-frame-label"
|
||||
:transform (dm/str (text-transform label-pos zoom))
|
||||
:transform (dm/str frame-transform " " (text-transform label-pos zoom))
|
||||
:style {:fill (when selected? "var(--color-primary-dark)")}
|
||||
:visibility (if show-artboard-names? "visible" "hidden")
|
||||
:on-mouse-down on-mouse-down
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue