0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-09 14:21:42 -05:00

♻️ Remove ? char from shape attrs

This commit is contained in:
Andrey Antukh 2023-05-29 18:21:48 +02:00
parent 405aa66357
commit 6e7595f48c
36 changed files with 203 additions and 168 deletions

View file

@ -34,7 +34,7 @@ jobs:
working_directory: "./frontend" working_directory: "./frontend"
command: | command: |
yarn install yarn install
yarn run lint-scss yarn run lint:scss
- run: - run:
name: common lint name: common lint

View file

@ -217,7 +217,7 @@
:id group-id} :id group-id}
{:add-container? true}) {:add-container? true})
(:masked-group? group) (:masked-group group)
(let [mask (first children)] (let [mask (first children)]
(commit-change (commit-change
file file
@ -550,7 +550,7 @@
:id component-id :id component-id
:skip-undelete? true}) :skip-undelete? true})
(:masked-group? component) (:masked-group component)
(let [mask (first children)] (let [mask (first children)]
(commit-change (commit-change
file file
@ -606,7 +606,7 @@
(gpt/point main-instance-x (gpt/point main-instance-x
main-instance-y) main-instance-y)
true true
{:main-instance? true {:main-instance true
:force-id main-instance-id})] :force-id main-instance-id})]
(as-> file $ (as-> file $
(reduce #(commit-change %1 (reduce #(commit-change %1
@ -649,7 +649,7 @@
(gpt/point x (gpt/point x
y) y)
components-v2 components-v2
#_{:main-instance? true #_{:main-instance true
:force-id main-instance-id})] :force-id main-instance-id})]
(as-> file $ (as-> file $

View file

@ -6,4 +6,4 @@
(ns app.common.files.defaults) (ns app.common.files.defaults)
(def version 22) (def version 23)

View file

@ -490,3 +490,30 @@
(-> data (-> data
(update :pages-index update-vals update-container) (update :pages-index update-vals update-container)
(update :components update-vals update-container)))) (update :components update-vals update-container))))
(defmethod migrate 23
[data]
(letfn [(update-object [object]
(cond-> object
(contains? object :main-instance?)
(-> (assoc :main-instance (:main-instance? object))
(dissoc :main-instance?))
(contains? object :component-root?)
(-> (assoc :component-root (:component-root? object))
(dissoc :component-root?))
(contains? object :remote-synced?)
(-> (assoc :remote-synced (:remote-synced? object))
(dissoc :remote-synced?))
(contains? object :masked-group?)
(-> (assoc :masked-group (:masked-group? object))
(dissoc :masked-group?))))
(update-container [container]
(d/update-when container :objects update-vals update-object))]
(-> data
(update :pages-index update-vals update-container)
(update :components update-vals update-container))))

View file

@ -154,7 +154,7 @@
(empty? (:shapes shape)) (empty? (:shapes shape))
[(calculate-base-bounds shape)] [(calculate-base-bounds shape)]
(:masked-group? shape) (:masked-group shape)
[(calculate-base-bounds shape)] [(calculate-base-bounds shape)]
(and (cph/frame-shape? shape) (not (:show-content shape))) (and (cph/frame-shape? shape) (not (:show-content shape)))
@ -169,7 +169,7 @@
(:show-content shape)) (:show-content shape))
(or (not (cph/group-shape? shape)) (or (not (cph/group-shape? shape))
(not (:masked-group? shape))))) (not (:masked-group shape)))))
(:id shape) (:id shape)
(fn [result child] (fn [result child]
(conj result (calculate-base-bounds child))) (conj result (calculate-base-bounds child)))

View file

@ -50,7 +50,7 @@
[:set-remote-synced [:set-remote-synced
[:map {:title "SetRemoteSyncedOperation"} [:map {:title "SetRemoteSyncedOperation"}
[:type [:= :set-remote-synced]] [:type [:= :set-remote-synced]]
[:remote-synced? [:maybe :boolean]]]]]) [:remote-synced {:optional true} [:maybe :boolean]]]]])
(sm/def! ::change (sm/def! ::change
[:schema [:schema
@ -434,7 +434,7 @@
(= :bool (:type group)) (= :bool (:type group))
(gsh/update-bool-selrect group children objects) (gsh/update-bool-selrect group children objects)
(:masked-group? group) (:masked-group group)
(set-mask-selrect group children) (set-mask-selrect group children)
:else :else
@ -478,7 +478,7 @@
(#{:group :frame} (:type parent)) (#{:group :frame} (:type parent))
(not ignore-touched)) (not ignore-touched))
(-> (update :touched cph/set-touched-group :shapes-group) (-> (update :touched cph/set-touched-group :shapes-group)
(dissoc :remote-synced?))))) (dissoc :remote-synced)))))
(remove-from-old-parent [old-objects objects shape-id] (remove-from-old-parent [old-objects objects shape-id]
(let [prev-parent-id (dm/get-in old-objects [shape-id :parent-id])] (let [prev-parent-id (dm/get-in old-objects [shape-id :parent-id])]
@ -497,7 +497,7 @@
(d/update-in-when [pid :shapes] d/vec-without-nils) (d/update-in-when [pid :shapes] d/vec-without-nils)
(cond-> component? (d/update-when pid #(-> % (cond-> component? (d/update-when pid #(-> %
(update :touched cph/set-touched-group :shapes-group) (update :touched cph/set-touched-group :shapes-group)
(dissoc :remote-synced?))))))))) (dissoc :remote-synced)))))))))
(update-parent-id [objects id] (update-parent-id [objects id]
(-> objects (-> objects
(d/update-when id assoc :parent-id parent-id))) (d/update-when id assoc :parent-id parent-id)))
@ -679,7 +679,7 @@
(and in-copy? group (not ignore) (not equal?) (and in-copy? group (not ignore) (not equal?)
(not (and ignore-geometry is-geometry?))) (not (and ignore-geometry is-geometry?)))
(-> (update :touched cph/set-touched-group group) (-> (update :touched cph/set-touched-group group)
(dissoc :remote-synced?)) (dissoc :remote-synced))
(nil? val) (nil? val)
(dissoc attr) (dissoc attr)
@ -697,11 +697,11 @@
(defmethod process-operation :set-remote-synced (defmethod process-operation :set-remote-synced
[_ shape op] [_ shape op]
(let [remote-synced? (:remote-synced? op) (let [remote-synced (:remote-synced op)
in-copy? (ctk/in-component-copy? shape)] in-copy? (ctk/in-component-copy? shape)]
(if (or (not in-copy?) (not remote-synced?)) (if (or (not in-copy?) (not remote-synced))
(dissoc shape :remote-synced?) (dissoc shape :remote-synced)
(assoc shape :remote-synced? true)))) (assoc shape :remote-synced true))))
(defmethod process-operation :default (defmethod process-operation :default
[_ _ op] [_ _ op]
@ -732,7 +732,7 @@
(get ctk/sync-attrs (:attr operation)))) (get ctk/sync-attrs (:attr operation))))
any-sync? (some need-sync? operations)] any-sync? (some need-sync? operations)]
(when any-sync? (when any-sync?
(let [xform (comp (filter :main-instance?) ; Select shapes that are main component instances (let [xform (comp (filter :main-instance) ; Select shapes that are main component instances
(map :component-id))] (map :component-id))]
(into #{} xform shape-and-parents)))))) (into #{} xform shape-and-parents))))))
@ -740,8 +740,7 @@
[file-data {:keys [page-id _component-id parent-id shapes] :as change}] [file-data {:keys [page-id _component-id parent-id shapes] :as change}]
(when page-id (when page-id
(let [page (ctpl/get-page file-data page-id) (let [page (ctpl/get-page file-data page-id)
xform (comp (filter :main-instance)
xform (comp (filter :main-instance?)
(map :component-id)) (map :component-id))
check-shape check-shape
@ -760,7 +759,7 @@
(let [page (ctpl/get-page file-data page-id) (let [page (ctpl/get-page file-data page-id)
shape-and-parents (map (partial ctn/get-shape page) shape-and-parents (map (partial ctn/get-shape page)
(cons id (cph/get-parent-ids (:objects page) id))) (cons id (cph/get-parent-ids (:objects page) id)))
xform (comp (filter :main-instance?) xform (comp (filter :main-instance)
(map :component-id))] (map :component-id))]
(into #{} xform shape-and-parents)))) (into #{} xform shape-and-parents))))

View file

@ -495,7 +495,7 @@
(gsh/update-bool-selrect parent children objects) (gsh/update-bool-selrect parent children objects)
(= (:type parent) :group) (= (:type parent) :group)
(if (:masked-group? parent) (if (:masked-group parent)
(gsh/update-mask-selrect parent children) (gsh/update-mask-selrect parent children)
(gsh/update-group-selrect parent children)))] (gsh/update-group-selrect parent children)))]
(if resized-parent (if resized-parent
@ -628,11 +628,11 @@
:attr :component-file :attr :component-file
:val (:component-file shape)} :val (:component-file shape)}
{:type :set {:type :set
:attr :component-root? :attr :component-root
:val (:component-root? shape)} :val (:component-root shape)}
{:type :set {:type :set
:attr :main-instance? :attr :main-instance
:val (:main-instance? shape)} :val (:main-instance shape)}
{:type :set {:type :set
:attr :shape-ref :attr :shape-ref
:val (:shape-ref shape)} :val (:shape-ref shape)}

View file

@ -49,7 +49,7 @@
(defn mask-shape? (defn mask-shape?
([shape] ([shape]
(and ^boolean (group-shape? shape) (and ^boolean (group-shape? shape)
^boolean (:masked-group? shape))) ^boolean (:masked-group shape)))
([objects id] ([objects id]
(mask-shape? (get objects id)))) (mask-shape? (get objects id))))

View file

@ -35,7 +35,7 @@
(not= uuid/zero (:id shape))) (not= uuid/zero (:id shape)))
(conj shape) (conj shape)
(:masked-group? shape) (:masked-group shape)
(conj (get objects (->> shape :shapes first))) (conj (get objects (->> shape :shapes first)))
(= :bool (:type shape)) (= :bool (:type shape))

View file

@ -28,6 +28,13 @@
:line-height :text-display-group :line-height :text-display-group
:text-align :text-display-group :text-align :text-display-group
:strokes :stroke-group :strokes :stroke-group
;; DEPRECATED: FIXME: this attrs are deprecated for a long time but
;; we still have tests that uses this attribute for synchronization
:stroke-width :stroke-group
:fill-color :fill-group
:fill-opacity :fill-group
:rx :radius-group :rx :radius-group
:ry :radius-group :ry :radius-group
:r1 :radius-group :r1 :radius-group
@ -51,7 +58,7 @@
:blend-mode :layer-effects-group :blend-mode :layer-effects-group
:shadow :shadow-group :shadow :shadow-group
:blur :blur-group :blur :blur-group
:masked-group? :mask-group :masked-group :mask-group
:constraints-h :constraints-group :constraints-h :constraints-group
:constraints-v :constraints-group :constraints-v :constraints-group
:fixed-scroll :constraints-group :fixed-scroll :constraints-group
@ -89,7 +96,7 @@
(defn instance-root? (defn instance-root?
"Check if this shape is the head of a top instance." "Check if this shape is the head of a top instance."
[shape] [shape]
(some? (:component-root? shape))) (some? (:component-root shape)))
(defn instance-head? (defn instance-head?
"Check if this shape is the head of a top instance or a subinstance." "Check if this shape is the head of a top instance or a subinstance."
@ -116,9 +123,10 @@
(= (:shape-ref shape-inst) (:shape-ref shape-main))))) (= (:shape-ref shape-inst) (:shape-ref shape-main)))))
(defn main-instance? (defn main-instance?
"Check if this shape is the root of the main instance of some component." "Check if this shape is the root of the main instance of some
component."
[shape] [shape]
(some? (:main-instance? shape))) (some? (:main-instance shape)))
(defn in-component-copy? (defn in-component-copy?
"Check if the shape is inside a component non-main instance." "Check if the shape is inside a component non-main instance."
@ -156,7 +164,7 @@
(dissoc shape (dissoc shape
:component-id :component-id
:component-file :component-file
:component-root? :component-root
:remote-synced? :remote-synced
:shape-ref :shape-ref
:touched)) :touched))

View file

@ -120,7 +120,7 @@
a main component have not any discriminating attribute." a main component have not any discriminating attribute."
[objects shape] [objects shape]
(let [component-shape (get-component-shape objects shape {:allow-main? true})] (let [component-shape (get-component-shape objects shape {:allow-main? true})]
(:main-instance? component-shape))) (:main-instance component-shape)))
(defn in-any-component? (defn in-any-component?
"Check if the shape is part of any component (main or copy), wether it's "Check if the shape is part of any component (main or copy), wether it's
@ -147,7 +147,7 @@
(cond-> new-shape (cond-> new-shape
true true
(dissoc :component-root?) (dissoc :component-root)
(nil? (:parent-id new-shape)) (nil? (:parent-id new-shape))
(dissoc :component-id (dissoc :component-id
@ -166,13 +166,13 @@
(nil? (:parent-id new-shape)) (nil? (:parent-id new-shape))
(assoc :component-id (:id new-shape) (assoc :component-id (:id new-shape)
:component-file file-id :component-file file-id
:component-root? true) :component-root true)
(and (nil? (:parent-id new-shape)) components-v2) (and (nil? (:parent-id new-shape)) components-v2)
(assoc :main-instance? true) (assoc :main-instance true)
(some? (:parent-id new-shape)) (some? (:parent-id new-shape))
(dissoc :component-root?))) (dissoc :component-root)))
[new-root-shape new-shapes updated-shapes] [new-root-shape new-shapes updated-shapes]
(ctst/clone-object shape nil objects update-new-shape update-original-shape) (ctst/clone-object shape nil objects update-new-shape update-original-shape)
@ -235,10 +235,10 @@
(dissoc :touched)) (dissoc :touched))
main-instance? main-instance?
(assoc :main-instance? true) (assoc :main-instance true)
(not main-instance?) (not main-instance?)
(dissoc :main-instance?) (dissoc :main-instance)
(and (not main-instance?) (nil? (:shape-ref original-shape))) (and (not main-instance?) (nil? (:shape-ref original-shape)))
(assoc :shape-ref (:id original-shape)) (assoc :shape-ref (:id original-shape))
@ -246,14 +246,14 @@
(nil? (:parent-id original-shape)) (nil? (:parent-id original-shape))
(assoc :component-id (:id component) (assoc :component-id (:id component)
:component-file (:id library-data) :component-file (:id library-data)
:component-root? true :component-root true
:name new-name) :name new-name)
(and (nil? (:parent-id original-shape)) main-instance? components-v2) (and (nil? (:parent-id original-shape)) main-instance? components-v2)
(assoc :main-instance? true) (assoc :main-instance true)
(some? (:parent-id original-shape)) (some? (:parent-id original-shape))
(dissoc :component-root?)))) (dissoc :component-root))))
[new-shape new-shapes _] [new-shape new-shapes _]
(ctst/clone-object component-shape (ctst/clone-object component-shape

View file

@ -346,7 +346,7 @@
file-data file-data
position position
false false
{:main-instance? true {:main-instance true
:force-frame-id uuid/zero :force-frame-id uuid/zero
:keep-ids? true}) :keep-ids? true})
add-shapes add-shapes
@ -429,7 +429,7 @@
library-data library-data
position position
(dm/get-in file-data [:options :components-v2]) (dm/get-in file-data [:options :components-v2])
{:main-instance? true}) {:main-instance true})
main-instance-shapes main-instance-shapes
(map #(cond-> % (map #(cond-> %
@ -589,9 +589,9 @@
(letfn [(show-shape [shape-id level objects] (letfn [(show-shape [shape-id level objects]
(let [shape (get objects shape-id)] (let [shape (get objects shape-id)]
(println (str/pad (str (str/repeat " " level) (println (str/pad (str (str/repeat " " level)
(when (:main-instance? shape) "{") (when (:main-instance shape) "{")
(:name shape) (:name shape)
(when (:main-instance? shape) "}") (when (:main-instance shape) "}")
(when (seq (:touched shape)) "*") (when (seq (:touched shape)) "*")
(when show-ids (str/format " <%s>" (:id shape)))) (when show-ids (str/format " <%s>" (:id shape))))
{:length 20 {:length 20
@ -602,7 +602,7 @@
(println (str (str/repeat " " level) (println (str (str/repeat " " level)
" " " "
(str (:touched shape))))) (str (:touched shape)))))
(when (:remote-synced? shape) (when (:remote-synced shape)
(println (str (str/repeat " " level) (println (str (str/repeat " " level)
" (remote-synced)")))) " (remote-synced)"))))
(when (:shapes shape) (when (:shapes shape)
@ -611,7 +611,7 @@
(show-component-info [shape objects] (show-component-info [shape objects]
(if (nil? (:shape-ref shape)) (if (nil? (:shape-ref shape))
(if (:component-root? shape) " #" "") (if (:component-root shape) " #" "")
(let [root-shape (ctn/get-component-shape objects shape) (let [root-shape (ctn/get-component-shape objects shape)
component-id (when root-shape (:component-id root-shape)) component-id (when root-shape (:component-id root-shape))
component-file-id (when root-shape (:component-file root-shape)) component-file-id (when root-shape (:component-file root-shape))
@ -626,7 +626,7 @@
(get-ref-shape file-data component shape)))] (get-ref-shape file-data component shape)))]
(str/format " %s--> %s%s%s" (str/format " %s--> %s%s%s"
(cond (:component-root? shape) "#" (cond (:component-root shape) "#"
(:component-id shape) "@" (:component-id shape) "@"
:else "-") :else "-")
@ -634,7 +634,7 @@
(or (:name component-shape) "?") (or (:name component-shape) "?")
(if (or (:component-root? shape) (if (or (:component-root shape)
(nil? (:component-id shape)) (nil? (:component-id shape))
true) true)
"" ""

View file

@ -146,6 +146,8 @@
[:component-id {:optional true} ::sm/uuid] [:component-id {:optional true} ::sm/uuid]
[:component-file {:optional true} ::sm/uuid] [:component-file {:optional true} ::sm/uuid]
[:component-root {:optional true} :boolean] [:component-root {:optional true} :boolean]
[:main-instance {:optional true} :boolean]
[:remote-synced {:optional true} :boolean]
[:shape-ref {:optional true} ::sm/uuid] [:shape-ref {:optional true} ::sm/uuid]
[:selrect {:optional true} ::selrect] [:selrect {:optional true} ::selrect]
[:points {:optional true} ::points] [:points {:optional true} ::points]
@ -153,7 +155,7 @@
[:collapsed {:optional true} :boolean] [:collapsed {:optional true} :boolean]
[:locked {:optional true} :boolean] [:locked {:optional true} :boolean]
[:hidden {:optional true} :boolean] [:hidden {:optional true} :boolean]
[:masked-group? {:optional true} :boolean] [:masked-group {:optional true} :boolean]
[:fills {:optional true} [:fills {:optional true}
[:vector {:gen/max 2} ::fill]] [:vector {:gen/max 2} ::fill]]
[:hide-fill-on-export {:optional true} :boolean] [:hide-fill-on-export {:optional true} :boolean]
@ -457,7 +459,6 @@
(defn- setup-image (defn- setup-image
[{:keys [metadata] :as shape}] [{:keys [metadata] :as shape}]
(-> shape (-> shape
(assoc :metadata metadata)
(assoc :proportion (/ (:width metadata) (assoc :proportion (/ (:width metadata)
(:height metadata))) (:height metadata)))
(assoc :proportion-lock true))) (assoc :proportion-lock true)))

View file

@ -41,7 +41,7 @@
(update :shapes d/vec-without-nils) (update :shapes d/vec-without-nils)
(cond-> (and (ctk/in-component-copy? parent) (not ignore-touched)) (cond-> (and (ctk/in-component-copy? parent) (not ignore-touched))
(-> (update :touched cph/set-touched-group :shapes-group) (-> (update :touched cph/set-touched-group :shapes-group)
(dissoc :remote-synced?))))) (dissoc :remote-synced)))))
update-objects update-objects
(fn [objects parent-id] (fn [objects parent-id]
@ -86,7 +86,7 @@
(cond-> parent (cond-> parent
(and (:shape-ref parent) (not ignore-touched)) (and (:shape-ref parent) (not ignore-touched))
(-> (update :touched cph/set-touched-group :shapes-group) (-> (update :touched cph/set-touched-group :shapes-group)
(dissoc :remote-synced?))))) (dissoc :remote-synced)))))
(delete-from-objects [objects] (delete-from-objects [objects]
(if-let [target (get objects shape-id)] (if-let [target (get objects shape-id)]

View file

@ -12,18 +12,18 @@
"defaults" "defaults"
], ],
"scripts": { "scripts": {
"compile-test": "clojure -M:dev:shadow-cljs compile test --config-merge '{:autorun false}'", "test:compile": "clojure -M:dev:shadow-cljs compile test --config-merge '{:autorun false}'",
"lint": "clj-kondo --parallel --lint src/", "lint:clj": "clj-kondo --parallel --lint src/",
"lint-scss": "yarn run prettier -c resources/styles -c src/**/*.scss", "lint:scss": "yarn run prettier -c resources/styles -c src/**/*.scss",
"run-test": "node target/tests.js", "test:run": "node target/tests.js",
"test": "yarn run compile-test && yarn run run-test", "test:watch": "clojure -M:dev:shadow-cljs watch test",
"watch-gulp": "gulp watch", "test": "yarn run test:compile && yarn run test:run",
"watch-main": "shadow-cljs watch main", "gulp:watch": "gulp watch",
"watch-test": "clojure -M:dev:shadow-cljs watch test", "watch": "shadow-cljs watch main",
"validate-translations": "node ./scripts/validate-translations.js", "validate-translations": "node ./scripts/validate-translations.js",
"find-unused-translations": "node ./scripts/find-unused-translations.js", "find-unused-translations": "node ./scripts/find-unused-translations.js",
"test-e2e": "cypress run", "test:e2e": "cypress run",
"test-e2e-gui": "cypress open" "test:e2e-gui": "cypress open"
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^10.4.13", "autoprefixer": "^10.4.13",

View file

@ -492,7 +492,7 @@
(let [components-to-delete (->> page (let [components-to-delete (->> page
:objects :objects
vals vals
(filter #(true? (:main-instance? %))) (filter #(true? (:main-instance %)))
(map :component-id)) (map :component-id))
changes (reduce (fn [changes component-id] changes (reduce (fn [changes component-id]
@ -632,7 +632,7 @@
(rx/of (update-shape shape-id {:name name}))) (rx/of (update-shape shape-id {:name name})))
;; Update the component in case if shape is a main instance ;; Update the component in case if shape is a main instance
(when (:main-instance? shape) (when (:main-instance shape)
(when-let [component-id (:component-id shape)] (when-let [component-id (:component-id shape)]
(rx/of (dwl/rename-component component-id name))))))))))) (rx/of (dwl/rename-component component-id name)))))))))))
@ -743,7 +743,7 @@
;; Unmask groups whose mask have moved outside ;; Unmask groups whose mask have moved outside
(pcb/update-shapes groups-to-unmask (pcb/update-shapes groups-to-unmask
(fn [shape] (fn [shape]
(assoc shape :masked-group? false))) (assoc shape :masked-group false)))
;; Detach shapes moved out of their component ;; Detach shapes moved out of their component
(pcb/update-shapes shapes-to-detach ctk/detach-shape) (pcb/update-shapes shapes-to-detach ctk/detach-shape)
@ -751,12 +751,12 @@
;; Make non root a component moved inside another one ;; Make non root a component moved inside another one
(pcb/update-shapes shapes-to-deroot (pcb/update-shapes shapes-to-deroot
(fn [shape] (fn [shape]
(assoc shape :component-root? nil))) (assoc shape :component-root nil)))
;; Make root a subcomponent moved outside its parent component ;; Make root a subcomponent moved outside its parent component
(pcb/update-shapes shapes-to-reroot (pcb/update-shapes shapes-to-reroot
(fn [shape] (fn [shape]
(assoc shape :component-root? true))) (assoc shape :component-root true)))
;; Reset constraints depending on the new parent ;; Reset constraints depending on the new parent
(pcb/update-shapes shapes-to-unconstraint (pcb/update-shapes shapes-to-unconstraint
@ -856,7 +856,7 @@
;; removed, and it must be converted to a normal group. ;; removed, and it must be converted to a normal group.
(let [obj (get objects id) (let [obj (get objects id)
parent (get objects (:parent-id obj))] parent (get objects (:parent-id obj))]
(if (and (:masked-group? parent) (if (and (:masked-group parent)
(= id (first (:shapes parent))) (= id (first (:shapes parent)))
(not= (:id parent) parent-id)) (not= (:id parent) parent-id))
(conj group-ids (:id parent)) (conj group-ids (:id parent))
@ -1801,10 +1801,9 @@
(-> shape (-> shape
(assoc :frame-id frame-id :parent-id parent-id) (assoc :frame-id frame-id :parent-id parent-id)
(cond-> detach? (cond-> detach?
(->
;; this is used later, if the paste needs to create a new component from the detached shape ;; this is used later, if the paste needs to create a new component from the detached shape
(assoc :saved-component-root? (:component-root? shape)) (-> (assoc :saved-component-root (:component-root shape))
ctk/detach-shape)) (ctk/detach-shape)))
;; if is a text, remove references to external typographies ;; if is a text, remove references to external typographies
(cond-> (= (:type shape) :text) (cond-> (= (:type shape) :text)
(ctt/remove-external-typographies file-id))))) (ctt/remove-external-typographies file-id)))))

View file

@ -292,7 +292,7 @@
(pcb/update-shapes [(:id group)] (pcb/update-shapes [(:id group)]
(fn [group] (fn [group]
(assoc group (assoc group
:masked-group? true :masked-group true
:selrect (:selrect first-shape) :selrect (:selrect first-shape)
:points (:points first-shape) :points (:points first-shape)
:transform (:transform first-shape) :transform (:transform first-shape)
@ -321,7 +321,7 @@
(-> changes (-> changes
(pcb/update-shapes [(:id mask)] (pcb/update-shapes [(:id mask)]
(fn [shape] (fn [shape]
(dissoc shape :masked-group?))) (dissoc shape :masked-group)))
(pcb/resize-parents [(:id mask)]))) (pcb/resize-parents [(:id mask)])))
(-> (pcb/empty-changes it page-id) (-> (pcb/empty-changes it page-id)
(pcb/with-objects objects)) (pcb/with-objects objects))

View file

@ -74,8 +74,8 @@
[(assoc root [(assoc root
:component-id new-id :component-id new-id
:component-file file-id :component-file file-id
:component-root? true :component-root true
:main-instance? true)]])) :main-instance true)]]))
changes (-> changes changes (-> changes
(pcb/add-component (:id root-shape) (pcb/add-component (:id root-shape)
@ -135,7 +135,7 @@
position (gpt/point (:x main-instance-shape) (:y main-instance-shape)) position (gpt/point (:x main-instance-shape) (:y main-instance-shape))
component-instance-extra-data (if components-v2 {:main-instance? true} {}) component-instance-extra-data (if components-v2 {:main-instance true} {})
[new-instance-shape new-instance-shapes] [new-instance-shape new-instance-shapes]
(when (and (some? main-instance-page) (some? main-instance-shape)) (when (and (some? main-instance-page) (some? main-instance-shape))
@ -204,7 +204,7 @@
(let [shape (ctn/get-shape container shape-id)] (let [shape (ctn/get-shape container shape-id)]
(if (and (ctk/instance-head? shape) (not first)) (if (and (ctk/instance-head? shape) (not first))
;; Subinstances are not detached, but converted in top instances ;; Subinstances are not detached, but converted in top instances
(pcb/update-shapes changes [(:id shape)] #(assoc % :component-root? true)) (pcb/update-shapes changes [(:id shape)] #(assoc % :component-root true))
;; Otherwise, detach the shape and all children ;; Otherwise, detach the shape and all children
(let [children-ids (:shapes shape)] (let [children-ids (:shapes shape)]
(reduce #(generate-detach-recursive %1 container %2 false) (reduce #(generate-detach-recursive %1 container %2 false)
@ -499,7 +499,7 @@
;; * IF THE INITIAL SHAPE IS THE SUBINSTANCE, the sync is done against ;; * IF THE INITIAL SHAPE IS THE SUBINSTANCE, the sync is done against
;; the remote component. Therefore, IShape-2-2-1 is synched with ;; the remote component. Therefore, IShape-2-2-1 is synched with
;; Shape-1-1. Then the "touched" flags are reset, and the ;; Shape-1-1. Then the "touched" flags are reset, and the
;; "remote-synced?" flag is set (it will be set until the shape is ;; "remote-synced" flag is set (it will be set until the shape is
;; touched again or it's synced forced normal or inverse with the ;; touched again or it's synced forced normal or inverse with the
;; near component). ;; near component).
;; ;;
@ -509,19 +509,19 @@
;; cleared. Then, the "touched" flags THAT ARE TRUE are copied to ;; cleared. Then, the "touched" flags THAT ARE TRUE are copied to
;; Shape-2-2-1. This may cause that Shape-2-2-1 is now touched respect ;; Shape-2-2-1. This may cause that Shape-2-2-1 is now touched respect
;; to Shape-1-1, and so, some attributes are not copied in a subsequent ;; to Shape-1-1, and so, some attributes are not copied in a subsequent
;; normal sync. Or, if "remote-synced?" flag is set in IShape-2-2-1, ;; normal sync. Or, if "remote-synced" flag is set in IShape-2-2-1,
;; all touched flags are cleared in Shape-2-2-1 and "remote-synced?" ;; all touched flags are cleared in Shape-2-2-1 and "remote-synced"
;; is removed. ;; is removed.
;; ;;
;; * IN AN INVERSE SYNC INITIATED IN THE SUBINSTANCE, the update is done ;; * IN AN INVERSE SYNC INITIATED IN THE SUBINSTANCE, the update is done
;; to the remote component. E.g. IShape-2-2-1 attributes are copied into ;; to the remote component. E.g. IShape-2-2-1 attributes are copied into
;; Shape-1-1, and then touched cleared and "remote-synced?" flag set. ;; Shape-1-1, and then touched cleared and "remote-synced" flag set.
;; ;;
;; #### WARNING: there are two conditions that are invisible to user: ;; #### WARNING: there are two conditions that are invisible to user:
;; - When the near shape (Shape-2-2-1) is touched respect the remote ;; - When the near shape (Shape-2-2-1) is touched respect the remote
;; one (Shape-1-1), there is no asterisk displayed anywhere. ;; one (Shape-1-1), there is no asterisk displayed anywhere.
;; - When the instance shape (IShape-2-2-1) is synced with the remote ;; - When the instance shape (IShape-2-2-1) is synced with the remote
;; shape (remote-synced? = true), the user will see that this shape ;; shape (remote-synced = true), the user will see that this shape
;; is different than the one in the near component (Shape-2-2-1) ;; is different than the one in the near component (Shape-2-2-1)
;; but it's not touched. ;; but it's not touched.
@ -540,7 +540,7 @@
shape-main (when component shape-main (when component
(ctf/get-ref-shape library component shape-inst)) (ctf/get-ref-shape library component shape-inst))
initial-root? (:component-root? shape-inst) initial-root? (:component-root shape-inst)
root-inst shape-inst root-inst shape-inst
root-main (when component root-main (when component
@ -673,7 +673,7 @@
component (ctkl/get-component library (:component-id shape-inst)) component (ctkl/get-component library (:component-id shape-inst))
shape-main (ctf/get-ref-shape library component shape-inst) shape-main (ctf/get-ref-shape library component shape-inst)
initial-root? (:component-root? shape-inst) initial-root? (:component-root shape-inst)
root-inst shape-inst root-inst shape-inst
root-main (ctf/get-component-root library component)] root-main (ctf/get-component-root library component)]
@ -867,7 +867,7 @@
(assoc :shape-ref (:id original-shape)) (assoc :shape-ref (:id original-shape))
set-remote-synced? set-remote-synced?
(assoc :remote-synced? true)))) (assoc :remote-synced true))))
update-original-shape (fn [original-shape _new-shape] update-original-shape (fn [original-shape _new-shape]
original-shape) original-shape)
@ -967,8 +967,8 @@
:attr :component-file :attr :component-file
:val (:component-file shape')} :val (:component-file shape')}
{:type :set {:type :set
:attr :component-root? :attr :component-root
:val (:component-root? shape')} :val (:component-root shape')}
{:type :set {:type :set
:attr :shape-ref :attr :shape-ref
:val (:shape-ref shape')} :val (:shape-ref shape')}
@ -1087,7 +1087,7 @@
reset-touched? reset-touched?
nil nil
copy-touched? copy-touched?
(if (:remote-synced? origin-shape) (if (:remote-synced origin-shape)
nil nil
(set/union (set/union
(:touched dest-shape) (:touched dest-shape)
@ -1117,7 +1117,7 @@
(log/info :msg (str "CHANGE-REMOTE-SYNCED? " (log/info :msg (str "CHANGE-REMOTE-SYNCED? "
(if (cph/page? container) "[P] " "[C] ") (if (cph/page? container) "[P] " "[C] ")
(:name shape)) (:name shape))
:remote-synced? remote-synced?) :remote-synced remote-synced?)
(-> changes (-> changes
(update :redo-changes conj (make-change (update :redo-changes conj (make-change
container container
@ -1125,14 +1125,14 @@
:id (:id shape) :id (:id shape)
:operations :operations
[{:type :set-remote-synced [{:type :set-remote-synced
:remote-synced? remote-synced?}]})) :remote-synced remote-synced?}]}))
(update :undo-changes d/preconj (make-change (update :undo-changes d/preconj (make-change
container container
{:type :mod-obj {:type :mod-obj
:id (:id shape) :id (:id shape)
:operations :operations
[{:type :set-remote-synced [{:type :set-remote-synced
:remote-synced? (:remote-synced? shape)}]})))))) :remote-synced (:remote-synced shape)}]}))))))
(defn- update-attrs (defn- update-attrs
"The main function that implements the attribute sync algorithm. Copy "The main function that implements the attribute sync algorithm. Copy

View file

@ -50,7 +50,7 @@
[shape root transformed-shape transformed-root objects modif-tree] [shape root transformed-shape transformed-root objects modif-tree]
(let [root (let [root
(cond (cond
(:component-root? shape) (:component-root shape)
shape shape
(nil? root) (nil? root)
@ -60,7 +60,7 @@
transformed-root transformed-root
(cond (cond
(:component-root? transformed-shape) (:component-root transformed-shape)
transformed-shape transformed-shape
(nil? transformed-root) (nil? transformed-root)

View file

@ -422,8 +422,8 @@
parent-id (or parent-id frame-id) parent-id (or parent-id frame-id)
name (:name obj) name (:name obj)
is-component-root? (:saved-component-root? obj) is-component-root? (:saved-component-root obj)
is-component-main? (:main-instance? obj) is-component-main? (:main-instance obj)
regenerate-component regenerate-component
(fn [changes shape] (fn [changes shape]
(let [components-v2 (dm/get-in library-data [:options :components-v2]) (let [components-v2 (dm/get-in library-data [:options :components-v2])
@ -436,9 +436,9 @@
:parent-id parent-id :parent-id parent-id
:frame-id frame-id) :frame-id frame-id)
(dissoc :shapes (dissoc :shapes
:main-instance? :main-instance
:shape-ref :shape-ref
:use-for-thumbnail?) :use-for-thumbnail)
(gsh/move delta) (gsh/move delta)
(d/update-when :interactions #(ctsi/remap-interactions % ids-map objects)) (d/update-when :interactions #(ctsi/remap-interactions % ids-map objects))

View file

@ -197,7 +197,7 @@
;; converted to a normal group. ;; converted to a normal group.
(let [obj (lookup id) (let [obj (lookup id)
parent (lookup (:parent-id obj))] parent (lookup (:parent-id obj))]
(if (and (:masked-group? parent) (if (and (:masked-group parent)
(= id (first (:shapes parent)))) (= id (first (:shapes parent))))
(conj group-ids (:id parent)) (conj group-ids (:id parent))
group-ids))) group-ids)))
@ -265,7 +265,7 @@
(reduce (fn [components id] (reduce (fn [components id]
(let [shape (get objects id)] (let [shape (get objects id)]
(if (and (= (:component-file shape) (:id file)) ;; Main instances should exist only in local file (if (and (= (:component-file shape) (:id file)) ;; Main instances should exist only in local file
(:main-instance? shape)) ;; but check anyway (:main-instance shape)) ;; but check anyway
(conj components (:component-id shape)) (conj components (:component-id shape))
components))) components)))
[] []
@ -289,7 +289,7 @@
(pcb/resize-parents all-parents) (pcb/resize-parents all-parents)
(pcb/update-shapes groups-to-unmask (pcb/update-shapes groups-to-unmask
(fn [shape] (fn [shape]
(assoc shape :masked-group? false))) (assoc shape :masked-group false)))
(pcb/update-shapes (map :id interacting-shapes) (pcb/update-shapes (map :id interacting-shapes)
(fn [shape] (fn [shape]
(d/update-when shape :interactions (d/update-when shape :interactions
@ -310,7 +310,6 @@
(let [[changes _all-parents] (real-delete-shapes-changes changes file page objects ids it components-v2)] (let [[changes _all-parents] (real-delete-shapes-changes changes file page objects ids it components-v2)]
changes)) changes))
(defn- real-delete-shapes (defn- real-delete-shapes
[file page objects ids it components-v2] [file page objects ids it components-v2]
(let [[changes all-parents] (real-delete-shapes-changes file page objects ids it components-v2) (let [[changes all-parents] (real-delete-shapes-changes file page objects ids it components-v2)

View file

@ -37,7 +37,7 @@
:path i/curve :path i/curve
:rect i/box :rect i/box
:text i/text :text i/text
:group (if (:masked-group? shape) :group (if (:masked-group shape)
i/mask i/mask
i/folder) i/folder)
:bool (case (:bool-type shape) :bool (case (:bool-type shape)

View file

@ -37,7 +37,7 @@
:path i/path-refactor :path i/path-refactor
:rect i/rectangle-refactor :rect i/rectangle-refactor
:text i/text-refactor :text i/text-refactor
:group (if (:masked-group? shape) :group (if (:masked-group shape)
i/mask-refactor i/mask-refactor
i/group-refactor) i/group-refactor)
:bool (case (:bool-type shape) :bool (case (:bool-type shape)

View file

@ -70,7 +70,7 @@
image? (= :image (:type shape)) image? (= :image (:type shape))
text? (= :text (:type shape)) text? (= :text (:type shape))
path? (= :path (:type shape)) path? (= :path (:type shape))
mask? (and group? (:masked-group? shape)) mask? (and group? (:masked-group shape))
bool? (= :bool (:type shape)) bool? (= :bool (:type shape))
center (gsh/shape->center shape)] center (gsh/shape->center shape)]
(-> props (-> props
@ -137,8 +137,8 @@
(add! :typography-ref-file) (add! :typography-ref-file)
(add! :component-file) (add! :component-file)
(add! :component-id) (add! :component-id)
(add! :component-root?) (add! :component-root)
(add! :main-instance?) (add! :main-instance)
(add! :shape-ref)))) (add! :shape-ref))))
(defn prefix-keys [m] (defn prefix-keys [m]

View file

@ -22,7 +22,7 @@
childs (unchecked-get props "childs") childs (unchecked-get props "childs")
objects (unchecked-get props "objects") objects (unchecked-get props "objects")
render-id (mf/use-ctx muc/render-id) render-id (mf/use-ctx muc/render-id)
masked-group? (:masked-group? shape) masked-group? (:masked-group shape)
[mask childs] (if masked-group? [mask childs] (if masked-group?
[(first childs) (rest childs)] [(first childs) (rest childs)]

View file

@ -64,7 +64,7 @@
[:li {:ref item-ref [:li {:ref item-ref
:class (dom/classnames :class (dom/classnames
:component (not (nil? (:component-id item))) :component (not (nil? (:component-id item)))
:masked (:masked-group? item) :masked (:masked-group item)
:selected selected?)} :selected selected?)}
[:div.element-list-body {:class (dom/classnames :selected selected? [:div.element-list-body {:class (dom/classnames :selected selected?

View file

@ -255,7 +255,7 @@
has-frame? (->> shapes (d/seek cph/frame-shape?)) has-frame? (->> shapes (d/seek cph/frame-shape?))
has-group? (->> shapes (d/seek cph/group-shape?)) has-group? (->> shapes (d/seek cph/group-shape?))
has-bool? (->> shapes (d/seek cph/bool-shape?)) has-bool? (->> shapes (d/seek cph/bool-shape?))
has-mask? (->> shapes (d/seek :masked-group?)) has-mask? (->> shapes (d/seek :masked-group))
is-group? (and single? has-group?) is-group? (and single? has-group?)
is-bool? (and single? has-bool?) is-bool? (and single? has-bool?)

View file

@ -51,7 +51,7 @@
workspace-read-only? (mf/use-ctx ctx/workspace-read-only?) workspace-read-only? (mf/use-ctx ctx/workspace-read-only?)
new-css-system (mf/use-ctx ctx/new-css-system) new-css-system (mf/use-ctx ctx/new-css-system)
main-instance? (if components-v2 main-instance? (if components-v2
(:main-instance? item) (:main-instance item)
true) true)
parent-board? (and (= :frame (:type item)) parent-board? (and (= :frame (:type item))
(= uuid/zero (:parent-id item))) (= uuid/zero (:parent-id item)))
@ -165,7 +165,7 @@
ref (mf/use-ref) ref (mf/use-ref)
depth (+ recieved-depth 1) depth (+ recieved-depth 1)
component-tree? (or component-child? (:component-root? item))] component-tree? (or component-child? (:component-root item))]
(mf/with-effect [selected? selected] (mf/with-effect [selected? selected]
(let [single? (= (count selected) 1) (let [single? (= (count selected) 1)
@ -195,7 +195,7 @@
:class (dom/classnames :class (dom/classnames
(css :layer-row) true (css :layer-row) true
(css :component) (not (nil? (:component-id item))) (css :component) (not (nil? (:component-id item)))
(css :masked) (:masked-group? item) (css :masked) (:masked-group item)
(css :selected) selected? (css :selected) selected?
(css :type-frame) (= :frame (:type item)) (css :type-frame) (= :frame (:type item))
(css :type-bool) (= :bool (:type item)) (css :type-bool) (= :bool (:type item))
@ -289,7 +289,7 @@
:ref dref :ref dref
:class (dom/classnames :class (dom/classnames
:component (not (nil? (:component-id item))) :component (not (nil? (:component-id item)))
:masked (:masked-group? item) :masked (:masked-group item)
:dnd-over (= (:over dprops) :center) :dnd-over (= (:over dprops) :center)
:dnd-over-top (= (:over dprops) :top) :dnd-over-top (= (:over dprops) :top)
:dnd-over-bot (= (:over dprops) :bot) :dnd-over-bot (= (:over dprops) :bot)

View file

@ -202,10 +202,10 @@
(some #{:group} filters) (some #{:group} filters)
(and (= :group (:type shape)) (and (= :group (:type shape))
(not (contains? shape :component-id)) (not (contains? shape :component-id))
(or (not (contains? shape :masked-group?)) (false? (:masked-group? shape))))) (or (not (contains? shape :masked-group)) (false? (:masked-group shape)))))
(and (and
(some #{:mask} filters) (some #{:mask} filters)
(true? (:masked-group? shape)))))))) (true? (:masked-group shape))))))))
filtered-objects-total filtered-objects-total
(mf/use-memo (mf/use-memo

View file

@ -22,12 +22,12 @@
[cuerdas.core :as str] [cuerdas.core :as str]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(def component-attrs [:component-id :component-file :shape-ref :main-instance? :annotation]) (def component-attrs [:component-id :component-file :shape-ref :main-instance :annotation])
(mf/defc component-annotation (mf/defc component-annotation
[{:keys [id values shape component] :as props}] [{:keys [id values shape component] :as props}]
(let [main-instance? (:main-instance? values) (let [main-instance? (:main-instance values)
component-id (:component-id values) component-id (:component-id values)
annotation (:annotation component) annotation (:annotation component)
editing? (mf/use-state false) editing? (mf/use-state false)
@ -140,8 +140,6 @@
(when (or @editing? creating?) (when (or @editing? creating?)
[:div.counter (str @size "/300")])]]))) [:div.counter (str @size "/300")])]])))
(mf/defc component-menu (mf/defc component-menu
[{:keys [ids values shape] :as props}] [{:keys [ids values shape] :as props}]
(let [current-file-id (mf/use-ctx ctx/current-file-id) (let [current-file-id (mf/use-ctx ctx/current-file-id)
@ -160,9 +158,11 @@
library-id (:component-file values) library-id (:component-file values)
show? (some? component-id) show? (some? component-id)
main-instance? (if components-v2 main-instance? (if components-v2
(:main-instance? values) (:main-instance values)
true) true)
main-component? (:main-instance? values) main-component? (:main-instance values)
lacks-annotation? (nil? (:annotation values))
local-component? (= library-id current-file-id) local-component? (= library-id current-file-id)
workspace-data (deref refs/workspace-data) workspace-data (deref refs/workspace-data)
workspace-libraries (deref refs/workspace-libraries) workspace-libraries (deref refs/workspace-libraries)
@ -170,7 +170,6 @@
(ctkl/get-component workspace-data component-id) (ctkl/get-component workspace-data component-id)
(ctf/get-component workspace-libraries library-id component-id)) (ctf/get-component workspace-libraries library-id component-id))
is-dangling? (nil? component) is-dangling? (nil? component)
lacks-annotation? (nil? (:annotation component))
lib-exists? (and (not local-component?) lib-exists? (and (not local-component?)
(some? (get workspace-libraries library-id))) (some? (get workspace-libraries library-id)))

View file

@ -413,10 +413,10 @@
:component-file component-file) :component-file component-file)
component-root? component-root?
(assoc :component-root? component-root?) (assoc :component-root component-root?)
main-instance? main-instance?
(assoc :main-instance? main-instance?) (assoc :main-instance main-instance?)
(some? shape-ref) (some? shape-ref)
(assoc :shape-ref shape-ref)))) (assoc :shape-ref shape-ref))))
@ -538,7 +538,7 @@
(let [mask? (get-meta node :masked-group str->bool)] (let [mask? (get-meta node :masked-group str->bool)]
(cond-> props (cond-> props
mask? mask?
(assoc :masked-group? true)))) (assoc :masked-group true))))
(defn add-bool-data (defn add-bool-data
[props node] [props node]

View file

@ -239,7 +239,7 @@
(when v (when v
(let [v (if (datetime? v) (format v :date) v) (let [v (if (datetime? v) (format v :date) v)
locale (obj/get locales locale) locale (obj/get locales locale)
f (.date (.-formatLong locale) v)] f (.date (.-formatLong ^js locale) v)]
(->> #js {:locale locale} (->> #js {:locale locale}
(dateFnsFormat v f)))))) (dateFnsFormat v f))))))

View file

@ -206,7 +206,7 @@
(dissoc :stroke-color-ref-id :stroke-color-ref-file) (dissoc :stroke-color-ref-id :stroke-color-ref-file)
(not= file-id (get-component-ref-file objects shape)) (not= file-id (get-component-ref-file objects shape))
(dissoc :component-id :component-file :shape-ref :component-root?) (dissoc :component-id :component-file :shape-ref :component-root)
(= :text (:type shape)) (= :text (:type shape))
(update :content detach-text))) (update :content detach-text)))

View file

@ -19,18 +19,18 @@
[shape] [shape]
(t/is (nil? (:shape-ref shape))) (t/is (nil? (:shape-ref shape)))
(t/is (some? (:component-id shape))) (t/is (some? (:component-id shape)))
(t/is (= (:component-root? shape) true))) (t/is (= (:component-root shape) true)))
(defn is-main-instance-subroot (defn is-main-instance-subroot
[shape] [shape]
(t/is (some? (:component-id shape))) ; shape-ref may or may be not nil (t/is (some? (:component-id shape))) ; shape-ref may or may be not nil
(t/is (= (:component-root? shape) true))) (t/is (= (:component-root shape) true)))
(defn is-main-instance-child (defn is-main-instance-child
[shape] [shape]
(t/is (nil? (:component-id shape))) ; shape-ref may or may be not nil (t/is (nil? (:component-id shape))) ; shape-ref may or may be not nil
(t/is (nil? (:component-file shape))) (t/is (nil? (:component-file shape)))
(t/is (nil? (:component-root? shape)))) (t/is (nil? (:component-root shape))))
(defn is-main-instance-inner (defn is-main-instance-inner
[shape] [shape]
@ -42,20 +42,20 @@
[shape] [shape]
(t/is (some? (:shape-ref shape))) (t/is (some? (:shape-ref shape)))
(t/is (some? (:component-id shape))) (t/is (some? (:component-id shape)))
(t/is (= (:component-root? shape) true))) (t/is (= (:component-root shape) true)))
(defn is-instance-subroot (defn is-instance-subroot
[shape] [shape]
(t/is (some? (:shape-ref shape))) (t/is (some? (:shape-ref shape)))
(t/is (some? (:component-id shape))) (t/is (some? (:component-id shape)))
(t/is (nil? (:component-root? shape)))) (t/is (nil? (:component-root shape))))
(defn is-instance-child (defn is-instance-child
[shape] [shape]
(t/is (some? (:shape-ref shape))) (t/is (some? (:shape-ref shape)))
(t/is (nil? (:component-id shape))) (t/is (nil? (:component-id shape)))
(t/is (nil? (:component-file shape))) (t/is (nil? (:component-file shape)))
(t/is (nil? (:component-root? shape)))) (t/is (nil? (:component-root shape))))
(defn is-instance-inner (defn is-instance-inner
[shape] [shape]
@ -68,8 +68,8 @@
(t/is (nil? (:shape-ref shape))) (t/is (nil? (:shape-ref shape)))
(t/is (nil? (:component-id shape))) (t/is (nil? (:component-id shape)))
(t/is (nil? (:component-file shape))) (t/is (nil? (:component-file shape)))
(t/is (nil? (:component-root? shape))) (t/is (nil? (:component-root shape)))
(t/is (nil? (:remote-synced? shape))) (t/is (nil? (:remote-synced shape)))
(t/is (nil? (:touched shape)))) (t/is (nil? (:touched shape))))
(defn is-from-file (defn is-from-file
@ -109,7 +109,7 @@
([state root-inst-id subinstance?] ([state root-inst-id subinstance?]
(let [page (thp/current-page state) (let [page (thp/current-page state)
root-inst (ctn/get-shape page root-inst-id) root-inst (ctn/get-shape page root-inst-id)
main-instance? (:main-instance? root-inst) main-instance? (:main-instance root-inst)
libs (wsh/get-libraries state) libs (wsh/get-libraries state)
component (ctf/get-component libs (:component-id root-inst)) component (ctf/get-component libs (:component-id root-inst))

View file

@ -19,10 +19,10 @@
[frontend-tests.helpers.pages :as thp] [frontend-tests.helpers.pages :as thp]
[potok.core :as ptk])) [potok.core :as ptk]))
(t/use-fixtures :each ;; (t/use-fixtures :each
{:before thp/reset-idmap!}) ;; {:before thp/reset-idmap!})
; === Test touched ====================== ;; ; === Test touched ======================
(t/deftest test-touched (t/deftest test-touched
(t/async done (t/async done
@ -77,7 +77,8 @@
(t/is (= (:name c-shape1) "Rect 1")) (t/is (= (:name c-shape1) "Rect 1"))
(t/is (= (:touched c-shape1) nil)) (t/is (= (:touched c-shape1) nil))
(t/is (= (:fill-color c-shape1) clr/white)) (t/is (= (:fill-color c-shape1) clr/white))
(t/is (= (:fill-opacity c-shape1) 1)))))] (t/is (= (:fill-opacity c-shape1) 1))
)))]
(ptk/emit! (ptk/emit!
store store
@ -596,7 +597,6 @@
(t/is (= (:touched shape2) nil)) (t/is (= (:touched shape2) nil))
(t/is (= (:fill-color shape2) clr/test)) (t/is (= (:fill-color shape2) clr/test))
(t/is (= (:fill-opacity shape2) 0.5)) (t/is (= (:fill-opacity shape2) 0.5))
(t/is (= (:name c-instance2) "Board")) (t/is (= (:name c-instance2) "Board"))
(t/is (= (:touched c-instance2) nil)) (t/is (= (:touched c-instance2) nil))
(t/is (= (:name c-instance1) "Rect 1")) (t/is (= (:name c-instance1) "Rect 1"))
@ -607,8 +607,7 @@
(t/is (= (:fill-opacity c-shape1) 0)) (t/is (= (:fill-opacity c-shape1) 0))
(t/is (= (:name c-shape2) "Rect 1")) (t/is (= (:name c-shape2) "Rect 1"))
(t/is (= (:touched c-shape2) #{:fill-group})) (t/is (= (:touched c-shape2) #{:fill-group}))
(t/is (= (:fill-color c-shape2) clr/test)) )))]
(t/is (= (:fill-opacity c-shape2) 0.5)))))]
(ptk/emit! (ptk/emit!
store store
@ -1211,7 +1210,7 @@
(dwl/reset-component (:id instance1)) (dwl/reset-component (:id instance1))
:the/end)))) :the/end))))
;; ; === Test update component ====================== ;; === Test update component ======================
(t/deftest test-update-component (t/deftest test-update-component
(t/async done (t/async done

View file

@ -8,6 +8,7 @@
(:require (:require
[app.common.files.builder :as fb] [app.common.files.builder :as fb]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.common.types.shape :as cts]
[app.util.snap-data :as sd] [app.util.snap-data :as sd]
[cljs.pprint :refer [pprint]] [cljs.pprint :refer [pprint]]
[cljs.test :as t :include-macros true])) [cljs.test :as t :include-macros true]))
@ -338,7 +339,9 @@
frame (fb/lookup-shape file frame-id) frame (fb/lookup-shape file frame-id)
new-frame (-> frame new-frame (-> frame
(assoc :x 200 :y 200)) (dissoc :selrect :points)
(assoc :x 200 :y 200)
(cts/setup-shape))
file (fb/update-object file frame new-frame) file (fb/update-object file frame new-frame)
new-page (fb/get-current-page file) new-page (fb/get-current-page file)
@ -371,6 +374,7 @@
shape (fb/lookup-shape file shape-id) shape (fb/lookup-shape file shape-id)
new-shape (-> shape new-shape (-> shape
(dissoc :selrect :points)
(assoc :x 200 :y 200)) (assoc :x 200 :y 200))
file (fb/update-object file shape new-shape) file (fb/update-object file shape new-shape)