mirror of
https://github.com/penpot/penpot.git
synced 2025-06-14 23:11:37 +02:00
♻️ Refactor common.page.helpers namespace.
This commit is contained in:
parent
24724e3340
commit
a1da4d4233
55 changed files with 1235 additions and 1348 deletions
|
@ -10,7 +10,7 @@
|
|||
[app.common.geom.point :as gpt]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.math :as mth]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.fonts :as df]
|
||||
[app.main.render :as render]
|
||||
|
@ -60,7 +60,7 @@
|
|||
(gpt/negate)
|
||||
(gmt/translate-matrix))
|
||||
|
||||
mod-ids (cons frame-id (cp/get-children frame-id objects))
|
||||
mod-ids (cons frame-id (cph/get-children-ids objects frame-id))
|
||||
updt-fn #(-> %1
|
||||
(assoc-in [%2 :modifiers :displacement] modifier)
|
||||
(update %2 gsh/transform-shape))
|
||||
|
@ -133,7 +133,7 @@
|
|||
[objects object-id]
|
||||
(if (uuid/zero? object-id)
|
||||
(let [object (get objects object-id)
|
||||
shapes (cp/select-toplevel-shapes objects {:include-frames? true})
|
||||
shapes (cph/get-immediate-children objects)
|
||||
srect (gsh/selection-rect shapes)
|
||||
object (merge object (select-keys srect [:x :y :width :height]))
|
||||
object (gsh/transform-shape object)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
"The main container for a frame in handoff mode"
|
||||
(:require
|
||||
[app.common.geom.shapes :as geom]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.main.data.viewer :as dv]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.shapes.bool :as bool]
|
||||
|
@ -116,12 +116,12 @@
|
|||
(mf/fnc bool-container
|
||||
{::mf/wrap-props false}
|
||||
[props]
|
||||
(let [shape (unchecked-get props "shape")
|
||||
children-ids (cp/get-children (:id shape) objects)
|
||||
childs (select-keys objects children-ids)
|
||||
props (-> (obj/new)
|
||||
(obj/merge! props)
|
||||
(obj/merge! #js {:childs childs}))]
|
||||
(let [shape (unchecked-get props "shape")
|
||||
children (->> (cph/get-children-ids objects (:id shape))
|
||||
(select-keys objects))
|
||||
props (-> (obj/new)
|
||||
(obj/merge! props)
|
||||
(obj/merge! #js {:childs children}))]
|
||||
[:> bool-wrapper props]))))
|
||||
|
||||
(defn svg-raw-container-factory
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
[app.common.data :as d]
|
||||
[app.common.geom.matrix :as gmt]
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.spec.page :as csp]
|
||||
[app.main.data.comments :as dcm]
|
||||
[app.main.data.viewer :as dv]
|
||||
|
@ -35,11 +35,10 @@
|
|||
|
||||
update-fn #(d/update-when %1 %2 assoc-in [:modifiers :displacement] modifier)]
|
||||
|
||||
(->> (cp/get-children frame-id objects)
|
||||
(->> (cph/get-children-ids objects frame-id)
|
||||
(into [frame-id])
|
||||
(reduce update-fn objects)))))
|
||||
|
||||
|
||||
(mf/defc viewport
|
||||
{::mf/wrap [mf/memo]}
|
||||
[{:keys [page interactions-mode frame base-frame frame-offset size]}]
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
[app.common.geom.matrix :as gmt]
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.common.geom.shapes :as geom]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.spec.interactions :as cti]
|
||||
[app.main.data.viewer :as dv]
|
||||
[app.main.refs :as refs]
|
||||
|
@ -330,7 +330,8 @@
|
|||
{::mf/wrap-props false}
|
||||
[props]
|
||||
(let [shape (unchecked-get props "shape")
|
||||
childs (select-keys objects (cp/get-children (:id shape) objects))
|
||||
childs (->> (cph/get-children-ids objects (:id shape))
|
||||
(select-keys objects))
|
||||
props (obj/merge! #js {} props
|
||||
#js {:childs childs
|
||||
:objects objects})]
|
||||
|
@ -399,7 +400,7 @@
|
|||
update-fn #(assoc-in %1 [%2 :modifiers :displacement] modifier)
|
||||
|
||||
frame-id (:id frame)
|
||||
modifier-ids (into [frame-id] (cp/get-children frame-id objects))
|
||||
modifier-ids (into [frame-id] (cph/get-children-ids objects frame-id))
|
||||
objects (reduce update-fn objects modifier-ids)
|
||||
frame (assoc-in frame [:modifiers :displacement] modifier)
|
||||
|
||||
|
|
|
@ -100,13 +100,11 @@
|
|||
|
||||
(mf/defc menu
|
||||
[{:keys [layout project file team-id page-id] :as props}]
|
||||
(let [show-menu? (mf/use-state false)
|
||||
(let [show-menu? (mf/use-state false)
|
||||
show-sub-menu? (mf/use-state false)
|
||||
editing? (mf/use-state false)
|
||||
|
||||
frames (mf/deref refs/workspace-frames)
|
||||
|
||||
editing? (mf/use-state false)
|
||||
edit-input-ref (mf/use-ref nil)
|
||||
frames (mf/deref refs/workspace-frames)
|
||||
|
||||
add-shared-fn
|
||||
(st/emitf (dw/set-file-shared (:id file) true))
|
||||
|
|
|
@ -12,9 +12,7 @@
|
|||
others are defined using a generic wrapper implemented in
|
||||
common."
|
||||
(:require
|
||||
[app.common.pages :as cp]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.refs :as refs]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.main.ui.shapes.circle :as circle]
|
||||
[app.main.ui.shapes.image :as image]
|
||||
[app.main.ui.shapes.rect :as rect]
|
||||
|
@ -29,7 +27,6 @@
|
|||
[app.main.ui.workspace.shapes.text :as text]
|
||||
[app.util.object :as obj]
|
||||
[debug :refer [debug?]]
|
||||
[okulary.core :as l]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(declare shape-wrapper)
|
||||
|
@ -42,31 +39,23 @@
|
|||
(def image-wrapper (common/generic-wrapper-factory image/image-shape))
|
||||
(def rect-wrapper (common/generic-wrapper-factory rect/rect-shape))
|
||||
|
||||
(defn make-is-moving-ref
|
||||
[id]
|
||||
(fn []
|
||||
(let [check-moving (fn [local]
|
||||
(and (= :move (:transform local))
|
||||
(contains? (:selected local) id)))]
|
||||
(l/derived check-moving refs/workspace-local))))
|
||||
|
||||
(mf/defc root-shape
|
||||
"Draws the root shape of the viewport and recursively all the shapes"
|
||||
{::mf/wrap-props false}
|
||||
[props]
|
||||
(let [objects (obj/get props "objects")
|
||||
active-frames (obj/get props "active-frames")
|
||||
root-shapes (get-in objects [uuid/zero :shapes])
|
||||
shapes (->> root-shapes (mapv #(get objects %)))
|
||||
|
||||
root-children (->> shapes
|
||||
(filter #(not= :frame (:type %)))
|
||||
(mapcat #(cp/get-object-with-children (:id %) objects)))]
|
||||
|
||||
shapes (cph/get-immediate-children objects)]
|
||||
[:*
|
||||
[:& ff/fontfaces-style {:shapes root-children}]
|
||||
;; 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 %))))]
|
||||
[:& ff/fontfaces-style {:shapes (into [] xform shapes)}])
|
||||
|
||||
(for [item shapes]
|
||||
(if (= (:type item) :frame)
|
||||
(if (cph/frame-shape? item)
|
||||
[:& frame-wrapper {:shape item
|
||||
:key (:id item)
|
||||
:objects objects
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
(ns app.main.ui.workspace.shapes.frame
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.main.ui.hooks :as hooks]
|
||||
[app.main.ui.shapes.frame :as frame]
|
||||
[app.main.ui.shapes.shape :refer [shape-container]]
|
||||
|
@ -105,7 +105,7 @@
|
|||
(hooks/use-equal-memo))
|
||||
|
||||
all-children
|
||||
(-> (cp/get-children-objects (:id shape) objects)
|
||||
(-> (cph/get-children objects (:id shape))
|
||||
(hooks/use-equal-memo))
|
||||
|
||||
show-thumbnail?
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,7 @@
|
|||
(ns app.main.ui.workspace.sidebar.layers
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.common :as dwc]
|
||||
|
@ -58,18 +58,16 @@
|
|||
(when (kbd/enter? event) (accept-edit))
|
||||
(when (kbd/esc? event) (cancel-edit)))]
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps shape-for-rename)
|
||||
#(when (and (= shape-for-rename (:id shape))
|
||||
(not (:edition @local)))
|
||||
(start-edit)))
|
||||
(mf/with-effect [shape-for-rename]
|
||||
(when (and (= shape-for-rename (:id shape))
|
||||
(not (:edition @local)))
|
||||
(start-edit)))
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps (:edition @local))
|
||||
#(when (:edition @local)
|
||||
(let [name-input (mf/ref-val name-ref)]
|
||||
(dom/select-text! name-input))
|
||||
nil))
|
||||
(mf/with-effect [(:edition @local)]
|
||||
(when (:edition @local)
|
||||
(let [name-input (mf/ref-val name-ref)]
|
||||
(dom/select-text! name-input)
|
||||
nil)))
|
||||
|
||||
(if (:edition @local)
|
||||
[:input.element-name
|
||||
|
@ -92,9 +90,10 @@
|
|||
|
||||
(mf/defc layer-item
|
||||
[{:keys [index item selected objects] :as props}]
|
||||
(let [id (:id item)
|
||||
selected? (contains? selected id)
|
||||
container? (or (= (:type item) :frame) (= (:type item) :group))
|
||||
(let [id (:id item)
|
||||
selected? (contains? selected id)
|
||||
container? (or (cph/frame-shape? item)
|
||||
(cph/group-shape? item))
|
||||
|
||||
disable-drag (mf/use-state false)
|
||||
|
||||
|
@ -160,7 +159,7 @@
|
|||
(if (= side :center)
|
||||
(st/emit! (dw/relocate-selected-shapes (:id item) 0))
|
||||
(let [to-index (if (= side :top) (inc index) index)
|
||||
parent-id (cp/get-parent (:id item) objects)]
|
||||
parent-id (cph/get-parent-id objects (:id item))]
|
||||
(st/emit! (dw/relocate-selected-shapes parent-id to-index)))))
|
||||
|
||||
on-hold
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
(ns app.main.ui.workspace.sidebar.options.menus.component
|
||||
(:require
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.libraries :as dwl]
|
||||
|
@ -16,7 +16,7 @@
|
|||
[app.main.ui.context :as ctx]
|
||||
[app.main.ui.icons :as i]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [t]]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(def component-attrs [:component-id :component-file :shape-ref])
|
||||
|
@ -25,47 +25,59 @@
|
|||
[{:keys [ids values] :as props}]
|
||||
(let [current-file-id (mf/use-ctx ctx/current-file-id)
|
||||
|
||||
id (first ids)
|
||||
locale (mf/deref i18n/locale)
|
||||
local (mf/use-state {:menu-open false})
|
||||
id (first ids)
|
||||
local (mf/use-state {:menu-open false})
|
||||
|
||||
show? (some? (:component-id values))
|
||||
local-library (mf/deref refs/workspace-local-library)
|
||||
libraries (mf/deref refs/workspace-libraries)
|
||||
{:keys [component-id component-file]} values
|
||||
component-id (:component-id values)
|
||||
library-id (:component-file values)
|
||||
|
||||
component (cp/get-component component-id component-file local-library libraries)
|
||||
local-file (deref refs/workspace-local-library)
|
||||
libraries (deref refs/workspace-libraries)
|
||||
|
||||
on-menu-click (mf/use-callback
|
||||
(fn [event]
|
||||
(dom/prevent-default event)
|
||||
(dom/stop-propagation event)
|
||||
(swap! local assoc :menu-open true)))
|
||||
;; NOTE: this is necessary because the `cph/get-component`
|
||||
;; expects a map of all libraries, including the local one.
|
||||
libraries (assoc libraries (:id local-file) local-file)
|
||||
|
||||
on-menu-close (mf/use-callback
|
||||
#(swap! local assoc :menu-open false))
|
||||
component (cph/get-component libraries library-id component-id)
|
||||
show? (some? component-id)
|
||||
|
||||
do-detach-component (st/emitf (dwl/detach-component id))
|
||||
do-reset-component (st/emitf (dwl/reset-component id))
|
||||
do-update-component (st/emitf (dwl/update-component-sync id component-file))
|
||||
on-menu-click
|
||||
(mf/use-callback
|
||||
(fn [event]
|
||||
(dom/prevent-default event)
|
||||
(dom/stop-propagation event)
|
||||
(swap! local assoc :menu-open true)))
|
||||
|
||||
on-menu-close
|
||||
(mf/use-callback
|
||||
#(swap! local assoc :menu-open false))
|
||||
|
||||
do-detach-component
|
||||
(st/emitf (dwl/detach-component id))
|
||||
|
||||
do-reset-component
|
||||
(st/emitf (dwl/reset-component id))
|
||||
|
||||
do-update-component
|
||||
(st/emitf (dwl/update-component-sync id library-id))
|
||||
|
||||
do-update-remote-component
|
||||
(st/emitf (modal/show
|
||||
{:type :confirm
|
||||
:message ""
|
||||
:title (t locale "modals.update-remote-component.message")
|
||||
:hint (t locale "modals.update-remote-component.hint")
|
||||
:cancel-label (t locale "modals.update-remote-component.cancel")
|
||||
:accept-label (t locale "modals.update-remote-component.accept")
|
||||
:title (tr "modals.update-remote-component.message")
|
||||
:hint (tr "modals.update-remote-component.hint")
|
||||
:cancel-label (tr "modals.update-remote-component.cancel")
|
||||
:accept-label (tr "modals.update-remote-component.accept")
|
||||
:accept-style :primary
|
||||
:on-accept do-update-component}))
|
||||
|
||||
do-show-component (st/emitf (dw/go-to-component component-id))
|
||||
do-navigate-component-file (st/emitf (dwl/nav-to-component-file component-file))]
|
||||
do-navigate-component-file (st/emitf (dwl/nav-to-component-file library-id))]
|
||||
(when show?
|
||||
[:div.element-set
|
||||
[:div.element-set-title
|
||||
[:span (t locale "workspace.options.component")]]
|
||||
[:span (tr "workspace.options.component")]]
|
||||
[:div.element-set-content
|
||||
[:div.row-flex.component-row
|
||||
i/component
|
||||
|
@ -78,14 +90,14 @@
|
|||
;; app/main/ui/workspace/context_menu.cljs
|
||||
[:& context-menu {:on-close on-menu-close
|
||||
:show (:menu-open @local)
|
||||
:options (if (= (:component-file values) current-file-id)
|
||||
[[(t locale "workspace.shape.menu.detach-instance") do-detach-component]
|
||||
[(t locale "workspace.shape.menu.reset-overrides") do-reset-component]
|
||||
[(t locale "workspace.shape.menu.update-main") do-update-component]
|
||||
[(t locale "workspace.shape.menu.show-main") do-show-component]]
|
||||
:options (if (= library-id current-file-id)
|
||||
[[(tr "workspace.shape.menu.detach-instance") do-detach-component]
|
||||
[(tr "workspace.shape.menu.reset-overrides") do-reset-component]
|
||||
[(tr "workspace.shape.menu.update-main") do-update-component]
|
||||
[(tr "workspace.shape.menu.show-main") do-show-component]]
|
||||
|
||||
[[(t locale "workspace.shape.menu.detach-instance") do-detach-component]
|
||||
[(t locale "workspace.shape.menu.reset-overrides") do-reset-component]
|
||||
[(t locale "workspace.shape.menu.go-main") do-navigate-component-file]
|
||||
[(t locale "workspace.shape.menu.update-main") do-update-remote-component]])}]]]]])))
|
||||
[[(tr "workspace.shape.menu.detach-instance") do-detach-component]
|
||||
[(tr "workspace.shape.menu.reset-overrides") do-reset-component]
|
||||
[(tr "workspace.shape.menu.go-main") do-navigate-component-file]
|
||||
[(tr "workspace.shape.menu.update-main") do-update-remote-component]])}]]]]])))
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
(ns app.main.ui.workspace.sidebar.options.menus.interactions
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.spec.interactions :as csi]
|
||||
[app.common.spec.page :as csp]
|
||||
[app.common.uuid :as uuid]
|
||||
|
@ -178,10 +178,10 @@
|
|||
|
||||
(mf/defc interaction-entry
|
||||
[{:keys [index shape interaction update-interaction remove-interaction]}]
|
||||
(let [objects (deref refs/workspace-page-objects)
|
||||
destination (get objects (:destination interaction))
|
||||
frames (mf/use-memo (mf/deps objects)
|
||||
#(cp/select-frames objects))
|
||||
(let [objects (deref refs/workspace-page-objects)
|
||||
destination (get objects (:destination interaction))
|
||||
frames (mf/with-memo [objects]
|
||||
(cph/get-frames objects))
|
||||
|
||||
overlay-pos-type (:overlay-pos-type interaction)
|
||||
close-click-outside? (:close-click-outside interaction false)
|
||||
|
@ -190,10 +190,10 @@
|
|||
way (-> interaction :animation :way)
|
||||
direction (-> interaction :animation :direction)
|
||||
|
||||
extended-open? (mf/use-state false)
|
||||
extended-open? (mf/use-state false)
|
||||
|
||||
ext-delay-ref (mf/use-ref nil)
|
||||
ext-duration-ref (mf/use-ref nil)
|
||||
ext-delay-ref (mf/use-ref nil)
|
||||
ext-duration-ref (mf/use-ref nil)
|
||||
|
||||
select-text
|
||||
(fn [ref] (fn [_] (dom/select-text! (mf/ref-val ref))))
|
||||
|
@ -550,7 +550,7 @@
|
|||
[:& page-flows {:flows flows}])
|
||||
|
||||
[:div.element-set.interactions-options
|
||||
(when (and shape (not (cp/unframed-shape? shape)))
|
||||
(when (and shape (not (cph/unframed-shape? shape)))
|
||||
[:div.element-set-title
|
||||
[:span (tr "workspace.options.interactions")]
|
||||
[:div.add-page {:on-click add-interaction}
|
||||
|
@ -558,7 +558,7 @@
|
|||
[:div.element-set-content
|
||||
(when (= (count interactions) 0)
|
||||
[:*
|
||||
(when (and shape (not (cp/unframed-shape? shape)))
|
||||
(when (and shape (not (cph/unframed-shape? shape)))
|
||||
[:*
|
||||
[:div.interactions-help-icon i/plus]
|
||||
[:div.interactions-help.separator (tr "workspace.options.add-interaction")]])
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
["react-virtualized" :as rvt]
|
||||
[app.common.data :as d]
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.text :as txt]
|
||||
[app.main.data.fonts :as fts]
|
||||
[app.main.data.shortcuts :as dsc]
|
||||
|
@ -575,7 +575,7 @@
|
|||
[:input.element-name.adv-typography-name
|
||||
{:type "text"
|
||||
:ref name-input-ref
|
||||
:default-value (cp/merge-path-item (:path typography) (:name typography))
|
||||
:default-value (cph/merge-path-item (:path typography) (:name typography))
|
||||
:on-blur on-name-blur
|
||||
:on-change on-name-change}]
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.main.data.shortcuts :as dsc]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.path.shortcuts :as psc]
|
||||
|
@ -154,13 +154,13 @@
|
|||
|
||||
selected (mf/ref-val selected-ref)
|
||||
|
||||
remove-xfm (mapcat #(cp/get-parents % objects))
|
||||
remove-xfm (mapcat #(cph/get-parent-ids objects %))
|
||||
remove-id? (cond-> (into #{} remove-xfm selected)
|
||||
@ctrl?
|
||||
(into (filter is-group?) ids))
|
||||
|
||||
hover-shape (->> ids
|
||||
(filterv (comp not remove-id?))
|
||||
(filter (comp not remove-id?))
|
||||
(first)
|
||||
(get objects))]
|
||||
(reset! hover hover-shape)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.spec.interactions :as cti]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.refs :as refs]
|
||||
|
@ -210,7 +210,7 @@
|
|||
(st/emit! (dw/start-move-overlay-pos index)))]
|
||||
|
||||
(when dest-shape
|
||||
(let [orig-frame (cp/get-frame orig-shape objects)
|
||||
(let [orig-frame (cph/get-frame objects orig-shape)
|
||||
marker-x (+ (:x orig-frame) (:x position))
|
||||
marker-y (+ (:y orig-frame) (:y position))
|
||||
width (:width dest-shape)
|
||||
|
@ -326,7 +326,7 @@
|
|||
:objects objects
|
||||
:hover-disabled? hover-disabled?}]))])))
|
||||
(when (and shape
|
||||
(not (cp/unframed-shape? shape))
|
||||
(not (cph/unframed-shape? shape))
|
||||
(not (#{:move :rotate} current-transform)))
|
||||
[:& interaction-handle {:key (:id shape)
|
||||
:index nil
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
(:require
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.main.refs :as refs]
|
||||
[app.util.object :as obj]
|
||||
[app.util.path.format :as upf]
|
||||
|
@ -89,7 +89,7 @@
|
|||
transform (mf/deref refs/current-transform)
|
||||
|
||||
outlines-ids (->> (set/union selected hover)
|
||||
(cp/clean-loops objects))
|
||||
(cph/clean-loops objects))
|
||||
|
||||
show-outline? (fn [shape] (and (not (:hidden shape))
|
||||
(not (:blocked shape))))
|
||||
|
|
|
@ -50,13 +50,10 @@
|
|||
vbox-x (:x vbox)
|
||||
vbox-y (:y vbox)
|
||||
|
||||
base-objects-rect
|
||||
(mf/use-memo
|
||||
(mf/deps objects)
|
||||
(fn []
|
||||
(let [root-shapes (-> objects cph/get-top-frame :shapes)
|
||||
shapes (->> root-shapes (mapv #(get objects %)))]
|
||||
(gsh/selection-rect shapes))))
|
||||
base-objects-rect (mf/with-memo [objects]
|
||||
(-> objects
|
||||
(cph/get-immediate-children)
|
||||
(gsh/selection-rect)))
|
||||
|
||||
inv-zoom (/ 1 zoom)
|
||||
vbox-height (- (:height vbox) (* inv-zoom scroll-height))
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
[app.common.data :as d]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.math :as mth]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.worker :as uw]
|
||||
[beicon.core :as rx]
|
||||
|
@ -225,7 +225,7 @@
|
|||
:frame-id (:id frame)
|
||||
:include-frames? true
|
||||
:rect rect})
|
||||
(rx/map #(cp/clean-loops @refs/workspace-page-objects %))
|
||||
(rx/map #(cph/clean-loops @refs/workspace-page-objects %))
|
||||
(rx/map #(set/difference % selected))
|
||||
(rx/map #(->> % (map (partial get @refs/workspace-page-objects)))))
|
||||
(rx/of nil))))]
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
[app.common.data :as d]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.math :as mth]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.spec :as us]
|
||||
[app.main.snap :as snap]
|
||||
[app.util.geom.snap-points :as sp]
|
||||
[beicon.core :as rx]
|
||||
|
@ -151,18 +152,14 @@
|
|||
(mf/defc snap-points
|
||||
{::mf/wrap [mf/memo]}
|
||||
[{:keys [layout zoom objects selected page-id drawing transform modifiers] :as props}]
|
||||
|
||||
(let [shapes (into [] (keep (d/getf objects)) selected)
|
||||
(us/assert set? selected)
|
||||
(let [shapes (into [] (keep (d/getf objects)) selected)
|
||||
|
||||
filter-shapes
|
||||
(into #{}
|
||||
(comp (mapcat #(cp/get-object-with-children % objects))
|
||||
(map :id))
|
||||
selected)
|
||||
(into selected (mapcat #(cph/get-children-ids objects %)) selected)
|
||||
|
||||
remove-snap? (mf/use-memo
|
||||
(mf/deps layout filter-shapes)
|
||||
#(snap/make-remove-snap layout filter-shapes))
|
||||
remove-snap? (mf/with-memo [layout filter-shapes]
|
||||
(snap/make-remove-snap layout filter-shapes))
|
||||
|
||||
shapes (if drawing [drawing] shapes)]
|
||||
(when (or drawing transform)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
(:require
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.interactions :as dwi]
|
||||
[app.main.refs :as refs]
|
||||
|
@ -161,7 +161,7 @@
|
|||
on-frame-enter (unchecked-get props "on-frame-enter")
|
||||
on-frame-leave (unchecked-get props "on-frame-leave")
|
||||
on-frame-select (unchecked-get props "on-frame-select")
|
||||
frames (cp/select-frames objects)]
|
||||
frames (cph/get-frames objects)]
|
||||
|
||||
[:g.frame-titles
|
||||
(for [frame frames]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue