mirror of
https://github.com/penpot/penpot.git
synced 2025-05-14 18:16:38 +02:00
✨ Fix linter issues on frontend (part 2).
This commit is contained in:
parent
e90185b553
commit
3e4e54870b
41 changed files with 276 additions and 401 deletions
|
@ -1,6 +1,7 @@
|
||||||
{:lint-as
|
{:lint-as
|
||||||
{promesa.core/let clojure.core/let
|
{promesa.core/let clojure.core/let
|
||||||
rumext.alpha/defc clojure.core/defn
|
rumext.alpha/defc clojure.core/defn
|
||||||
|
rumext.alpha/fnc clojure.core/fn
|
||||||
app.common.data/export clojure.core/def
|
app.common.data/export clojure.core/def
|
||||||
app.db/with-atomic clojure.core/with-open}
|
app.db/with-atomic clojure.core/with-open}
|
||||||
|
|
||||||
|
@ -16,6 +17,8 @@
|
||||||
"app/worker/.*"
|
"app/worker/.*"
|
||||||
"app/main/ui.*"
|
"app/main/ui.*"
|
||||||
"app/libs/.*"
|
"app/libs/.*"
|
||||||
|
"app/main/data/workspace/path/selection.cljs"
|
||||||
|
"app/main/data/workspace/transforms.cljs"
|
||||||
]}
|
]}
|
||||||
|
|
||||||
:linters
|
:linters
|
||||||
|
|
|
@ -10,14 +10,13 @@
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.common.pages.spec :as spec]
|
[app.common.pages.spec :as spec]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.main.data.workspace.undo :as dwu]
|
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[app.main.worker :as uw]
|
[app.main.data.workspace.undo :as dwu]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
[app.main.worker :as uw]
|
||||||
[app.util.logging :as log]
|
[app.util.logging :as log]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[cljs.spec.alpha :as s]
|
[cljs.spec.alpha :as s]
|
||||||
[clojure.set :as set]
|
|
||||||
[potok.core :as ptk]))
|
[potok.core :as ptk]))
|
||||||
|
|
||||||
;; Change this to :info :debug or :trace to debug this module
|
;; Change this to :info :debug or :trace to debug this module
|
||||||
|
@ -59,29 +58,29 @@
|
||||||
attrs)
|
attrs)
|
||||||
|
|
||||||
uops (cond-> uops
|
uops (cond-> uops
|
||||||
(not (empty? uops))
|
(seq uops)
|
||||||
(conj {:type :set-touched :touched (:touched old-obj)}))
|
(conj {:type :set-touched :touched (:touched old-obj)}))
|
||||||
|
|
||||||
change {:type :mod-obj :page-id page-id :id id}]
|
change {:type :mod-obj :page-id page-id :id id}]
|
||||||
|
|
||||||
(cond-> changes
|
(cond-> changes
|
||||||
(not (empty? rops))
|
(seq rops)
|
||||||
(update :redo-changes conj (assoc change :operations rops))
|
(update :redo-changes conj (assoc change :operations rops))
|
||||||
|
|
||||||
(not (empty? uops))
|
(seq uops)
|
||||||
(update :undo-changes conj (assoc change :operations uops)))))
|
(update :undo-changes conj (assoc change :operations uops)))))
|
||||||
|
|
||||||
(defn update-shapes
|
(defn update-shapes
|
||||||
([ids f] (update-shapes ids f nil))
|
([ids f] (update-shapes ids f nil))
|
||||||
([ids f {:keys [reg-objects? save-undo? keys]
|
([ids f {:keys [reg-objects? save-undo? keys]
|
||||||
:or {reg-objects? false save-undo? true attrs nil}}]
|
:or {reg-objects? false save-undo? true}}]
|
||||||
|
|
||||||
(us/assert ::coll-of-uuid ids)
|
(us/assert ::coll-of-uuid ids)
|
||||||
(us/assert fn? f)
|
(us/assert fn? f)
|
||||||
|
|
||||||
(ptk/reify ::update-shapes
|
(ptk/reify ::update-shapes
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state)
|
objects (wsh/lookup-page-objects state)
|
||||||
changes {:redo-changes []
|
changes {:redo-changes []
|
||||||
|
@ -107,7 +106,7 @@
|
||||||
[page-id changes]
|
[page-id changes]
|
||||||
(ptk/reify ::update-indices
|
(ptk/reify ::update-indices
|
||||||
ptk/EffectEvent
|
ptk/EffectEvent
|
||||||
(effect [_ state stream]
|
(effect [_ _ _]
|
||||||
(uw/ask! {:cmd :update-page-indices
|
(uw/ask! {:cmd :update-page-indices
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
:changes changes}))))
|
:changes changes}))))
|
||||||
|
@ -147,7 +146,7 @@
|
||||||
state))))
|
state))))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ _ _]
|
||||||
(when-not @error
|
(when-not @error
|
||||||
(let [;; adds page-id to page changes (that have the `id` field instead)
|
(let [;; adds page-id to page changes (that have the `id` field instead)
|
||||||
add-page-id
|
add-page-id
|
||||||
|
@ -163,7 +162,7 @@
|
||||||
(group-by :page-id))
|
(group-by :page-id))
|
||||||
|
|
||||||
process-page-changes
|
process-page-changes
|
||||||
(fn [[page-id changes]]
|
(fn [[page-id _changes]]
|
||||||
(update-indices page-id redo-changes))]
|
(update-indices page-id redo-changes))]
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(rx/from (map process-page-changes changes-by-pages))
|
(rx/from (map process-page-changes changes-by-pages))
|
||||||
|
|
|
@ -7,23 +7,13 @@
|
||||||
(ns app.main.data.workspace.colors
|
(ns app.main.data.workspace.colors
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.pages :as cp]
|
|
||||||
[app.common.spec :as us]
|
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.main.data.modal :as md]
|
[app.main.data.modal :as md]
|
||||||
[app.main.data.workspace.changes :as dch]
|
[app.main.data.workspace.changes :as dch]
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[app.main.data.workspace.texts :as dwt]
|
[app.main.data.workspace.texts :as dwt]
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
[app.main.store :as st]
|
|
||||||
[app.main.streams :as ms]
|
|
||||||
[app.util.color :as color]
|
|
||||||
[app.util.i18n :refer [tr]]
|
|
||||||
[app.util.router :as rt]
|
|
||||||
[app.util.time :as dt]
|
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[cljs.spec.alpha :as s]
|
[cljs.spec.alpha :as s]
|
||||||
[clojure.set :as set]
|
|
||||||
[potok.core :as ptk]))
|
[potok.core :as ptk]))
|
||||||
|
|
||||||
(def clear-color-for-rename
|
(def clear-color-for-rename
|
||||||
|
@ -38,17 +28,16 @@
|
||||||
[file-id color-id name]
|
[file-id color-id name]
|
||||||
(ptk/reify ::rename-color
|
(ptk/reify ::rename-color
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ _ _]
|
||||||
(->> (rp/mutation! :rename-color {:id color-id :name name})
|
(->> (rp/mutation! :rename-color {:id color-id :name name})
|
||||||
(rx/map (partial rename-color-result file-id))))))
|
(rx/map (partial rename-color-result file-id))))))
|
||||||
|
|
||||||
(defn rename-color-result
|
(defn rename-color-result
|
||||||
[file-id color]
|
[_file-id color]
|
||||||
(ptk/reify ::rename-color-result
|
(ptk/reify ::rename-color-result
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(update-in state [:workspace-file :colors] #(d/replace-by-id % color)))))
|
||||||
(update-in [:workspace-file :colors] #(d/replace-by-id % color))))))
|
|
||||||
|
|
||||||
(defn change-palette-size
|
(defn change-palette-size
|
||||||
[size]
|
[size]
|
||||||
|
@ -125,7 +114,7 @@
|
||||||
[ids color]
|
[ids color]
|
||||||
(ptk/reify ::change-fill
|
(ptk/reify ::change-fill
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state s]
|
(watch [_ state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
|
|
||||||
|
@ -157,32 +146,29 @@
|
||||||
[ids color]
|
[ids color]
|
||||||
(ptk/reify ::change-stroke
|
(ptk/reify ::change-stroke
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state s]
|
(watch [_ _ _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [attrs (cond-> {}
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
(contains? color :color)
|
||||||
|
(assoc :stroke-color (:color color))
|
||||||
|
|
||||||
attrs (cond-> {}
|
(contains? color :id)
|
||||||
(contains? color :color)
|
(assoc :stroke-color-ref-id (:id color))
|
||||||
(assoc :stroke-color (:color color))
|
|
||||||
|
|
||||||
(contains? color :id)
|
(contains? color :file-id)
|
||||||
(assoc :stroke-color-ref-id (:id color))
|
(assoc :stroke-color-ref-file (:file-id color))
|
||||||
|
|
||||||
(contains? color :file-id)
|
(contains? color :gradient)
|
||||||
(assoc :stroke-color-ref-file (:file-id color))
|
(assoc :stroke-color-gradient (:gradient color))
|
||||||
|
|
||||||
(contains? color :gradient)
|
(contains? color :opacity)
|
||||||
(assoc :stroke-color-gradient (:gradient color))
|
(assoc :stroke-opacity (:opacity color)))]
|
||||||
|
|
||||||
(contains? color :opacity)
|
(rx/of (dch/update-shapes ids (fn [shape]
|
||||||
(assoc :stroke-opacity (:opacity color)))]
|
(cond-> (d/merge shape attrs)
|
||||||
|
(= (:stroke-style shape) :none)
|
||||||
(rx/of (dch/update-shapes ids (fn [shape]
|
(assoc :stroke-style :solid
|
||||||
(cond-> (d/merge shape attrs)
|
:stroke-width 1
|
||||||
(= (:stroke-style shape) :none)
|
:stroke-opacity 1)))))))))
|
||||||
(assoc :stroke-style :solid
|
|
||||||
:stroke-width 1
|
|
||||||
:stroke-opacity 1)))))))))
|
|
||||||
|
|
||||||
|
|
||||||
(defn picker-for-selected-shape
|
(defn picker-for-selected-shape
|
||||||
|
|
|
@ -6,19 +6,14 @@
|
||||||
|
|
||||||
(ns app.main.data.workspace.comments
|
(ns app.main.data.workspace.comments
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
|
||||||
[app.common.exceptions :as ex]
|
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.main.constants :as c]
|
[app.main.data.comments :as dcm]
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.data.workspace.common :as dwc]
|
[app.main.data.workspace.common :as dwc]
|
||||||
[app.main.data.comments :as dcm]
|
|
||||||
[app.main.store :as st]
|
|
||||||
[app.main.streams :as ms]
|
[app.main.streams :as ms]
|
||||||
[app.util.router :as rt]
|
[app.util.router :as rt]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[cljs.spec.alpha :as s]
|
|
||||||
[potok.core :as ptk]))
|
[potok.core :as ptk]))
|
||||||
|
|
||||||
(declare handle-interrupt)
|
(declare handle-interrupt)
|
||||||
|
@ -29,7 +24,7 @@
|
||||||
(us/assert ::us/uuid file-id)
|
(us/assert ::us/uuid file-id)
|
||||||
(ptk/reify ::initialize-comments
|
(ptk/reify ::initialize-comments
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ _ stream]
|
||||||
(let [stoper (rx/filter #(= ::finalize %) stream)]
|
(let [stoper (rx/filter #(= ::finalize %) stream)]
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(rx/of (dcm/retrieve-comment-threads file-id))
|
(rx/of (dcm/retrieve-comment-threads file-id))
|
||||||
|
@ -47,8 +42,8 @@
|
||||||
[]
|
[]
|
||||||
(ptk/reify ::handle-interrupt
|
(ptk/reify ::handle-interrupt
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(let [local (:comments-local state)]
|
(let [local (:comments-local state)]
|
||||||
(cond
|
(cond
|
||||||
(:draft local) (rx/of (dcm/close-thread))
|
(:draft local) (rx/of (dcm/close-thread))
|
||||||
(:open local) (rx/of (dcm/close-thread))
|
(:open local) (rx/of (dcm/close-thread))
|
||||||
|
@ -62,7 +57,7 @@
|
||||||
[position]
|
[position]
|
||||||
(ptk/reify ::handle-comment-layer-click
|
(ptk/reify ::handle-comment-layer-click
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(let [local (:comments-local state)]
|
(let [local (:comments-local state)]
|
||||||
(if (some? (:open local))
|
(if (some? (:open local))
|
||||||
(rx/of (dcm/close-thread))
|
(rx/of (dcm/close-thread))
|
||||||
|
@ -74,14 +69,13 @@
|
||||||
(rx/of (dcm/create-draft params))))))))
|
(rx/of (dcm/create-draft params))))))))
|
||||||
|
|
||||||
(defn center-to-comment-thread
|
(defn center-to-comment-thread
|
||||||
[{:keys [id position] :as thread}]
|
[{:keys [position] :as thread}]
|
||||||
(us/assert ::dcm/comment-thread thread)
|
(us/assert ::dcm/comment-thread thread)
|
||||||
(ptk/reify :center-to-comment-thread
|
(ptk/reify :center-to-comment-thread
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(update state :workspace-local
|
(update state :workspace-local
|
||||||
(fn [{:keys [vbox vport zoom] :as local}]
|
(fn [{:keys [vbox zoom] :as local}]
|
||||||
(prn "center-to-comment-thread" vbox)
|
|
||||||
(let [pw (/ 50 zoom)
|
(let [pw (/ 50 zoom)
|
||||||
ph (/ 200 zoom)
|
ph (/ 200 zoom)
|
||||||
nw (mth/round (- (/ (:width vbox) 2) pw))
|
nw (mth/round (- (/ (:width vbox) 2) pw))
|
||||||
|
@ -93,11 +87,11 @@
|
||||||
(update local :vbox assoc :x nx :y ny)))))))
|
(update local :vbox assoc :x nx :y ny)))))))
|
||||||
|
|
||||||
(defn navigate
|
(defn navigate
|
||||||
[{:keys [project-id file-id page-id] :as thread}]
|
[thread]
|
||||||
(us/assert ::dcm/comment-thread thread)
|
(us/assert ::dcm/comment-thread thread)
|
||||||
(ptk/reify ::navigate
|
(ptk/reify ::navigate
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ _ stream]
|
||||||
(let [pparams {:project-id (:project-id thread)
|
(let [pparams {:project-id (:project-id thread)
|
||||||
:file-id (:file-id thread)}
|
:file-id (:file-id thread)}
|
||||||
qparams {:page-id (:page-id thread)}]
|
qparams {:page-id (:page-id thread)}]
|
||||||
|
|
|
@ -40,15 +40,13 @@
|
||||||
[{:keys [file] :as bundle}]
|
[{:keys [file] :as bundle}]
|
||||||
(ptk/reify ::setup-selection-index
|
(ptk/reify ::setup-selection-index
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ _ _]
|
||||||
(let [msg {:cmd :initialize-indices
|
(let [msg {:cmd :initialize-indices
|
||||||
:file-id (:id file)
|
:file-id (:id file)
|
||||||
:data (:data file)}]
|
:data (:data file)}]
|
||||||
(->> (uw/ask! msg)
|
(->> (uw/ask! msg)
|
||||||
(rx/map (constantly ::index-initialized)))))))
|
(rx/map (constantly ::index-initialized)))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;; --- Common Helpers & Events
|
;; --- Common Helpers & Events
|
||||||
|
|
||||||
(defn get-frame-at-point
|
(defn get-frame-at-point
|
||||||
|
@ -59,7 +57,7 @@
|
||||||
|
|
||||||
(defn- extract-numeric-suffix
|
(defn- extract-numeric-suffix
|
||||||
[basename]
|
[basename]
|
||||||
(if-let [[match p1 p2] (re-find #"(.*)-([0-9]+)$" basename)]
|
(if-let [[_ p1 p2] (re-find #"(.*)-([0-9]+)$" basename)]
|
||||||
[p1 (+ 1 (d/parse-integer p2))]
|
[p1 (+ 1 (d/parse-integer p2))]
|
||||||
[basename 1]))
|
[basename 1]))
|
||||||
|
|
||||||
|
@ -112,7 +110,7 @@
|
||||||
(def undo
|
(def undo
|
||||||
(ptk/reify ::undo
|
(ptk/reify ::undo
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [edition (get-in state [:workspace-local :edition])
|
(let [edition (get-in state [:workspace-local :edition])
|
||||||
drawing (get state :workspace-drawing)]
|
drawing (get state :workspace-drawing)]
|
||||||
;; Editors handle their own undo's
|
;; Editors handle their own undo's
|
||||||
|
@ -131,7 +129,7 @@
|
||||||
(def redo
|
(def redo
|
||||||
(ptk/reify ::redo
|
(ptk/reify ::redo
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [edition (get-in state [:workspace-local :edition])
|
(let [edition (get-in state [:workspace-local :edition])
|
||||||
drawing (get state :workspace-drawing)]
|
drawing (get state :workspace-drawing)]
|
||||||
(when-not (or (some? edition) (not-empty drawing))
|
(when-not (or (some? edition) (not-empty drawing))
|
||||||
|
@ -180,10 +178,10 @@
|
||||||
(assoc-in state [:workspace-local :selected] ids))
|
(assoc-in state [:workspace-local :selected] ids))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)]
|
objects (wsh/lookup-page-objects state page-id)]
|
||||||
(rx/of (expand-all-parents ids objects))))))
|
(rx/of (expand-all-parents ids objects))))))
|
||||||
|
|
||||||
(declare clear-edition-mode)
|
(declare clear-edition-mode)
|
||||||
|
|
||||||
|
@ -202,12 +200,11 @@
|
||||||
state)))
|
state)))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ _ stream]
|
||||||
(let [objects (wsh/lookup-page-objects state)]
|
(->> stream
|
||||||
(->> stream
|
(rx/filter interrupt?)
|
||||||
(rx/filter interrupt?)
|
(rx/take 1)
|
||||||
(rx/take 1)
|
(rx/map (constantly clear-edition-mode))))))
|
||||||
(rx/map (constantly clear-edition-mode)))))))
|
|
||||||
|
|
||||||
;; If these event change modules review /src/app/main/data/workspace/path/undo.cljs
|
;; If these event change modules review /src/app/main/data/workspace/path/undo.cljs
|
||||||
(def clear-edition-mode
|
(def clear-edition-mode
|
||||||
|
@ -282,7 +279,7 @@
|
||||||
(us/verify ::shape-attrs attrs)
|
(us/verify ::shape-attrs attrs)
|
||||||
(ptk/reify ::add-shape
|
(ptk/reify ::add-shape
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
|
|
||||||
|
@ -313,7 +310,7 @@
|
||||||
(defn move-shapes-into-frame [frame-id shapes]
|
(defn move-shapes-into-frame [frame-id shapes]
|
||||||
(ptk/reify ::move-shapes-into-frame
|
(ptk/reify ::move-shapes-into-frame
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
to-move-shapes (->> (cp/select-toplevel-shapes objects {:include-frames? false})
|
to-move-shapes (->> (cp/select-toplevel-shapes objects {:include-frames? false})
|
||||||
|
@ -349,7 +346,7 @@
|
||||||
(us/assert ::set-of-uuid ids)
|
(us/assert ::set-of-uuid ids)
|
||||||
(ptk/reify ::delete-shapes
|
(ptk/reify ::delete-shapes
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
|
|
||||||
|
@ -504,7 +501,7 @@
|
||||||
[type frame-x frame-y data]
|
[type frame-x frame-y data]
|
||||||
(ptk/reify ::create-and-add-shape
|
(ptk/reify ::create-and-add-shape
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ state _]
|
||||||
(let [{:keys [width height]} data
|
(let [{:keys [width height]} data
|
||||||
|
|
||||||
[vbc-x vbc-y] (viewport-center state)
|
[vbc-x vbc-y] (viewport-center state)
|
||||||
|
@ -524,7 +521,7 @@
|
||||||
[image {:keys [x y]}]
|
[image {:keys [x y]}]
|
||||||
(ptk/reify ::image-uploaded
|
(ptk/reify ::image-uploaded
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ _ _]
|
||||||
(let [{:keys [name width height id mtype]} image
|
(let [{:keys [name width height id mtype]} image
|
||||||
shape {:name name
|
shape {:name name
|
||||||
:width width
|
:width width
|
||||||
|
|
|
@ -7,17 +7,15 @@
|
||||||
(ns app.main.data.workspace.drawing
|
(ns app.main.data.workspace.drawing
|
||||||
"Drawing interactions."
|
"Drawing interactions."
|
||||||
(:require
|
(:require
|
||||||
[beicon.core :as rx]
|
|
||||||
[potok.core :as ptk]
|
|
||||||
[app.common.spec :as us]
|
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.main.data.workspace.common :as dwc]
|
[app.main.data.workspace.common :as dwc]
|
||||||
[app.main.data.workspace.selection :as dws]
|
[app.main.data.workspace.drawing.box :as box]
|
||||||
[app.main.data.workspace.path :as path]
|
|
||||||
[app.main.data.workspace.drawing.common :as common]
|
[app.main.data.workspace.drawing.common :as common]
|
||||||
[app.main.data.workspace.drawing.curve :as curve]
|
[app.main.data.workspace.drawing.curve :as curve]
|
||||||
[app.main.data.workspace.drawing.box :as box]))
|
[app.main.data.workspace.path :as path]
|
||||||
|
[beicon.core :as rx]
|
||||||
|
[potok.core :as ptk]))
|
||||||
|
|
||||||
(declare start-drawing)
|
(declare start-drawing)
|
||||||
(declare handle-drawing)
|
(declare handle-drawing)
|
||||||
|
@ -38,7 +36,7 @@
|
||||||
(update :workspace-layout disj :scale-text)))
|
(update :workspace-layout disj :scale-text)))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ _ stream]
|
||||||
(let [stoper (rx/filter (ptk/type? ::clear-drawing) stream)]
|
(let [stoper (rx/filter (ptk/type? ::clear-drawing) stream)]
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(when (= tool :path)
|
(when (= tool :path)
|
||||||
|
@ -88,16 +86,17 @@
|
||||||
(update-in state [:workspace-drawing :object] merge data)))
|
(update-in state [:workspace-drawing :object] merge data)))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ _ _]
|
||||||
(rx/of (case type
|
(rx/of
|
||||||
:path
|
(case type
|
||||||
(path/handle-new-shape)
|
:path
|
||||||
|
(path/handle-new-shape)
|
||||||
|
|
||||||
:curve
|
:curve
|
||||||
(curve/handle-drawing-curve)
|
(curve/handle-drawing-curve)
|
||||||
|
|
||||||
;; default
|
;; default
|
||||||
(box/handle-drawing-box))))))
|
(box/handle-drawing-box))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
(defn truncate-zero [num default]
|
(defn truncate-zero [num default]
|
||||||
(if (mth/almost-zero? num) default num))
|
(if (mth/almost-zero? num) default num))
|
||||||
|
|
||||||
(defn resize-shape [{:keys [x y width height transform transform-inverse] :as shape} point lock?]
|
(defn resize-shape [{:keys [x y width height] :as shape} point lock?]
|
||||||
(let [;; The new shape behaves like a resize on the bottom-right corner
|
(let [;; The new shape behaves like a resize on the bottom-right corner
|
||||||
initial (gpt/point (+ x width) (+ y height))
|
initial (gpt/point (+ x width) (+ y height))
|
||||||
shapev (gpt/point width height)
|
shapev (gpt/point width height)
|
||||||
|
@ -53,9 +53,7 @@
|
||||||
(ptk/reify ::handle-drawing-box
|
(ptk/reify ::handle-drawing-box
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [{:keys [flags]} (:workspace-local state)
|
(let [stoper? #(or (ms/mouse-up? %) (= % :interrupt))
|
||||||
|
|
||||||
stoper? #(or (ms/mouse-up? %) (= % :interrupt))
|
|
||||||
stoper (rx/filter stoper? stream)
|
stoper (rx/filter stoper? stream)
|
||||||
initial @ms/mouse-position
|
initial @ms/mouse-position
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,13 @@
|
||||||
|
|
||||||
(ns app.main.data.workspace.drawing.common
|
(ns app.main.data.workspace.drawing.common
|
||||||
(:require
|
(:require
|
||||||
[beicon.core :as rx]
|
|
||||||
[potok.core :as ptk]
|
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.main.data.workspace.common :as dwc]
|
[app.main.data.workspace.common :as dwc]
|
||||||
[app.main.data.workspace.selection :as dws]
|
|
||||||
[app.main.data.workspace.undo :as dwu]
|
[app.main.data.workspace.undo :as dwu]
|
||||||
[app.main.streams :as ms]
|
[app.main.worker :as uw]
|
||||||
[app.main.worker :as uw]))
|
[beicon.core :as rx]
|
||||||
|
[potok.core :as ptk]))
|
||||||
|
|
||||||
(def clear-drawing
|
(def clear-drawing
|
||||||
(ptk/reify ::clear-drawing
|
(ptk/reify ::clear-drawing
|
||||||
|
@ -25,7 +23,7 @@
|
||||||
(def handle-finish-drawing
|
(def handle-finish-drawing
|
||||||
(ptk/reify ::handle-finish-drawing
|
(ptk/reify ::handle-finish-drawing
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(let [shape (get-in state [:workspace-drawing :object])]
|
(let [shape (get-in state [:workspace-drawing :object])]
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(when (:initialized? shape)
|
(when (:initialized? shape)
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
(ns app.main.data.workspace.drawing.curve
|
(ns app.main.data.workspace.drawing.curve
|
||||||
(:require
|
(:require
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.geom.shapes.path :as gsp]
|
[app.common.geom.shapes.path :as gsp]
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
|
@ -19,7 +18,7 @@
|
||||||
|
|
||||||
(def simplify-tolerance 0.3)
|
(def simplify-tolerance 0.3)
|
||||||
|
|
||||||
(defn stoper-event? [{:keys [type shift] :as event}]
|
(defn stoper-event? [{:keys [type] :as event}]
|
||||||
(ms/mouse-event? event) (= type :up))
|
(ms/mouse-event? event) (= type :up))
|
||||||
|
|
||||||
(defn initialize-drawing [state]
|
(defn initialize-drawing [state]
|
||||||
|
@ -73,9 +72,8 @@
|
||||||
(defn handle-drawing-curve []
|
(defn handle-drawing-curve []
|
||||||
(ptk/reify ::handle-drawing-curve
|
(ptk/reify ::handle-drawing-curve
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ _ stream]
|
||||||
(let [{:keys [flags]} (:workspace-local state)
|
(let [stoper (rx/filter stoper-event? stream)
|
||||||
stoper (rx/filter stoper-event? stream)
|
|
||||||
mouse (rx/sample 10 ms/mouse-position)]
|
mouse (rx/sample 10 ms/mouse-position)]
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(rx/of initialize-drawing)
|
(rx/of initialize-drawing)
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
|
|
||||||
(ns app.main.data.workspace.grid
|
(ns app.main.data.workspace.grid
|
||||||
(:require
|
(:require
|
||||||
[beicon.core :as rx]
|
|
||||||
[potok.core :as ptk]
|
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.main.data.workspace.changes :as dch]))
|
[app.main.data.workspace.changes :as dch]
|
||||||
|
[beicon.core :as rx]
|
||||||
|
[potok.core :as ptk]))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Grid
|
;; Grid
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
(us/assert ::us/uuid frame-id)
|
(us/assert ::us/uuid frame-id)
|
||||||
(ptk/reify ::add-frame-grid
|
(ptk/reify ::add-frame-grid
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
data (get-in state [:workspace-data :pages-index page-id])
|
data (get-in state [:workspace-data :pages-index page-id])
|
||||||
params (or (get-in data [:options :saved-grids :square])
|
params (or (get-in data [:options :saved-grids :square])
|
||||||
|
@ -56,21 +56,21 @@
|
||||||
[frame-id index]
|
[frame-id index]
|
||||||
(ptk/reify ::set-frame-grid
|
(ptk/reify ::set-frame-grid
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ _ _]
|
||||||
(rx/of (dch/update-shapes [frame-id] (fn [o] (update o :grids (fnil #(d/remove-at-index % index) []))))))))
|
(rx/of (dch/update-shapes [frame-id] (fn [o] (update o :grids (fnil #(d/remove-at-index % index) []))))))))
|
||||||
|
|
||||||
(defn set-frame-grid
|
(defn set-frame-grid
|
||||||
[frame-id index data]
|
[frame-id index data]
|
||||||
(ptk/reify ::set-frame-grid
|
(ptk/reify ::set-frame-grid
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ _ _]
|
||||||
(rx/of (dch/update-shapes [frame-id] #(assoc-in % [:grids index] data))))))
|
(rx/of (dch/update-shapes [frame-id] #(assoc-in % [:grids index] data))))))
|
||||||
|
|
||||||
(defn set-default-grid
|
(defn set-default-grid
|
||||||
[type params]
|
[type params]
|
||||||
(ptk/reify ::set-default-grid
|
(ptk/reify ::set-default-grid
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [pid (:current-page-id state)
|
(let [pid (:current-page-id state)
|
||||||
prev-value (get-in state [:workspace-data :pages-index pid :options :saved-grids type])]
|
prev-value (get-in state [:workspace-data :pages-index pid :options :saved-grids type])]
|
||||||
(rx/of (dch/commit-changes
|
(rx/of (dch/commit-changes
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
;;
|
||||||
|
;; Copyright (c) UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.main.data.workspace.groups
|
(ns app.main.data.workspace.groups
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
|
@ -5,7 +11,6 @@
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.main.data.workspace.changes :as dch]
|
[app.main.data.workspace.changes :as dch]
|
||||||
[app.main.data.workspace.common :as dwc]
|
[app.main.data.workspace.common :as dwc]
|
||||||
[app.main.data.workspace.selection :as dws]
|
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[potok.core :as ptk]))
|
[potok.core :as ptk]))
|
||||||
|
@ -22,7 +27,6 @@
|
||||||
[shapes prefix keep-name]
|
[shapes prefix keep-name]
|
||||||
(let [selrect (gsh/selection-rect shapes)
|
(let [selrect (gsh/selection-rect shapes)
|
||||||
frame-id (-> shapes first :frame-id)
|
frame-id (-> shapes first :frame-id)
|
||||||
parent-id (-> shapes first :parent-id)
|
|
||||||
group-name (if (and keep-name
|
group-name (if (and keep-name
|
||||||
(= (count shapes) 1)
|
(= (count shapes) 1)
|
||||||
(= (:type (first shapes)) :group))
|
(= (:type (first shapes)) :group))
|
||||||
|
@ -166,7 +170,7 @@
|
||||||
(def group-selected
|
(def group-selected
|
||||||
(ptk/reify ::group-selected
|
(ptk/reify ::group-selected
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
selected (wsh/lookup-selected state)
|
selected (wsh/lookup-selected state)
|
||||||
|
@ -183,7 +187,7 @@
|
||||||
(def ungroup-selected
|
(def ungroup-selected
|
||||||
(ptk/reify ::ungroup-selected
|
(ptk/reify ::ungroup-selected
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
selected (wsh/lookup-selected state)
|
selected (wsh/lookup-selected state)
|
||||||
|
@ -200,7 +204,7 @@
|
||||||
(def mask-group
|
(def mask-group
|
||||||
(ptk/reify ::mask-group
|
(ptk/reify ::mask-group
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
selected (wsh/lookup-selected state)
|
selected (wsh/lookup-selected state)
|
||||||
|
@ -257,7 +261,7 @@
|
||||||
(def unmask-group
|
(def unmask-group
|
||||||
(ptk/reify ::unmask-group
|
(ptk/reify ::unmask-group
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
selected (wsh/lookup-selected state)]
|
selected (wsh/lookup-selected state)]
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
(:component-id change)
|
(:component-id change)
|
||||||
:objects
|
:objects
|
||||||
(:id change)])
|
(:id change)])
|
||||||
:default nil))
|
:else nil))
|
||||||
|
|
||||||
prefix (if (:component-id change) "[C] " "[P] ")
|
prefix (if (:component-id change) "[C] " "[P] ")
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
(us/assert ::cp/color color)
|
(us/assert ::cp/color color)
|
||||||
(ptk/reify ::add-color
|
(ptk/reify ::add-color
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state s]
|
(watch [it _ _]
|
||||||
(let [rchg {:type :add-color
|
(let [rchg {:type :add-color
|
||||||
:color color}
|
:color color}
|
||||||
uchg {:type :del-color
|
uchg {:type :del-color
|
||||||
|
@ -104,7 +104,7 @@
|
||||||
(us/assert ::cp/recent-color color)
|
(us/assert ::cp/recent-color color)
|
||||||
(ptk/reify ::add-recent-color
|
(ptk/reify ::add-recent-color
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state s]
|
(watch [it _ _]
|
||||||
(let [rchg {:type :add-recent-color
|
(let [rchg {:type :add-recent-color
|
||||||
:color color}]
|
:color color}]
|
||||||
(rx/of (dch/commit-changes {:redo-changes [rchg]
|
(rx/of (dch/commit-changes {:redo-changes [rchg]
|
||||||
|
@ -123,7 +123,7 @@
|
||||||
(us/assert ::us/uuid file-id)
|
(us/assert ::us/uuid file-id)
|
||||||
(ptk/reify ::update-color
|
(ptk/reify ::update-color
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [[path name] (cp/parse-path-name (:name color))
|
(let [[path name] (cp/parse-path-name (:name color))
|
||||||
color (assoc color :path path :name name)
|
color (assoc color :path path :name name)
|
||||||
prev (get-in state [:workspace-data :colors id])
|
prev (get-in state [:workspace-data :colors id])
|
||||||
|
@ -141,7 +141,7 @@
|
||||||
(us/assert ::us/uuid id)
|
(us/assert ::us/uuid id)
|
||||||
(ptk/reify ::delete-color
|
(ptk/reify ::delete-color
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [prev (get-in state [:workspace-data :colors id])
|
(let [prev (get-in state [:workspace-data :colors id])
|
||||||
rchg {:type :del-color
|
rchg {:type :del-color
|
||||||
:id id}
|
:id id}
|
||||||
|
@ -156,7 +156,7 @@
|
||||||
(us/assert ::cp/media-object media)
|
(us/assert ::cp/media-object media)
|
||||||
(ptk/reify ::add-media
|
(ptk/reify ::add-media
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it _ _]
|
||||||
(let [obj (select-keys media [:id :name :width :height :mtype])
|
(let [obj (select-keys media [:id :name :width :height :mtype])
|
||||||
rchg {:type :add-media
|
rchg {:type :add-media
|
||||||
:object obj}
|
:object obj}
|
||||||
|
@ -172,7 +172,7 @@
|
||||||
(us/assert ::us/string new-name)
|
(us/assert ::us/string new-name)
|
||||||
(ptk/reify ::rename-media
|
(ptk/reify ::rename-media
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [object (get-in state [:workspace-data :media id])
|
(let [object (get-in state [:workspace-data :media id])
|
||||||
[path name] (cp/parse-path-name new-name)
|
[path name] (cp/parse-path-name new-name)
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@
|
||||||
(us/assert ::us/uuid id)
|
(us/assert ::us/uuid id)
|
||||||
(ptk/reify ::delete-media
|
(ptk/reify ::delete-media
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [prev (get-in state [:workspace-data :media id])
|
(let [prev (get-in state [:workspace-data :media id])
|
||||||
rchg {:type :del-media
|
rchg {:type :del-media
|
||||||
:id id}
|
:id id}
|
||||||
|
@ -212,7 +212,7 @@
|
||||||
(us/assert ::cp/typography typography)
|
(us/assert ::cp/typography typography)
|
||||||
(ptk/reify ::add-typography
|
(ptk/reify ::add-typography
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state s]
|
(watch [it _ _]
|
||||||
(let [rchg {:type :add-typography
|
(let [rchg {:type :add-typography
|
||||||
:typography typography}
|
:typography typography}
|
||||||
uchg {:type :del-typography
|
uchg {:type :del-typography
|
||||||
|
@ -230,7 +230,7 @@
|
||||||
(us/assert ::us/uuid file-id)
|
(us/assert ::us/uuid file-id)
|
||||||
(ptk/reify ::update-typography
|
(ptk/reify ::update-typography
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [[path name] (cp/parse-path-name (:name typography))
|
(let [[path name] (cp/parse-path-name (:name typography))
|
||||||
typography (assoc typography :path path :name name)
|
typography (assoc typography :path path :name name)
|
||||||
prev (get-in state [:workspace-data :typographies (:id typography)])
|
prev (get-in state [:workspace-data :typographies (:id typography)])
|
||||||
|
@ -248,7 +248,7 @@
|
||||||
(us/assert ::us/uuid id)
|
(us/assert ::us/uuid id)
|
||||||
(ptk/reify ::delete-typography
|
(ptk/reify ::delete-typography
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [prev (get-in state [:workspace-data :typographies id])
|
(let [prev (get-in state [:workspace-data :typographies id])
|
||||||
rchg {:type :del-typography
|
rchg {:type :del-typography
|
||||||
:id id}
|
:id id}
|
||||||
|
@ -262,7 +262,7 @@
|
||||||
"Add a new component to current file library, from the currently selected shapes."
|
"Add a new component to current file library, from the currently selected shapes."
|
||||||
(ptk/reify ::add-component
|
(ptk/reify ::add-component
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [file-id (:current-file-id state)
|
(let [file-id (:current-file-id state)
|
||||||
page-id (:current-page-id state)
|
page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
|
@ -285,7 +285,7 @@
|
||||||
(us/assert ::us/string new-name)
|
(us/assert ::us/string new-name)
|
||||||
(ptk/reify ::rename-component
|
(ptk/reify ::rename-component
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [[path name] (cp/parse-path-name new-name)
|
(let [[path name] (cp/parse-path-name new-name)
|
||||||
component (get-in state [:workspace-data :components id])
|
component (get-in state [:workspace-data :components id])
|
||||||
objects (get component :objects)
|
objects (get component :objects)
|
||||||
|
@ -315,7 +315,7 @@
|
||||||
[{:keys [id] :as params}]
|
[{:keys [id] :as params}]
|
||||||
(ptk/reify ::duplicate-component
|
(ptk/reify ::duplicate-component
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [component (cp/get-component id
|
(let [component (cp/get-component id
|
||||||
(:current-file-id state)
|
(:current-file-id state)
|
||||||
(dwlh/get-local-file state)
|
(dwlh/get-local-file state)
|
||||||
|
@ -324,7 +324,7 @@
|
||||||
unames (set (map :name all-components))
|
unames (set (map :name all-components))
|
||||||
new-name (dwc/generate-unique-name unames (:name component))
|
new-name (dwc/generate-unique-name unames (:name component))
|
||||||
|
|
||||||
[new-shape new-shapes updated-shapes]
|
[new-shape new-shapes _updated-shapes]
|
||||||
(dwlh/duplicate-component component)
|
(dwlh/duplicate-component component)
|
||||||
|
|
||||||
rchanges [{:type :add-component
|
rchanges [{:type :add-component
|
||||||
|
@ -346,7 +346,7 @@
|
||||||
(us/assert ::us/uuid id)
|
(us/assert ::us/uuid id)
|
||||||
(ptk/reify ::delete-component
|
(ptk/reify ::delete-component
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [component (get-in state [:workspace-data :components id])
|
(let [component (get-in state [:workspace-data :components id])
|
||||||
|
|
||||||
rchanges [{:type :del-component
|
rchanges [{:type :del-component
|
||||||
|
@ -371,7 +371,7 @@
|
||||||
(us/assert ::us/point position)
|
(us/assert ::us/point position)
|
||||||
(ptk/reify ::instantiate-component
|
(ptk/reify ::instantiate-component
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [local-library (dwlh/get-local-file state)
|
(let [local-library (dwlh/get-local-file state)
|
||||||
libraries (get state :workspace-libraries)
|
libraries (get state :workspace-libraries)
|
||||||
component (cp/get-component component-id file-id local-library libraries)
|
component (cp/get-component component-id file-id local-library libraries)
|
||||||
|
@ -449,7 +449,7 @@
|
||||||
(us/assert ::us/uuid id)
|
(us/assert ::us/uuid id)
|
||||||
(ptk/reify ::detach-component
|
(ptk/reify ::detach-component
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
shapes (cp/get-object-with-children id objects)
|
shapes (cp/get-object-with-children id objects)
|
||||||
|
@ -511,13 +511,13 @@
|
||||||
(us/assert ::us/uuid file-id)
|
(us/assert ::us/uuid file-id)
|
||||||
(ptk/reify ::nav-to-component-file
|
(ptk/reify ::nav-to-component-file
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ state _]
|
||||||
(let [file (get-in state [:workspace-libraries file-id])
|
(let [file (get-in state [:workspace-libraries file-id])
|
||||||
pparams {:project-id (:project-id file)
|
pparams {:project-id (:project-id file)
|
||||||
:file-id (:id file)}
|
:file-id (:id file)}
|
||||||
qparams {:page-id (first (get-in file [:data :pages]))
|
qparams {:page-id (first (get-in file [:data :pages]))
|
||||||
:layout :assets}]
|
:layout :assets}]
|
||||||
(st/emit! (rt/nav-new-window :workspace pparams qparams))))))
|
(rx/of (rt/nav-new-window :workspace pparams qparams))))))
|
||||||
|
|
||||||
(defn ext-library-changed
|
(defn ext-library-changed
|
||||||
[file-id modified-at revn changes]
|
[file-id modified-at revn changes]
|
||||||
|
@ -540,7 +540,7 @@
|
||||||
(us/assert ::us/uuid id)
|
(us/assert ::us/uuid id)
|
||||||
(ptk/reify ::reset-component
|
(ptk/reify ::reset-component
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(log/info :msg "RESET-COMPONENT of shape" :id (str id))
|
(log/info :msg "RESET-COMPONENT of shape" :id (str id))
|
||||||
(let [local-library (dwlh/get-local-file state)
|
(let [local-library (dwlh/get-local-file state)
|
||||||
libraries (dwlh/get-libraries state)
|
libraries (dwlh/get-libraries state)
|
||||||
|
@ -574,7 +574,7 @@
|
||||||
(us/assert ::us/uuid id)
|
(us/assert ::us/uuid id)
|
||||||
(ptk/reify ::update-component
|
(ptk/reify ::update-component
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(log/info :msg "UPDATE-COMPONENT of shape" :id (str id))
|
(log/info :msg "UPDATE-COMPONENT of shape" :id (str id))
|
||||||
(let [page-id (get state :current-page-id)
|
(let [page-id (get state :current-page-id)
|
||||||
local-library (dwlh/get-local-file state)
|
local-library (dwlh/get-local-file state)
|
||||||
|
@ -642,7 +642,7 @@
|
||||||
state))
|
state))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(log/info :msg "SYNC-FILE"
|
(log/info :msg "SYNC-FILE"
|
||||||
:file (dwlh/pretty-file file-id state)
|
:file (dwlh/pretty-file file-id state)
|
||||||
:library (dwlh/pretty-file library-id state))
|
:library (dwlh/pretty-file library-id state))
|
||||||
|
@ -702,7 +702,7 @@
|
||||||
(us/assert ::us/uuid library-id)
|
(us/assert ::us/uuid library-id)
|
||||||
(ptk/reify ::sync-file-2nd-stage
|
(ptk/reify ::sync-file-2nd-stage
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(log/info :msg "SYNC-FILE (2nd stage)"
|
(log/info :msg "SYNC-FILE (2nd stage)"
|
||||||
:file (dwlh/pretty-file file-id state)
|
:file (dwlh/pretty-file file-id state)
|
||||||
:library (dwlh/pretty-file library-id state))
|
:library (dwlh/pretty-file library-id state))
|
||||||
|
@ -727,7 +727,7 @@
|
||||||
(assoc-in state [:workspace-file :ignore-sync-until] (dt/now)))
|
(assoc-in state [:workspace-file :ignore-sync-until] (dt/now)))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ state _]
|
||||||
(rp/mutation :ignore-sync
|
(rp/mutation :ignore-sync
|
||||||
{:file-id (get-in state [:workspace-file :id])
|
{:file-id (get-in state [:workspace-file :id])
|
||||||
:date (dt/now)}))))
|
:date (dt/now)}))))
|
||||||
|
@ -737,7 +737,7 @@
|
||||||
(us/assert ::us/uuid file-id)
|
(us/assert ::us/uuid file-id)
|
||||||
(ptk/reify ::notify-sync-file
|
(ptk/reify ::notify-sync-file
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ state _]
|
||||||
(let [libraries-need-sync (filter #(> (:modified-at %) (:synced-at %))
|
(let [libraries-need-sync (filter #(> (:modified-at %) (:synced-at %))
|
||||||
(vals (get state :workspace-libraries)))
|
(vals (get state :workspace-libraries)))
|
||||||
do-update #(do (apply st/emit! (map (fn [library]
|
do-update #(do (apply st/emit! (map (fn [library]
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
(assert (nil? (:shape-ref shape)))
|
(assert (nil? (:shape-ref shape)))
|
||||||
(let [;; Ensure that the component root is not an instance and
|
(let [;; Ensure that the component root is not an instance and
|
||||||
;; it's no longer tied to a frame.
|
;; it's no longer tied to a frame.
|
||||||
update-new-shape (fn [new-shape original-shape]
|
update-new-shape (fn [new-shape _original-shape]
|
||||||
(cond-> new-shape
|
(cond-> new-shape
|
||||||
true
|
true
|
||||||
(-> (assoc :frame-id nil)
|
(-> (assoc :frame-id nil)
|
||||||
|
@ -338,10 +338,10 @@
|
||||||
(defmulti generate-sync-shape
|
(defmulti generate-sync-shape
|
||||||
"Generate changes to synchronize one shape with all assets of the given type
|
"Generate changes to synchronize one shape with all assets of the given type
|
||||||
that is using, in the given library."
|
that is using, in the given library."
|
||||||
(fn [type library-id state container shape] type))
|
(fn [type _library-id _state _container _shape] type))
|
||||||
|
|
||||||
(defmethod generate-sync-shape :components
|
(defmethod generate-sync-shape :components
|
||||||
[_ library-id state container shape]
|
[_ _ state container shape]
|
||||||
(generate-sync-shape-direct container
|
(generate-sync-shape-direct container
|
||||||
(:id shape)
|
(:id shape)
|
||||||
(get-local-file state)
|
(get-local-file state)
|
||||||
|
@ -666,7 +666,7 @@
|
||||||
[(d/concat rchanges child-rchanges)
|
[(d/concat rchanges child-rchanges)
|
||||||
(d/concat uchanges child-uchanges)]))
|
(d/concat uchanges child-uchanges)]))
|
||||||
|
|
||||||
(defn- generate-sync-shape-inverse
|
(defn generate-sync-shape-inverse
|
||||||
"Generate changes to update the component a shape is linked to, from
|
"Generate changes to update the component a shape is linked to, from
|
||||||
the values in the shape and all its children."
|
the values in the shape and all its children."
|
||||||
[page-id shape-id local-library libraries]
|
[page-id shape-id local-library libraries]
|
||||||
|
@ -886,10 +886,10 @@
|
||||||
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)
|
||||||
|
|
||||||
[new-shape new-shapes _]
|
[_ new-shapes _]
|
||||||
(cp/clone-object component-shape
|
(cp/clone-object component-shape
|
||||||
(:id parent-shape)
|
(:id parent-shape)
|
||||||
(get component :objects)
|
(get component :objects)
|
||||||
|
@ -939,7 +939,7 @@
|
||||||
(cp/get-parents (:id component-parent-shape)
|
(cp/get-parents (:id component-parent-shape)
|
||||||
(:objects component))))
|
(:objects component))))
|
||||||
|
|
||||||
update-new-shape (fn [new-shape original-shape]
|
update-new-shape (fn [new-shape _original-shape]
|
||||||
(reposition-shape new-shape
|
(reposition-shape new-shape
|
||||||
root-instance
|
root-instance
|
||||||
root-main))
|
root-main))
|
||||||
|
@ -950,7 +950,7 @@
|
||||||
:shape-ref (:id new-shape))
|
:shape-ref (:id new-shape))
|
||||||
original-shape))
|
original-shape))
|
||||||
|
|
||||||
[new-shape new-shapes updated-shapes]
|
[_new-shape new-shapes updated-shapes]
|
||||||
(cp/clone-object shape
|
(cp/clone-object shape
|
||||||
(:id component-parent-shape)
|
(:id component-parent-shape)
|
||||||
(get page :objects)
|
(get page :objects)
|
||||||
|
@ -1141,33 +1141,6 @@
|
||||||
:remote-synced? (:remote-synced? shape)}]})]]
|
:remote-synced? (:remote-synced? shape)}]})]]
|
||||||
[rchanges uchanges]))))
|
[rchanges uchanges]))))
|
||||||
|
|
||||||
(defn- set-touched-shapes-group
|
|
||||||
[shape container]
|
|
||||||
(if-not (:shape-ref shape)
|
|
||||||
empty-changes
|
|
||||||
(do
|
|
||||||
(log/info :msg (str "SET-TOUCHED-SHAPES-GROUP "
|
|
||||||
(if (cp/page? container) "[P] " "[C] ")
|
|
||||||
(:name shape)))
|
|
||||||
(let [rchanges [(make-change
|
|
||||||
container
|
|
||||||
{:type :mod-obj
|
|
||||||
:id (:id shape)
|
|
||||||
:operations
|
|
||||||
[{:type :set-touched
|
|
||||||
:touched (cp/set-touched-group
|
|
||||||
(:touched shape)
|
|
||||||
:shapes-group)}]})]
|
|
||||||
|
|
||||||
uchanges [(make-change
|
|
||||||
container
|
|
||||||
{:type :mod-obj
|
|
||||||
:id (:id shape)
|
|
||||||
:operations
|
|
||||||
[{:type :set-touched
|
|
||||||
:touched (:touched shape)}]})]]
|
|
||||||
[rchanges uchanges]))))
|
|
||||||
|
|
||||||
(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
|
||||||
attributes that have changed in the origin shape to the dest shape.
|
attributes that have changed in the origin shape to the dest shape.
|
||||||
|
|
|
@ -16,11 +16,7 @@
|
||||||
[app.main.data.workspace.changes :as dch]
|
[app.main.data.workspace.changes :as dch]
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.workspace.persistence :as dwp]
|
[app.main.data.workspace.persistence :as dwp]
|
||||||
[app.main.repo :as rp]
|
|
||||||
[app.main.store :as st]
|
|
||||||
[app.main.streams :as ms]
|
[app.main.streams :as ms]
|
||||||
[app.util.avatars :as avatars]
|
|
||||||
[app.util.i18n :as i18n :refer [tr]]
|
|
||||||
[app.util.time :as dt]
|
[app.util.time :as dt]
|
||||||
[app.util.websockets :as ws]
|
[app.util.websockets :as ws]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
|
@ -104,7 +100,7 @@
|
||||||
[file-id]
|
[file-id]
|
||||||
(ptk/reify ::send-keepalive
|
(ptk/reify ::send-keepalive
|
||||||
ptk/EffectEvent
|
ptk/EffectEvent
|
||||||
(effect [_ state stream]
|
(effect [_ state _]
|
||||||
(when-let [ws (get-in state [:ws file-id])]
|
(when-let [ws (get-in state [:ws file-id])]
|
||||||
(ws/send! ws {:type :keepalive})))))
|
(ws/send! ws {:type :keepalive})))))
|
||||||
|
|
||||||
|
@ -112,9 +108,8 @@
|
||||||
[file-id point]
|
[file-id point]
|
||||||
(ptk/reify ::handle-pointer-update
|
(ptk/reify ::handle-pointer-update
|
||||||
ptk/EffectEvent
|
ptk/EffectEvent
|
||||||
(effect [_ state stream]
|
(effect [_ state _]
|
||||||
(let [ws (get-in state [:ws file-id])
|
(let [ws (get-in state [:ws file-id])
|
||||||
sid (:session-id state)
|
|
||||||
pid (:current-page-id state)
|
pid (:current-page-id state)
|
||||||
msg {:type :pointer-update
|
msg {:type :pointer-update
|
||||||
:page-id pid
|
:page-id pid
|
||||||
|
@ -128,7 +123,7 @@
|
||||||
[file-id]
|
[file-id]
|
||||||
(ptk/reify ::finalize
|
(ptk/reify ::finalize
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(when-let [ws (get-in state [:ws file-id])]
|
(when-let [ws (get-in state [:ws file-id])]
|
||||||
(ws/-close ws))
|
(ws/-close ws))
|
||||||
(rx/of ::finalize))))
|
(rx/of ::finalize))))
|
||||||
|
@ -187,7 +182,7 @@
|
||||||
(update state :workspace-presence update-presence))))))
|
(update state :workspace-presence update-presence))))))
|
||||||
|
|
||||||
(defn handle-pointer-update
|
(defn handle-pointer-update
|
||||||
[{:keys [page-id profile-id session-id x y] :as msg}]
|
[{:keys [page-id session-id x y] :as msg}]
|
||||||
(ptk/reify ::handle-pointer-update
|
(ptk/reify ::handle-pointer-update
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
|
@ -213,7 +208,7 @@
|
||||||
(us/assert ::file-change-event msg)
|
(us/assert ::file-change-event msg)
|
||||||
(ptk/reify ::handle-file-change
|
(ptk/reify ::handle-file-change
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ _ _]
|
||||||
(let [changes-by-pages (group-by :page-id changes)
|
(let [changes-by-pages (group-by :page-id changes)
|
||||||
process-page-changes
|
process-page-changes
|
||||||
(fn [[page-id changes]]
|
(fn [[page-id changes]]
|
||||||
|
@ -239,7 +234,7 @@
|
||||||
(us/assert ::library-change-event msg)
|
(us/assert ::library-change-event msg)
|
||||||
(ptk/reify ::handle-library-change
|
(ptk/reify ::handle-library-change
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(when (contains? (:workspace-libraries state) file-id)
|
(when (contains? (:workspace-libraries state) file-id)
|
||||||
(rx/of (dwl/ext-library-changed file-id modified-at revn changes)
|
(rx/of (dwl/ext-library-changed file-id modified-at revn changes)
|
||||||
(dwl/notify-sync-file file-id))))))
|
(dwl/notify-sync-file file-id))))))
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
(assoc-in state (st/get-path state :content) content)))
|
(assoc-in state (st/get-path state :content) content)))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [objects (wsh/lookup-page-objects state)
|
(let [objects (wsh/lookup-page-objects state)
|
||||||
page-id (:current-page-id state)
|
page-id (:current-page-id state)
|
||||||
id (get-in state [:workspace-local :edition])
|
id (get-in state [:workspace-local :edition])
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
[state]
|
[state]
|
||||||
(dissoc state :last-point :prev-handler :drag-handler :preview))
|
(dissoc state :last-point :prev-handler :drag-handler :preview))
|
||||||
|
|
||||||
(defn finish-path [source]
|
(defn finish-path
|
||||||
|
[_source]
|
||||||
(ptk/reify ::finish-path
|
(ptk/reify ::finish-path
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
[app.main.data.workspace.path.spec :as spec]
|
[app.main.data.workspace.path.spec :as spec]
|
||||||
[app.main.data.workspace.path.state :as st]
|
[app.main.data.workspace.path.state :as st]
|
||||||
[app.main.data.workspace.path.streams :as streams]
|
[app.main.data.workspace.path.streams :as streams]
|
||||||
[app.main.data.workspace.path.tools :as tools]
|
|
||||||
[app.main.data.workspace.path.undo :as undo]
|
[app.main.data.workspace.path.undo :as undo]
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[app.main.streams :as ms]
|
[app.main.streams :as ms]
|
||||||
|
@ -60,9 +59,8 @@
|
||||||
state)))))
|
state)))))
|
||||||
|
|
||||||
(defn drag-handler
|
(defn drag-handler
|
||||||
([{:keys [x y alt? shift?] :as position}]
|
([position]
|
||||||
(drag-handler nil nil :c1 position))
|
(drag-handler nil nil :c1 position))
|
||||||
|
|
||||||
([position index prefix {:keys [x y alt? shift?]}]
|
([position index prefix {:keys [x y alt? shift?]}]
|
||||||
(ptk/reify ::drag-handler
|
(ptk/reify ::drag-handler
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
|
@ -110,7 +108,7 @@
|
||||||
(update-in (st/get-path state) helpers/update-selrect))))
|
(update-in (st/get-path state) helpers/update-selrect))))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(let [id (st/get-path-id state)
|
(let [id (st/get-path-id state)
|
||||||
handler (get-in state [:workspace-local :edit-path id :prev-handler])]
|
handler (get-in state [:workspace-local :edit-path id :prev-handler])]
|
||||||
;; Update the preview because can be outdated after the dragging
|
;; Update the preview because can be outdated after the dragging
|
||||||
|
@ -124,9 +122,6 @@
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [id (st/get-path-id state)
|
(let [id (st/get-path-id state)
|
||||||
zoom (get-in state [:workspace-local :zoom])
|
|
||||||
start-position @ms/mouse-position
|
|
||||||
|
|
||||||
stop-stream
|
stop-stream
|
||||||
(->> stream (rx/filter #(or (helpers/end-path-event? %)
|
(->> stream (rx/filter #(or (helpers/end-path-event? %)
|
||||||
(ms/mouse-up? %))))
|
(ms/mouse-up? %))))
|
||||||
|
@ -166,9 +161,7 @@
|
||||||
(ptk/reify ::start-path-from-point
|
(ptk/reify ::start-path-from-point
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [start-point @ms/mouse-position
|
(let [mouse-up (->> stream (rx/filter #(or (helpers/end-path-event? %)
|
||||||
zoom (get-in state [:workspace-local :zoom])
|
|
||||||
mouse-up (->> stream (rx/filter #(or (helpers/end-path-event? %)
|
|
||||||
(ms/mouse-up? %))))
|
(ms/mouse-up? %))))
|
||||||
content (get-in state (st/get-path state :content))
|
content (get-in state (st/get-path state :content))
|
||||||
points (upg/content->points content)
|
points (upg/content->points content)
|
||||||
|
@ -195,7 +188,7 @@
|
||||||
(rx/merge-map #(rx/empty))))
|
(rx/merge-map #(rx/empty))))
|
||||||
|
|
||||||
(defn make-drag-stream
|
(defn make-drag-stream
|
||||||
[stream snap-toggled zoom points down-event]
|
[stream snap-toggled _zoom points down-event]
|
||||||
(let [mouse-up (->> stream (rx/filter #(or (helpers/end-path-event? %)
|
(let [mouse-up (->> stream (rx/filter #(or (helpers/end-path-event? %)
|
||||||
(ms/mouse-up? %))))
|
(ms/mouse-up? %))))
|
||||||
|
|
||||||
|
@ -211,7 +204,7 @@
|
||||||
(rx/of (finish-drag)))))))
|
(rx/of (finish-drag)))))))
|
||||||
|
|
||||||
(defn handle-drawing-path
|
(defn handle-drawing-path
|
||||||
[id]
|
[_id]
|
||||||
(ptk/reify ::handle-drawing-path
|
(ptk/reify ::handle-drawing-path
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
|
@ -278,11 +271,11 @@
|
||||||
state)))
|
state)))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ _ _]
|
||||||
(->> (rx/of (setup-frame-path)
|
(rx/of (setup-frame-path)
|
||||||
dwdc/handle-finish-drawing
|
dwdc/handle-finish-drawing
|
||||||
(dwc/start-edition-mode shape-id)
|
(dwc/start-edition-mode shape-id)
|
||||||
(change-edit-mode :draw))))))
|
(change-edit-mode :draw)))))
|
||||||
|
|
||||||
(defn handle-new-shape
|
(defn handle-new-shape
|
||||||
"Creates a new path shape"
|
"Creates a new path shape"
|
||||||
|
@ -333,7 +326,7 @@
|
||||||
(defn check-changed-content []
|
(defn check-changed-content []
|
||||||
(ptk/reify ::check-changed-content
|
(ptk/reify ::check-changed-content
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(let [id (st/get-path-id state)
|
(let [id (st/get-path-id state)
|
||||||
content (get-in state (st/get-path state :content))
|
content (get-in state (st/get-path state :content))
|
||||||
old-content (get-in state [:workspace-local :edit-path id :old-content])
|
old-content (get-in state [:workspace-local :edit-path id :old-content])
|
||||||
|
@ -354,7 +347,7 @@
|
||||||
id (assoc-in [:workspace-local :edit-path id :edit-mode] mode))))
|
id (assoc-in [:workspace-local :edit-path id :edit-mode] mode))))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(let [id (st/get-path-id state)]
|
(let [id (st/get-path-id state)]
|
||||||
(cond
|
(cond
|
||||||
(and id (= :move mode)) (rx/of (common/finish-path "change-edit-mode"))
|
(and id (= :move mode)) (rx/of (common/finish-path "change-edit-mode"))
|
||||||
|
|
|
@ -8,11 +8,9 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.math :as mth]
|
|
||||||
[app.main.data.workspace.common :as dwc]
|
|
||||||
[app.main.data.workspace.changes :as dch]
|
[app.main.data.workspace.changes :as dch]
|
||||||
|
[app.main.data.workspace.common :as dwc]
|
||||||
[app.main.data.workspace.path.changes :as changes]
|
[app.main.data.workspace.path.changes :as changes]
|
||||||
[app.main.data.workspace.path.common :as common]
|
|
||||||
[app.main.data.workspace.path.drawing :as drawing]
|
[app.main.data.workspace.path.drawing :as drawing]
|
||||||
[app.main.data.workspace.path.helpers :as helpers]
|
[app.main.data.workspace.path.helpers :as helpers]
|
||||||
[app.main.data.workspace.path.selection :as selection]
|
[app.main.data.workspace.path.selection :as selection]
|
||||||
|
@ -47,7 +45,7 @@
|
||||||
(defn apply-content-modifiers []
|
(defn apply-content-modifiers []
|
||||||
(ptk/reify ::apply-content-modifiers
|
(ptk/reify ::apply-content-modifiers
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [objects (wsh/lookup-page-objects state)
|
(let [objects (wsh/lookup-page-objects state)
|
||||||
|
|
||||||
id (st/get-path-id state)
|
id (st/get-path-id state)
|
||||||
|
@ -137,7 +135,7 @@
|
||||||
[position shift?]
|
[position shift?]
|
||||||
(ptk/reify ::start-move-path-point
|
(ptk/reify ::start-move-path-point
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ state _]
|
||||||
(let [id (get-in state [:workspace-local :edition])
|
(let [id (get-in state [:workspace-local :edition])
|
||||||
selected-points (get-in state [:workspace-local :edit-path id :selected-points] #{})
|
selected-points (get-in state [:workspace-local :edit-path id :selected-points] #{})
|
||||||
selected? (contains? selected-points position)]
|
selected? (contains? selected-points position)]
|
||||||
|
@ -151,7 +149,7 @@
|
||||||
[start-position]
|
[start-position]
|
||||||
(ptk/reify ::drag-selected-points
|
(ptk/reify ::drag-selected-points
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ state stream]
|
||||||
(let [stopper (->> stream (rx/filter ms/mouse-up?))
|
(let [stopper (->> stream (rx/filter ms/mouse-up?))
|
||||||
id (get-in state [:workspace-local :edition])
|
id (get-in state [:workspace-local :edition])
|
||||||
snap-toggled (get-in state [:workspace-local :edit-path id :snap-toggled])
|
snap-toggled (get-in state [:workspace-local :edit-path id :snap-toggled])
|
||||||
|
@ -206,7 +204,7 @@
|
||||||
state)))
|
state)))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ state stream]
|
||||||
(let [id (get-in state [:workspace-local :edition])
|
(let [id (get-in state [:workspace-local :edition])
|
||||||
current-move (get-in state [:workspace-local :edit-path id :current-move])]
|
current-move (get-in state [:workspace-local :edit-path id :current-move])]
|
||||||
(if (= same-event current-move)
|
(if (= same-event current-move)
|
||||||
|
@ -240,7 +238,7 @@
|
||||||
[index prefix]
|
[index prefix]
|
||||||
(ptk/reify ::start-move-handler
|
(ptk/reify ::start-move-handler
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ state stream]
|
||||||
(let [id (get-in state [:workspace-local :edition])
|
(let [id (get-in state [:workspace-local :edition])
|
||||||
cx (d/prefix-keyword prefix :x)
|
cx (d/prefix-keyword prefix :x)
|
||||||
cy (d/prefix-keyword prefix :y)
|
cy (d/prefix-keyword prefix :y)
|
||||||
|
@ -297,7 +295,7 @@
|
||||||
(assoc-in [:workspace-local :edit-path id :edit-mode] :draw))))
|
(assoc-in [:workspace-local :edit-path id :edit-mode] :draw))))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ state stream]
|
||||||
(let [mode (get-in state [:workspace-local :edit-path id :edit-mode])]
|
(let [mode (get-in state [:workspace-local :edit-path id :edit-mode])]
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(rx/of (undo/start-path-undo))
|
(rx/of (undo/start-path-undo))
|
||||||
|
@ -327,5 +325,5 @@
|
||||||
(update-in (st/get-path state :content) upt/split-segments #{from-p to-p} t))))
|
(update-in (st/get-path state :content) upt/split-segments #{from-p to-p} t))))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ _ _]
|
||||||
(rx/of (changes/save-path-content {:preserve-move-to true})))))
|
(rx/of (changes/save-path-content {:preserve-move-to true})))))
|
||||||
|
|
|
@ -6,25 +6,23 @@
|
||||||
|
|
||||||
(ns app.main.data.workspace.path.helpers
|
(ns app.main.data.workspace.path.helpers
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
|
||||||
[app.common.geom.matrix :as gmt]
|
[app.common.geom.matrix :as gmt]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[app.main.data.workspace.path.common :as common]
|
[app.main.data.workspace.path.common :as common]
|
||||||
[app.main.data.workspace.path.state :refer [get-path]]
|
|
||||||
[app.main.streams :as ms]
|
[app.main.streams :as ms]
|
||||||
[app.util.path.commands :as upc]
|
[app.util.path.commands :as upc]
|
||||||
[app.util.path.subpaths :as ups]
|
[app.util.path.subpaths :as ups]
|
||||||
[potok.core :as ptk]))
|
[potok.core :as ptk]))
|
||||||
|
|
||||||
(defn end-path-event? [{:keys [type shift] :as event}]
|
(defn end-path-event? [event]
|
||||||
(or (= (ptk/type event) ::common/finish-path)
|
(or (= (ptk/type event) ::common/finish-path)
|
||||||
(= (ptk/type event) :esc-pressed)
|
(= (ptk/type event) :esc-pressed)
|
||||||
(= :app.main.data.workspace.common/clear-edition-mode (ptk/type event))
|
(= :app.main.data.workspace.common/clear-edition-mode (ptk/type event))
|
||||||
(= :app.main.data.workspace/finalize-page (ptk/type event))
|
(= :app.main.data.workspace/finalize-page (ptk/type event))
|
||||||
(= event :interrupt) ;; ESC
|
(= event :interrupt) ;; ESC
|
||||||
(and (ms/mouse-double-click? event))))
|
(ms/mouse-double-click? event)))
|
||||||
|
|
||||||
(defn content-center
|
(defn content-center
|
||||||
[content]
|
[content]
|
||||||
|
@ -35,7 +33,6 @@
|
||||||
(defn content->points+selrect
|
(defn content->points+selrect
|
||||||
"Given the content of a shape, calculate its points and selrect"
|
"Given the content of a shape, calculate its points and selrect"
|
||||||
[shape content]
|
[shape content]
|
||||||
|
|
||||||
(let [{:keys [flip-x flip-y]} shape
|
(let [{:keys [flip-x flip-y]} shape
|
||||||
transform
|
transform
|
||||||
(cond-> (:transform shape (gmt/matrix))
|
(cond-> (:transform shape (gmt/matrix))
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
(defn esc-pressed []
|
(defn esc-pressed []
|
||||||
(ptk/reify :esc-pressed
|
(ptk/reify :esc-pressed
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
;; Not interrupt when we're editing a path
|
;; Not interrupt when we're editing a path
|
||||||
(let [edition-id (or (get-in state [:workspace-drawing :object :id])
|
(let [edition-id (or (get-in state [:workspace-drawing :object :id])
|
||||||
(get-in state [:workspace-local :edition]))
|
(get-in state [:workspace-local :edition]))
|
||||||
|
|
|
@ -40,8 +40,8 @@
|
||||||
|
|
||||||
(s/def ::content-entry
|
(s/def ::content-entry
|
||||||
(s/keys :req-un [::command]
|
(s/keys :req-un [::command]
|
||||||
:req-opt [::params
|
:opt-un [::params
|
||||||
::relative?]))
|
::relative?]))
|
||||||
(s/def ::content
|
(s/def ::content
|
||||||
(s/coll-of ::content-entry :kind vector?))
|
(s/coll-of ::content-entry :kind vector?))
|
||||||
|
|
||||||
|
|
|
@ -6,17 +6,16 @@
|
||||||
|
|
||||||
(ns app.main.data.workspace.path.streams
|
(ns app.main.data.workspace.path.streams
|
||||||
(:require
|
(:require
|
||||||
[app.main.data.workspace.path.helpers :as helpers]
|
|
||||||
[app.main.data.workspace.path.state :as state]
|
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
|
[app.common.math :as mth]
|
||||||
|
[app.main.data.workspace.path.state :as state]
|
||||||
|
[app.main.snap :as snap]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.streams :as ms]
|
[app.main.streams :as ms]
|
||||||
|
[app.util.path.geom :as upg]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[potok.core :as ptk]
|
|
||||||
[app.common.math :as mth]
|
|
||||||
[app.main.snap :as snap]
|
|
||||||
[okulary.core :as l]
|
[okulary.core :as l]
|
||||||
[app.util.path.geom :as upg]))
|
[potok.core :as ptk]))
|
||||||
|
|
||||||
(defonce drag-threshold 5)
|
(defonce drag-threshold 5)
|
||||||
|
|
||||||
|
@ -122,7 +121,7 @@
|
||||||
(rx/map check-path-snap))))
|
(rx/map check-path-snap))))
|
||||||
|
|
||||||
(defn position-stream
|
(defn position-stream
|
||||||
[snap-toggled points]
|
[snap-toggled _points]
|
||||||
(let [zoom (get-in @st/state [:workspace-local :zoom] 1)
|
(let [zoom (get-in @st/state [:workspace-local :zoom] 1)
|
||||||
;; ranges (snap/create-ranges points)
|
;; ranges (snap/create-ranges points)
|
||||||
d-pos (/ snap/snap-path-accuracy zoom)
|
d-pos (/ snap/snap-path-accuracy zoom)
|
||||||
|
|
|
@ -6,11 +6,9 @@
|
||||||
|
|
||||||
(ns app.main.data.workspace.path.tools
|
(ns app.main.data.workspace.path.tools
|
||||||
(:require
|
(:require
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.main.data.workspace.changes :as dch]
|
[app.main.data.workspace.changes :as dch]
|
||||||
[app.main.data.workspace.common :as dwc]
|
[app.main.data.workspace.common :as dwc]
|
||||||
[app.main.data.workspace.path.changes :as changes]
|
[app.main.data.workspace.path.changes :as changes]
|
||||||
[app.main.data.workspace.path.common :as common]
|
|
||||||
[app.main.data.workspace.path.state :as st]
|
[app.main.data.workspace.path.state :as st]
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[app.util.path.subpaths :as ups]
|
[app.util.path.subpaths :as ups]
|
||||||
|
@ -25,7 +23,7 @@
|
||||||
([points tool-fn]
|
([points tool-fn]
|
||||||
(ptk/reify ::process-path-tool
|
(ptk/reify ::process-path-tool
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [objects (wsh/lookup-page-objects state)
|
(let [objects (wsh/lookup-page-objects state)
|
||||||
id (st/get-path-id state)
|
id (st/get-path-id state)
|
||||||
page-id (:current-page-id state)
|
page-id (:current-page-id state)
|
||||||
|
@ -33,7 +31,7 @@
|
||||||
|
|
||||||
selected-points (get-in state [:workspace-local :edit-path id :selected-points] #{})
|
selected-points (get-in state [:workspace-local :edit-path id :selected-points] #{})
|
||||||
points (or points selected-points)]
|
points (or points selected-points)]
|
||||||
(when (and (not (empty? points)) (some? shape))
|
(when (and (seq points) (some? shape))
|
||||||
(let [new-content (-> (tool-fn (:content shape) points)
|
(let [new-content (-> (tool-fn (:content shape) points)
|
||||||
(ups/close-subpaths))
|
(ups/close-subpaths))
|
||||||
[rch uch] (changes/generate-path-changes objects page-id shape (:content shape) new-content)]
|
[rch uch] (changes/generate-path-changes objects page-id shape (:content shape) new-content)]
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.undo-stack :as u]
|
[app.common.data.undo-stack :as u]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.main.data.workspace.path.state :as st]
|
|
||||||
[app.main.data.workspace.path.changes :as changes]
|
[app.main.data.workspace.path.changes :as changes]
|
||||||
|
[app.main.data.workspace.path.state :as st]
|
||||||
[app.main.store :as store]
|
[app.main.store :as store]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[okulary.core :as l]
|
[okulary.core :as l]
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
undo-stack)))))
|
undo-stack)))))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ _ _]
|
||||||
(rx/of (changes/save-path-content {:preserve-move-to true})))))
|
(rx/of (changes/save-path-content {:preserve-move-to true})))))
|
||||||
|
|
||||||
(defn redo-path []
|
(defn redo-path []
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
undo-stack))))
|
undo-stack))))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ _ _]
|
||||||
(rx/of (changes/save-path-content)))))
|
(rx/of (changes/save-path-content)))))
|
||||||
|
|
||||||
(defn merge-head
|
(defn merge-head
|
||||||
|
@ -92,10 +92,9 @@
|
||||||
(ptk/reify ::add-undo-entry
|
(ptk/reify ::add-undo-entry
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [id (st/get-path-id state)
|
(let [id (st/get-path-id state)
|
||||||
entry (make-entry state)
|
|
||||||
stack (get-in state [:workspace-local :edit-path id :undo-stack])
|
stack (get-in state [:workspace-local :edit-path id :undo-stack])
|
||||||
head (u/peek stack)
|
head (u/peek stack)
|
||||||
stack (-> stack (u/undo) (u/fixup head))]
|
stack (-> stack (u/undo) (u/fixup head))]
|
||||||
(-> state
|
(-> state
|
||||||
(d/assoc-in-when
|
(d/assoc-in-when
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.common.media :as cm]
|
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
|
@ -26,11 +24,9 @@
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.util.avatars :as avatars]
|
|
||||||
[app.util.http :as http]
|
[app.util.http :as http]
|
||||||
[app.util.i18n :as i18n :refer [tr]]
|
[app.util.i18n :as i18n :refer [tr]]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[app.util.router :as rt]
|
|
||||||
[app.util.time :as dt]
|
[app.util.time :as dt]
|
||||||
[app.util.uri :as uu]
|
[app.util.uri :as uu]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
|
@ -52,7 +48,7 @@
|
||||||
[file-id]
|
[file-id]
|
||||||
(ptk/reify ::initialize-persistence
|
(ptk/reify ::initialize-persistence
|
||||||
ptk/EffectEvent
|
ptk/EffectEvent
|
||||||
(effect [_ state stream]
|
(effect [_ _ stream]
|
||||||
(let [stoper (rx/filter #(= ::finalize %) stream)
|
(let [stoper (rx/filter #(= ::finalize %) stream)
|
||||||
forcer (rx/filter #(= ::force-persist %) stream)
|
forcer (rx/filter #(= ::force-persist %) stream)
|
||||||
notifier (->> stream
|
notifier (->> stream
|
||||||
|
@ -120,12 +116,11 @@
|
||||||
(ptk/reify ::persist-changes
|
(ptk/reify ::persist-changes
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [conj (fnil conj [])
|
(let [into* (fnil into [])]
|
||||||
into* (fnil into [])]
|
|
||||||
(update-in state [:workspace-persistence :queue] into* changes)))
|
(update-in state [:workspace-persistence :queue] into* changes)))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ state _]
|
||||||
(let [sid (:session-id state)
|
(let [sid (:session-id state)
|
||||||
file (get state :workspace-file)
|
file (get state :workspace-file)
|
||||||
queue (get-in state [:workspace-persistence :queue] [])
|
queue (get-in state [:workspace-persistence :queue] [])
|
||||||
|
@ -176,7 +171,7 @@
|
||||||
(us/verify ::us/uuid file-id)
|
(us/verify ::us/uuid file-id)
|
||||||
(ptk/reify ::persist-synchronous-changes
|
(ptk/reify ::persist-synchronous-changes
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ state _]
|
||||||
(let [sid (:session-id state)
|
(let [sid (:session-id state)
|
||||||
file (get-in state [:workspace-libraries file-id])
|
file (get-in state [:workspace-libraries file-id])
|
||||||
|
|
||||||
|
@ -259,7 +254,7 @@
|
||||||
[project-id file-id]
|
[project-id file-id]
|
||||||
(ptk/reify ::fetch-bundle
|
(ptk/reify ::fetch-bundle
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ _ _]
|
||||||
(->> (rx/zip (rp/query :file {:id file-id})
|
(->> (rx/zip (rp/query :file {:id file-id})
|
||||||
(rp/query :team-users {:file-id file-id})
|
(rp/query :team-users {:file-id file-id})
|
||||||
(rp/query :project {:id project-id})
|
(rp/query :project {:id project-id})
|
||||||
|
@ -285,7 +280,7 @@
|
||||||
(assoc-in state [:workspace-file :is-shared] is-shared))
|
(assoc-in state [:workspace-file :is-shared] is-shared))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ _ _]
|
||||||
(let [params {:id id :is-shared is-shared}]
|
(let [params {:id id :is-shared is-shared}]
|
||||||
(->> (rp/mutation :set-file-shared params)
|
(->> (rp/mutation :set-file-shared params)
|
||||||
(rx/ignore))))))
|
(rx/ignore))))))
|
||||||
|
@ -300,7 +295,7 @@
|
||||||
(us/assert ::us/uuid team-id)
|
(us/assert ::us/uuid team-id)
|
||||||
(ptk/reify ::fetch-shared-files
|
(ptk/reify ::fetch-shared-files
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ _ _]
|
||||||
(->> (rp/query :team-shared-files {:team-id team-id})
|
(->> (rp/query :team-shared-files {:team-id team-id})
|
||||||
(rx/map shared-files-fetched)))))
|
(rx/map shared-files-fetched)))))
|
||||||
|
|
||||||
|
@ -320,7 +315,7 @@
|
||||||
[file-id library-id]
|
[file-id library-id]
|
||||||
(ptk/reify ::link-file-to-library
|
(ptk/reify ::link-file-to-library
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ _ _]
|
||||||
(let [fetched #(assoc-in %2 [:workspace-libraries (:id %1)] %1)
|
(let [fetched #(assoc-in %2 [:workspace-libraries (:id %1)] %1)
|
||||||
params {:file-id file-id
|
params {:file-id file-id
|
||||||
:library-id library-id}]
|
:library-id library-id}]
|
||||||
|
@ -332,7 +327,7 @@
|
||||||
[file-id library-id]
|
[file-id library-id]
|
||||||
(ptk/reify ::unlink-file-from-library
|
(ptk/reify ::unlink-file-from-library
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ _ _]
|
||||||
(let [unlinked #(d/dissoc-in % [:workspace-libraries library-id])
|
(let [unlinked #(d/dissoc-in % [:workspace-libraries library-id])
|
||||||
params {:file-id file-id
|
params {:file-id file-id
|
||||||
:library-id library-id}]
|
:library-id library-id}]
|
||||||
|
@ -348,7 +343,7 @@
|
||||||
(->> (rx/of (-> (tubax/xml->clj text)
|
(->> (rx/of (-> (tubax/xml->clj text)
|
||||||
(assoc :name name))))
|
(assoc :name name))))
|
||||||
|
|
||||||
(catch :default err
|
(catch :default _err
|
||||||
(rx/throw {:type :svg-parser}))))
|
(rx/throw {:type :svg-parser}))))
|
||||||
|
|
||||||
(defn fetch-svg [name uri]
|
(defn fetch-svg [name uri]
|
||||||
|
@ -458,7 +453,7 @@
|
||||||
(s/def ::process-media-objects
|
(s/def ::process-media-objects
|
||||||
(s/and
|
(s/and
|
||||||
(s/keys :req-un [::file-id ::local?]
|
(s/keys :req-un [::file-id ::local?]
|
||||||
:opt-in [::name ::data ::uris ::mtype])
|
:opt-un [::name ::data ::uris ::mtype])
|
||||||
(fn [props]
|
(fn [props]
|
||||||
(or (contains? props :blobs)
|
(or (contains? props :blobs)
|
||||||
(contains? props :uris)))))
|
(contains? props :uris)))))
|
||||||
|
@ -468,7 +463,7 @@
|
||||||
(us/assert ::process-media-objects params)
|
(us/assert ::process-media-objects params)
|
||||||
(ptk/reify ::process-media-objects
|
(ptk/reify ::process-media-objects
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ _ _]
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(rx/of (dm/show {:content (tr "media.loading")
|
(rx/of (dm/show {:content (tr "media.loading")
|
||||||
:type :info
|
:type :info
|
||||||
|
@ -515,7 +510,7 @@
|
||||||
(us/assert ::clone-media-objects-params params)
|
(us/assert ::clone-media-objects-params params)
|
||||||
(ptk/reify ::clone-media-objects
|
(ptk/reify ::clone-media-objects
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ _ _]
|
||||||
(let [{:keys [on-success on-error]
|
(let [{:keys [on-success on-error]
|
||||||
:or {on-success identity
|
:or {on-success identity
|
||||||
on-error identity}} (meta params)
|
on-error identity}} (meta params)
|
||||||
|
@ -548,7 +543,7 @@
|
||||||
[ids]
|
[ids]
|
||||||
(ptk/reify ::remove-thumbnails
|
(ptk/reify ::remove-thumbnails
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ _ _]
|
||||||
;; Removes the thumbnail while it's regenerated
|
;; Removes the thumbnail while it's regenerated
|
||||||
(rx/of (dch/update-shapes
|
(rx/of (dch/update-shapes
|
||||||
ids
|
ids
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
:height (mth/abs (- end-y start-y))}))]
|
:height (mth/abs (- end-y start-y))}))]
|
||||||
(ptk/reify ::handle-selection
|
(ptk/reify ::handle-selection
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ _ stream]
|
||||||
(let [stop? (fn [event] (or (dwc/interrupt? event) (ms/mouse-up? event)))
|
(let [stop? (fn [event] (or (dwc/interrupt? event) (ms/mouse-up? event)))
|
||||||
stoper (->> stream (rx/filter stop?))]
|
stoper (->> stream (rx/filter stop?))]
|
||||||
(rx/concat
|
(rx/concat
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
(conj selected id))))))
|
(conj selected id))))))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)]
|
objects (wsh/lookup-page-objects state page-id)]
|
||||||
(rx/of (dwc/expand-all-parents [id] objects)))))))
|
(rx/of (dwc/expand-all-parents [id] objects)))))))
|
||||||
|
@ -136,7 +136,7 @@
|
||||||
(assoc-in state [:workspace-local :selected] ids))
|
(assoc-in state [:workspace-local :selected] ids))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(let [objects (wsh/lookup-page-objects state)]
|
(let [objects (wsh/lookup-page-objects state)]
|
||||||
(rx/of (dwc/expand-all-parents ids objects))))))
|
(rx/of (dwc/expand-all-parents ids objects))))))
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@
|
||||||
[]
|
[]
|
||||||
(ptk/reify ::select-all
|
(ptk/reify ::select-all
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
new-selected (let [selected-objs
|
new-selected (let [selected-objs
|
||||||
|
@ -204,7 +204,7 @@
|
||||||
[preserve?]
|
[preserve?]
|
||||||
(ptk/reify ::select-shapes-by-current-selrect
|
(ptk/reify ::select-shapes-by-current-selrect
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state)
|
objects (wsh/lookup-page-objects state)
|
||||||
selected (wsh/lookup-selected state)
|
selected (wsh/lookup-selected state)
|
||||||
|
@ -224,25 +224,23 @@
|
||||||
(rx/map select-shapes))))))))
|
(rx/map select-shapes))))))))
|
||||||
|
|
||||||
(defn select-inside-group
|
(defn select-inside-group
|
||||||
([group-id position] (select-inside-group group-id position false))
|
[group-id position]
|
||||||
([group-id position deep-children]
|
(ptk/reify ::select-inside-group
|
||||||
(ptk/reify ::select-inside-group
|
ptk/WatchEvent
|
||||||
ptk/WatchEvent
|
(watch [_ state _]
|
||||||
(watch [_ state stream]
|
(let [page-id (:current-page-id state)
|
||||||
(let [page-id (:current-page-id state)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
group (get objects group-id)
|
||||||
group (get objects group-id)
|
children (map #(get objects %) (:shapes group))
|
||||||
children (map #(get objects %) (:shapes group))
|
|
||||||
|
|
||||||
;; We need to reverse the children because if two children
|
;; We need to reverse the children because if two children
|
||||||
;; overlap we want to select the one that's over (and it's
|
;; overlap we want to select the one that's over (and it's
|
||||||
;; in the later vector position
|
;; in the later vector position
|
||||||
selected (->> children
|
selected (->> children
|
||||||
reverse
|
reverse
|
||||||
(d/seek #(geom/has-point? % position)))]
|
(d/seek #(geom/has-point? % position)))]
|
||||||
(when selected
|
(when selected
|
||||||
(rx/of (select-shape (:id selected)))))))))
|
(rx/of (select-shape (:id selected))))))))
|
||||||
|
|
||||||
|
|
||||||
;; --- Duplicate Shapes
|
;; --- Duplicate Shapes
|
||||||
(declare prepare-duplicate-change)
|
(declare prepare-duplicate-change)
|
||||||
|
@ -321,7 +319,6 @@
|
||||||
name (dwc/generate-unique-name names (:name obj))
|
name (dwc/generate-unique-name names (:name obj))
|
||||||
renamed-obj (assoc obj :id id :name name)
|
renamed-obj (assoc obj :id id :name name)
|
||||||
moved-obj (geom/move renamed-obj delta)
|
moved-obj (geom/move renamed-obj delta)
|
||||||
frames (cp/select-frames objects)
|
|
||||||
parent-id (or parent-id frame-id)
|
parent-id (or parent-id frame-id)
|
||||||
|
|
||||||
children-changes
|
children-changes
|
||||||
|
@ -378,7 +375,7 @@
|
||||||
(def duplicate-selected
|
(def duplicate-selected
|
||||||
(ptk/reify ::duplicate-selected
|
(ptk/reify ::duplicate-selected
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
selected (wsh/lookup-selected state)
|
selected (wsh/lookup-selected state)
|
||||||
|
|
|
@ -10,14 +10,13 @@
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.data.workspace.colors :as mdc]
|
[app.main.data.workspace.colors :as mdc]
|
||||||
[app.main.data.workspace.common :as dwc]
|
[app.main.data.workspace.common :as dwc]
|
||||||
[app.main.data.workspace.undo :as dwu]
|
|
||||||
[app.main.data.workspace.drawing :as dwd]
|
[app.main.data.workspace.drawing :as dwd]
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.workspace.texts :as dwtxt]
|
[app.main.data.workspace.texts :as dwtxt]
|
||||||
[app.main.data.workspace.transforms :as dwt]
|
[app.main.data.workspace.transforms :as dwt]
|
||||||
|
[app.main.data.workspace.undo :as dwu]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]))
|
||||||
[potok.core :as ptk]))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Shortcuts
|
;; Shortcuts
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.geom.matrix :as gmt]
|
[app.common.geom.matrix :as gmt]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.proportions :as gpr]
|
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
|
@ -18,14 +17,12 @@
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
[app.util.color :as uc]
|
[app.util.color :as uc]
|
||||||
[app.util.object :as obj]
|
|
||||||
[app.util.path.parser :as upp]
|
[app.util.path.parser :as upp]
|
||||||
[app.util.svg :as usvg]
|
[app.util.svg :as usvg]
|
||||||
[app.util.uri :as uu]
|
[app.util.uri :as uu]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[potok.core :as ptk]
|
[potok.core :as ptk]))
|
||||||
[promesa.core :as p]))
|
|
||||||
|
|
||||||
(defonce default-rect {:x 0 :y 0 :width 1 :height 1 :rx 0 :ry 0})
|
(defonce default-rect {:x 0 :y 0 :width 1 :height 1 :rx 0 :ry 0})
|
||||||
(defonce default-circle {:r 0 :cx 0 :cy 0})
|
(defonce default-circle {:r 0 :cx 0 :cy 0})
|
||||||
|
@ -163,7 +160,7 @@
|
||||||
(gsh/setup-selrect))))
|
(gsh/setup-selrect))))
|
||||||
|
|
||||||
(defn create-path-shape [name frame-id svg-data {:keys [attrs] :as data}]
|
(defn create-path-shape [name frame-id svg-data {:keys [attrs] :as data}]
|
||||||
(when (and (contains? attrs :d) (not (empty? (:d attrs)) ))
|
(when (and (contains? attrs :d) (seq (:d attrs)))
|
||||||
(let [svg-transform (usvg/parse-transform (:transform attrs))
|
(let [svg-transform (usvg/parse-transform (:transform attrs))
|
||||||
path-content (upp/parse-path (:d attrs))
|
path-content (upp/parse-path (:d attrs))
|
||||||
content (cond-> path-content
|
content (cond-> path-content
|
||||||
|
@ -387,7 +384,7 @@
|
||||||
[svg-data file-id position]
|
[svg-data file-id position]
|
||||||
(ptk/reify ::svg-uploaded
|
(ptk/reify ::svg-uploaded
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [_ _ _]
|
||||||
;; Once the SVG is uploaded, we need to extract all the bitmap
|
;; Once the SVG is uploaded, we need to extract all the bitmap
|
||||||
;; images and upload them separatelly, then proceed to create
|
;; images and upload them separatelly, then proceed to create
|
||||||
;; all shapes.
|
;; all shapes.
|
||||||
|
@ -414,7 +411,7 @@
|
||||||
[svg-data {:keys [x y] :as position}]
|
[svg-data {:keys [x y] :as position}]
|
||||||
(ptk/reify ::create-svg-shapes
|
(ptk/reify ::create-svg-shapes
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state _]
|
||||||
(try
|
(try
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
|
|
|
@ -16,17 +16,11 @@
|
||||||
[app.main.data.workspace.common :as dwc]
|
[app.main.data.workspace.common :as dwc]
|
||||||
[app.main.data.workspace.selection :as dws]
|
[app.main.data.workspace.selection :as dws]
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[app.main.data.workspace.transforms :as dwt]
|
|
||||||
[app.main.data.workspace.undo :as dwu]
|
[app.main.data.workspace.undo :as dwu]
|
||||||
[app.main.fonts :as fonts]
|
[app.util.router :as rt]
|
||||||
[app.util.object :as obj]
|
|
||||||
[app.util.text-editor :as ted]
|
[app.util.text-editor :as ted]
|
||||||
[app.util.timers :as ts]
|
[app.util.timers :as ts]
|
||||||
[app.util.router :as rt]
|
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[cljs.spec.alpha :as s]
|
|
||||||
[cuerdas.core :as str]
|
|
||||||
[goog.object :as gobj]
|
|
||||||
[potok.core :as ptk]))
|
[potok.core :as ptk]))
|
||||||
|
|
||||||
(defn update-editor
|
(defn update-editor
|
||||||
|
@ -42,7 +36,7 @@
|
||||||
[]
|
[]
|
||||||
(ptk/reify ::focus-editor
|
(ptk/reify ::focus-editor
|
||||||
ptk/EffectEvent
|
ptk/EffectEvent
|
||||||
(effect [_ state stream]
|
(effect [_ state _]
|
||||||
(when-let [editor (:workspace-editor state)]
|
(when-let [editor (:workspace-editor state)]
|
||||||
(ts/schedule #(.focus ^js editor))))))
|
(ts/schedule #(.focus ^js editor))))))
|
||||||
|
|
||||||
|
@ -59,7 +53,7 @@
|
||||||
[{:keys [id] :as shape}]
|
[{:keys [id] :as shape}]
|
||||||
(ptk/reify ::finalize-editor-state
|
(ptk/reify ::finalize-editor-state
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(let [content (-> (get-in state [:workspace-editor-state id])
|
(let [content (-> (get-in state [:workspace-editor-state id])
|
||||||
(ted/get-editor-current-content))]
|
(ted/get-editor-current-content))]
|
||||||
|
|
||||||
|
@ -88,7 +82,7 @@
|
||||||
decorator))))
|
decorator))))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ _ stream]
|
||||||
;; We need to finalize editor on two main events: (1) when user
|
;; We need to finalize editor on two main events: (1) when user
|
||||||
;; explicitly navigates to other section or page; (2) when user
|
;; explicitly navigates to other section or page; (2) when user
|
||||||
;; leaves the editor.
|
;; leaves the editor.
|
||||||
|
@ -149,7 +143,7 @@
|
||||||
[{:keys [id attrs]}]
|
[{:keys [id attrs]}]
|
||||||
(ptk/reify ::update-root-attrs
|
(ptk/reify ::update-root-attrs
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(let [objects (wsh/lookup-page-objects state)
|
(let [objects (wsh/lookup-page-objects state)
|
||||||
shape (get objects id)
|
shape (get objects id)
|
||||||
|
|
||||||
|
@ -168,7 +162,7 @@
|
||||||
(d/update-in-when state [:workspace-editor-state id] ted/update-editor-current-block-data attrs))
|
(d/update-in-when state [:workspace-editor-state id] ted/update-editor-current-block-data attrs))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(when-not (some? (get-in state [:workspace-editor-state id]))
|
(when-not (some? (get-in state [:workspace-editor-state id]))
|
||||||
(let [objects (wsh/lookup-page-objects state)
|
(let [objects (wsh/lookup-page-objects state)
|
||||||
shape (get objects id)
|
shape (get objects id)
|
||||||
|
@ -195,7 +189,7 @@
|
||||||
(d/update-in-when state [:workspace-editor-state id] ted/update-editor-current-inline-styles attrs))
|
(d/update-in-when state [:workspace-editor-state id] ted/update-editor-current-inline-styles attrs))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(when-not (some? (get-in state [:workspace-editor-state id]))
|
(when-not (some? (get-in state [:workspace-editor-state id]))
|
||||||
(let [objects (wsh/lookup-page-objects state)
|
(let [objects (wsh/lookup-page-objects state)
|
||||||
shape (get objects id)
|
shape (get objects id)
|
||||||
|
@ -232,7 +226,7 @@
|
||||||
(defn resize-text-batch [changes]
|
(defn resize-text-batch [changes]
|
||||||
(ptk/reify ::resize-text-batch
|
(ptk/reify ::resize-text-batch
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (get-in state [:workspace-data :pages-index page-id :objects])]
|
objects (get-in state [:workspace-data :pages-index page-id :objects])]
|
||||||
(if-not (every? #(contains? objects(first %)) changes)
|
(if-not (every? #(contains? objects(first %)) changes)
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
[app.common.geom.matrix :as gmt]
|
[app.common.geom.matrix :as gmt]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.math :as mth]
|
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.main.data.workspace.changes :as dch]
|
[app.main.data.workspace.changes :as dch]
|
||||||
|
@ -19,13 +18,10 @@
|
||||||
[app.main.data.workspace.selection :as dws]
|
[app.main.data.workspace.selection :as dws]
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[app.main.data.workspace.undo :as dwu]
|
[app.main.data.workspace.undo :as dwu]
|
||||||
[app.main.refs :as refs]
|
|
||||||
[app.main.snap :as snap]
|
[app.main.snap :as snap]
|
||||||
[app.main.store :as st]
|
|
||||||
[app.main.streams :as ms]
|
[app.main.streams :as ms]
|
||||||
[app.util.path.shapes-to-path :as ups]
|
[app.util.path.shapes-to-path :as ups]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[beicon.core :as rx]
|
|
||||||
[cljs.spec.alpha :as s]
|
[cljs.spec.alpha :as s]
|
||||||
[potok.core :as ptk]))
|
[potok.core :as ptk]))
|
||||||
|
|
||||||
|
|
|
@ -6,21 +6,10 @@
|
||||||
|
|
||||||
(ns app.main.data.workspace.undo
|
(ns app.main.data.workspace.undo
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
|
||||||
[app.common.geom.proportions :as gpr]
|
|
||||||
[app.common.geom.shapes :as gsh]
|
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.common.pages.spec :as spec]
|
[app.common.pages.spec :as spec]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.main.worker :as uw]
|
|
||||||
[app.main.streams :as ms]
|
|
||||||
[app.util.logging :as log]
|
|
||||||
[app.util.timers :as ts]
|
|
||||||
[beicon.core :as rx]
|
|
||||||
[cljs.spec.alpha :as s]
|
[cljs.spec.alpha :as s]
|
||||||
[clojure.set :as set]
|
|
||||||
[cuerdas.core :as str]
|
|
||||||
[potok.core :as ptk]))
|
[potok.core :as ptk]))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -42,7 +31,7 @@
|
||||||
(subvec undo (- cnt MAX-UNDO-SIZE))
|
(subvec undo (- cnt MAX-UNDO-SIZE))
|
||||||
undo)))
|
undo)))
|
||||||
|
|
||||||
(defn- materialize-undo
|
(defn materialize-undo
|
||||||
[changes index]
|
[changes index]
|
||||||
(ptk/reify ::materialize-undo
|
(ptk/reify ::materialize-undo
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
|
@ -51,15 +40,6 @@
|
||||||
(update :workspace-data cp/process-changes changes)
|
(update :workspace-data cp/process-changes changes)
|
||||||
(assoc-in [:workspace-undo :index] index)))))
|
(assoc-in [:workspace-undo :index] index)))))
|
||||||
|
|
||||||
(defn- reset-undo
|
|
||||||
[index]
|
|
||||||
(ptk/reify ::reset-undo
|
|
||||||
ptk/UpdateEvent
|
|
||||||
(update [_ state]
|
|
||||||
(-> state
|
|
||||||
(update :workspace-undo dissoc :undo-index)
|
|
||||||
(update-in [:workspace-undo :items] (fn [queue] (into [] (take (inc index) queue))))))))
|
|
||||||
|
|
||||||
(defn- add-undo-entry
|
(defn- add-undo-entry
|
||||||
[state entry]
|
[state entry]
|
||||||
(if (and entry
|
(if (and entry
|
||||||
|
@ -81,7 +61,7 @@
|
||||||
(update-in [:workspace-undo :transaction :undo-changes] #(into undo-changes %))
|
(update-in [:workspace-undo :transaction :undo-changes] #(into undo-changes %))
|
||||||
(update-in [:workspace-undo :transaction :redo-changes] #(into % redo-changes))))
|
(update-in [:workspace-undo :transaction :redo-changes] #(into % redo-changes))))
|
||||||
|
|
||||||
(defn- append-undo
|
(defn append-undo
|
||||||
[entry]
|
[entry]
|
||||||
(us/assert ::undo-entry entry)
|
(us/assert ::undo-entry entry)
|
||||||
(ptk/reify ::append-undo
|
(ptk/reify ::append-undo
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
[app.main.ui.shapes.circle :as circle]
|
[app.main.ui.shapes.circle :as circle]
|
||||||
[app.main.ui.shapes.embed :as embed]
|
[app.main.ui.shapes.embed :as embed]
|
||||||
[app.main.ui.shapes.export :as use]
|
[app.main.ui.shapes.export :as use]
|
||||||
[app.main.ui.shapes.filters :as filters]
|
|
||||||
[app.main.ui.shapes.frame :as frame]
|
[app.main.ui.shapes.frame :as frame]
|
||||||
[app.main.ui.shapes.group :as group]
|
[app.main.ui.shapes.group :as group]
|
||||||
[app.main.ui.shapes.image :as image]
|
[app.main.ui.shapes.image :as image]
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
(ns app.main.fonts
|
(ns app.main.fonts
|
||||||
"A fonts loading macros."
|
"A fonts loading macros."
|
||||||
(:require
|
(:require
|
||||||
[cuerdas.core :as str]
|
[clojure.data.json :as json]
|
||||||
[clojure.java.io :as io]
|
[clojure.java.io :as io]
|
||||||
[clojure.data.json :as json]))
|
[cuerdas.core :as str]))
|
||||||
|
|
||||||
(defn- parse-gfont-variant
|
(defn- parse-gfont-variant
|
||||||
[variant]
|
[variant]
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
[app.util.http :as http]
|
[app.util.http :as http]
|
||||||
[app.util.logging :as log]
|
[app.util.logging :as log]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[app.util.timers :as ts]
|
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[clojure.set :as set]
|
[clojure.set :as set]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
|
@ -104,7 +103,7 @@
|
||||||
[url on-loaded]
|
[url on-loaded]
|
||||||
(let [node (create-link-element url)
|
(let [node (create-link-element url)
|
||||||
head (.-head ^js js/document)]
|
head (.-head ^js js/document)]
|
||||||
(gev/listenOnce node "load" (fn [event]
|
(gev/listenOnce node "load" (fn [_]
|
||||||
(when (fn? on-loaded)
|
(when (fn? on-loaded)
|
||||||
(on-loaded))))
|
(on-loaded))))
|
||||||
(dom/append-child! head node)))
|
(dom/append-child! head node)))
|
||||||
|
@ -140,7 +139,7 @@
|
||||||
(str base ":" variants "&display=block")))
|
(str base ":" variants "&display=block")))
|
||||||
|
|
||||||
(defmethod load-font :google
|
(defmethod load-font :google
|
||||||
[{:keys [id family variants ::on-loaded] :as font}]
|
[{:keys [id ::on-loaded] :as font}]
|
||||||
(when (exists? js/window)
|
(when (exists? js/window)
|
||||||
(log/debug :action "load-font" :font-id id :backend "google")
|
(log/debug :action "load-font" :font-id id :backend "google")
|
||||||
(let [url (generate-gfonts-url font)]
|
(let [url (generate-gfonts-url font)]
|
||||||
|
@ -183,11 +182,13 @@
|
||||||
(str/join "\n")))
|
(str/join "\n")))
|
||||||
|
|
||||||
(defmethod load-font :custom
|
(defmethod load-font :custom
|
||||||
[{:keys [id family variants ::on-loaded] :as font}]
|
[{:keys [id ::on-loaded] :as font}]
|
||||||
(when (exists? js/window)
|
(when (exists? js/window)
|
||||||
(js/console.log "[debug:fonts]: loading custom font" id)
|
(js/console.log "[debug:fonts]: loading custom font" id)
|
||||||
(let [css (generate-custom-font-css font)]
|
(let [css (generate-custom-font-css font)]
|
||||||
(add-font-css! css))))
|
(add-font-css! css)
|
||||||
|
(when (fn? on-loaded)
|
||||||
|
(on-loaded)))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; LOAD API
|
;; LOAD API
|
||||||
|
|
|
@ -10,11 +10,8 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.main.constants :as c]
|
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[beicon.core :as rx]
|
|
||||||
[okulary.core :as l]))
|
[okulary.core :as l]))
|
||||||
|
|
||||||
;; ---- Global refs
|
;; ---- Global refs
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
["react-dom/server" :as rds]
|
["react-dom/server" :as rds]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.main.exports :as exports]
|
[app.main.exports :as exports]
|
||||||
[app.main.exports :as svg]
|
|
||||||
[app.main.fonts :as fonts]
|
[app.main.fonts :as fonts]
|
||||||
[app.util.http :as http]
|
[app.util.http :as http]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
|
@ -31,16 +30,13 @@
|
||||||
[]))
|
[]))
|
||||||
|
|
||||||
(defn populate-images-cache
|
(defn populate-images-cache
|
||||||
([data]
|
[data]
|
||||||
(populate-images-cache data nil))
|
(let [images (->> (:objects data)
|
||||||
|
(vals)
|
||||||
([data {:keys [resolve-media?] :or {resolve-media? false}}]
|
(mapcat get-image-data))]
|
||||||
(let [images (->> (:objects data)
|
(->> (rx/from images)
|
||||||
(vals)
|
(rx/map #(cfg/resolve-file-media %))
|
||||||
(mapcat get-image-data))]
|
(rx/flat-map http/fetch-data-uri))))
|
||||||
(->> (rx/from images)
|
|
||||||
(rx/map #(cfg/resolve-file-media %))
|
|
||||||
(rx/flat-map http/fetch-data-uri)))))
|
|
||||||
|
|
||||||
(defn populate-fonts-cache [data]
|
(defn populate-fonts-cache [data]
|
||||||
(let [texts (->> (:objects data)
|
(let [texts (->> (:objects data)
|
||||||
|
|
|
@ -10,9 +10,7 @@
|
||||||
[app.common.uri :as u]
|
[app.common.uri :as u]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.util.http :as http]
|
[app.util.http :as http]
|
||||||
[app.util.time :as dt]
|
[beicon.core :as rx]))
|
||||||
[beicon.core :as rx]
|
|
||||||
[cuerdas.core :as str]))
|
|
||||||
|
|
||||||
(defn handle-response
|
(defn handle-response
|
||||||
[{:keys [status body] :as response}]
|
[{:keys [status body] :as response}]
|
||||||
|
@ -86,7 +84,7 @@
|
||||||
([id params] (mutation id params)))
|
([id params] (mutation id params)))
|
||||||
|
|
||||||
(defmethod mutation :login-with-oauth
|
(defmethod mutation :login-with-oauth
|
||||||
[id {:keys [provider] :as params}]
|
[_ {:keys [provider] :as params}]
|
||||||
(let [uri (u/join base-uri "api/auth/oauth/" (d/name provider))
|
(let [uri (u/join base-uri "api/auth/oauth/" (d/name provider))
|
||||||
params (dissoc params :provider)]
|
params (dissoc params :provider)]
|
||||||
(->> (http/send! {:method :post :uri uri :query params})
|
(->> (http/send! {:method :post :uri uri :query params})
|
||||||
|
@ -94,7 +92,7 @@
|
||||||
(rx/mapcat handle-response))))
|
(rx/mapcat handle-response))))
|
||||||
|
|
||||||
(defmethod mutation :send-feedback
|
(defmethod mutation :send-feedback
|
||||||
[id params]
|
[_ params]
|
||||||
(->> (http/send! {:method :post
|
(->> (http/send! {:method :post
|
||||||
:uri (u/join base-uri "api/feedback")
|
:uri (u/join base-uri "api/feedback")
|
||||||
:body (http/transit-data params)})
|
:body (http/transit-data params)})
|
||||||
|
@ -102,7 +100,7 @@
|
||||||
(rx/mapcat handle-response)))
|
(rx/mapcat handle-response)))
|
||||||
|
|
||||||
(defmethod query :export
|
(defmethod query :export
|
||||||
[id params]
|
[_ params]
|
||||||
(->> (http/send! {:method :post
|
(->> (http/send! {:method :post
|
||||||
:uri (u/join base-uri "export")
|
:uri (u/join base-uri "export")
|
||||||
:body (http/transit-data params)
|
:body (http/transit-data params)
|
||||||
|
|
|
@ -19,24 +19,24 @@
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[clojure.set :as set]))
|
[clojure.set :as set]))
|
||||||
|
|
||||||
(defonce ^:private snap-accuracy 5)
|
(def ^:const snap-accuracy 5)
|
||||||
(defonce ^:private snap-path-accuracy 10)
|
(def ^:const snap-path-accuracy 10)
|
||||||
(defonce ^:private snap-distance-accuracy 10)
|
(def ^:const snap-distance-accuracy 10)
|
||||||
|
|
||||||
(defn- remove-from-snap-points
|
(defn- remove-from-snap-points
|
||||||
[remove-id?]
|
[remove-id?]
|
||||||
(fn [query-result]
|
(fn [query-result]
|
||||||
(->> query-result
|
(->> query-result
|
||||||
(map (fn [[value data]] [value (remove (comp remove-id? second) data)]))
|
(map (fn [[value data]] [value (remove (comp remove-id? second) data)]))
|
||||||
(filter (fn [[_ data]] (not (empty? data)))))))
|
(filter (fn [[_ data]] (seq data))))))
|
||||||
|
|
||||||
(defn- flatten-to-points
|
(defn- flatten-to-points
|
||||||
[query-result]
|
[query-result]
|
||||||
(mapcat (fn [[v data]] (map (fn [[point _]] point) data)) query-result))
|
(mapcat (fn [[_ data]] (map (fn [[point _]] point) data)) query-result))
|
||||||
|
|
||||||
(defn- calculate-distance [query-result point coord]
|
(defn- calculate-distance [query-result point coord]
|
||||||
(->> query-result
|
(->> query-result
|
||||||
(map (fn [[value data]] [(mth/abs (- value (coord point))) [(coord point) value]]))))
|
(map (fn [[value _]] [(mth/abs (- value (coord point))) [(coord point) value]]))))
|
||||||
|
|
||||||
(defn- get-min-distance-snap [points coord]
|
(defn- get-min-distance-snap [points coord]
|
||||||
(fn [query-result]
|
(fn [query-result]
|
||||||
|
@ -286,8 +286,9 @@
|
||||||
(fn [matches other]
|
(fn [matches other]
|
||||||
|
|
||||||
(let [matches (into {} matches)
|
(let [matches (into {} matches)
|
||||||
other (into {} other)
|
other (into {} other)
|
||||||
keys (set/union (keys matches) (keys other))]
|
keys (set/union (set (keys matches))
|
||||||
|
(set (keys other)))]
|
||||||
(into {}
|
(into {}
|
||||||
(map (fn [key]
|
(map (fn [key]
|
||||||
[key
|
[key
|
||||||
|
@ -308,7 +309,7 @@
|
||||||
|
|
||||||
min-match-coord
|
min-match-coord
|
||||||
(fn [matches]
|
(fn [matches]
|
||||||
(if (and (seq matches) (not (empty? matches)))
|
(if (seq matches)
|
||||||
(->> matches (reduce get-min))
|
(->> matches (reduce get-min))
|
||||||
default))]
|
default))]
|
||||||
|
|
||||||
|
|
|
@ -75,12 +75,12 @@
|
||||||
(logjs "state" (get-in @state [:workspace-data :pages-index page-id :objects]))))
|
(logjs "state" (get-in @state [:workspace-data :pages-index page-id :objects]))))
|
||||||
|
|
||||||
(defn ^:export dump-object [name]
|
(defn ^:export dump-object [name]
|
||||||
(let [page-id (get @state :current-page-id)]
|
(let [page-id (get @state :current-page-id)
|
||||||
(let [objects (get-in @state [:workspace-data :pages-index page-id :objects])
|
objects (get-in @state [:workspace-data :pages-index page-id :objects])
|
||||||
target (or (d/seek (fn [[id shape]] (= name (:name shape))) objects)
|
target (or (d/seek (fn [[_ shape]] (= name (:name shape))) objects)
|
||||||
(get objects (uuid name)))]
|
(get objects (uuid name)))]
|
||||||
(->> target
|
(->> target
|
||||||
(logjs "state")))))
|
(logjs "state"))))
|
||||||
|
|
||||||
(defn ^:export dump-tree
|
(defn ^:export dump-tree
|
||||||
([] (dump-tree false false))
|
([] (dump-tree false false))
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
(let [page-id (get @state :current-page-id)
|
(let [page-id (get @state :current-page-id)
|
||||||
objects (get-in @state [:workspace-data :pages-index page-id :objects])
|
objects (get-in @state [:workspace-data :pages-index page-id :objects])
|
||||||
components (get-in @state [:workspace-data :components])
|
components (get-in @state [:workspace-data :components])
|
||||||
libraries (get-in @state [:workspace-libraries])
|
libraries (get @state :workspace-libraries)
|
||||||
root (d/seek #(nil? (:parent-id %)) (vals objects))]
|
root (d/seek #(nil? (:parent-id %)) (vals objects))]
|
||||||
|
|
||||||
(letfn [(show-shape [shape-id level objects]
|
(letfn [(show-shape [shape-id level objects]
|
||||||
|
|
|
@ -7,12 +7,10 @@
|
||||||
(ns app.main.streams
|
(ns app.main.streams
|
||||||
"User interaction events and streams."
|
"User interaction events and streams."
|
||||||
(:require
|
(:require
|
||||||
[beicon.core :as rx]
|
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.refs :as refs]
|
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.util.globals :as globals]
|
[app.util.globals :as globals]
|
||||||
[app.util.keyboard :as kbd]))
|
[app.util.keyboard :as kbd]
|
||||||
|
[beicon.core :as rx]))
|
||||||
|
|
||||||
;; --- User Events
|
;; --- User Events
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,7 @@
|
||||||
|
|
||||||
(ns app.main.worker
|
(ns app.main.worker
|
||||||
(:require
|
(:require
|
||||||
[cljs.spec.alpha :as s]
|
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.common.spec :as us]
|
|
||||||
[app.util.worker :as uw]))
|
[app.util.worker :as uw]))
|
||||||
|
|
||||||
(defn on-error
|
(defn on-error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue