mirror of
https://github.com/penpot/penpot.git
synced 2025-02-15 11:38:24 -05:00
📎 Allow to debug touched attibute
This commit is contained in:
parent
e26ba1fabd
commit
d5e70e51ba
1 changed files with 48 additions and 42 deletions
|
@ -76,50 +76,56 @@
|
||||||
(let [page-id (get @state :current-page-id)]
|
(let [page-id (get @state :current-page-id)]
|
||||||
(logjs "state" (get-in @state [:workspace-data :pages-index page-id :objects]))))
|
(logjs "state" (get-in @state [:workspace-data :pages-index page-id :objects]))))
|
||||||
|
|
||||||
(defn ^:export dump-tree []
|
(defn ^:export dump-tree
|
||||||
(let [page-id (get @state :current-page-id)
|
([] (dump-tree false))
|
||||||
objects (get-in @state [:workspace-data :pages-index page-id :objects])
|
([show-touched]
|
||||||
components (get-in @state [:workspace-data :components])
|
(let [page-id (get @state :current-page-id)
|
||||||
libraries (get-in @state [:workspace-libraries])
|
objects (get-in @state [:workspace-data :pages-index page-id :objects])
|
||||||
root (d/seek #(nil? (:parent-id %)) (vals objects))]
|
components (get-in @state [:workspace-data :components])
|
||||||
|
libraries (get-in @state [:workspace-libraries])
|
||||||
|
root (d/seek #(nil? (:parent-id %)) (vals objects))]
|
||||||
|
|
||||||
(letfn [(show-shape [shape-id level objects]
|
(letfn [(show-shape [shape-id level objects]
|
||||||
(let [shape (get objects shape-id)]
|
(let [shape (get objects shape-id)]
|
||||||
(println (str/pad (str (str/repeat " " level)
|
(println (str/pad (str (str/repeat " " level)
|
||||||
(:name shape))
|
(:name shape))
|
||||||
{:length 20
|
{:length 20
|
||||||
:type :right})
|
:type :right})
|
||||||
(show-component shape objects))
|
(show-component shape objects))
|
||||||
(when (:shapes shape)
|
(when (and show-touched (seq (:touched shape)))
|
||||||
(dorun (for [shape-id (:shapes shape)]
|
(println (str (str/repeat " " level)
|
||||||
(show-shape shape-id (inc level) objects))))))
|
" "
|
||||||
|
(str (:touched shape)))))
|
||||||
|
(when (:shapes shape)
|
||||||
|
(dorun (for [shape-id (:shapes shape)]
|
||||||
|
(show-shape shape-id (inc level) objects))))))
|
||||||
|
|
||||||
(show-component [shape objects]
|
(show-component [shape objects]
|
||||||
(let [root-id (cph/get-root-component (:id shape) objects)
|
(let [root-id (cph/get-root-component (:id shape) objects)
|
||||||
root-shape (when root-id (get objects root-id))
|
root-shape (when root-id (get objects root-id))
|
||||||
component-id (when root-shape (:component-id root-shape))
|
component-id (when root-shape (:component-id root-shape))
|
||||||
component-file-id (when root-shape (:component-file root-shape))
|
component-file-id (when root-shape (:component-file root-shape))
|
||||||
component-file (when component-file-id (get libraries component-file-id))
|
component-file (when component-file-id (get libraries component-file-id))
|
||||||
shape-ref (:shape-ref shape)
|
shape-ref (:shape-ref shape)
|
||||||
component (when component-id
|
component (when component-id
|
||||||
(if component-file
|
(if component-file
|
||||||
(get-in component-file [:data :components component-id])
|
(get-in component-file [:data :components component-id])
|
||||||
(get components component-id)))
|
(get components component-id)))
|
||||||
component-shape (when (and component shape-ref)
|
component-shape (when (and component shape-ref)
|
||||||
(get-in component [:objects shape-ref]))]
|
(get-in component [:objects shape-ref]))]
|
||||||
(if component-shape
|
(if component-shape
|
||||||
(str/format " %s--> %s%s"
|
(str/format " %s--> %s%s"
|
||||||
(if (:component-id shape) "#" "-")
|
(if (:component-id shape) "#" "-")
|
||||||
(when component-file (str/format "<%s> " (:name component-file)))
|
(when component-file (str/format "<%s> " (:name component-file)))
|
||||||
(:name component-shape))
|
(:name component-shape))
|
||||||
"")))]
|
"")))]
|
||||||
|
|
||||||
(println "[Workspace]")
|
(println "[Workspace]")
|
||||||
(show-shape (:id root) 0 objects)
|
(show-shape (:id root) 0 objects)
|
||||||
|
|
||||||
(dorun (for [component (vals components)]
|
(dorun (for [component (vals components)]
|
||||||
(do
|
(do
|
||||||
(println)
|
(println)
|
||||||
(println (str/format "[%s]" (:name component)))
|
(println (str/format "[%s]" (:name component)))
|
||||||
(show-shape (:id component) 0 (:objects component))))))))
|
(show-shape (:id component) 0 (:objects component)))))))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue