Compare commits

...

12 Commits

Author SHA1 Message Date
Andrey Antukh
96d9e101cc 📎 Update version.txt file. 2021-05-26 16:57:34 +02:00
Andrey Antukh
7eb3693804 📎 Update changelog. 2021-05-26 16:56:59 +02:00
Andrey Antukh
cad2b831ed Make the navigation async by default.
This leaves some time to eventloop to terminate other
async events before navigate.
2021-05-26 16:38:03 +02:00
Andrey Antukh
b2dc849e52 Improve editor lifecycle management. 2021-05-26 16:38:03 +02:00
alonso.torres
0de8bfeba6 🐛 Fix problem when creating a component with empty data 2021-05-26 16:12:29 +02:00
Andrey Antukh
6710d99878 🐛 Fix dashboard ordering issue. 2021-05-26 15:22:41 +02:00
alonso.torres
7a32d902ec 🐛 Fix problem with moving shapes into frames 2021-05-26 14:33:55 +02:00
alonso.torres
52f699c175 🐛 Fix problems with mov-objects 2021-05-26 13:43:57 +02:00
Andrey Antukh
ba211e3cbd 🐛 Fix wrong type usage on libraries changes. 2021-05-26 13:31:07 +02:00
Andrey Antukh
897f41bc7a Fix custom fonts embbedding issue. 2021-05-26 12:39:41 +02:00
Andrey Antukh
2834850337 📎 Add safety check on reg-objects change impl. 2021-05-26 12:14:02 +02:00
Andrey Antukh
67cd877281 🐛 Fix unexpected excetion related to rounding integers. 2021-05-26 11:54:40 +02:00
13 changed files with 154 additions and 110 deletions

View File

@@ -11,6 +11,22 @@
### :heart: Community contributions by (Thank you!)
## 1.6.1-alpha
### :bug: Bugs fixed
- Make the navigation async by default.
- Improve editor lifecycle management.
- Fix problem when creating a component with empty data.
- Fix dashboard ordering issue.
- Fix problem with moving shapes into frames.
- Fix problems with mov-objects.
- Fix wrong type usage on libraries changes.
- Fix custom fonts embbedding issue.
- Add safety check on reg-objects change impl.
- Fix unexpected excetion related to rounding integers.
## 1.6.0-alpha
### :sparkles: New features

View File

