Skip to content

Commit

Permalink
fix: subs dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
tiensonqin authored and andelf committed Sep 8, 2022
1 parent 7fa9209 commit 56668ee
Showing 2 changed files with 7 additions and 14 deletions.
9 changes: 2 additions & 7 deletions src/main/frontend/components/editor.cljs
Original file line number Diff line number Diff line change
@@ -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
12 changes: 5 additions & 7 deletions src/main/frontend/state.cljs
Original file line number Diff line number Diff line change
@@ -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
[]

0 comments on commit 56668ee

Please sign in to comment.