From 56668eeaefdce4ed285c94639ca3d20e97e6c746 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Tue, 6 Sep 2022 09:04:02 +0800 Subject: [PATCH] fix: subs dependencies --- src/main/frontend/components/editor.cljs | 9 ++------- src/main/frontend/state.cljs | 12 +++++------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/main/frontend/components/editor.cljs b/src/main/frontend/components/editor.cljs index 226391ad1..ca1d0c821 100644 --- a/src/main/frontend/components/editor.cljs +++ b/src/main/frontend/components/editor.cljs @@ -506,11 +506,6 @@ [:span {:id (str "mock-text_" idx) :key idx} c])))]) -(rum/defc mock-textarea-wrapper < rum/reactive - [] - (let [content (state/sub-edit-content)] - (mock-textarea content))) - (rum/defc animated-modal < rum/reactive [modal-name component set-default-width?] (when-let [pos (:pos (state/get-editor-action-data))] @@ -582,7 +577,7 @@ (shortcut/mixin :shortcut.handler/block-editing-only) lifecycle/lifecycle [state {:keys [format block]} id _config] - (let [content (state/sub-edit-content) + (let [content (state/sub-edit-content id) heading-class (get-editor-style-class content format)] [:div.editor-inner {:class (if block "block-editor" "non-block-editor")} @@ -597,7 +592,7 @@ :auto-focus false :class heading-class}) - (mock-textarea-wrapper) + (mock-textarea content) (modals id format) (when format diff --git a/src/main/frontend/state.cljs b/src/main/frontend/state.cljs index a7ea6fde9..b67da1fa7 100644 --- a/src/main/frontend/state.cljs +++ b/src/main/frontend/state.cljs @@ -488,9 +488,6 @@ should be done through this fn in order to get global config and config defaults ;; State cursor fns for use with rum components ;; ============================================ -;; State that some subs are dependent on. Should they use sub too? -(declare get-edit-input-id document-mode?) - (defn sub "Creates a rum cursor, https://github.com/tonsky/rum#cursors, for use in rum components. Similar to re-frame subscriptions" @@ -562,8 +559,8 @@ Similar to re-frame subscriptions" (get-in (sub-config) [:default-home :page] "")) (defn sub-edit-content - [] - (sub [:editor/content (get-edit-input-id)])) + [id] + (sub [:editor/content id])) (defn- get-selected-block-ids [blocks] @@ -608,8 +605,9 @@ Similar to re-frame subscriptions" (defn doc-mode-enter-for-new-line? [] - (and (document-mode?) - (not (:shortcut/doc-mode-enter-for-new-block? (sub-config))))) + (let [config (sub-config)] + (and (:document/mode? config) + (not (:shortcut/doc-mode-enter-for-new-block? config))))) (defn user-groups []