@@ -96,7 +96,7 @@
the nearest integer."
[v]
#?(:cljs (js/Math.round v)
:clj (Math/round v)))
:clj (Math/round (float v))))
(defn ceil
"Returns the smallest integer greater than

View File

@@ -142,7 +142,7 @@
(defmethod process-change :reg-objects
[data {:keys [page-id component-id shapes]}]
(letfn [(reg-objects [objects]
(reduce #(update %1 %2 update-group %1) objects
(reduce #(d/update-when %1 %2 update-group %1) objects
(sequence (comp
(mapcat #(cons % (cph/get-parents % objects)))
(map #(get objects %))
@@ -221,28 +221,31 @@
;; the new destination target parent id.
(if (= prev-parent-id parent-id)
objects
(loop [sid shape-id
pid prev-parent-id
objects objects]
(let [obj (get objects pid)]
(cond-> objects
true
(update-in [pid :shapes] strip-id sid)
(let [sid shape-id
pid prev-parent-id
obj (get objects pid)
component? (and (:shape-ref obj)
(= (:type obj) :group)
(not ignore-touched))]
(and (:shape-ref obj)
(= (:type obj) :group)
(not ignore-touched))
(->
(update-in [pid :touched]
cph/set-touched-group :shapes-group)
(d/dissoc-in [pid :remote-synced?]))))))))
(-> objects
(d/update-in-when [pid :shapes] strip-id sid)
(cond-> component?
(d/update-when
pid
#(-> %
(update :touched cph/set-touched-group :shapes-group)
(dissoc :remote-synced?)))))))))
(update-parent-id [objects id]
(assoc-in objects [id :parent-id] parent-id))
(-> objects
(d/update-when id assoc :parent-id parent-id)))
;; Updates the frame-id references that might be outdated
(assign-frame-id [frame-id objects id]
(let [objects (update objects id assoc :frame-id frame-id)
(let [objects (-> objects
(d/update-when id assoc :frame-id frame-id))
obj (get objects id)]
(cond-> objects
;; If we moving frame, the parent frame is the root

View File

@@ -181,7 +181,7 @@
(defn calculate-invalid-targets
[shape-id objects]
(let [result #{shape-id}
children (get-in objects [shape-id :shape])
children (get-in objects [shape-id :shapes])
reduce-fn (fn [result child-id]
(into result (calculate-invalid-targets child-id objects)))]
(reduce reduce-fn result children)))

View File

@@ -115,7 +115,6 @@
[{:keys [redo-changes undo-changes origin save-undo? file-id]
:or {save-undo? true}}]
(log/debug :msg "commit-changes"
:js/redo-changes redo-changes
:js/undo-changes undo-changes)

View File

@@ -264,13 +264,14 @@
objects (wsh/lookup-page-objects state page-id)
selected (wsh/lookup-selected state)
selected (cp/clean-loops objects selected)]
(let [[group rchanges uchanges]
(dwlh/generate-add-component selected objects page-id file-id)]
(when-not (empty? rchanges)
(rx/of (dch/commit-changes {:redo-changes rchanges
:undo-changes uchanges
:origin it})
(dwc/select-shapes (d/ordered-set (:id group))))))))))
(when-not (empty? selected)
(let [[group rchanges uchanges]
(dwlh/generate-add-component selected objects page-id file-id)]
(when-not (empty? rchanges)
(rx/of (dch/commit-changes {:redo-changes rchanges
:undo-changes uchanges
:origin it})
(dwc/select-shapes (d/ordered-set (:id group)))))))))))
(defn rename-component
"Rename the component with the given id, in the current file library."
@@ -414,22 +415,22 @@
(get component :objects)
update-new-shape)
rchanges (map (fn [obj]
{:type :add-obj
:id (:id obj)
:page-id page-id
:frame-id (:frame-id obj)
:parent-id (:parent-id obj)
:ignore-touched true
:obj obj})
new-shapes)
rchanges (mapv (fn [obj]
{:type :add-obj
:id (:id obj)
:page-id page-id
:frame-id (:frame-id obj)
:parent-id (:parent-id obj)
:ignore-touched true
:obj obj})
new-shapes)
uchanges (map (fn [obj]
{:type :del-obj
:id (:id obj)
:page-id page-id
:ignore-touched true})
new-shapes)]
uchanges (mapv (fn [obj]
{:type :del-obj
:id (:id obj)
:page-id page-id
:ignore-touched true})
new-shapes)]
(rx/of (dch/commit-changes {:redo-changes rchanges
:undo-changes uchanges
@@ -448,53 +449,53 @@
objects (wsh/lookup-page-objects state page-id)
shapes (cp/get-object-with-children id objects)
rchanges (map (fn [obj]
{:type :mod-obj
:page-id page-id
:id (:id obj)
:operations [{:type :set
:attr :component-id
:val nil}
{:type :set
:attr :component-file
:val nil}
{:type :set
:attr :component-root?
:val nil}
{:type :set
:attr :remote-synced?
:val nil}
{:type :set
:attr :shape-ref
:val nil}
{:type :set
:attr :touched
:val nil}]})
shapes)
rchanges (mapv (fn [obj]
{:type :mod-obj
:page-id page-id
:id (:id obj)
:operations [{:type :set
:attr :component-id
:val nil}
{:type :set
:attr :component-file
:val nil}
{:type :set
:attr :component-root?
:val nil}
{:type :set
:attr :remote-synced?
:val nil}
{:type :set
:attr :shape-ref
:val nil}
{:type :set
:attr :touched
:val nil}]})
shapes)
uchanges (map (fn [obj]
{:type :mod-obj
:page-id page-id
:id (:id obj)
:operations [{:type :set
:attr :component-id
:val (:component-id obj)}
{:type :set
:attr :component-file
:val (:component-file obj)}
{:type :set
:attr :component-root?
:val (:component-root? obj)}
{:type :set
:attr :remote-synced?
:val (:remote-synced? obj)}
{:type :set
:attr :shape-ref
:val (:shape-ref obj)}
{:type :set
:attr :touched
:val (:touched obj)}]})
shapes)]
uchanges (mapv (fn [obj]
{:type :mod-obj
:page-id page-id
:id (:id obj)
:operations [{:type :set
:attr :component-id
:val (:component-id obj)}
{:type :set
:attr :component-file
:val (:component-file obj)}
{:type :set
:attr :component-root?
:val (:component-root? obj)}
{:type :set
:attr :remote-synced?
:val (:remote-synced? obj)}
{:type :set
:attr :shape-ref
:val (:shape-ref obj)}
{:type :set
:attr :touched
:val (:touched obj)}]})
shapes)]
(rx/of (dch/commit-changes {:redo-changes rchanges
:undo-changes uchanges

View File

@@ -22,6 +22,7 @@
[app.util.object :as obj]
[app.util.text-editor :as ted]
[app.util.timers :as ts]
[app.util.router :as rt]
[beicon.core :as rx]
[cljs.spec.alpha :as s]
[cuerdas.core :as str]
@@ -54,17 +55,6 @@
(update state :workspace-editor-state assoc id editor-state)
(update state :workspace-editor-state dissoc id)))))
(defn initialize-editor-state
[{:keys [id content] :as shape} decorator]
(ptk/reify ::initialize-editor-state
ptk/UpdateEvent
(update [_ state]
(update-in state [:workspace-editor-state id]
(fn [_]
(ted/create-editor-state
(some->> content ted/import-content)
decorator))))))
(defn finalize-editor-state
[{:keys [id] :as shape}]
(ptk/reify ::finalize-editor-state
@@ -72,6 +62,7 @@
(watch [_ state stream]
(let [content (-> (get-in state [:workspace-editor-state id])
(ted/get-editor-current-content))]
(if (ted/content-has-text? content)
(let [content (d/merge (ted/export-content content)
(dissoc (:content shape) :children))]
@@ -85,6 +76,28 @@
(rx/of (dws/deselect-shape id)
(dwc/delete-shapes [id])))))))
(defn initialize-editor-state
[{:keys [id content] :as shape} decorator]
(ptk/reify ::initialize-editor-state
ptk/UpdateEvent
(update [_ state]
(update-in state [:workspace-editor-state id]
(fn [_]
(ted/create-editor-state
(some->> content ted/import-content)
decorator))))
ptk/WatchEvent
(watch [_ state stream]
;; We need to finalize editor on two main events: (1) when user
;; explicitly navigates to other section or page; (2) when user
;; leaves the editor.
(->> (rx/merge
(rx/filter (ptk/type? ::rt/navigate) stream)
(rx/filter #(= ::finalize-editor-state %) stream))
(rx/take 1)
(rx/map #(finalize-editor-state shape))))))
(defn select-all
"Select all content of the current editor. When not editor found this
event is noop."

View File

@@ -282,7 +282,8 @@
moving-shapes (->> ids
(cp/clean-loops objects)
(map #(get objects %))
(remove #(= (:frame-id %) frame-id)))
(remove #(or (nil? %)
(= (:frame-id %) frame-id))))
rch [{:type :mov-objects
:page-id page-id

View File

@@ -171,7 +171,8 @@
(for [{:keys [id] :as project} projects]
(let [files (when recent-map
(->> (vals recent-map)
(filterv #(= id (:project-id %)))))]
(filterv #(= id (:project-id %)))
(sort-by :modified-at #(compare %2 %1))))]
[:& project-item {:project project
:files files
:first? (= project (first projects))

View File

@@ -61,7 +61,8 @@
(defn get-font-css
"Given a font and the variant-id, retrieves the style CSS for it."
[{:keys [id backend family variants] :as font} font-variant-id]
(if (= :google backend)
(cond
(= :google backend)
(let [uri (fonts/generate-gfonts-url {:family family :variants [{:id font-variant-id}]})]
(->> (http/send! {:method :get
:mode :cors
@@ -70,6 +71,14 @@
:response-type :text})
(rx/map :body)
(http/as-promise)))
(= :custom backend)
(let [variant (d/seek #(= (:id %) font-variant-id) variants)
result (fonts/generate-custom-font-variant-css family variant)]
(p/resolved result))
:else
(let [{:keys [name weight style suffix] :as variant} (d/seek #(= (:id %) font-variant-id) variants)
result (str/fmt font-face-template {:family family
:style style

View File

@@ -95,7 +95,7 @@
(st/emit! (dwt/initialize-editor-state shape default-decorator)
(dwt/select-all shape))
#(do
(st/emit! (dwt/finalize-editor-state shape))
(st/emit! ::dwt/finalize-editor-state)
(doseq [key keys]
(events/unlistenByKey key)))))

View File

@@ -84,12 +84,13 @@
ptk/EffectEvent
(effect [_ state stream]
(let [router (:router state)
history (:history state)
path (resolve router id params qparams)]
(if ^boolean replace
(bhistory/replace-token! history path)
(bhistory/set-token! history path))))))
(ts/asap
#(let [router (:router state)
history (:history state)
path (resolve router id params qparams)]
(if ^boolean replace
(bhistory/replace-token! history path)
(bhistory/set-token! history path)))))))
(defn nav
([id] (nav id nil nil))

View File

@@ -1 +1 @@
1.6.0-alpha
1.6.1-alpha