From ac4bfc9bac797ade5f4250abf05f57aadf2e5511 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 15 Apr 2021 14:41:56 +0200 Subject: [PATCH 1/3] :bug: Fix excesive font fetching on embedding it. --- .../src/app/main/ui/shapes/text/embed.cljs | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/frontend/src/app/main/ui/shapes/text/embed.cljs b/frontend/src/app/main/ui/shapes/text/embed.cljs index 0ef584e5e..5c869e38a 100644 --- a/frontend/src/app/main/ui/shapes/text/embed.cljs +++ b/frontend/src/app/main/ui/shapes/text/embed.cljs @@ -8,6 +8,7 @@ ;; Copyright (c) UXBOX Labs SL (ns app.main.ui.shapes.text.embed + (:refer-clojure :exclude [memoize]) (:require [app.common.data :as d] [app.common.text :as txt] @@ -36,7 +37,7 @@ [node] (let [current-font (if (not (nil? (:font-id node))) #{(select-keys node [:font-id :font-variant-id])} - #{}) + #{(select-keys txt/default-text-attrs [:font-id :font-variant-id])}) children-font (map get-node-fonts (:children node))] (reduce set/union (conj children-font current-font)))) @@ -74,21 +75,31 @@ replace-text (fn [text [url data]] (str/replace text url data))] (reduce replace-text css url-to-data)))) +;; NOTE: we can't move this to generic hooks namespace because that +;; namespace imports some code incompatible with webworkers and this +;; font embbeding should be able run on browser and webworker +;; contexts. +(defn- memoize + [val] + (let [ref (mf/use-ref #js {})] + (when-not (= (mf/ref-val ref) val) + (mf/set-ref-val! ref val)) + (mf/ref-val ref))) + (mf/defc embed-fontfaces-style - {::mf/wrap-props false} + {::mf/wrap-props false + ::mf/wrap [mf/memo]} [props] (let [node (obj/get props "node") + fonts (-> node get-node-fonts memoize) style (mf/use-state nil)] - (mf/use-effect - (mf/deps node) - (fn [] - (let [font-to-embed (get-node-fonts node) - font-to-embed (if (empty? font-to-embed) #{txt/default-text-attrs} font-to-embed) - embeded (map embed-font font-to-embed)] - (-> (p/all embeded) - (p/then (fn [result] - (reset! style (str/join "\n" result)))))))) + (mf/use-effect + (mf/deps fonts) + (fn [] + (-> (p/all (map embed-font fonts)) + (p/then (fn [result] + (reset! style (str/join "\n" result))))))) (when (some? @style) [:style @style]))) From db7518025d05f6eba09a56c4a281667c3f6ce880 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 15 Apr 2021 12:41:52 +0200 Subject: [PATCH 2/3] :tada: Add html template for feedback email. --- backend/resources/emails/feedback/en.html | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 backend/resources/emails/feedback/en.html diff --git a/backend/resources/emails/feedback/en.html b/backend/resources/emails/feedback/en.html new file mode 100644 index 000000000..478a3cc3c --- /dev/null +++ b/backend/resources/emails/feedback/en.html @@ -0,0 +1,45 @@ + + + + + + + + +

+ Feedback from:
+ {% if profile %} + + Name: + {{profile.fullname}} + +
+ + + Email: + {{profile.email}} + +
+ + + ID: + {{profile.id}} + + {% else %} + + Email: + {{profile.email}} + + {% endif %} +

+

+ Subject:
+ {{subject}} +

+ +

+ Message:
+ {{content|linebreaks-br|safe}} +

+ + From e3691cc0e3800e588db7bc9009cafd493bcda6e0 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 15 Apr 2021 15:08:36 +0200 Subject: [PATCH 3/3] :fire: Remove console.log. --- frontend/src/app/util/text_editor_impl.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/src/app/util/text_editor_impl.js b/frontend/src/app/util/text_editor_impl.js index 48c7b055f..40ad894ec 100644 --- a/frontend/src/app/util/text_editor_impl.js +++ b/frontend/src/app/util/text_editor_impl.js @@ -109,8 +109,6 @@ export function applyInlineStyle(state, styles) { let content = null; for (let style of styles) { - console.log("applyInlineStyle", style); - const [p, k, v] = style.split("$$$"); const prefix = [p, k, ""].join("$$$");