From f47bb6bcd03dcee777787e75bafde6a5d02d28d4 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 27 May 2021 18:12:29 +0200 Subject: [PATCH] :sparkles: Minor fix on previous commit. --- common/app/common/text.cljc | 22 ++++--------------- frontend/tests/app/test_draft_conversion.cljs | 4 ++-- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/common/app/common/text.cljc b/common/app/common/text.cljc index 6f3613eca..a3d1e97fd 100644 --- a/common/app/common/text.cljc +++ b/common/app/common/text.cljc @@ -82,27 +82,13 @@ (defn encode-style-value [v] - (cond - (uuid? v) (str "u:" v) - (string? v) (str "s:" v) - (number? v) (str "n:" v) - (keyword? v) (str "k:" (name v)) - (map? v) (str "m:" (t/encode v)) - (nil? v) (str "z:null") - :else (str "o:" v))) + #?(:cljs (t/encode v) + :clj (t/encode-str v))) (defn decode-style-value [v] - (let [prefix (subs v 0 2)] - (case prefix - "s:" (subs v 2) - "n:" (js/Number (subs v 2)) - "k:" (keyword (subs v 2)) - "m:" (t/decode (subs v 2)) - "u:" (uuid/uuid (subs v 2)) - "z:" nil - "o:" (subs v 2) - v))) + #?(:cljs (t/decode v) + :clj (t/decode-str v))) (defn encode-style [key val] diff --git a/frontend/tests/app/test_draft_conversion.cljs b/frontend/tests/app/test_draft_conversion.cljs index bcbdf469e..72c143e6a 100644 --- a/frontend/tests/app/test_draft_conversion.cljs +++ b/frontend/tests/app/test_draft_conversion.cljs @@ -20,8 +20,8 @@ :font-weight "400", :font-style "normal", :text text}]}]}]}] - (cljs.pprint/pprint (txt/convert-to-draft content)) - (cljs.pprint/pprint (txt/convert-from-draft (txt/convert-to-draft content))) + ;; (cljs.pprint/pprint (txt/convert-to-draft content)) + ;; (cljs.pprint/pprint (txt/convert-from-draft (txt/convert-to-draft content))) (t/is (= (txt/convert-from-draft (txt/convert-to-draft content)) content))))