♻️ Move app.common.pages to app.common.files

This commit is contained in:
Andrey Antukh 2023-11-15 16:35:52 +01:00
parent 8345548a7a
commit 52fbc678f3
139 changed files with 1459 additions and 1510 deletions

View file

@ -9,7 +9,7 @@
["js-beautify" :as beautify]
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.common.types.shape-tree :as ctst]
[app.main.data.workspace.state-helpers :as wsh]
[app.main.fonts :as fonts]
@ -23,7 +23,7 @@
(def style-type "css")
(def markup-type "html")
(def page-template
"<!DOCTYPE html>
@ -57,7 +57,7 @@
(defn shapes->fonts
[shapes]
(->> shapes
(filter cph/text-shape?)
(filter cfh/text-shape?)
(map (comp fonts/get-content-fonts :content))
(reduce set/union #{})))
@ -70,7 +70,7 @@
shape (get objects shape-id)
all-children
(->> (cph/selected-with-children objects [shape-id])
(->> (cfh/selected-with-children objects [shape-id])
(ctst/sort-z-index objects)
(keep (d/getf objects)))

View file

@ -8,8 +8,8 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.pages.helpers :as cph]
[app.common.schema :as sm]
[app.common.transit :as t]
[app.common.types.shape-tree :as ctt]
@ -688,7 +688,7 @@
(conj id))]
(-> state
(assoc-in [:viewer-local :selected]
(cph/expand-region-selection objects selection)))))))
(cfh/expand-region-selection objects selection)))))))
(defn select-all
[]

View file

@ -9,6 +9,7 @@
[app.common.attrs :as attrs]
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.changes-builder :as pcb]
[app.common.files.helpers :as cfh]
[app.common.geom.align :as gal]
[app.common.geom.point :as gpt]
@ -16,8 +17,6 @@
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.geom.shapes.grid-layout :as gslg]
[app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph]
[app.common.text :as txt]
[app.common.transit :as t]
[app.common.types.component :as ctk]
@ -495,7 +494,7 @@
objects (->> (:objects page)
(d/mapm (fn [_ val] (dissoc val :use-for-thumbnail))))
main-instances-ids (set (keep #(when (ctk/main-instance? (val %)) (key %)) objects))
ids-to-remove (set (apply concat (map #(cph/get-children-ids objects %) main-instances-ids)))
ids-to-remove (set (apply concat (map #(cfh/get-children-ids objects %) main-instances-ids)))
add-component-copy
(fn [objs id shape]
@ -688,7 +687,7 @@
(watch [_ state _]
(when-let [shape-id (dm/get-in state [:workspace-local :shape-for-rename])]
(let [shape (wsh/lookup-shape state shape-id)
name (cph/clean-path name)]
name (cfh/clean-path name)]
(rx/concat
;; Remove rename state from workspace local state
(rx/of #(update % :workspace-local dissoc :shape-for-rename))
@ -781,7 +780,7 @@
(defn relocate-shapes-changes [it objects parents parent-id page-id to-index ids
groups-to-delete groups-to-unmask shapes-to-detach
shapes-to-reroot shapes-to-deroot shapes-to-unconstraint]
(let [ordered-indexes (cph/order-by-indexed-shapes objects ids)
(let [ordered-indexes (cfh/order-by-indexed-shapes objects ids)
shapes (map (d/getf objects) ordered-indexes)
parent (get objects parent-id)]
@ -793,8 +792,8 @@
(pcb/update-shapes ordered-indexes ctl/remove-layout-item-data))
;; Remove the hide in viewer flag
(cond-> (and (not= uuid/zero parent-id) (cph/frame-shape? parent))
(pcb/update-shapes ordered-indexes #(cond-> % (cph/frame-shape? %) (assoc :hide-in-viewer true))))
(cond-> (and (not= uuid/zero parent-id) (cfh/frame-shape? parent))
(pcb/update-shapes ordered-indexes #(cond-> % (cfh/frame-shape? %) (assoc :hide-in-viewer true))))
;; Move the shapes
(pcb/change-parent parent-id
@ -880,12 +879,12 @@
objects (wsh/lookup-page-objects state page-id)
;; Ignore any shape whose parent is also intended to be moved
ids (cph/clean-loops objects ids)
ids (cfh/clean-loops objects ids)
;; If we try to move a parent into a child we remove it
ids (filter #(not (cph/is-parent? objects parent-id %)) ids)
ids (filter #(not (cfh/is-parent? objects parent-id %)) ids)
all-parents (into #{parent-id} (map #(cph/get-parent-id objects %)) ids)
all-parents (into #{parent-id} (map #(cfh/get-parent-id objects %)) ids)
parents (if ignore-parents? #{parent-id} all-parents)
groups-to-delete
@ -904,7 +903,7 @@
(empty? (remove removed-id? (:shapes group))))
;; Adds group to the remove and check its parent
(let [to-check (concat to-check [(cph/get-parent-id objects current-id)])]
(let [to-check (concat to-check [(cfh/get-parent-id objects current-id)])]
(recur (first to-check)
(rest to-check)
(conj removed-id? current-id)
@ -955,7 +954,7 @@
(not component-shape-parent))
ids-to-detach (when detach?
(cons id (cph/get-children-ids objects id)))]
(cons id (cfh/get-children-ids objects id)))]
[(cond-> shapes-to-detach detach? (into ids-to-detach))
(cond-> shapes-to-deroot deroot? (conj id))
@ -1380,8 +1379,8 @@
page-id (get state :current-page-id)
pparams {:file-id file-id :project-id project-id}
qparams {:page-id page-id :layout :assets}
component-path (cph/split-path (get-in state [:workspace-data :components component-id :path]))
paths (map (fn [i] (cph/join-path (take (inc i) component-path))) (range (count component-path)))]
component-path (cfh/split-path (get-in state [:workspace-data :components component-id :path]))
paths (map (fn [i] (cfh/join-path (take (inc i) component-path))) (range (count component-path)))]
(rx/concat
(rx/from (map #(set-assets-group-open file-id :components % true) paths))
(rx/of (rt/nav :workspace pparams qparams)
@ -1462,7 +1461,7 @@
(watch [_ state _]
(let [selected (wsh/lookup-selected state)
objects (wsh/lookup-page-objects state)
all-selected (into [] (mapcat #(cph/get-children-with-self objects %)) selected)
all-selected (into [] (mapcat #(cfh/get-children-with-self objects %)) selected)
head (get objects (first selected))
not-group-like? (and (= (count selected) 1)
@ -1510,7 +1509,7 @@
;; Narrow the objects map so it contains only relevant data for
;; selected and its parents
objects (cph/selected-subtree objects selected)
objects (cfh/selected-subtree objects selected)
selected (->> (ctst/sort-z-index objects selected)
(reverse)
(into (d/ordered-set)))]
@ -1538,7 +1537,7 @@
(reduce into [])
(filter :fill-image)
(map :fill-image))
stroke-images-data (->> (:strokes obj)
(filter :stroke-image)
(map :stroke-image))
@ -1547,7 +1546,7 @@
stroke-images-data
(when (= type :image)
[(:metadata obj)]))]
(if (> (count images-data) 0)
(->> (rx/from images-data)
(rx/mapcat (fn [image-data]
@ -1587,9 +1586,9 @@
(watch [_ state _]
(let [objects (wsh/lookup-page-objects state)
selected (->> (wsh/lookup-selected state)
(cph/clean-loops objects))
(cfh/clean-loops objects))
parent-frame-id (cph/common-parent-frame objects selected)
parent-frame-id (cfh/common-parent-frame objects selected)
pdata (reduce (partial collect-object-ids objects) {} selected)
initial {:type :copied-shapes
:file-id (:current-file-id state)
@ -1767,7 +1766,7 @@
(let [fills (mapv #(translate-staled-media % :fill-image media-idx) (:fills p-data))]
(assoc p-data :fills fills)))))
content (txt/transform-nodes #(translate-staled-media % :fill-image media-idx) (:content obj))]
(if (= (:type item) :add-obj)
(-> item
(update-in [:obj :metadata]
@ -1793,15 +1792,15 @@
orig-pos (gpt/point (:x1 wrapper) (:y1 wrapper))
frame-id (first page-selected)
frame-object (get page-objects frame-id)
base (cph/get-base-shape page-objects page-selected)
index (cph/get-position-on-parent page-objects (:id base))
base (cfh/get-base-shape page-objects page-selected)
index (cfh/get-position-on-parent page-objects (:id base))
tree-root (get-tree-root-shapes paste-objects)
only-one-root-shape? (and
(< 1 (count paste-objects))
(= 1 (count tree-root)))
all-objects (merge page-objects paste-objects)
comps-nesting-loop? (not (->> (keys paste-objects)
(map #(cph/components-nesting-loop? all-objects % (:id base)))
(map #(cfh/components-nesting-loop? all-objects % (:id base)))
(every? nil?)))]
(cond
@ -1904,8 +1903,8 @@
process-shape
(fn [_ shape]
(let [assign-shapes? (and (or (cph/group-shape? shape)
(cph/bool-shape? shape))
(let [assign-shapes? (and (or (cfh/group-shape? shape)
(cfh/bool-shape? shape))
(nil? (:shapes shape)))]
(-> shape
(assoc :frame-id frame-id :parent-id parent-id)
@ -2234,7 +2233,7 @@
copies-no-ref (filter #(not (:shape-ref %)) copies)
find-childs-no-ref (fn [acc-map item]
(let [id (:id item)
childs (->> (cph/get-children objects id)
childs (->> (cfh/get-children objects id)
(filter #(not (:shape-ref %))))]
(if (seq childs)
(assoc acc-map id childs)

View file

@ -7,9 +7,9 @@
(ns app.main.data.workspace.bool
(:require
[app.common.data :as d]
[app.common.files.changes-builder :as pcb]
[app.common.files.helpers :as cph]
[app.common.geom.shapes :as gsh]
[app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph]
[app.common.svg.path.shapes-to-path :as stp]
[app.common.types.container :as ctn]
[app.common.types.shape :as cts]

View file

@ -9,11 +9,10 @@
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.exceptions :as ex]
[app.common.files.changes :as cpc]
[app.common.files.changes-builder :as pcb]
[app.common.files.helpers :as cph]
[app.common.logging :as log]
[app.common.pages :as cp]
[app.common.pages.changes :as cpc]
[app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph]
[app.common.schema :as sm]
[app.common.types.shape-tree :as ctst]
[app.common.uuid :as uuid]
@ -218,7 +217,7 @@
(update-in state path (fn [file]
(-> file
(cp/process-changes redo-changes false)
(cpc/process-changes redo-changes false)
(ctst/update-object-indices page-id))))
(catch :default err

View file

@ -6,7 +6,7 @@
(ns app.main.data.workspace.collapse
(:require
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.common.uuid :as uuid]
[potok.core :as ptk]))
@ -20,7 +20,7 @@
(let [expand-fn (fn [expanded]
(merge expanded
(->> ids
(map #(cph/get-parent-ids objects %))
(map #(cfh/get-parent-ids objects %))
flatten
(remove #(= % uuid/zero))
(map (fn [id] {id true}))

View file

@ -9,7 +9,7 @@
[app.common.colors :as cc]
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.common.schema :as sm]
[app.common.types.component :as ctk]
[app.main.broadcast :as mbc]
@ -231,7 +231,7 @@
(contains? attrs :image)
(assoc :stroke-image (:image attrs)))
attrs (->
attrs (->
(merge attrs color-attrs)
(dissoc :image)
(dissoc :gradient))]
@ -415,7 +415,7 @@
(watch [_ state _]
(let [objects (wsh/lookup-page-objects state)
selected (->> (wsh/lookup-selected state)
(cph/clean-loops objects))
(cfh/clean-loops objects))
ids
(loop [pending (seq selected)
@ -424,8 +424,8 @@
result
(let [cur (first pending)
;; We treat frames that aren't components and with no fill the same as groups
group? (or (cph/group-shape? objects cur)
(and (cph/frame-shape? objects cur)
group? (or (cfh/group-shape? objects cur)
(and (cfh/frame-shape? objects cur)
(empty? (dm/get-in objects [cur :fills]))
(not (ctk/instance-head? (get objects cur)))))
@ -666,7 +666,7 @@
(let [selected (wsh/lookup-selected state)
shapes (wsh/lookup-shapes state selected)
shape (first shapes)
fills (if (cph/text-shape? shape)
fills (if (cfh/text-shape? shape)
(:fills (dwt/current-text-values
{:editor-state (dm/get-in state [:workspace-editor-state (:id shape)])
:shape shape

View file

@ -7,9 +7,9 @@
(ns app.main.data.workspace.comments
(:require
[app.common.data.macros :as dm]
[app.common.files.changes-builder :as pcb]
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
[app.common.pages.changes-builder :as pcb]
[app.common.schema :as sm]
[app.common.types.shape-tree :as ctst]
[app.main.data.comments :as dcm]

View file

@ -7,9 +7,9 @@
(ns app.main.data.workspace.drawing.common
(:require
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.shapes :as gsh]
[app.common.math :as mth]
[app.common.pages.helpers :as cph]
[app.common.types.modifiers :as ctm]
[app.common.types.shape :as cts]
[app.main.data.workspace.shapes :as dwsh]
@ -39,7 +39,7 @@
(rx/concat
(when (:initialized? shape)
(let [click-draw? (:click-draw? shape)
text? (cph/text-shape? shape)
text? (cfh/text-shape? shape)
vbox (dm/get-in state [:workspace-local :vbox])
min-side (mth/min 100
@ -70,19 +70,19 @@
;; Add & select the created shape to the workspace
(rx/concat
(if (cph/frame-shape? shape)
(if (cfh/frame-shape? shape)
(rx/of (dwu/start-undo-transaction (:id shape)))
(rx/empty))
(rx/of (dwsh/add-shape shape {:no-select? (= tool :curve)}))
(if (cph/frame-shape? shape)
(if (cfh/frame-shape? shape)
(rx/concat
(->> (uw/ask! {:cmd :selection/query
:page-id page-id
:rect (:selrect shape)
:include-frames? true
:full-frame? true})
(rx/map #(cph/clean-loops objects %))
(rx/map #(cfh/clean-loops objects %))
(rx/map #(dwsh/move-shapes-into-frame (:id shape) %)))
(rx/of (dwu/commit-undo-transaction (:id shape))))
(rx/empty)))))

View file

@ -7,7 +7,7 @@
(ns app.main.data.workspace.fix-deleted-fonts
(:require
[app.common.data :as d]
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.common.text :as txt]
[app.main.data.workspace.changes :as dch]
[app.main.data.workspace.state-helpers :as wsh]
@ -39,7 +39,7 @@
(defn should-fix-deleted-font-shape?
[shape]
(let [text-nodes (txt/node-seq txt/is-text-node? (:content shape))]
(and (cph/text-shape? shape) (some has-invalid-font-family text-nodes))))
(and (cfh/text-shape? shape) (some has-invalid-font-family text-nodes))))
(defn should-fix-deleted-font-component?
[component]

View file

@ -9,7 +9,7 @@
[app.common.colors :as clr]
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.pages.changes-builder :as pcb]
[app.common.files.changes-builder :as pcb]
[app.main.data.workspace.changes :as dch]
[app.main.data.workspace.state-helpers :as wsh]
[beicon.core :as rx]

View file

@ -8,9 +8,9 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.changes-builder :as pcb]
[app.common.files.helpers :as cfh]
[app.common.geom.shapes :as gsh]
[app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph]
[app.common.types.component :as ctk]
[app.common.types.container :as ctn]
[app.common.types.pages-list :as ctpl]
@ -29,7 +29,7 @@
(defn shapes-for-grouping
[objects selected]
(->> selected
(cph/order-by-indexed-shapes objects)
(cfh/order-by-indexed-shapes objects)
reverse
(map #(get objects %))))
@ -42,8 +42,8 @@
group, one (or many) groups can become empty because they have had a
single shape which is moved to the created group."
[objects parent-id shapes]
(let [ids (cph/clean-loops objects (into #{} (map :id) shapes))
parents (into #{} (map #(cph/get-parent-id objects %)) ids)]
(let [ids (cfh/clean-loops objects (into #{} (map :id) shapes))
parents (into #{} (map #(cfh/get-parent-id objects %)) ids)]
(loop [current-id (first parents)
to-check (rest parents)
removed-id? ids
@ -59,7 +59,7 @@
(empty? (remove removed-id? (:shapes group))))
;; Adds group to the remove and check its parent
(let [to-check (concat to-check [(cph/get-parent-id objects current-id)]) ]
(let [to-check (concat to-check [(cfh/get-parent-id objects current-id)]) ]
(recur (first to-check)
(rest to-check)
(conj removed-id? current-id)
@ -85,7 +85,7 @@
group-idx (->> shapes
last
:id
(cph/get-position-on-parent objects)
(cfh/get-position-on-parent objects)
inc)
group (cts/setup-shape {:type :group
@ -137,9 +137,9 @@
(defn remove-group-changes
[it page-id group objects]
(let [children (->> (:shapes group)
(cph/order-by-indexed-shapes objects)
(cfh/order-by-indexed-shapes objects)
(mapv #(get objects %)))
parent-id (cph/get-parent-id objects (:id group))
parent-id (cfh/get-parent-id objects (:id group))
parent (get objects parent-id)
index-in-parent
@ -152,7 +152,7 @@
;; Shapes that are in a component (including root) must be detached,
;; because cannot be easyly synchronized back to the main component.
shapes-to-detach (filter ctk/in-component-copy?
(cph/get-children-with-self objects (:id group)))]
(cfh/get-children-with-self objects (:id group)))]
(-> (pcb/empty-changes it page-id)
(pcb/with-objects objects)
@ -163,11 +163,11 @@
(defn remove-frame-changes
[it page-id frame objects]
(let [children (->> (:shapes frame)
(cph/order-by-indexed-shapes objects)
(cfh/order-by-indexed-shapes objects)
(mapv #(get objects %)))
parent-id (cph/get-parent-id objects (:id frame))
parent-id (cfh/get-parent-id objects (:id frame))
idx-in-parent (->> (:id frame)
(cph/get-position-on-parent objects)
(cfh/get-position-on-parent objects)
inc)]
(-> (pcb/empty-changes it page-id)
@ -228,7 +228,7 @@
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
selected (->> (wsh/lookup-selected state)
(cph/clean-loops objects)
(cfh/clean-loops objects)
(remove #(ctn/has-any-copy-parent? objects (get objects %))))
shapes (shapes-for-grouping objects selected)
parents (into #{} (map :parent-id) shapes)]
@ -256,10 +256,10 @@
(ctk/main-instance? shape)
(remove-component-changes it page-id shape objects file-data file)
(or (cph/group-shape? shape) (cph/bool-shape? shape))
(or (cfh/group-shape? shape) (cfh/bool-shape? shape))
(remove-group-changes it page-id shape objects)
(cph/frame-shape? shape)
(cfh/frame-shape? shape)
(remove-frame-changes it page-id shape objects))]
(cond-> changes
@ -273,7 +273,7 @@
selected)
parents (into #{}
(comp (map #(cph/get-parent objects %))
(comp (map #(cfh/get-parent objects %))
(keep :id))
selected)
@ -301,7 +301,7 @@
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
selected (->> (wsh/lookup-selected state)
(cph/clean-loops objects)
(cfh/clean-loops objects)
(remove #(ctn/has-any-copy-parent? objects (get objects %))))
shapes (shapes-for-grouping objects selected)
first-shape (first shapes)]

View file

@ -7,9 +7,9 @@
(ns app.main.data.workspace.guides
(:require
[app.common.data.macros :as dm]
[app.common.files.changes-builder :as pcb]
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
[app.common.pages.changes-builder :as pcb]
[app.common.types.page :as ctp]
[app.main.data.workspace.changes :as dwc]
[app.main.data.workspace.state-helpers :as wsh]

View file

@ -8,10 +8,9 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.changes-builder :as pcb]
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph]
[app.common.types.page :as ctp]
[app.common.types.shape-tree :as ctst]
[app.common.types.shape.interactions :as ctsi]
@ -100,7 +99,7 @@
"Check if some frame is origin or destination of any navigate interaction
in the page"
[objects frame-id]
(let [children (cph/get-children-with-self objects frame-id)]
(let [children (cfh/get-children-with-self objects frame-id)]
(or (some ctsi/flow-origin? (map :interactions children))
(some #(ctsi/flow-to? % frame-id) (map :interactions (vals objects))))))
@ -112,7 +111,7 @@
(watch [_ state _]
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
frame (cph/get-root-frame objects (:id shape))
frame (cfh/get-root-frame objects (:id shape))
flows (get-in state [:workspace-data
:pages-index
page-id
@ -203,7 +202,7 @@
from-id (-> state wsh/lookup-selected first)
from-shape (wsh/lookup-shape state from-id)
from-frame-id (if (cph/frame-shape? from-shape)
from-frame-id (if (cfh/frame-shape? from-shape)
from-id (:frame-id from-shape))
target-frame (ctst/get-frame-by-position objects position)]
@ -307,7 +306,7 @@
overlay-pos (-> shape
(get-in [:interactions index])
:overlay-position)
orig-frame (cph/get-frame objects shape)
orig-frame (cfh/get-frame objects shape)
frame-pos (gpt/point (:x orig-frame) (:y orig-frame))
offset (-> initial-pos
(gpt/subtract overlay-pos)

View file

@ -8,14 +8,13 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.changes :as ch]
[app.common.files.changes-builder :as pcb]
[app.common.files.helpers :as cfh]
[app.common.files.libraries-helpers :as cflh]
[app.common.files.shapes-helpers :as cfsh]
[app.common.geom.point :as gpt]
[app.common.logging :as log]
[app.common.pages :as cp]
[app.common.pages.changes :as ch]
[app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph]
[app.common.types.color :as ctc]
[app.common.types.component :as ctk]
[app.common.types.components-list :as ctkl]
@ -85,7 +84,7 @@
(defn extract-path-if-missing
[item]
(let [[path name] (cph/parse-path-name (:name item))]
(let [[path name] (cfh/parse-path-name (:name item))]
(if (and
(= (:name item) name)
(contains? item :path))
@ -131,7 +130,7 @@
(defn- do-update-color
[it state color file-id]
(let [data (get state :workspace-data)
[path name] (cph/parse-path-name (:name color))
[path name] (cfh/parse-path-name (:name color))
color (assoc color :path path :name name)
changes (-> (pcb/empty-changes it)
(pcb/with-library-data data)
@ -202,7 +201,7 @@
(let [new-name (str/trim new-name)]
(if (str/empty? new-name)
(rx/empty)
(let [[path name] (cph/parse-path-name new-name)
(let [[path name] (cfh/parse-path-name new-name)
data (get state :workspace-data)
object (get-in data [:media id])
new-object (assoc object :path path :name name)
@ -274,7 +273,7 @@
(watch [it state _]
(when (and (some? new-name) (not= "" new-name))
(let [data (get state :workspace-data)
[path name] (cph/parse-path-name new-name)
[path name] (cfh/parse-path-name new-name)
object (get-in data [:typographies id])
new-object (assoc object :path path :name name)]
(do-update-tipography it state new-object file-id))))))
@ -326,7 +325,7 @@
(watch [_ state _]
(let [objects (wsh/lookup-page-objects state)
selected (->> (wsh/lookup-selected state)
(cph/clean-loops objects)
(cfh/clean-loops objects)
(remove #(ctn/has-any-copy-parent? objects (get objects %)))) ;; We don't want to change the structure of component copies
components-v2 (features/active-feature? state "components/v2")]
(rx/of (add-component2 selected components-v2))))))
@ -340,7 +339,7 @@
(let [components-v2 (features/active-feature? state "components/v2")
objects (wsh/lookup-page-objects state)
selected (->> (wsh/lookup-selected state)
(cph/clean-loops objects)
(cfh/clean-loops objects)
(remove #(ctn/has-any-copy-parent? objects (get objects %)))) ;; We don't want to change the structure of component copies
added-components (map
#(add-component2 [%] components-v2)
@ -363,7 +362,7 @@
(if (str/empty? new-name)
(rx/empty)
(let [data (get state :workspace-data)
[path name] (cph/parse-path-name new-name)
[path name] (cfh/parse-path-name new-name)
components-v2 (features/active-feature? state "components/v2")
update-fn
@ -390,7 +389,7 @@
ptk/WatchEvent
(watch [_ state _]
(when-let [component (dm/get-in state [:workspace-data :components component-id])]
(let [name (cph/clean-path name)
(let [name (cfh/clean-path name)
shape-id (:main-instance-id component)
page-id (:main-instance-page component)]
(rx/concat
@ -544,7 +543,7 @@
(watch [it state _]
(let [file (wsh/get-local-file state)
page-id (get state :current-page-id)
container (cph/get-container file :page page-id)
container (cfh/get-container file :page page-id)
changes (-> (pcb/empty-changes it)
(pcb/with-container container)
@ -573,10 +572,10 @@
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
file (wsh/get-local-file state)
container (cph/get-container file :page page-id)
container (cfh/get-container file :page page-id)
selected (->> state
(wsh/lookup-selected)
(cph/clean-loops objects))
(cfh/clean-loops objects))
changes (reduce
(fn [changes id]
@ -614,7 +613,7 @@
(update-in [:workspace-libraries library-id]
assoc :modified-at modified-at :revn revn)
(d/update-in-when [:workspace-libraries library-id :data]
cp/process-changes changes)))
ch/process-changes changes)))
ptk/WatchEvent
(watch [_ _ _]
@ -637,7 +636,7 @@
libraries (wsh/get-libraries state)
page-id (:current-page-id state)
container (cph/get-container file :page page-id)
container (cfh/get-container file :page page-id)
components-v2
(features/active-feature? state "components/v2")
@ -685,7 +684,7 @@
(log/info :msg "UPDATE-COMPONENT of shape" :id (str id) :undo-group undo-group)
(let [page-id (get state :current-page-id)
local-file (wsh/get-local-file state)
container (cph/get-container local-file :page page-id)
container (cfh/get-container local-file :page page-id)
shape (ctn/get-shape container id)
components-v2 (features/active-feature? state "components/v2")]

View file

@ -8,12 +8,12 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.changes-builder :as pcb]
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
[app.common.geom.shapes.grid-layout :as gslg]
[app.common.logging :as log]
[app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph]
[app.common.spec :as us]
[app.common.text :as txt]
[app.common.types.color :as ctc]
@ -116,14 +116,14 @@
; main nested in the original component.
(let [origin-shape-id (get @inverted-ids-map (:id shape))
objects (:objects main-instance-page)
parent-ids (cph/get-parent-ids-seq-with-self objects origin-shape-id)]
parent-ids (cfh/get-parent-ids-seq-with-self objects origin-shape-id)]
(cond-> shape
(@nested-main-heads origin-shape-id)
(dissoc :main-instance)
(some @nested-main-heads parent-ids)
(assoc :shape-ref origin-shape-id))))
xf-shape (comp (map remap-frame)
(map convert-nested-main))
@ -219,7 +219,7 @@
([changes library-data component-id it page delta old-id parent-id]
(let [component (ctkl/get-deleted-component library-data component-id)
shapes (cph/get-children-with-self (:objects component) (:main-instance-id component))
shapes (cfh/get-children-with-self (:objects component) (:main-instance-id component))
shapes (map #(gsh/move % delta) shapes)
first-shape (cond-> (first shapes)
(not (nil? parent-id))
@ -269,7 +269,7 @@
asset-id
library-id
state
(cph/make-container page :page)
(cfh/make-container page :page)
components-v2)))
changes))))
@ -305,7 +305,7 @@
asset-id
library-id
state
(cph/make-container local-component :component)
(cfh/make-container local-component :component)
components-v2)))
changes))))
@ -314,7 +314,7 @@
or a component) that use assets of the given type in the given library."
[it asset-type asset-id library-id state container components-v2]
(if (cph/page? container)
(if (cfh/page? container)
(log/debug :msg "Sync page in local file" :page-id (:id container))
(log/debug :msg "Sync component in local library" :component-id (:id container)))
@ -884,10 +884,10 @@
(log/info :msg (str "ADD [P] " (:name component-shape)))
(let [component-parent-shape (ctn/get-shape component-page (:parent-id component-shape))
parent-shape (d/seek #(ctk/is-main-of? component-parent-shape %)
(cph/get-children-with-self (:objects container)
(cfh/get-children-with-self (:objects container)
(:id root-instance)))
all-parents (into [(:id parent-shape)]
(cph/get-parent-ids (:objects container)
(cfh/get-parent-ids (:objects container)
(:id parent-shape)))
update-new-shape (fn [new-shape original-shape]
@ -945,7 +945,7 @@
:shapes all-parents}))
changes' (reduce del-obj-change changes' new-shapes)]
(if (and (cph/touched-group? parent-shape :shapes-group) omit-touched?)
(if (and (cfh/touched-group? parent-shape :shapes-group) omit-touched?)
changes
changes')))
@ -954,10 +954,10 @@
(log/info :msg (str "ADD [C] " (:name shape)))
(let [parent-shape (ctn/get-shape page (:parent-id shape))
component-parent-shape (d/seek #(ctk/is-main-of? % parent-shape)
(cph/get-children-with-self (:objects component-container)
(cfh/get-children-with-self (:objects component-container)
(:id root-main)))
all-parents (into [(:id component-parent-shape)]
(cph/get-parent-ids (:objects component-container)
(cfh/get-parent-ids (:objects component-container)
(:id component-parent-shape)))
update-new-shape (fn [new-shape _original-shape]
@ -1034,12 +1034,12 @@
(defn- remove-shape
[changes shape container omit-touched?]
(log/info :msg (str "REMOVE-SHAPE "
(if (cph/page? container) "[P] " "[C] ")
(if (cfh/page? container) "[P] " "[C] ")
(:name shape)))
(let [objects (get container :objects)
parents (cph/get-parent-ids objects (:id shape))
parents (cfh/get-parent-ids objects (:id shape))
parent (first parents)
children (cph/get-children-ids objects (:id shape))
children (cfh/get-children-ids objects (:id shape))
ids (into [(:id shape)] children)
add-redo-change (fn [changes id]
@ -1057,7 +1057,7 @@
container
(as-> {:type :add-obj
:id id
:index (cph/get-position-on-parent objects id)
:index (cfh/get-position-on-parent objects id)
:parent-id (:parent-id shape')
:ignore-touched true
:obj shape'} $
@ -1076,14 +1076,14 @@
changes'
children)]
(if (and (cph/touched-group? parent :shapes-group) omit-touched?)
(if (and (cfh/touched-group? parent :shapes-group) omit-touched?)
changes
changes')))
(defn- move-shape
[changes shape index-before index-after container omit-touched?]
(log/info :msg (str "MOVE "
(if (cph/page? container) "[P] " "[C] ")
(if (cfh/page? container) "[P] " "[C] ")
(:name shape)
" "
index-before
@ -1107,7 +1107,7 @@
:index index-before
:ignore-touched true})))]
(if (and (cph/touched-group? parent :shapes-group) omit-touched?)
(if (and (cfh/touched-group? parent :shapes-group) omit-touched?)
changes
changes')))
@ -1119,7 +1119,7 @@
changes
(do
(log/info :msg (str "CHANGE-TOUCHED "
(if (cph/page? container) "[P] " "[C] ")
(if (cfh/page? container) "[P] " "[C] ")
(:name dest-shape))
:options options)
(let [new-touched (cond
@ -1154,7 +1154,7 @@
changes
(do
(log/info :msg (str "CHANGE-REMOTE-SYNCED? "
(if (cph/page? container) "[P] " "[C] ")
(if (cfh/page? container) "[P] " "[C] ")
(:name shape))
:remote-synced remote-synced?)
(-> changes
@ -1184,7 +1184,7 @@
(log/info :msg (str "SYNC "
(:name origin-shape)
" -> "
(if (cph/page? container) "[P] " "[C] ")
(if (cfh/page? container) "[P] " "[C] ")
(:name dest-shape)))
(let [;; To synchronize geometry attributes we need to make a prior
@ -1205,7 +1205,7 @@
(if (nil? attr)
(if (empty? roperations)
changes
(let [all-parents (cph/get-parent-ids (:objects container)
(let [all-parents (cfh/get-parent-ids (:objects container)
(:id dest-shape))]
(-> changes
(update :redo-changes conj (make-change
@ -1259,7 +1259,7 @@
(defn- make-change
[container change]
(if (cph/page? container)
(if (cfh/page? container)
(assoc change :page-id (:id container))
(assoc change :component-id (:id container))))

View file

@ -9,9 +9,9 @@
[app.common.data.macros :as dm]
[app.common.exceptions :as ex]
[app.common.files.builder :as fb]
[app.common.files.changes-builder :as pcb]
[app.common.logging :as log]
[app.common.math :as mth]
[app.common.pages.changes-builder :as pcb]
[app.common.schema :as sm]
[app.common.svg :refer [optimize]]
[app.common.svg.shapes-builder :as csvg.shapes-builder]
@ -259,7 +259,7 @@
(ptk/reify ::upload-fill-image
ptk/WatchEvent
(watch [_ state _]
(let [on-upload-success
(let [on-upload-success
(fn [image]
(on-success image)
(dmm/notify-finished-loading))

View file

@ -9,12 +9,12 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.modifiers :as gm]
[app.common.geom.point :as gpt]
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.math :as mth]
[app.common.pages.helpers :as cph]
[app.common.types.component :as ctk]
[app.common.types.container :as ctn]
[app.common.types.modifiers :as ctm]
@ -95,7 +95,7 @@
(if (:component-root shape)
transformed-shape
(gsh/transform-shape root (dm/get-in modif-tree [(:id root) :modifiers])))]
(get-ignore-tree ignore-tree shape transformed-shape root transformed-root)))
([ignore-tree shape root transformed-root]
@ -112,7 +112,7 @@
(assoc
shape-id
(check-delta shape root transformed-shape transformed-root)))
set-child
(fn [ignore-tree child]
(get-ignore-tree ignore-tree child root transformed-root))]
@ -474,7 +474,7 @@
ids-with-children
(into ids
(mapcat (partial cph/get-children-ids objects))
(mapcat (partial cfh/get-children-ids objects))
ids)
ignore-tree
@ -492,7 +492,7 @@
ids
(fn [shape]
(let [modif (get-in object-modifiers [(:id shape) :modifiers])
text-shape? (cph/text-shape? shape)
text-shape? (cfh/text-shape? shape)
position-data (when text-shape?
(dm/get-in text-modifiers [(:id shape) :position-data]))]
(-> shape

View file

@ -8,7 +8,7 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.pages.changes :as cpc]
[app.common.files.changes :as cpc]
[app.common.schema :as sm]
[app.common.uuid :as uuid]
[app.main.data.common :refer [handle-notification]]

View file

@ -7,7 +7,7 @@
(ns app.main.data.workspace.path.changes
(:require
[app.common.data.macros :as dm]
[app.common.pages.changes-builder :as pcb]
[app.common.files.changes-builder :as pcb]
[app.main.data.workspace.changes :as dch]
[app.main.data.workspace.path.common :refer [content?]]
[app.main.data.workspace.path.helpers :as helpers]

View file

@ -8,9 +8,9 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.geom.shapes.path :as upg]
[app.common.pages.helpers :as cph]
[app.common.svg.path.command :as upc]
[app.common.svg.path.shapes-to-path :as upsp]
[app.common.svg.path.subpath :as ups]
@ -289,7 +289,7 @@
edit-path (dm/get-in state [:workspace-local :edit-path id])
content (st/get-path state :content)
state (cond-> state
(cph/path-shape? objects id)
(cfh/path-shape? objects id)
(st/set-content (ups/close-subpaths content)))]
(cond-> state
(or (not edit-path) (= :draw (:edit-mode edit-path)))

View file

@ -6,8 +6,8 @@
(ns app.main.data.workspace.path.shapes-to-path
(:require
[app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph]
[app.common.files.changes-builder :as pcb]
[app.common.files.helpers :as cph]
[app.common.svg.path.shapes-to-path :as upsp]
[app.common.types.container :as ctn]
[app.main.data.workspace.changes :as dch]

View file

@ -7,9 +7,8 @@
(ns app.main.data.workspace.persistence
(:require
[app.common.data.macros :as dm]
[app.common.files.changes :as cpc]
[app.common.logging :as log]
[app.common.pages :as cp]
[app.common.pages.changes :as cpc]
[app.common.types.shape-tree :as ctst]
[app.common.uuid :as uuid]
[app.main.data.workspace.changes :as dch]
@ -259,12 +258,12 @@
entries (seq changes)]
(if-let [[page-id changes] (first entries)]
(recur (-> fdata
(cp/process-changes changes)
(cpc/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] cpc/process-changes changes)))
state))))

View file

@ -8,14 +8,13 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.changes-builder :as pcb]
[app.common.files.focus :as cpf]
[app.common.files.helpers :as cfh]
[app.common.files.libraries-helpers :as cflh]
[app.common.geom.point :as gpt]
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.pages.changes-builder :as pcb]
[app.common.pages.focus :as cpf]
[app.common.pages.helpers :as cph]
[app.common.record :as cr]
[app.common.types.component :as ctk]
[app.common.types.file :as ctf]
@ -202,7 +201,7 @@
ptk/UpdateEvent
(update [_ state]
(let [objects (or objects (wsh/lookup-page-objects state))
append-to-selection (cph/expand-region-selection objects (into #{} [(get-in state [:workspace-local :last-selected]) id]))
append-to-selection (cfh/expand-region-selection objects (into #{} [(get-in state [:workspace-local :last-selected]) id]))
selection (-> state
wsh/lookup-selected
(conj id))]
@ -259,7 +258,7 @@
(-> parents first lookup)
(lookup uuid/zero))
toselect (->> (cph/get-immediate-children objects (:id parent))
toselect (->> (cfh/get-immediate-children objects (:id parent))
(into (d/ordered-set) (comp (remove :hidden) (remove :blocked) (map :id))))]
(rx/of (select-shapes toselect))))))
@ -313,10 +312,10 @@
:ignore-groups? ignore-groups?
:full-frame? true
:using-selrect? true})
(rx/map #(cph/clean-loops objects %))
(rx/map #(cfh/clean-loops objects %))
(rx/map #(into initial-set (comp
(filter (complement blocked?))
(remove (partial cph/hidden-parent? objects))) %))
(remove (partial cfh/hidden-parent? objects))) %))
(rx/map select-shapes)))))))
(defn select-inside-group
@ -357,7 +356,7 @@
(let [shapes (map (d/getf all-objects) ids)
unames (volatile! (cfh/get-used-names (:objects page)))
update-unames! (fn [new-name] (vswap! unames conj new-name))
all-ids (reduce #(into %1 (cons %2 (cph/get-children-ids all-objects %2))) (d/ordered-set) ids)
all-ids (reduce #(into %1 (cons %2 (cfh/get-children-ids all-objects %2))) (d/ordered-set) ids)
ids-map (into {} (map #(vector % (uuid/next))) all-ids)
changes
@ -423,9 +422,9 @@
(prepare-duplicate-component-change changes objects page obj parent-id delta libraries library-data it)
:else
(let [frame? (cph/frame-shape? obj)
group? (cph/group-shape? obj)
bool? (cph/bool-shape? obj)
(let [frame? (cfh/frame-shape? obj)
group? (cfh/group-shape? obj)
bool? (cfh/bool-shape? obj)
new-id (ids-map (:id obj))
parent-id (or parent-id frame-id)
name (:name obj)
@ -554,7 +553,7 @@
(let [;; index-map is a map that goes from parent-id => vector([id index-in-parent])
index-map (reduce (fn [index-map id]
(let [parent-id (get-in objects [id :parent-id])
parent-index (cph/get-position-on-parent objects id)]
parent-index (cfh/get-position-on-parent objects id)]
(update index-map parent-id (fnil conj []) [id parent-index])))
{}
ids)
@ -608,7 +607,7 @@
[obj state objects]
(let [{:keys [id-original id-duplicated]}
(get-in state [:workspace-local :duplicated])
move? (and (cph/frame-shape? obj)
move? (and (cfh/frame-shape? obj)
(not (ctk/instance-head? obj)))]
(if (or (and (not= id-original (:id obj))
(not= id-duplicated (:id obj)))
@ -706,7 +705,7 @@
focus (-> (:workspace-focus-selected state)
(set/union added)
(set/difference removed))
focus (cph/clean-loops objects focus)]
focus (cfh/clean-loops objects focus)]
(-> state
(assoc :workspace-focus-selected focus))))))

View file

@ -9,9 +9,9 @@
[app.common.colors :as clr]
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.shapes.flex-layout :as flex]
[app.common.geom.shapes.grid-layout :as grid]
[app.common.pages.helpers :as cph]
[app.common.types.component :as ctc]
[app.common.types.modifiers :as ctm]
[app.common.types.shape.layout :as ctl]
@ -78,13 +78,13 @@
(let [shape
(-> shape
(merge initial-layout-data)
;; (cond-> (= type :grid) (-> ctl/assign-cells ctl/reorder-grid-children))
;; If the original shape is not a frame we set clip content and show-viewer to false
(cond-> (not from-frame?)
(assoc :show-content true :hide-in-viewer true)))
params (calculate-params objects (cph/get-immediate-children objects (:id shape)) shape)]
params (calculate-params objects (cfh/get-immediate-children objects (:id shape)) shape)]
(cond-> (merge shape params)
(= type :grid) (-> ctl/assign-cells ctl/reorder-grid-children)))
@ -149,9 +149,9 @@
selected (wsh/lookup-selected state)
selected-shapes (map (d/getf objects) selected)
single? (= (count selected-shapes) 1)
has-group? (->> selected-shapes (d/seek cph/group-shape?))
has-group? (->> selected-shapes (d/seek cfh/group-shape?))
is-group? (and single? has-group?)
has-mask? (->> selected-shapes (d/seek cph/mask-shape?))
has-mask? (->> selected-shapes (d/seek cfh/mask-shape?))
is-mask? (and single? has-mask?)
has-component? (some true? (map ctc/instance-root? selected-shapes))
is-component? (and single? has-component?)
@ -167,7 +167,7 @@
(let [parent-id (:parent-id (first selected-shapes))
shapes-ids (:shapes (first selected-shapes))
ordered-ids (into (d/ordered-set) shapes-ids)
group-index (cph/get-index-replacement selected objects)]
group-index (cfh/get-index-replacement selected objects)]
(rx/of
(dwse/select-shapes ordered-ids)
(dws/create-artboard-from-selection new-shape-id parent-id group-index)
@ -186,7 +186,7 @@
(create-layout-from-id new-shape-id type false)
(dwc/update-shapes [new-shape-id] #(assoc % :layout-item-h-sizing :auto :layout-item-v-sizing :auto))
(dwc/update-shapes selected #(assoc % :layout-item-h-sizing :fix :layout-item-v-sizing :fix))))
(rx/of (ptk/data-event :layout/update [new-shape-id])
(dwu/commit-undo-transaction undo-id)))))))
@ -348,7 +348,7 @@
(defn fix-child-sizing
[objects parent-changes shape]
(let [parent (-> (cph/get-parent objects (:id shape))
(let [parent (-> (cfh/get-parent objects (:id shape))
(d/deep-merge parent-changes))
auto-width? (ctl/auto-width? parent)
@ -425,8 +425,8 @@
ptk/WatchEvent
(watch [_ state _]
(let [objects (wsh/lookup-page-objects state)
children-ids (->> ids (mapcat #(cph/get-children-ids objects %)))
parent-ids (->> ids (map #(cph/get-parent-id objects %)))
children-ids (->> ids (mapcat #(cfh/get-children-ids objects %)))
parent-ids (->> ids (map #(cfh/get-parent-id objects %)))
undo-id (js/Symbol)]
(rx/of (dwu/start-undo-transaction undo-id)
(dwc/update-shapes ids (d/patch-object changes))

View file

@ -8,9 +8,9 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.changes-builder :as pcb]
[app.common.files.helpers :as cfh]
[app.common.files.shapes-helpers :as cfsh]
[app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph]
[app.common.schema :as sm]
[app.common.types.container :as ctn]
[app.common.types.page :as ctp]
@ -52,7 +52,7 @@
(cfsh/prepare-add-shape shape objects selected))
changes (cond-> changes
(cph/text-shape? shape)
(cfh/text-shape? shape)
(pcb/set-undo-group (:id shape)))
undo-id (js/Symbol)]
@ -65,7 +65,7 @@
(when-not no-select?
(dws/select-shapes (d/ordered-set (:id shape))))
(dwu/commit-undo-transaction undo-id))
(when (cph/text-shape? shape)
(when (cfh/text-shape? shape)
(->> (rx/of (dwe/start-edition-mode (:id shape)))
(rx/observe-on :async)))))))))
@ -106,7 +106,7 @@
components-v2 (features/active-feature? state "components/v2")
ids (cph/clean-loops objects ids)
ids (cfh/clean-loops objects ids)
in-component-copy?
(fn [shape-id]
@ -194,14 +194,14 @@
all-parents
(reduce (fn [res id]
;; All parents of any deleted shape must be resized.
(into res (cph/get-parent-ids objects id)))
(into res (cfh/get-parent-ids objects id)))
(d/ordered-set)
ids)
all-children
(->> ids ;; Children of deleted shapes must be also deleted.
(reduce (fn [res id]
(into res (cph/get-children-ids objects id)))
(into res (cfh/get-children-ids objects id)))
[])
(reverse)
(into (d/ordered-set)))
@ -211,7 +211,7 @@
(let [all-ids (into empty-parents ids)
contains? (partial contains? all-ids)
xform (comp (map lookup)
(filter #(or (cph/group-shape? %) (cph/bool-shape? %)))
(filter #(or (cfh/group-shape? %) (cfh/bool-shape? %)))
(remove #(->> (:shapes %) (remove contains?) seq))
(map :id))
parents (into #{} xform all-parents)]
@ -298,10 +298,10 @@
(ctst/top-nested-frame {:x frame-x :y frame-y}))
selected (wsh/lookup-selected state)
base (cph/get-base-shape objects selected)
base (cfh/get-base-shape objects selected)
parent-id (if (or (and (= 1 (count selected))
(cph/frame-shape? (get objects (first selected))))
(cfh/frame-shape? (get objects (first selected))))
(empty? selected))
frame-id
(:parent-id base))
@ -339,7 +339,7 @@
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
selected (wsh/lookup-selected state)
selected (cph/clean-loops objects selected)
selected (cfh/clean-loops objects selected)
changes (-> (pcb/empty-changes it page-id)
(pcb/with-objects objects))
@ -390,7 +390,7 @@
;; We have change only the hidden behaviour, to hide only the
;; selected shape, block behaviour remains the same.
ids (if (boolean? blocked)
(into ids (->> ids (mapcat #(cph/get-children-ids objects %))))
(into ids (->> ids (mapcat #(cfh/get-children-ids objects %))))
ids)]
(rx/of (dch/update-shapes ids update-fn {:attrs #{:blocked :hidden}}))))))

View file

@ -8,9 +8,9 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.common.svg.path.command :as upc]
[app.common.uuid :as uuid]))
@ -53,7 +53,7 @@
(and (contains? objects id)
(or (not omit-blocked?)
(not (get-in objects [id :blocked] false)))))]
(let [selected (->> selected (cph/clean-loops objects))]
(let [selected (->> selected (cfh/clean-loops objects))]
(into (d/ordered-set)
(filter selectable?)
selected)))))
@ -126,7 +126,7 @@
[parent-id state]
(let [objects (lookup-page-objects state)
modifiers (:workspace-modifiers state)
children-ids (cph/get-children-ids objects parent-id)
children-ids (cfh/get-children-ids objects parent-id)
children
(-> (select-keys objects children-ids)
(update-vals

View file

@ -8,8 +8,8 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph]
[app.common.files.changes-builder :as pcb]
[app.common.files.helpers :as cfh]
[app.common.svg :as csvg]
[app.common.svg.shapes-builder :as csvg.shapes-builder]
[app.common.types.shape-tree :as ctst]
@ -69,7 +69,7 @@
objects (wsh/lookup-page-objects state page-id)
frame-id (ctst/top-nested-frame objects position)
selected (wsh/lookup-selected state)
base (cph/get-base-shape objects selected)
base (cfh/get-base-shape objects selected)
selected-id (first selected)
selected-frame? (and (= 1 (count selected))

View file

@ -9,10 +9,10 @@
[app.common.attrs :as attrs]
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
[app.common.math :as mth]
[app.common.pages.helpers :as cph]
[app.common.text :as txt]
[app.common.types.modifiers :as ctm]
[app.common.uuid :as uuid]
@ -277,8 +277,8 @@
(update-text-content shape txt/is-root-node? d/txt-merge attrs)
(assoc shape :content (d/txt-merge {:type "root"} attrs))))
shape-ids (cond (cph/text-shape? shape) [id]
(cph/group-shape? shape) (cph/get-children-ids objects id))]
shape-ids (cond (cfh/text-shape? shape) [id]
(cfh/group-shape? shape) (cfh/get-children-ids objects id))]
(rx/of (dch/update-shapes shape-ids update-fn))))))
@ -304,8 +304,8 @@
update-fn #(update-text-content % txt/is-paragraph-node? merge-fn attrs)
shape-ids (cond
(cph/text-shape? shape) [id]
(cph/group-shape? shape) (cph/get-children-ids objects id))]
(cfh/text-shape? shape) [id]
(cfh/group-shape? shape) (cfh/get-children-ids objects id))]
(rx/of (dch/update-shapes shape-ids update-fn))))))))
@ -325,8 +325,8 @@
(or (txt/is-text-node? node)
(txt/is-paragraph-node? node)))
shape-ids (cond
(cph/text-shape? shape) [id]
(cph/group-shape? shape) (cph/get-children-ids objects id))]
(cfh/text-shape? shape) [id]
(cfh/group-shape? shape) (cfh/get-children-ids objects id))]
(rx/of (dch/update-shapes shape-ids #(update-text-content % update-node? d/txt-merge attrs))))))))
@ -363,8 +363,8 @@
shape-ids
(cond
(cph/text-shape? shape) [id]
(cph/group-shape? shape) (cph/get-children-ids objects id))
(cfh/text-shape? shape) [id]
(cfh/group-shape? shape) (cfh/get-children-ids objects id))
update-content
(fn [content]
@ -677,7 +677,7 @@
objects (wsh/lookup-page-objects state)
xform (comp (keep (d/getf objects))
(filter cph/text-shape?))
(filter cfh/text-shape?))
shapes (into [] xform selected)
shape (first shapes)

View file

@ -7,8 +7,8 @@
(ns app.main.data.workspace.thumbnails
(:require
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.logging :as l]
[app.common.pages.helpers :as cph]
[app.common.thumbnails :as thc]
[app.common.uuid :as uuid]
[app.main.data.workspace.changes :as dch]
@ -200,8 +200,8 @@
new-shape (get new-objects id)
old-shape (get old-objects id)
old-frame-id (if (cph/frame-shape? old-shape) id (:frame-id old-shape))
new-frame-id (if (cph/frame-shape? new-shape) id (:frame-id new-shape))]
old-frame-id (if (cfh/frame-shape? old-shape) id (:frame-id old-shape))
new-frame-id (if (cfh/frame-shape? new-shape) id (:frame-id new-shape))]
(cond-> #{}
(and (some? old-frame-id) (not= uuid/zero old-frame-id))

View file

@ -9,6 +9,8 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.changes-builder :as pcb]
[app.common.files.helpers :as cfh]
[app.common.geom.matrix :as gmt]
[app.common.geom.modifiers :as gm]
[app.common.geom.point :as gpt]
@ -17,8 +19,6 @@
[app.common.geom.shapes.flex-layout :as gslf]
[app.common.geom.shapes.grid-layout :as gslg]
[app.common.math :as mth]
[app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph]
[app.common.types.component :as ctk]
[app.common.types.container :as ctn]
[app.common.types.modifiers :as ctm]
@ -450,12 +450,12 @@
exclude-frames
(into #{}
(filter (partial cph/frame-shape? objects))
(cph/selected-with-children objects selected))
(filter (partial cfh/frame-shape? objects))
(cfh/selected-with-children objects selected))
exclude-frames-siblings
(into exclude-frames
(comp (mapcat (partial cph/get-siblings-ids objects))
(comp (mapcat (partial cfh/get-siblings-ids objects))
(filter (partial ctl/any-layout-immediate-child-id? objects)))
selected)
@ -514,7 +514,7 @@
:else
[move-vector nil])
nesting-loop? (some #(cph/components-nesting-loop? objects (:id %) target-frame) shapes)
nesting-loop? (some #(cfh/components-nesting-loop? objects (:id %) target-frame) shapes)
is-component-copy? (ctk/in-component-copy? (get objects target-frame))]
(cond-> (dwm/create-modif-tree ids (ctm/move-modifiers move-vector))
@ -578,7 +578,7 @@
(->> children
;; Add the position to move the children
(map (fn [id]
(let [position (cph/get-position-on-parent objects id)]
(let [position (cfh/get-position-on-parent objects id)]
[id (get-move-to-index parent-id position)])))
(sort-by second >)
(reduce (fn [changes [child-id index]]
@ -771,7 +771,7 @@
frame (get objects frame-id)
layout? (:layout frame)
shapes (->> ids (cph/clean-loops objects) (keep lookup))
shapes (->> ids (cfh/clean-loops objects) (keep lookup))
moving-shapes
(cond->> shapes
@ -782,12 +782,12 @@
(remove #(and (= (:frame-id %) frame-id)
(not= (:parent-id %) frame-id))))
ordered-indexes (cph/order-by-indexed-shapes objects (map :id moving-shapes))
ordered-indexes (cfh/order-by-indexed-shapes objects (map :id moving-shapes))
moving-shapes (map (d/getf objects) ordered-indexes)
all-parents
(reduce (fn [res id]
(into res (cph/get-parent-ids objects id)))
(into res (cfh/get-parent-ids objects id)))
(d/ordered-set)
ids)
@ -796,7 +796,7 @@
(let [all-ids (into empty-parents ids)
contains? (partial contains? all-ids)
xform (comp (map lookup)
(filter cph/group-shape?)
(filter cfh/group-shape?)
(remove #(->> (:shapes %) (remove contains?) seq))
(map :id))
parents (into #{} xform all-parents)]
@ -826,7 +826,7 @@
(let [shape-component (ctn/get-component-shape objects shape)]
(if (= (:id frame-component) (:id shape-component))
result
(into result (cph/get-children-ids-with-self objects (:id shape)))))
(into result (cfh/get-children-ids-with-self objects (:id shape)))))
result))
#{}
moving-shapes)
@ -840,7 +840,7 @@
;; Remove layout-item properties when moving a shape outside a layout
(cond-> (not (ctl/any-layout? objects frame-id))
(pcb/update-shapes moving-shapes-ids ctl/remove-layout-item-data))
(pcb/update-shapes moving-shapes-ids #(cond-> % (cph/frame-shape? %) (assoc :hide-in-viewer true)))
(pcb/update-shapes moving-shapes-ids #(cond-> % (cfh/frame-shape? %) (assoc :hide-in-viewer true)))
(pcb/update-shapes shape-ids-to-detach ctk/detach-shape)
(pcb/change-parent frame-id moving-shapes drop-index)
(pcb/reorder-grid-children [frame-id])

View file

@ -8,8 +8,8 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.changes :as cpc]
[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]

View file

@ -8,12 +8,12 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.align :as gal]
[app.common.geom.point :as gpt]
[app.common.geom.rect :as gpr]
[app.common.geom.shapes :as gsh]
[app.common.math :as mth]
[app.common.pages.helpers :as cph]
[app.main.data.workspace.state-helpers :as wsh]
[app.main.streams :as ms]
[beicon.core :as rx]
@ -40,7 +40,7 @@
(initialize [state local]
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
shapes (cph/get-immediate-children objects)
shapes (cfh/get-immediate-children objects)
srect (gsh/shapes->rect shapes)
local (assoc local :vport size :zoom 1 :zoom-inverse 1 :hide-toolbar false)]

View file

@ -6,12 +6,12 @@
(ns app.main.data.workspace.zoom
(:require
[app.common.files.helpers :as cfh]
[app.common.geom.align :as gal]
[app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt]
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.main.data.workspace.state-helpers :as wsh]
[app.main.streams :as ms]
[beicon.core :as rx]
@ -75,7 +75,7 @@
(update [_ state]
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
shapes (cph/get-immediate-children objects)
shapes (cfh/get-immediate-children objects)
srect (gsh/shapes->rect shapes)]
(if (empty? shapes)
state

View file

@ -9,7 +9,7 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cph]
[app.common.types.shape-tree :as ctt]
[app.common.types.shape.layout :as ctl]
[app.main.data.workspace.state-helpers :as wsh]

View file

@ -16,13 +16,13 @@
[app.common.colors :as clr]
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.geom.shapes.bounds :as gsb]
[app.common.logging :as l]
[app.common.math :as mth]
[app.common.pages.helpers :as cph]
[app.common.types.file :as ctf]
[app.common.types.modifiers :as ctm]
[app.common.types.shape-tree :as ctst]
@ -108,7 +108,7 @@
(mf/fnc bool-wrapper
[{:keys [shape] :as props}]
(let [childs (mf/with-memo [(:id shape) objects]
(->> (cph/get-children-ids objects (:id shape))
(->> (cfh/get-children-ids objects (:id shape))
(select-keys objects)))]
[:& bool-shape {:shape shape :childs childs}]))))
@ -166,7 +166,7 @@
(defn adapt-root-frame
[objects object]
(let [shapes (cph/get-immediate-children objects)
(let [shapes (cfh/get-immediate-children objects)
srect (gsh/shapes->rect shapes)
object (merge object (select-keys srect [:x :y :width :height]))]
(assoc object :fill-color "#f0f0f0")))
@ -175,7 +175,7 @@
[objects object-id]
(let [object (get objects object-id)
object (cond->> object
(cph/root? object)
(cfh/root? object)
(adapt-root-frame objects))
;; Replace the previous object with the new one
@ -184,7 +184,7 @@
vector (-> (gpt/point (:x object) (:y object))
(gpt/negate))
mod-ids (cons object-id (cph/get-children-ids objects object-id))
mod-ids (cons object-id (cfh/get-children-ids objects object-id))
updt-fn #(update %1 %2 gsh/transform-shape (ctm/move-modifiers vector))]
@ -195,7 +195,7 @@
[{:keys [data use-thumbnails embed include-metadata] :as props
:or {embed false include-metadata false}}]
(let [objects (:objects data)
shapes (cph/get-immediate-children objects)
shapes (cfh/get-immediate-children objects)
dim (calculate-dimensions objects)
vbox (format-viewbox dim)
bgcolor (dm/get-in data [:options :background] default-color)
@ -222,8 +222,8 @@
[:& export/export-page {:id (:id data) :options (:options data)}])
(let [shapes (->> shapes
(remove cph/frame-shape?)
(mapcat #(cph/get-children-with-self objects (:id %))))
(remove cfh/frame-shape?)
(mapcat #(cfh/get-children-with-self objects (:id %))))
fonts (ff/shapes->fonts shapes)]
[:& ff/fontfaces-style {:fonts fonts}])
@ -262,7 +262,7 @@
vector (gpt/negate delta-bounds)
children-ids
(cph/get-children-ids objects frame-id)
(cfh/get-children-ids objects frame-id)
objects
(mf/with-memo [frame-id objects vector]
@ -324,7 +324,7 @@
(mf/use-memo
(mf/deps vector objects root-shape-id)
(fn []
(let [children-ids (cons root-shape-id (cph/get-children-ids objects root-shape-id))
(let [children-ids (cons root-shape-id (cfh/get-children-ids objects root-shape-id))
update-fn #(update %1 %2 gsh/transform-shape (ctm/move-modifiers vector))]
(reduce update-fn objects children-ids))))
@ -538,7 +538,7 @@
fonts (ff/shape->fonts shape objects)
bounds (if (:show-content shape)
(let [ids (cph/get-children-ids objects shape-id)
(let [ids (cfh/get-children-ids objects shape-id)
children (sequence (keep (d/getf objects)) ids)]
(gsh/shapes->rect (cons shape children)))
(-> shape :points grc/points->rect))

View file

@ -8,13 +8,13 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.focus :as cpf]
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.geom.snap :as sp]
[app.common.math :as mth]
[app.common.pages.focus :as cpf]
[app.common.pages.helpers :as cph]
[app.common.uuid :refer [zero]]
[app.main.refs :as refs]
[app.main.worker :as uw]
@ -220,7 +220,7 @@
:frame-id frame-id
:include-frames? true
:rect area})
(rx/map #(cph/clean-loops objects %))
(rx/map #(cfh/clean-loops objects %))
(rx/map #(set/difference % selected))
(rx/map #(map (d/getf objects) %))))

View file

@ -7,7 +7,7 @@
(ns app.main.ui.hooks
"A collection of general purpose react hooks."
(:require
[app.common.pages.focus :as cpf]
[app.common.files.focus :as cpf]
[app.main.broadcast :as mbc]
[app.main.data.shortcuts :as dsc]
[app.main.refs :as refs]

View file

@ -8,13 +8,13 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.geom.shapes.flex-layout :as gsl]
[app.common.geom.shapes.points :as gpo]
[app.common.math :as mth]
[app.common.pages.helpers :as cph]
[app.common.types.modifiers :as ctm]
[app.common.uuid :as uuid]
[app.main.data.workspace.modifiers :as dwm]
@ -692,7 +692,7 @@
:row-gap (if flip-y true false)}
objects (wsh/lookup-page-objects @st/state)
children (->> (cph/get-immediate-children objects frame-id)
children (->> (cfh/get-immediate-children objects frame-id)
(remove :layout-item-absolute)
(remove :hidden))

View file

@ -8,12 +8,12 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.geom.shapes.bounds :as gsb]
[app.common.geom.shapes.text :as gst]
[app.common.pages.helpers :as cph]
[app.config :as cfg]
[app.config :as cf]
[app.main.ui.context :as muc]
[app.main.ui.shapes.attrs :as attrs]
[app.main.ui.shapes.embed :as embed]
@ -51,7 +51,7 @@
;; dependencies to really useful shape attrs instead of using
;; the shepe as-is.
selrect (mf/with-memo [shape]
(if (cph/text-shape? shape)
(if (cfh/text-shape? shape)
(gst/shape->rect shape)
(grc/points->rect (:points shape))))
@ -201,7 +201,7 @@
(mf/defc stroke-defs
{::mf/wrap-props false}
[{:keys [shape stroke render-id index]}]
(let [open-path? (and ^boolean (cph/path-shape? shape)
(let [open-path? (and ^boolean (cfh/path-shape? shape)
^boolean (gsh/open-path? shape))
gradient (:stroke-color-gradient stroke)
alignment (:stroke-alignment stroke :center)
@ -211,7 +211,7 @@
:gradient gradient
:shape shape}
stroke-image (:stroke-image stroke)
uri (when stroke-image (cfg/resolve-file-media stroke-image))
uri (when stroke-image (cf/resolve-file-media stroke-image))
embed (embed/use-data-uris [uri])
stroke-width (case (:stroke-alignment stroke :center)
@ -221,7 +221,7 @@
margin (gsb/shape-stroke-margin stroke stroke-width)
selrect (mf/with-memo [shape]
(if (cph/text-shape? shape)
(if (cfh/text-shape? shape)
(gst/shape->rect shape)
(grc/points->rect (:points shape))))
@ -398,7 +398,7 @@
has-stroke? (and (> stroke-width 0)
(not= stroke-style :none))
closed? (or (not ^boolean (cph/path-shape? shape))
closed? (or (not ^boolean (cfh/path-shape? shape))
(not ^boolean (gsh/open-path? shape)))
inner? (= :inner stroke-position)
outer? (= :outer stroke-position)]
@ -429,12 +429,12 @@
(obj/clone))
url-fill? (or ^boolean (some? (:fill-image shape))
^boolean (cph/image-shape? shape)
^boolean (cfh/image-shape? shape)
^boolean (> (count shape-fills) 1)
^boolean (some? (some :fill-color-gradient shape-fills))
^boolean (some? (some :fill-image shape-fills)))
props (if (cph/frame-shape? shape)
props (if (cfh/frame-shape? shape)
props
(if (or (some? (->> shape-shadow (remove :hidden) seq))
(and (some? shape-blur) (not ^boolean (:hidden shape-blur))))
@ -476,7 +476,7 @@
(let [fill (nth shape-fills 0)]
(obj/merge! style (attrs/get-fill-style fill render-id 0 (dm/get-prop shape :type))))
(and ^boolean (cph/path-shape? shape)
(and ^boolean (cfh/path-shape? shape)
^boolean (empty? shape-fills))
(obj/set! style "fill" "none"))
@ -540,7 +540,7 @@
shape-strokes (get shape :strokes)
props #js {:id stroke-id :className "strokes"}
props (if ^boolean (cph/frame-shape? shape)
props (if ^boolean (cfh/frame-shape? shape)
props
(cond
(and (some? shape-blur)

View file

@ -7,9 +7,9 @@
(ns app.main.ui.shapes.frame
(:require
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.common.types.shape.layout :as ctl]
[app.config :as cf]
[app.main.ui.context :as muc]
@ -32,7 +32,7 @@
{::mf/wrap-props false}
[props]
(let [shape (unchecked-get props "shape")]
(when (and ^boolean (cph/frame-shape? shape)
(when (and ^boolean (cfh/frame-shape? shape)
(not ^boolean (:show-content shape)))
(let [render-id (unchecked-get props "render-id")
@ -168,7 +168,7 @@
is-component? (mf/use-ctx muc/is-component?)
childs (cond-> childs
(ctl/any-layout? shape)
(cph/sort-layout-children-z-index))]
(cfh/sort-layout-children-z-index))]
[:> frame-container props
[:g.frame-children {:opacity (:opacity shape)}

View file

@ -8,11 +8,11 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt]
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.main.ui.context :as muc]
[app.main.ui.shapes.export :as ed]
[app.util.object :as obj]
@ -32,7 +32,7 @@
{::mf/wrap-props false}
[{:keys [id gradient shape]}]
(let [transform (mf/with-memo [shape]
(when (cph/frame-shape? shape)
(when (cfh/frame-shape? shape)
(gsh/transform-matrix shape nil (gpt/point 0.5 0.5))))
metadata? (mf/use-ctx ed/include-metadata-ctx)
@ -56,7 +56,7 @@
(mf/defc radial-gradient
{::mf/wrap-props false}
[{:keys [id gradient shape]}]
(let [path? (cph/path-shape? shape)
(let [path? (cfh/path-shape? shape)
transform (when ^boolean path?
(dm/get-prop shape :transform))

View file

@ -8,12 +8,12 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
[app.common.geom.shapes.grid-layout :as gsg]
[app.common.geom.shapes.points :as gpo]
[app.common.pages.helpers :as cph]
[app.common.types.shape.layout :as ctl]
[app.main.refs :as refs]
[rumext.v2 :as mf]))
@ -89,7 +89,7 @@
bounds (d/lazy-map (keys objects) #(gsh/shape->points (get objects %)))
children
(->> (cph/get-immediate-children objects (:id shape))
(->> (cfh/get-immediate-children objects (:id shape))
(remove :hidden)
(map #(vector (gpo/parent-coords-bounds (:points %) (:points shape)) %)))

View file

@ -8,8 +8,8 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.rect :as grc]
[app.common.pages.helpers :as cph]
[app.main.ui.context :as muc]
[cuerdas.core :as str]
[rumext.v2 :as mf]))
@ -55,7 +55,7 @@
(let [mask (unchecked-get props "mask")
render-id (mf/use-ctx muc/render-id)
svg-text? (and ^boolean (cph/text-shape? mask)
svg-text? (and ^boolean (cfh/text-shape? mask)
^boolean (some? (:position-data mask)))
points (dm/get-prop mask :points)

View file

@ -8,7 +8,7 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.main.refs :as refs]
[app.main.ui.context :as muc]
[app.main.ui.hooks :as h]
@ -78,9 +78,9 @@
shape-without-shadows (assoc shape :shadow [])
filter-str
(when (and (or (cph/group-shape? shape)
(cph/frame-shape? shape)
(cph/svg-raw-shape? shape))
(when (and (or (cfh/group-shape? shape)
(cfh/frame-shape? shape)
(cfh/svg-raw-shape? shape))
(not disable-shadows?))
(filters/filter-str filter-id shape))

View file

@ -7,7 +7,7 @@
(ns app.main.ui.shapes.text.fontfaces
(:require
[app.common.data :as d]
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.main.fonts :as fonts]
[app.main.ui.shapes.embed :as embed]
[app.util.object :as obj]
@ -93,17 +93,17 @@
(defn shape->fonts
[shape objects]
(let [initial (cond-> #{}
(cph/text-shape? shape)
(cfh/text-shape? shape)
(into (fonts/get-content-fonts (:content shape))))]
(->> (cph/get-children objects (:id shape))
(filter cph/text-shape?)
(->> (cfh/get-children objects (:id shape))
(filter cfh/text-shape?)
(map (comp fonts/get-content-fonts :content))
(reduce set/union initial))))
(defn shapes->fonts
[shapes]
(->> shapes
(filter cph/text-shape?)
(filter cfh/text-shape?)
(map (comp fonts/get-content-fonts :content))
(reduce set/union #{})))

View file

@ -10,9 +10,9 @@
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.exceptions :as ex]
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.geom.shapes.bounds :as gsb]
[app.common.pages.helpers :as cph]
[app.common.text :as txt]
[app.common.types.shape.interactions :as ctsi]
[app.main.data.comments :as dcm]
@ -276,7 +276,7 @@
(hooks/use-equal-memo
(->> (:objects page)
(vals)
(filter cph/text-shape?)))
(filter cfh/text-shape?)))
zoom (:zoom local)
zoom-type (:zoom-type local)

View file

@ -7,8 +7,8 @@
(ns app.main.ui.viewer.inspect.attributes.image
(:require-macros [app.main.style :as stl])
(:require
[app.common.files.helpers :as cfh]
[app.common.media :as cm]
[app.common.pages.helpers :as cph]
[app.config :as cf]
[app.main.ui.components.copy-button :refer [copy-button]]
[app.main.ui.context :as ctx]
@ -24,7 +24,7 @@
[{:keys [objects shapes]}]
(let [new-css-system (mf/use-ctx ctx/new-css-system)]
(if new-css-system
(for [shape (filter cph/image-shape? shapes)]
(for [shape (filter cfh/image-shape? shapes)]
[:div {:class (stl/css :attributes-block)
:key (str "image-" (:id shape))}
[:div {:class (stl/css :image-wrapper)}
@ -54,7 +54,7 @@
(tr "inspect.attributes.image.download")])])
(for [shape (filter cph/image-shape? shapes)]
(for [shape (filter cfh/image-shape? shapes)]
[:div.attributes-block {:key (str "image-" (:id shape))}
[:div.attributes-image-row
[:div.attributes-image

View file

@ -10,13 +10,12 @@
["js-beautify" :as beautify]
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.common.types.shape-tree :as ctst]
[app.config :as cfg]
[app.main.data.events :as ev]
[app.main.fonts :as fonts]
;; [app.main.data.preview :as dp]
[app.main.refs :as refs]
[app.main.store :as st]
[app.main.ui.components.code-block :refer [code-block]]
@ -128,7 +127,7 @@
all-children (->> shapes
(map :id)
(cph/selected-with-children objects)
(cfh/selected-with-children objects)
(ctst/sort-z-index objects)
(map (d/getf objects)))

View file

@ -8,7 +8,7 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.common.types.component :as ctk]
[app.common.types.shape.layout :as ctl]
[app.main.data.viewer :as dv]
@ -90,7 +90,7 @@
:shape-touched? touched?
:hidden? hidden?
:selected? selected?
:type-frame (cph/frame-shape? item)
:type-frame (cfh/frame-shape? item)
:disabled-double-click true}]
(when (and (not disable-collapse?) (:shapes item))

View file

@ -7,9 +7,9 @@
(ns app.main.ui.viewer.inspect.render
"The main container for a frame in inspect mode"
(:require
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.main.data.viewer :as dv]
[app.main.store :as st]
[app.main.ui.shapes.bool :as bool]
@ -33,16 +33,16 @@
(defn handle-hover-shape
[shape hover?]
(fn [event]
(when-not (or (cph/group-shape? shape)
(cph/root-frame? shape))
(when-not (or (cfh/group-shape? shape)
(cfh/root-frame? shape))
(dom/prevent-default event)
(dom/stop-propagation event)
(st/emit! (dv/hover-shape (:id shape) hover?)))))
(defn select-shape [shape]
(fn [event]
(when-not (or (cph/group-shape? shape)
(cph/root-frame? shape))
(when-not (or (cfh/group-shape? shape)
(cfh/root-frame? shape))
(dom/stop-propagation event)
(dom/prevent-default event)
(cond
@ -119,7 +119,7 @@
{::mf/wrap-props false}
[props]
(let [shape (unchecked-get props "shape")
children (->> (cph/get-children-ids objects (:id shape))
children (->> (cfh/get-children-ids objects (:id shape))
(select-keys objects))
props (-> (obj/create)
(obj/merge! props)

View file

@ -8,9 +8,9 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.common.types.modifiers :as ctm]
[app.common.types.page :as ctp]
[app.common.uuid :as uuid]
@ -34,7 +34,7 @@
(gpt/add delta)
(gpt/negate))
update-fn #(d/update-when %1 %2 gsh/transform-shape (ctm/move-modifiers vector))]
(->> (cph/get-children-ids objects frame-id)
(->> (cfh/get-children-ids objects frame-id)
(into [frame-id])
(reduce update-fn objects))))
@ -54,11 +54,11 @@
;; we have con consider the children if the fixed element is a group
fixed-children-ids
(into #{} (mapcat #(cph/get-children-ids (:objects page) (:id %)) fixed-ids))
(into #{} (mapcat #(cfh/get-children-ids (:objects page) (:id %)) fixed-ids))
parent-children-ids
(->> fixed-ids
(mapcat #(cons (:id %) (cph/get-parent-ids (:objects page) (:id %))))
(mapcat #(cons (:id %) (cfh/get-parent-ids (:objects page) (:id %))))
(remove #(= % uuid/zero)))
fixed-ids

View file

@ -8,8 +8,8 @@
"The main container for a frame in viewer mode"
(:require
[app.common.data :as d]
[app.common.files.helpers :as cfh]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.common.types.shape.interactions :as ctsi]
[app.main.data.viewer :as dv]
[app.main.refs :as refs]
@ -40,9 +40,9 @@
(defn- find-relative-to-base-frame
[shape objects overlays-ids base-frame]
(cond
(cph/frame-shape? shape) shape
(or (empty? overlays-ids) (nil? shape) (cph/root? shape)) base-frame
:else (find-relative-to-base-frame (cph/get-parent objects (:id shape)) objects overlays-ids base-frame)))
(cfh/frame-shape? shape) shape
(or (empty? overlays-ids) (nil? shape) (cfh/root? shape)) base-frame
:else (find-relative-to-base-frame (cfh/get-parent objects (:id shape)) objects overlays-ids base-frame)))
(defn- activate-interaction
[interaction shape base-frame frame-offset objects overlays]
@ -416,7 +416,7 @@
(mf/fnc bool-container
{::mf/wrap-props false}
[props]
(let [childs (->> (cph/get-children-ids objects (:id (unchecked-get props "shape")))
(let [childs (->> (cfh/get-children-ids objects (:id (unchecked-get props "shape")))
(select-keys objects))
props (obj/merge! #js {} props
#js {:childs childs

View file

@ -8,8 +8,8 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.main.data.viewer :as dv]
[app.main.render :as render]
[app.main.store :as st]
@ -79,7 +79,7 @@
#(mf/deferred % ts/idle-then-raf)]}
[{:keys [selected? frame on-click index objects page-id thumbnail-data]}]
(let [children-ids (cph/get-children-ids objects (:id frame))
(let [children-ids (cfh/get-children-ids objects (:id frame))
children-bounds (gsh/shapes->rect (concat [frame] (->> children-ids (keep (d/getf objects)))))]
[:div.thumbnail-item {:on-click #(on-click % index)}
[:div.thumbnail-preview

View file

@ -10,7 +10,7 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.common.types.component :as ctk]
[app.common.types.container :as ctn]
[app.common.types.page :as ctp]
@ -234,7 +234,7 @@
(mf/defc context-menu-thumbnail
[{:keys [shapes]}]
(let [single? (= (count shapes) 1)
has-frame? (some cph/frame-shape? shapes)
has-frame? (some cfh/frame-shape? shapes)
do-toggle-thumbnail #(st/emit! (dw/toggle-file-thumbnail-selected))]
(when (and single? has-frame?)
[:*
@ -253,9 +253,9 @@
single? (= (count shapes) 1)
do-create-artboard-from-selection #(st/emit! (dwsh/create-artboard-from-selection))
has-frame? (->> shapes (d/seek cph/frame-shape?))
has-group? (->> shapes (d/seek cph/group-shape?))
has-bool? (->> shapes (d/seek cph/bool-shape?))
has-frame? (->> shapes (d/seek cfh/frame-shape?))
has-group? (->> shapes (d/seek cfh/group-shape?))
has-bool? (->> shapes (d/seek cfh/bool-shape?))
has-mask? (->> shapes (d/seek :masked-group))
is-group? (and single? has-group?)
@ -307,10 +307,10 @@
(let [multiple? (> (count shapes) 1)
single? (= (count shapes) 1)
has-group? (->> shapes (d/seek cph/group-shape?))
has-bool? (->> shapes (d/seek cph/bool-shape?))
has-frame? (->> shapes (d/seek cph/frame-shape?))
has-path? (->> shapes (d/seek cph/path-shape?))
has-group? (->> shapes (d/seek cfh/group-shape?))
has-bool? (->> shapes (d/seek cfh/bool-shape?))
has-frame? (->> shapes (d/seek cfh/frame-shape?))
has-path? (->> shapes (d/seek cfh/path-shape?))
is-group? (and single? has-group?)
is-bool? (and single? has-bool?)
@ -396,7 +396,7 @@
prototype? (= options-mode :prototype)
single? (= (count shapes) 1)
has-frame? (->> shapes (d/seek cph/frame-shape?))
has-frame? (->> shapes (d/seek cfh/frame-shape?))
is-frame? (and single? has-frame?)]
(when (and prototype? is-frame?)
@ -410,7 +410,7 @@
(mf/defc context-menu-flex
[{:keys [shapes]}]
(let [single? (= (count shapes) 1)
has-frame? (->> shapes (d/seek cph/frame-shape?))
has-frame? (->> shapes (d/seek cfh/frame-shape?))
is-flex-container? (and single? has-frame? (= :flex (:layout (first shapes))))
ids (->> shapes (map :id))

View file

@ -6,7 +6,7 @@
(ns app.main.ui.workspace.header
(:require
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.common.uuid :as uuid]
[app.config :as cf]
[app.main.data.common :refer [show-shared-dialog]]
@ -351,8 +351,8 @@
shared? (:is-shared file)
objects (mf/deref refs/workspace-page-objects)
frames (->> (cph/get-immediate-children objects uuid/zero)
(filterv cph/frame-shape?))
frames (->> (cfh/get-immediate-children objects uuid/zero)
(filterv cfh/frame-shape?))
add-shared-fn
(mf/use-fn

View file

@ -4,36 +4,37 @@
;;
;; Copyright (c) KALEIDOS INC
(ns app.main.ui.workspace.left-header (:require-macros [app.main.style :as stl])
(:require
[app.common.pages.helpers :as cph]
[app.common.uuid :as uuid]
[app.config :as cf]
[app.main.data.common :refer [show-shared-dialog]]
[app.main.data.events :as ev]
[app.main.data.exports :as de]
[app.main.data.modal :as modal]
[app.main.data.shortcuts :as scd]
[app.main.data.workspace :as dw]
[app.main.data.workspace.colors :as dc]
[app.main.data.workspace.common :as dwc]
[app.main.data.workspace.libraries :as dwl]
[app.main.data.workspace.shortcuts :as sc]
[app.main.refs :as refs]
[app.main.repo :as rp]
[app.main.store :as st]
[app.main.ui.components.dropdown-menu :refer [dropdown-menu dropdown-menu-item]]
[app.main.ui.context :as ctx]
[app.main.ui.hooks.resize :as r]
[app.main.ui.icons :as i]
[app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd]
[app.util.router :as rt]
[beicon.core :as rx]
[cuerdas.core :as str]
[potok.core :as ptk]
[rumext.v2 :as mf]))
(ns app.main.ui.workspace.left-header
(:require-macros [app.main.style :as stl])
(:require
[app.common.files.helpers :as cfh]
[app.common.uuid :as uuid]
[app.config :as cf]
[app.main.data.common :refer [show-shared-dialog]]
[app.main.data.events :as ev]
[app.main.data.exports :as de]
[app.main.data.modal :as modal]
[app.main.data.shortcuts :as scd]
[app.main.data.workspace :as dw]
[app.main.data.workspace.colors :as dc]
[app.main.data.workspace.common :as dwc]
[app.main.data.workspace.libraries :as dwl]
[app.main.data.workspace.shortcuts :as sc]
[app.main.refs :as refs]
[app.main.repo :as rp]
[app.main.store :as st]
[app.main.ui.components.dropdown-menu :refer [dropdown-menu dropdown-menu-item]]
[app.main.ui.context :as ctx]
[app.main.ui.hooks.resize :as r]
[app.main.ui.icons :as i]
[app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd]
[app.util.router :as rt]
[beicon.core :as rx]
[cuerdas.core :as str]
[potok.core :as ptk]
[rumext.v2 :as mf]))
;; --- Header menu and submenus
@ -466,8 +467,8 @@
shared? (:is-shared file)
objects (mf/deref refs/workspace-page-objects)
frames (->> (cph/get-immediate-children objects uuid/zero)
(filterv cph/frame-shape?))
frames (->> (cfh/get-immediate-children objects uuid/zero)
(filterv cfh/frame-shape?))
add-shared-fn
(mf/use-fn

View file

@ -13,8 +13,8 @@
common."
(:require
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.rect :as grc]
[app.common.pages.helpers :as cph]
[app.common.uuid :as uuid]
[app.main.ui.context :as ctx]
[app.main.ui.shapes.circle :as circle]
@ -49,7 +49,7 @@
[props]
(let [objects (obj/get props "objects")
active-frames (obj/get props "active-frames")
shapes (cph/get-immediate-children objects)
shapes (cfh/get-immediate-children objects)
vbox (mf/use-ctx ctx/current-vbox)
shapes (mf/with-memo [shapes vbox]
@ -64,14 +64,14 @@
;; Render font faces only for shapes that are part of the root
;; frame but don't belongs to any other frame.
(let [xform (comp
(remove cph/frame-shape?)
(mapcat #(cph/get-children-with-self objects (:id %))))]
(remove cfh/frame-shape?)
(mapcat #(cfh/get-children-with-self objects (:id %))))]
[:& ff/fontfaces-style {:shapes (into [] xform shapes)}])
[:g.frame-children
(for [shape shapes]
[:g.ws-shape-wrapper {:key (dm/str (dm/get-prop shape :id))}
(if ^boolean (cph/frame-shape? shape)
(if ^boolean (cfh/frame-shape? shape)
[:& root-frame-wrapper
{:shape shape
:objects objects
@ -88,7 +88,7 @@
;; FIXME: WARN: this breaks react rule of hooks (hooks can't be under conditional)
active-frames
(when (cph/root-frame? shape)
(when (cfh/root-frame? shape)
(mf/use-ctx ctx/active-frames))
thumbnail?

View file

@ -8,9 +8,9 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.common.thumbnails :as thc]
[app.main.data.workspace.state-helpers :as wsh]
[app.main.data.workspace.thumbnails :as dwt]
@ -43,7 +43,7 @@
childs (mf/deref childs-ref)]
[:& (mf/provider embed/context) {:value true}
[:& shape-container {:shape shape :ref ref :disable-shadows? (cph/is-direct-child-of-root? shape)}
[:& shape-container {:shape shape :ref ref :disable-shadows? (cfh/is-direct-child-of-root? shape)}
[:& frame-shape {:shape shape :childs childs}]]]))))
(defn check-props
@ -100,7 +100,7 @@
;; FIXME: apply specific rendering optimizations separating to a component
bounds (if (:show-content shape)
(let [ids (cph/get-children-ids objects frame-id)
(let [ids (cfh/get-children-ids objects frame-id)
children (sequence (keep (d/getf objects)) ids)]
(gsh/shapes->rect (cons shape children)))
(-> shape :points grc/points->rect))

View file

@ -8,11 +8,11 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt]
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.common.types.modifiers :as ctm]
[app.main.store :as st]
[app.main.ui.hooks :as hooks]
@ -37,9 +37,9 @@
(when (some? base-node)
(let [shape-node (get-shape-node base-node id)
parent-node (get-shape-node base-node parent-id)
frame? (cph/frame-shape? shape)
group? (cph/group-shape? shape)
text? (cph/text-shape? shape)
frame? (cfh/frame-shape? shape)
group? (cfh/group-shape? shape)
text? (cfh/text-shape? shape)
masking-child? (:masking-child? (meta shape))]
(cond
frame?
@ -222,7 +222,7 @@
[objects]
(fn [{:keys [id parent-id] :as shape}]
(let [parent (get objects parent-id)
masking-child? (and (cph/mask-shape? parent) (= id (first (:shapes parent))))]
masking-child? (and (cfh/mask-shape? parent) (= id (first (:shapes parent))))]
(cond-> shape
masking-child?

View file

@ -8,11 +8,11 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
[app.common.geom.shapes.text :as gsht]
[app.common.math :as mth]
[app.common.pages.helpers :as cph]
[app.common.text :as txt]
[app.common.types.modifiers :as ctm]
[app.main.data.workspace.modifiers :as mdwm]
@ -275,7 +275,7 @@
(mf/use-memo
(mf/deps objects)
(fn []
(into {} (filter (comp cph/text-shape? second)) objects)))
(into {} (filter (comp cfh/text-shape? second)) objects)))
text-shapes
(hooks/use-equal-memo text-shapes)

View file

@ -9,7 +9,7 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.main.data.events :as ev]
[app.main.data.modal :as modal]
[app.main.data.workspace :as dw]
@ -82,7 +82,7 @@
(mf/use-fn
(mf/deps color file-id)
(fn [attrs]
(let [name (cph/merge-path-item (:path color) (:name color))
(let [name (cfh/merge-path-item (:path color) (:name color))
color (-> attrs
(assoc :id (:id color))
(assoc :file-id file-id)
@ -220,7 +220,7 @@
:on-blur input-blur
:on-key-down input-key-down
:auto-focus true
:default-value (cph/merge-path-item (:path color) (:name color))}]
:default-value (cfh/merge-path-item (:path color) (:name color))}]
[:div {:title (:name color)
:class (dom/classnames (css :name-block) true)
@ -278,7 +278,7 @@
:on-blur input-blur
:on-key-down input-key-down
:auto-focus true
:default-value (cph/merge-path-item (:path color) (:name color))}]
:default-value (cfh/merge-path-item (:path color) (:name color))}]
[:div.name-block {:title (:name color)
:on-double-click rename-color-clicked}
@ -387,7 +387,7 @@
(for [[path-item content] groups]
(when-not (empty? path-item)
[:& colors-group {:file-id file-id
:prefix (cph/merge-path-item prefix path-item)
:prefix (cfh/merge-path-item prefix path-item)
:key (dm/str "group-" path-item)
:groups content
:open-groups open-groups
@ -451,7 +451,7 @@
(for [[path-item content] groups]
(when-not (empty? path-item)
[:& colors-group {:file-id file-id
:prefix (cph/merge-path-item prefix path-item)
:prefix (cfh/merge-path-item prefix path-item)
:key (dm/str "group-" path-item)
:groups content
:open-groups open-groups

View file

@ -9,7 +9,7 @@
(:require-macros [app.main.style :refer [css]])
(:require
[app.common.data.macros :as dm]
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.common.spec :as us]
[app.common.thumbnails :as thc]
[app.common.types.component :as ctk]
@ -56,36 +56,36 @@
(let [path (if (str/empty? path)
(if reverse? "z" "a")
path)]
(str/lower (cph/merge-path-item path name))))
(str/lower (cfh/merge-path-item path name))))
(if ^boolean reverse? > <)))))
(defn add-group
[asset group-name]
(-> (:path asset)
(cph/merge-path-item group-name)
(cph/merge-path-item (:name asset))))
(cfh/merge-path-item group-name)
(cfh/merge-path-item (:name asset))))
(defn rename-group
[asset path last-path]
(-> (:path asset)
(str/slice 0 (count path))
(cph/split-path)
(cfh/split-path)
butlast
(vec)
(conj last-path)
(cph/join-path)
(cfh/join-path)
(str (str/slice (:path asset) (count path)))
(cph/merge-path-item (:name asset))))
(cfh/merge-path-item (:name asset))))
(defn ungroup
[asset path]
(-> (:path asset)
(str/slice 0 (count path))
(cph/split-path)
(cfh/split-path)
butlast
(cph/join-path)
(cfh/join-path)
(str (str/slice (:path asset) (count path)))
(cph/merge-path-item (:name asset))))
(cfh/merge-path-item (:name asset))))
(s/def ::asset-name ::us/not-empty-string)
(s/def ::name-group-form
@ -264,7 +264,7 @@
(st/emit!
(rename
(:id target-asset)
(cph/merge-path-item prefix (:name target-asset))))))))
(cfh/merge-path-item prefix (:name target-asset))))))))
(defn- get-component-thumbnail-uri
@ -318,7 +318,7 @@
(filter #(nil? (find-component %)))
(filter #(local-or-exists %)))
touched-not-dangling (filter #(and (cph/component-touched? objects (:id %))
touched-not-dangling (filter #(and (cfh/component-touched? objects (:id %))
(find-component %)) copies)
can-reset-overrides? (or (not components-v2) (seq touched-not-dangling))
@ -344,7 +344,7 @@
(not is-dangling?)
(or (not components-v2)
(and (not main-instance?)
(cph/component-touched? objects (:id shape)))))
(cfh/component-touched? objects (:id shape)))))
do-detach-component

View file

@ -9,8 +9,8 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.media :as cm]
[app.common.pages.helpers :as cph]
[app.common.types.file :as ctf]
[app.main.data.events :as ev]
[app.main.data.modal :as modal]
@ -31,7 +31,6 @@
[app.util.dom :as dom]
[app.util.dom.dnd :as dnd]
[app.util.i18n :as i18n :refer [tr]]
;; [app.util.timers :as tm]
[cuerdas.core :as str]
[okulary.core :as l]
[potok.core :as ptk]
@ -165,8 +164,8 @@
(css :cell-name) listing-thumbs?
(css :item-name) (not listing-thumbs?)
(css :editing) renaming?)
:value (cph/merge-path-item (:path component) (:name component))
:tooltip (cph/merge-path-item (:path component) (:name component))
:value (cfh/merge-path-item (:path component) (:name component))
:tooltip (cfh/merge-path-item (:path component) (:name component))
:display-value (:name component)
:editing renaming?
:disable-dbl-click true
@ -207,8 +206,8 @@
:cell-name listing-thumbs?
:item-name (not listing-thumbs?)
:editing renaming?)
:value (cph/merge-path-item (:path component) (:name component))
:tooltip (cph/merge-path-item (:path component) (:name component))
:value (cfh/merge-path-item (:path component) (:name component))
:tooltip (cfh/merge-path-item (:path component) (:name component))
:display-value (:name component)
:editing renaming?
:disable-dbl-click true
@ -311,7 +310,7 @@
(when-not (empty? path-item)
[:& components-group {:file-id file-id
:key path-item
:prefix (cph/merge-path-item prefix path-item)
:prefix (cfh/merge-path-item prefix path-item)
:groups content
:open-groups open-groups
:force-open? force-open?
@ -385,7 +384,7 @@
(when-not (empty? path-item)
[:& components-group {:file-id file-id
:key path-item
:prefix (cph/merge-path-item prefix path-item)
:prefix (cfh/merge-path-item prefix path-item)
:groups content
:open-groups open-groups
:force-open? force-open?

View file

@ -9,8 +9,8 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.media :as cm]
[app.common.pages.helpers :as cph]
[app.config :as cf]
[app.main.data.events :as ev]
[app.main.data.modal :as modal]
@ -112,8 +112,8 @@
(css :cell-name) listing-thumbs?
(css :item-name) (not listing-thumbs?)
(css :editing) renaming?)
:value (cph/merge-path-item (:path object) (:name object))
:tooltip (cph/merge-path-item (:path object) (:name object))
:value (cfh/merge-path-item (:path object) (:name object))
:tooltip (cfh/merge-path-item (:path object) (:name object))
:display-value (:name object)
:editing renaming?
:disable-dbl-click true
@ -151,8 +151,8 @@
:cell-name listing-thumbs?
:item-name (not listing-thumbs?)
:editing renaming?)
:value (cph/merge-path-item (:path object) (:name object))
:tooltip (cph/merge-path-item (:path object) (:name object))
:value (cfh/merge-path-item (:path object) (:name object))
:tooltip (cfh/merge-path-item (:path object) (:name object))
:display-value (:name object)
:editing renaming?
:disable-dbl-click true
@ -248,7 +248,7 @@
(when-not (empty? path-item)
[:& graphics-group {:file-id file-id
:key path-item
:prefix (cph/merge-path-item prefix path-item)
:prefix (cfh/merge-path-item prefix path-item)
:groups content
:open-groups open-groups
:force-open? force-open?
@ -315,7 +315,7 @@
(when-not (empty? path-item)
[:& graphics-group {:file-id file-id
:key path-item
:prefix (cph/merge-path-item prefix path-item)
:prefix (cfh/merge-path-item prefix path-item)
:groups content
:open-groups open-groups
:force-open? force-open?

View file

@ -7,7 +7,7 @@
(ns app.main.ui.workspace.sidebar.assets.groups
(:require-macros [app.main.style :as stl])
(:require
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.common.spec :as us]
[app.main.data.modal :as modal]
[app.main.data.workspace :as dw]
@ -25,7 +25,7 @@
(mf/defc asset-group-title
[{:keys [file-id section path group-open? on-rename on-ungroup]}]
(when-not (empty? path)
(let [[other-path last-path truncated] (cph/compact-path path 35 true)
(let [[other-path last-path truncated] (cfh/compact-path path 35 true)
menu-state (mf/use-state cmm/initial-context-menu-state)
new-css-system (mf/use-ctx ctx/new-css-system)
on-fold-group
@ -98,7 +98,7 @@
[assets reverse-sort?]
(when-not (empty? assets)
(reduce (fn [groups {:keys [path] :as asset}]
(let [path (cph/split-path (or path ""))]
(let [path (cfh/split-path (or path ""))]
(update-in groups
(conj path "")
(fn [group]

View file

@ -9,7 +9,7 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.main.data.modal :as modal]
[app.main.data.workspace :as dw]
[app.main.data.workspace.libraries :as dwl]
@ -232,7 +232,7 @@
(for [[path-item content] groups]
(when-not (empty? path-item)
[:& typographies-group {:file-id file-id
:prefix (cph/merge-path-item prefix path-item)
:prefix (cfh/merge-path-item prefix path-item)
:key (dm/str "group-" path-item)
:groups content
:open-groups open-groups
@ -294,7 +294,7 @@
(for [[path-item content] groups]
(when-not (empty? path-item)
[:& typographies-group {:file-id file-id
:prefix (cph/merge-path-item prefix path-item)
:prefix (cfh/merge-path-item prefix path-item)
:key (dm/str "group-" path-item)
:groups content
:open-groups open-groups

View file

@ -9,7 +9,7 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.common.types.component :as ctk]
[app.common.types.container :as ctn]
[app.common.types.shape.layout :as ctl]
@ -53,8 +53,8 @@
selected? (contains? selected id)
highlighted? (contains? highlighted id)
container? (or (cph/frame-shape? item)
(cph/group-shape? item))
container? (or (cfh/frame-shape? item)
(cfh/group-shape? item))
absolute? (ctl/layout-absolute? item)
components-v2 (mf/use-ctx ctx/components-v2)
@ -63,7 +63,7 @@
main-instance? (if components-v2
(:main-instance item)
true)
parent-board? (and (cph/frame-shape? item)
parent-board? (and (cfh/frame-shape? item)
(= uuid/zero (:parent-id item)))
toggle-collapse
(mf/use-fn
@ -153,7 +153,7 @@
:else index)
parent-id (if (= side :center)
id
(cph/get-parent-id objects id))
(cfh/get-parent-id objects id))
parent (get objects parent-id)]
(when-not (ctk/in-component-copy? parent) ;; We don't want to change the structure of component copies
(st/emit! (dw/relocate-selected-shapes parent-id to-index))))))
@ -232,8 +232,8 @@
:component (some? (:component-id item))
:masked (:masked-group item)
:selected selected?
:type-frame (cph/frame-shape? item)
:type-bool (cph/bool-shape? item)
:type-frame (cfh/frame-shape? item)
:type-bool (cfh/bool-shape? item)
:type-comp component-tree?
:hidden hidden?
:dnd-over (= (:over dprops) :center)
@ -294,7 +294,7 @@
:parent-size parent-size
:selected? selected?
:type-comp component-tree?
:type-frame (cph/frame-shape? item)
:type-frame (cfh/frame-shape? item)
:hidden? hidden?}]
[:div {:class (stl/css-case
:element-actions true
@ -348,7 +348,7 @@
:dnd-over-top (= (:over dprops) :top)
:dnd-over-bot (= (:over dprops) :bot)
:selected selected?
:type-frame (cph/frame-shape? item))}
:type-frame (cfh/frame-shape? item))}
[:div.element-list-body {:class (stl/css-case*
:selected selected?
@ -375,7 +375,7 @@
:disabled-double-click read-only?
:selected? selected?
:type-comp component-tree?
:type-frame (cph/frame-shape? item)
:type-frame (cfh/frame-shape? item)
:hidden? hidden?}]
[:div.element-actions {:class (when ^boolean has-shapes? "is-parent")}

View file

@ -9,7 +9,7 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.common.uuid :as uuid]
[app.main.data.workspace :as dw]
[app.main.refs :as refs]
@ -52,7 +52,7 @@
[:& hooks/sortable-container {}
(for [[index id] (reverse (d/enumerate (:shapes root)))]
(when-let [obj (get objects id)]
(if (cph/frame-shape? obj)
(if (cfh/frame-shape? obj)
[:& frame-wrapper
{:item obj
:selected selected
@ -131,7 +131,7 @@
(let [direct-filters (into #{} (filter #{:frame :rect :circle :path :bool :image :text}) filters)]
(contains? direct-filters (:type shape)))
(and (contains? filters :group)
(and (cph/group-shape? shape)
(and (cfh/group-shape? shape)
(not (contains? shape :component-id))
(or (not (contains? shape :masked-group))
(false? (:masked-group shape)))))

View file

@ -9,8 +9,8 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.common.types.shape.layout :as ctl]
[app.main.data.workspace :as udw]
[app.main.refs :as refs]
@ -88,7 +88,7 @@
selected-shapes (into [] (keep (d/getf objects)) selected)
first-selected-shape (first selected-shapes)
shape-parent-frame (cph/get-frame objects (:frame-id first-selected-shape))
shape-parent-frame (cfh/get-frame objects (:frame-id first-selected-shape))
edit-grid? (ctl/grid-layout? objects edition)
selected-cells (->> (dm/get-in grid-edition [edition :selected])

View file

@ -7,7 +7,7 @@
(ns app.main.ui.workspace.sidebar.options.menus.component
(:require-macros [app.main.style :as stl])
(:require
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.common.types.component :as ctk]
[app.common.types.file :as ctf]
[app.common.uuid :as uuid]
@ -179,14 +179,14 @@
(mf/defc component-group-item
[{:keys [item on-enter-group] :as props}]
(let [group-name (:name item)
path (cph/butlast-path group-name)
path (cfh/butlast-path group-name)
on-group-click #(on-enter-group group-name)]
[:div {:class (stl/css :component-group)
:key (uuid/next) :on-click on-group-click}
[:div
(when-not (str/blank? path)
[:span {:class (stl/css :component-group-path)} (str "\u00A0/\u00A0" path)])
[:span {:class (stl/css :component-group-name)} (cph/last-path group-name)]]
[:span {:class (stl/css :component-group-name)} (cfh/last-path group-name)]]
[:span i/arrow-slide]]))
@ -209,7 +209,7 @@
current-file-id)
paths (->> shapes
(map :name)
(map cph/split-path)
(map cfh/split-path)
(map butlast))
find-common-path (fn common-path [path n]
@ -220,8 +220,8 @@
(common-path (conj path current) (inc n)))))
path (if single?
(cph/butlast-path (:name shape))
(cph/join-path (if (not every-same-file?)
(cfh/butlast-path (:name shape))
(cfh/join-path (if (not every-same-file?)
""
(find-common-path [] 0))))
@ -237,10 +237,10 @@
components (->> (get-in libraries [(:file-id filters) :data :components])
vals
(remove #(true? (:deleted %)))
(map #(assoc % :full-name (cph/merge-path-item (:path %) (:name %)))))
(map #(assoc % :full-name (cfh/merge-path-item (:path %) (:name %)))))
get-subgroups (fn [path]
(let [split-path (cph/split-path path)]
(let [split-path (cfh/split-path path)]
(reduce (fn [acc dir]
(conj acc (str (last acc) " / " dir)))
[(first split-path)] (rest split-path))))
@ -251,7 +251,7 @@
(remove str/empty?)
(remove nil?)
(distinct)
(filter #(= (cph/butlast-path %) (:path filters))))
(filter #(= (cfh/butlast-path %) (:path filters))))
groups (when-not is-search?
(->> (sort (sequence xform components))
@ -305,7 +305,7 @@
on-go-back
(mf/use-fn
(mf/deps (:path filters))
#(swap! filters* assoc :path (cph/butlast-path (:path filters))))
#(swap! filters* assoc :path (cfh/butlast-path (:path filters))))
on-enter-group
(mf/use-fn #(swap! filters* assoc :path %))
@ -490,7 +490,7 @@
:type :dropdown}]])
(when (and can-swap? (not multi))
[:div {:class (stl/css :component-parent-name)}
(cph/merge-path-item (:path component) (:name component))])]]
(cfh/merge-path-item (:path component) (:name component))])]]
(when swap-opened?
[:& component-swap {:shapes shapes}])

View file

@ -9,7 +9,7 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.common.types.page :as ctp]
[app.common.types.shape-tree :as ctt]
[app.common.types.shape.interactions :as ctsi]
@ -265,7 +265,7 @@
destination (get objects (:destination interaction))
frames (mf/with-memo [objects] (ctt/get-viewer-frames objects {:all-frames? true}))
shape-parent-ids (mf/with-memo [objects] (cph/get-parent-ids objects (:id shape)))
shape-parent-ids (mf/with-memo [objects] (cfh/get-parent-ids objects (:id shape)))
shape-parents (mf/with-memo [frames shape] (filter (comp (set shape-parent-ids) :id) frames))
overlay-pos-type (:overlay-pos-type interaction)
@ -1082,7 +1082,7 @@
:shape shape}]
[:& page-flows {:flows flows}])
[:div {:class (stl/css :interaction-options)}
(when (and shape (not (cph/unframed-shape? shape)))
(when (and shape (not (cfh/unframed-shape? shape)))
[:div {:class (stl/css :element-title)}
[:& title-bar {:collapsable? false
:title (tr "workspace.options.interactions")
@ -1094,7 +1094,7 @@
[:div {:class (stl/css :help-content)}
(when (= (count interactions) 0)
[:*
(when (and shape (not (cph/unframed-shape? shape)))
(when (and shape (not (cfh/unframed-shape? shape)))
[:div {:class (stl/css :help-group)}
[:div {:class (stl/css :interactions-help-icon)} i/add-refactor]
[:div {:class (stl/css :interactions-help)}
@ -1123,7 +1123,7 @@
[:& page-flows {:flows flows}])
[:div.element-set.interactions-options
(when (and shape (not (cph/unframed-shape? shape)))
(when (and shape (not (cfh/unframed-shape? shape)))
[:div.element-set-title
[:span (tr "workspace.options.interactions")]
[:div.add-page {:on-click add-interaction}
@ -1131,7 +1131,7 @@
[:div.element-set-content
(when (= (count interactions) 0)
[:*
(when (and shape (not (cph/unframed-shape? shape)))
(when (and shape (not (cfh/unframed-shape? shape)))
[:*
[:div.interactions-help-icon i/plus]
[:div.interactions-help.separator (tr "workspace.options.add-interaction")]])

View file

@ -9,8 +9,8 @@
[app.common.colors :as clr]
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.common.types.shape-tree :as ctt]
[app.common.types.shape.layout :as ctl]
[app.main.data.workspace.modifiers :as dwm]
@ -60,7 +60,7 @@
objects id
(fn [shape]
(cond-> shape
(and (cph/text-shape? shape) (contains? text-modifiers id))
(and (cfh/text-shape? shape) (contains? text-modifiers id))
(dwm/apply-text-modifier (get text-modifiers id))
(contains? modifiers id)
@ -144,7 +144,7 @@
(fn []
(let [parent-id
(->> @hover-ids
(d/seek (partial cph/root-frame? base-objects)))]
(d/seek (partial cfh/root-frame? base-objects)))]
(when (some? parent-id)
(get base-objects parent-id)))))
@ -248,7 +248,7 @@
first-selected-shape (first selected-shapes)
selecting-first-level-frame? (and one-selected-shape?
(cph/root-frame? first-selected-shape))
(cfh/root-frame? first-selected-shape))
offset-x (if selecting-first-level-frame?
(:x first-selected-shape)
@ -374,7 +374,7 @@
(when show-frame-outline?
(let [outlined-frame-id
(->> @hover-ids
(filter #(cph/frame-shape? (get base-objects %)))
(filter #(cfh/frame-shape? (get base-objects %)))
(remove selected)
(first))
outlined-frame (get objects outlined-frame-id)]

View file

@ -7,9 +7,9 @@
(ns app.main.ui.workspace.viewport.actions
(:require
[app.common.data :as d]
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.math :as mth]
[app.common.pages.helpers :as cph]
[app.common.types.shape.layout :as ctl]
[app.common.uuid :as uuid]
[app.config :as cfg]
@ -208,7 +208,7 @@
editable? (contains? #{:text :rect :path :image :circle} type)
hover-shape (->> @hover-ids (filter (partial cph/is-child? objects id)) first)
hover-shape (->> @hover-ids (filter (partial cfh/is-child? objects id)) first)
selected-shape (get objects hover-shape)
grid-layout-id (->> @hover-ids reverse (d/seek (partial ctl/grid-layout? objects)))]

View file

@ -8,12 +8,12 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
[app.common.geom.shapes.flex-layout :as gsl]
[app.common.geom.shapes.grid-layout :as gsg]
[app.common.geom.shapes.points :as gpo]
[app.common.pages.helpers :as cph]
[app.common.types.shape.layout :as ctl]
[app.common.uuid :as uuid]
[cuerdas.core :as str]
@ -37,7 +37,7 @@
shape (or selected-frame (get objects hover-top-frame-id))]
(when (and shape (:layout shape))
(let [children (->> (cph/get-immediate-children objects (:id shape))
(let [children (->> (cfh/get-immediate-children objects (:id shape))
(remove :hidden))
bounds (d/lazy-map (keys objects) #(dm/get-in objects [% :points]))
@ -91,7 +91,7 @@
(let [row? (ctl/row? shape)
col? (ctl/col? shape)
children (->> (cph/get-immediate-children objects (:id shape))
children (->> (cfh/get-immediate-children objects (:id shape))
(remove :hidden)
(map #(vector (gpo/parent-coords-bounds (:points %) (:points shape)) %)))
@ -201,7 +201,7 @@
bounds (d/lazy-map (keys objects) #(dm/get-in objects [% :points]))]
(when (and (some? parent) (not= uuid/zero (:id parent)))
(let [children (->> (cph/get-immediate-children objects (:id parent))
(let [children (->> (cfh/get-immediate-children objects (:id parent))
(remove :hidden))]
[:g.debug-parent-bounds {:pointer-events "none"}
(for [[idx child] (d/enumerate children)]
@ -241,7 +241,7 @@
bounds (d/lazy-map (keys objects) #(dm/get-in objects [% :points]))]
(when (and (some? parent) (not= uuid/zero (:id parent)))
(let [children (->> (cph/get-immediate-children objects (:id parent))
(let [children (->> (cfh/get-immediate-children objects (:id parent))
(remove :hidden)
(map #(vector (gpo/parent-coords-bounds (:points %) (:points parent)) %)))

View file

@ -8,10 +8,10 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.grid :as gg]
[app.common.geom.rect :as grc]
[app.common.math :as mth]
[app.common.pages.helpers :as cph]
[app.common.types.shape-tree :as ctst]
[app.common.uuid :as uuid]
[app.main.refs :as refs]
@ -117,8 +117,8 @@
(reduce
(fn [sr parent]
(cond-> sr
(and (not (cph/root? parent))
(cph/frame-shape? parent)
(and (not (cfh/root? parent))
(cfh/frame-shape? parent)
(not (:show-content parent)))
(grc/clip-rect (:selrect parent))))
selrect

View file

@ -9,13 +9,13 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
[app.common.geom.shapes.grid-layout :as gsg]
[app.common.geom.shapes.points :as gpo]
[app.common.math :as mth]
[app.common.pages.helpers :as cph]
[app.common.types.modifiers :as ctm]
[app.common.types.shape.layout :as ctl]
[app.main.data.workspace :as dw]
@ -826,11 +826,11 @@
(mf/use-memo
(mf/deps objects shape modifiers)
(fn []
(let [ids (cph/get-children-ids objects (:id shape))
(let [ids (cfh/get-children-ids objects (:id shape))
objects (-> objects
(gsh/apply-objects-modifiers (select-keys modifiers ids))
(gsh/update-shapes-geometry (reverse ids)))]
(->> (cph/get-immediate-children objects (:id shape))
(->> (cfh/get-immediate-children objects (:id shape))
(keep (fn [child]
(when-not (:hidden child)
[(gpo/parent-coords-bounds (:points child) (:points shape)) child])))))))

View file

@ -7,10 +7,10 @@
(ns app.main.ui.workspace.viewport.guides
(:require
[app.common.colors :as colors]
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
[app.common.math :as mth]
[app.common.pages.helpers :as cph]
[app.common.types.shape-tree :as ctst]
[app.common.uuid :as uuid]
[app.main.data.workspace :as dw]
@ -293,7 +293,7 @@
(not (is-guide-inside-frame? (assoc guide :position pos) frame)))]
(when (or (nil? frame)
(and (cph/root-frame? frame)
(and (cfh/root-frame? frame)
(not (ctst/rotated-frame? frame))))
[:g.guide-area {:opacity (when frame-guide-outside? 0)}
(when-not disabled-guides?

View file

@ -8,10 +8,10 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.focus :as cpf]
[app.common.files.helpers :as cfh]
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.pages.focus :as cpf]
[app.common.pages.helpers :as cph]
[app.common.types.component :as ctk]
[app.common.types.shape-tree :as ctt]
[app.common.uuid :as uuid]
@ -117,7 +117,7 @@
;; If there are no children in the hover-ids we're in the empty side
(->> hover-ids
(remove #(contains? #{:group :bool} (get-in objects [% :type])))
(some #(cph/is-parent? objects % group-id))
(some #(cfh/is-parent? objects % group-id))
(not))))
(defn setup-hover-shapes
@ -220,15 +220,15 @@
(ctt/sort-z-index objects ids {:bottom-frames? mod?}))
grouped? (fn [id]
(and (cph/group-shape? objects id)
(not (cph/mask-shape? objects id))))
(and (cfh/group-shape? objects id)
(not (cfh/mask-shape? objects id))))
selected-with-parents
(into #{} (mapcat #(cph/get-parent-ids objects %)) selected)
(into #{} (mapcat #(cfh/get-parent-ids objects %)) selected)
root-frame-with-data?
#(as-> (get objects %) obj
(and (cph/root-frame? obj)
(and (cfh/root-frame? obj)
(d/not-empty? (:shapes obj))
(not (ctk/instance-head? obj))
(not (ctk/main-instance? obj))))
@ -252,14 +252,14 @@
no-fill-nested-frames?
(fn [id]
(let [shape (get objects id)]
(and (cph/frame-shape? shape)
(not (cph/is-direct-child-of-root? shape))
(and (cfh/frame-shape? shape)
(not (cfh/is-direct-child-of-root? shape))
(empty? (get shape :fills)))))
hover-shape
(->> ids
(remove remove-id?)
(remove (partial cph/hidden-parent? objects))
(remove (partial cfh/hidden-parent? objects))
(remove #(and mod? (no-fill-nested-frames? %)))
(filter #(or (empty? focus) (cpf/is-in-focus? objects focus %)))
(first)
@ -287,8 +287,8 @@
(let [all-frames (mf/use-memo (mf/deps objects) #(ctt/get-root-frames-ids objects))
selected-frames (mf/use-memo (mf/deps selected) #(->> all-frames (filter selected)))
xf-selected-frame (comp (remove cph/root-frame?)
(map #(cph/get-shape-id-root-frame objects %)))
xf-selected-frame (comp (remove cfh/root-frame?)
(map #(cfh/get-shape-id-root-frame objects %)))
selected-shapes-frames (mf/use-memo (mf/deps selected) #(into #{} xf-selected-frame selected))
@ -312,7 +312,7 @@
;; - If no hovering over any frames we keep the previous active one
;; - Check always that the active frames are inside the vbox
(let [hover-ids? (set (->> @hover-ids (map #(cph/get-shape-id-root-frame objects %))))
(let [hover-ids? (set (->> @hover-ids (map #(cfh/get-shape-id-root-frame objects %))))
is-active-frame?
(fn [id]

View file

@ -9,9 +9,9 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt]
[app.common.pages.helpers :as cph]
[app.common.types.shape.interactions :as ctsi]
[app.main.data.workspace :as dw]
[app.main.refs :as refs]
@ -225,7 +225,7 @@
(st/emit! (dw/start-move-overlay-pos index)))]
(when dest-shape
(let [orig-frame (cph/get-frame objects orig-shape)
(let [orig-frame (cfh/get-frame objects orig-shape)
marker-x (+ (:x orig-frame) (:x position))
marker-y (+ (:y orig-frame) (:y position))
width (:width dest-shape)
@ -361,7 +361,7 @@
:objects objects
:hover-disabled? hover-disabled?}]))])))
(when (and shape
(not (cph/unframed-shape? shape))
(not (cfh/unframed-shape? shape))
(not (#{:move :rotate} current-transform)))
[:& interaction-handle {:key (:id shape)
:index nil

View file

@ -9,8 +9,8 @@
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.exceptions :as ex]
[app.common.files.helpers :as cfh]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.common.types.container :as ctn]
[app.main.refs :as refs]
[app.main.ui.hooks :as hooks]
@ -43,7 +43,7 @@
selrect (dm/get-prop shape :selrect)
type (dm/get-prop shape :type)
content (get shape :content)
path? (cph/path-shape? shape)
path? (cfh/path-shape? shape)
path-data
(mf/with-memo [path? content]

View file

@ -7,9 +7,9 @@
(ns app.main.ui.workspace.viewport.scroll-bars
(:require
[app.common.colors :as clr]
[app.common.files.helpers :as cfh]
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.main.data.workspace :as dw]
[app.main.store :as st]
[app.main.ui.workspace.viewport.viewport-ref :refer [point->viewport]]
@ -53,7 +53,7 @@
base-objects-rect (mf/with-memo [objects]
(-> objects
(cph/get-immediate-children)
(cfh/get-immediate-children)
(gsh/shapes->rect)))
inv-zoom (/ 1 zoom)

View file

@ -8,9 +8,9 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.shapes :as gsh]
[app.common.geom.snap :as sp]
[app.common.pages.helpers :as cph]
[app.common.types.shape.layout :as ctl]
[app.main.snap :as snap]
[beicon.core :as rx]
@ -159,7 +159,7 @@
(let [shapes (into [] (keep (d/getf objects)) selected)
filter-shapes
(into selected (mapcat #(cph/get-children-ids objects %)) selected)
(into selected (mapcat #(cfh/get-children-ids objects %)) selected)
remove-snap-base?
(mf/with-memo [layout filter-shapes objects focus]

View file

@ -6,7 +6,7 @@
(ns app.main.ui.workspace.viewport.top-bar
(:require
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.common.types.shape.layout :as ctl]
[app.main.data.workspace :as dw]
[app.main.refs :as refs]
@ -30,14 +30,14 @@
single? (= (count selected) 1)
editing? (= (:id shape) edition)
draw-path? (and (some? drawing-obj)
(cph/path-shape? drawing-obj)
(cfh/path-shape? drawing-obj)
(not= :curve (:tool drawing)))
workspace-read-only? (mf/use-ctx ctx/workspace-read-only?)
path-edition? (or (and single? editing?
(and (not (cph/text-shape? shape))
(not (cph/frame-shape? shape))))
(and (not (cfh/text-shape? shape))
(not (cfh/frame-shape? shape))))
draw-path?)
grid-edition? (and single? editing? (ctl/grid-layout? shape))

View file

@ -8,8 +8,8 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.matrix :as gmt]
[app.common.pages.helpers :as cph]
[app.common.types.shape.layout :as ctl]
[cuerdas.core :as str]))
@ -34,18 +34,18 @@
[shape]
(or
;; path and path-like shapes
(cph/path-shape? shape)
(cph/bool-shape? shape)
(cfh/path-shape? shape)
(cfh/bool-shape? shape)
;; imported SVG images
(cph/svg-raw-shape? shape)
(cfh/svg-raw-shape? shape)
(some? (:svg-attrs shape))
;; CSS masks are not enough we need to delegate to SVG
(cph/mask-shape? shape)
(cfh/mask-shape? shape)
;; Texts with shadows or strokes we render in SVG
(and (cph/text-shape? shape)
(and (cfh/text-shape? shape)
(or (d/not-empty? (:shadow shape))
(d/not-empty? (:strokes shape))))

View file

@ -9,7 +9,7 @@
["react-dom/server" :as rds]
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.pages.helpers :as cph]
[app.common.files.helpers :as cfh]
[app.common.types.shape.layout :as ctl]
[app.config :as cfg]
[app.main.ui.shapes.text.html-text :as text]
@ -38,7 +38,7 @@
svg-markup
indent))
(cph/text-shape? shape)
(cfh/text-shape? shape)
(let [text-shape-html (rds/renderToStaticMarkup (mf/element text/text-shape #js {:shape shape :code? true}))]
(dm/fmt "%<div class=\"%\">\n%\n%</div>"
indent
@ -47,7 +47,7 @@
text-shape-html
indent))
(cph/image-shape? shape)
(cfh/image-shape? shape)
(let [data (or (:metadata shape) (:fill-image shape))
image-url (cfg/resolve-file-media data)]
(dm/fmt "%<img src=\"%\" class=\"%\">\n%</img>"

View file

@ -8,10 +8,10 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.matrix :as gmt]
[app.common.geom.shapes.bounds :as gsb]
[app.common.geom.shapes.points :as gpo]
[app.common.pages.helpers :as cph]
[app.common.text :as txt]
[app.common.types.shape.layout :as ctl]
[app.main.ui.shapes.text.styles :as sts]
@ -279,7 +279,7 @@ body {
(when wrapper? (str/fmt ".%s-wrapper > * {\n%s\n}" selector wrapper-child-properties))
(when svg? (str/fmt ".%s > svg {\n%s\n}" selector svg-child-props))
(str/fmt ".%s {\n%s\n}" selector properties)
(when (cph/text-shape? shape) (generate-text-css shape))]))))))
(when (cfh/text-shape? shape) (generate-text-css shape))]))))))
(defn get-css-property
([objects shape property]

View file

@ -9,9 +9,9 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.geom.matrix :as gmt]
[app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph]
[app.common.types.shape.layout :as ctl]
[app.main.ui.formats :as fmt]
[app.util.code-gen.common :as cgc]
@ -31,10 +31,10 @@
(cond
(or (and (ctl/any-layout-immediate-child? objects shape)
(not (ctl/layout-absolute? shape))
(or (cph/group-like-shape? shape)
(cph/frame-shape? shape)
(or (cfh/group-like-shape? shape)
(cfh/frame-shape? shape)
(cgc/svg-markup? shape)))
(cph/root-frame? shape))
(cfh/root-frame? shape))
:relative
(and (ctl/any-layout-immediate-child? objects shape)
@ -47,7 +47,7 @@
(defn get-shape-position
[shape objects coord]
(when (and (not (cph/root-frame? shape))
(when (and (not (cfh/root-frame? shape))
(or (not (ctl/any-layout-immediate-child? objects shape))
(ctl/layout-absolute? shape)))
@ -73,7 +73,7 @@
(defmethod get-value :flex
[_ shape objects]
(let [parent (cph/get-parent objects (:id shape))]
(let [parent (cfh/get-parent objects (:id shape))]
(when (and (ctl/flex-layout-immediate-child? objects shape)
(or (and (contains? #{:row :row-reverse} (:layout-flex-dir parent))
(= :fill (:layout-item-h-sizing shape)))
@ -83,7 +83,7 @@
(defn get-shape-size
[shape objects type]
(let [parent (cph/get-parent objects (:id shape))
(let [parent (cfh/get-parent objects (:id shape))
sizing (if (= type :width)
(:layout-item-h-sizing shape)
(:layout-item-v-sizing shape))]
@ -148,7 +148,7 @@
(let [single-fill? (= (count fills) 1)
ffill (first fills)
gradient? (some? (:fill-color-gradient ffill))]
(when (and (not (cgc/svg-markup? shape)) (not (cph/group-shape? shape)) single-fill? gradient?)
(when (and (not (cgc/svg-markup? shape)) (not (cfh/group-shape? shape)) single-fill? gradient?)
(fill->color ffill))))
(defmethod get-value :background-color
@ -156,12 +156,12 @@
(let [single-fill? (= (count fills) 1)
ffill (first fills)
gradient? (some? (:fill-color-gradient ffill))]
(when (and (not (cgc/svg-markup? shape)) (not (cph/group-shape? shape)) single-fill? (not gradient?))
(when (and (not (cgc/svg-markup? shape)) (not (cfh/group-shape? shape)) single-fill? (not gradient?))
(fill->color ffill))))
(defmethod get-value :background-image
[_ {:keys [fills] :as shape} _]
(when (and (not (cgc/svg-markup? shape)) (not (cph/group-shape? shape)) (> (count fills) 1))
(when (and (not (cgc/svg-markup? shape)) (not (cfh/group-shape? shape)) (> (count fills) 1))
(->> fills
(map fill->color))))
@ -186,7 +186,7 @@
(defmethod get-value :border-radius
[_ {:keys [rx r1 r2 r3 r4] :as shape} _]
(cond
(cph/circle-shape? shape)
(cfh/circle-shape? shape)
"50%"
(some? rx)
@ -219,7 +219,7 @@
(defmethod get-value :overflow
[_ shape _]
(when (and (cph/frame-shape? shape)
(when (and (cfh/frame-shape? shape)
(not (cgc/svg-markup? shape))
(not (:show-content shape)))
"hidden"))
@ -363,7 +363,7 @@
(defmethod get-value :z-index
[_ {:keys [layout-item-z-index] :as shape} objects]
(cond
(cph/root-frame? shape)
(cfh/root-frame? shape)
0
(ctl/any-layout-immediate-child? objects shape)
@ -381,7 +381,7 @@
(and (ctl/any-layout-immediate-child? objects shape) (some? (:layout-item-min-h shape)))
(:layout-item-min-h shape)
(and (ctl/auto-height? shape) (cph/frame-shape? shape) (not (:show-content shape)))
(and (ctl/auto-height? shape) (cfh/frame-shape? shape) (not (:show-content shape)))
(-> shape :selrect :height)))
(defmethod get-value :max-width
@ -396,7 +396,7 @@
(and (ctl/any-layout-immediate-child? objects shape) (some? (:layout-item-min-w shape)))
(:layout-item-min-w shape)
(and (ctl/auto-width? shape) (cph/frame-shape? shape) (not (:show-content shape)))
(and (ctl/auto-width? shape) (cfh/frame-shape? shape) (not (:show-content shape)))
(-> shape :selrect :width)))
(defmethod get-value :align-self

View file

@ -10,10 +10,10 @@
https://en.wikipedia.org/wiki/Range_tree"
(:require
[app.common.data :as d]
[app.common.files.helpers :as cfh]
[app.common.files.page-diff :as diff]
[app.common.geom.grid :as gg]
[app.common.geom.snap :as snap]
[app.common.pages.diff :as diff]
[app.common.pages.helpers :as cph]
[app.common.types.shape-tree :as ctst]
[app.common.types.shape.layout :as ctl]
[app.common.uuid :as uuid]
@ -87,7 +87,7 @@
(cond-> page-data
(and (not (ctl/any-layout-descent? objects frame))
(not (:hidden frame))
(not (cph/hidden-parent? objects frame-id)))
(not (cfh/hidden-parent? objects frame-id)))
(-> ;; Update root frame information
(assoc-in [uuid/zero :objects-data frame-id] frame-data)
@ -115,7 +115,7 @@
(cond-> page-data
(and (not (ctl/any-layout-descent? objects shape))
(not (:hidden shape))
(not (cph/hidden-parent? objects (:id shape))))
(not (cfh/hidden-parent? objects (:id shape))))
(-> (assoc-in [frame-id :objects-data (:id shape)] shape-data)
(update-in [frame-id :x] (make-insert-tree-data shape-data :x))
(update-in [frame-id :y] (make-insert-tree-data shape-data :y))))))
@ -135,7 +135,7 @@
;; Guide inside frame, we add the information only on that frame
(cond-> page-data
(and (not (:hidden frame))
(not (cph/hidden-parent? objects frame-id)))
(not (cfh/hidden-parent? objects frame-id)))
(-> (assoc-in [frame-id :objects-data (:id guide)] guide-data)
(update-in [frame-id (:axis guide)] (make-insert-tree-data guide-data (:axis guide)))))
@ -214,7 +214,7 @@
[snap-data {:keys [objects options] :as page}]
(let [frames (ctst/get-frames objects)
shapes (->> (vals (:objects page))
(remove cph/frame-shape?))
(remove cfh/frame-shape?))
guides (vals (:guides options))
page-data

View file

@ -7,8 +7,8 @@
(ns app.worker.impl
(:require
[app.common.data.macros :as dm]
[app.common.files.changes :as ch]
[app.common.logging :as log]
[app.common.pages.changes :as ch]
[app.config :as cf]
[okulary.core :as l]))

View file

@ -7,12 +7,12 @@
(ns app.worker.selection
(:require
[app.common.data :as d]
[app.common.files.helpers :as cfh]
[app.common.files.indices :as cfi]
[app.common.geom.point :as gpt]
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.geom.shapes.text :as gst]
[app.common.pages :as cp]
[app.common.pages.helpers :as cph]
[app.common.types.modifiers :as ctm]
[app.common.uuid :as uuid]
[app.util.quadtree :as qdt]
@ -31,7 +31,7 @@
(fn [index shape]
(let [{:keys [x y width height]}
(cond
(and ^boolean (cph/text-shape? shape)
(and ^boolean (cfh/text-shape? shape)
^boolean (some? (:position-data shape))
^boolean (d/not-empty? (:position-data shape)))
(gst/shape->bounds shape)
@ -81,10 +81,10 @@
(defn- create-index
[objects]
(let [shapes (-> objects (dissoc uuid/zero) vals)
parents-index (cp/generate-child-all-parents-index objects)
clip-parents-index (cp/create-clip-index objects parents-index)
parents-index (cfi/generate-child-all-parents-index objects)
clip-parents-index (cfi/create-clip-index objects parents-index)
root-shapes (cph/get-immediate-children objects uuid/zero)
root-shapes (cfh/get-immediate-children objects uuid/zero)
bounds (-> root-shapes gsh/shapes->rect add-padding-bounds)
index-shape (make-index-shape objects parents-index clip-parents-index)
@ -103,13 +103,13 @@
changed-ids (into #{}
(comp (filter #(not= % uuid/zero))
(filter changes?)
(mapcat #(into [%] (cph/get-children-ids new-objects %))))
(mapcat #(into [%] (cfh/get-children-ids new-objects %))))
(set/union (set (keys old-objects))
(set (keys new-objects))))
shapes (->> changed-ids (mapv #(get new-objects %)) (filterv (comp not nil?)))
parents-index (cp/generate-child-all-parents-index new-objects shapes)
clip-parents-index (cp/create-clip-index new-objects parents-index)
parents-index (cfi/generate-child-all-parents-index new-objects shapes)
clip-parents-index (cfi/create-clip-index new-objects parents-index)
new-index (qdt/remove-all index changed-ids)