diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 52a09c8c9..078f6c1a3 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -790,6 +790,7 @@ (defn relocate-shapes [ids parent-id to-index & [ignore-parents?]] (dm/assert! (every? uuid? ids)) + (dm/assert! (set? ids)) (dm/assert! (uuid? parent-id)) (dm/assert! (number? to-index)) diff --git a/frontend/src/app/plugins/shape.cljs b/frontend/src/app/plugins/shape.cljs index 1bcbea5dc..33148f752 100644 --- a/frontend/src/app/plugins/shape.cljs +++ b/frontend/src/app/plugins/shape.cljs @@ -12,10 +12,12 @@ [app.common.files.helpers :as cfh] [app.common.record :as crc] [app.common.text :as txt] + [app.common.uuid :as uuid] [app.main.data.workspace :as udw] [app.main.data.workspace.changes :as dwc] [app.main.store :as st] [app.plugins.utils :refer [get-data get-data-fn]] + [app.util.object :as obj] [cuerdas.core :as str])) (declare data->shape-proxy) @@ -69,8 +71,16 @@ (clone [_] (.log js/console (clj->js _data))) (delete [_] (.log js/console (clj->js _data))) - (appendChild [_ child] (.log js/console (clj->js _data))) - (insertChild [_ index child] (.log js/console (clj->js _data)))) + + (appendChild [self child] + (let [parent-id (get-data self :id) + child-id (uuid/uuid (obj/get child "id"))] + (st/emit! (udw/relocate-shapes #{ child-id } parent-id 0)))) + + (insertChild [self index child] + (let [parent-id (get-data self :id) + child-id (uuid/uuid (obj/get child "id"))] + (st/emit! (udw/relocate-shapes #{ child-id } parent-id index))))) (crc/define-properties! ShapeProxy @@ -117,9 +127,6 @@ (let [id (get-data self :id)] (st/emit! (dwc/update-shapes [id] #(assoc % :name value)))))} - {:name "children" - :get #(.getChildren ^js %)} - {:name "fills" :get #(get-state % :fills make-fills) ;;:set (fn [self value] (.log js/console self value)) @@ -130,6 +137,11 @@ ;;:set (fn [self value] (.log js/console self value)) }) + (cond-> (or (cfh/frame-shape? data) (cfh/group-shape? data) (cfh/svg-raw-shape? data) (cfh/bool-shape? data)) + (crc/add-properties! + {:name "children" + :get #(.getChildren ^js %)})) + (cond-> (cfh/text-shape? data) (crc/add-properties! {:name "characters"