From b2dc849e525b5781e0bd1c715e527cc4240980e3 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 26 May 2021 16:29:57 +0200 Subject: [PATCH 1/4] :sparkles: Improve editor lifecycle management. --- .../src/app/main/data/workspace/texts.cljs | 35 +++++++++++++------ .../main/ui/workspace/shapes/text/editor.cljs | 2 +- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/frontend/src/app/main/data/workspace/texts.cljs b/frontend/src/app/main/data/workspace/texts.cljs index c35e621bd..f789a50ff 100644 --- a/frontend/src/app/main/data/workspace/texts.cljs +++ b/frontend/src/app/main/data/workspace/texts.cljs @@ -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." diff --git a/frontend/src/app/main/ui/workspace/shapes/text/editor.cljs b/frontend/src/app/main/ui/workspace/shapes/text/editor.cljs index 1cdca4aaf..9e2cb3b97 100644 --- a/frontend/src/app/main/ui/workspace/shapes/text/editor.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/text/editor.cljs @@ -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))))) From cad2b831ed85d235d37e206dea37a01dd9a16d30 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 26 May 2021 16:30:23 +0200 Subject: [PATCH 2/4] :sparkles: Make the navigation async by default. This leaves some time to eventloop to terminate other async events before navigate. --- frontend/src/app/util/router.cljs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/util/router.cljs b/frontend/src/app/util/router.cljs index 0fc55dc8f..d7945580d 100644 --- a/frontend/src/app/util/router.cljs +++ b/frontend/src/app/util/router.cljs @@ -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)) From 7eb3693804eb3d09434b8b1c8bd802d0c10ed438 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 26 May 2021 16:56:59 +0200 Subject: [PATCH 3/4] :paperclip: Update changelog. --- CHANGES.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index d010a459d..bea7ce73e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 From 96d9e101cc6b79fc5f00f221154aba26cf108cd3 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 26 May 2021 16:57:34 +0200 Subject: [PATCH 4/4] :paperclip: Update version.txt file. --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index f721a9b5e..63fe0b565 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.6.0-alpha +1.6.1-alpha