Browse Source

Bump rum to batch updates

Tienson Qin 3 years ago
parent
commit
c3d95482bc
3 changed files with 19 additions and 26 deletions
  1. 1 1
      deps.edn
  2. 11 11
      src/main/frontend/components/block.cljs
  3. 7 14
      src/main/frontend/state.cljs

+ 1 - 1
deps.edn

@@ -2,7 +2,7 @@
  :deps
  {org.clojure/clojure                   {:mvn/version "1.10.0"}
   cheshire/cheshire                     {:mvn/version "5.10.0"}
-  rum/rum                               {:mvn/version "0.12.3"}
+  rum/rum                               {:mvn/version "0.12.8"}
   datascript/datascript                 {:mvn/version "1.3.8"}
   datascript-transit/datascript-transit {:mvn/version "0.3.0"}
   borkdude/rewrite-edn                  {:git/url "https://github.com/borkdude/rewrite-edn"

+ 11 - 11
src/main/frontend/components/block.cljs

@@ -2178,7 +2178,7 @@
                nil)
              (assoc state ::control-show? (atom false))))
    :should-update (fn [old-state new-state]
-                    (let [compare-keys [:block/uuid :block/content :block/parent :block/collapsed? :block/children
+                    (let [compare-keys [:block/uuid :block/content :block/parent :block/collapsed?
                                         :block/properties :block/left :block/children :block/_refs]
                           config-compare-keys [:show-cloze?]
                           b1 (second (:rum/args old-state))
@@ -2230,16 +2230,16 @@
         review-cards? (:review-cards? config)]
     [:div.ls-block
      (cond->
-      {:id block-id
-       :data-refs data-refs
-       :data-refs-self data-refs-self
-       :data-collapsed (and collapsed? has-child?)
-       :class (str uuid
-                   (when pre-block? " pre-block")
-                   (when (and card? (not review-cards?)) " shadow-xl"))
-       :blockid (str uuid)
-       :haschild (str has-child?)
-       :style {:padding-left (* (- level 1) 24)}}
+       {:id block-id
+        :data-refs data-refs
+        :data-refs-self data-refs-self
+        :data-collapsed (and collapsed? has-child?)
+        :class (str uuid
+                    (when pre-block? " pre-block")
+                    (when (and card? (not review-cards?)) " shadow-xl"))
+        :blockid (str uuid)
+        :haschild (str has-child?)
+        :style {:padding-left (* (- level 1) 24)}}
 
        level
        (assoc :level level)

+ 7 - 14
src/main/frontend/state.cljs

@@ -112,7 +112,6 @@
      :editor/last-saved-cursor              nil
      :editor/editing?                       nil
      ;; This key is not currently used but may be useful later?
-     :editor/last-edit-block-input-id       nil
      :editor/in-composition?                false
      :editor/content                        {}
      :editor/block                          nil
@@ -851,22 +850,16 @@
                 (-> state
                     (assoc-in [:editor/content edit-input-id] content)
                     (assoc
-                      :editor/block block
-                      :editor/editing? {edit-input-id true}
-                      :editor/last-edit-block-input-id edit-input-id
-                      :editor/last-edit-block block
-                      :editor/last-key-code nil
-                      :cursor-range cursor-range))))
-
+                     :editor/block block
+                     :editor/editing? {edit-input-id true}
+                     :editor/last-edit-block block
+                     :editor/last-key-code nil
+                     :cursor-range cursor-range))))
        (when-let [input (gdom/getElement edit-input-id)]
          (let [pos (count cursor-range)]
            (when content
-             (util/set-change-value input content)
-             ;; FIXME
-             ;; use set-change-value for now
-             ;; until somebody can figure out why set! value doesn't work here
-             ;; it seems to me textarea autoresize is completely broken
-             #_(set! (.-value input) (string/trim content)))
+             (util/set-change-value input content))
+
            (when move-cursor?
              (cursor/move-cursor-to input pos))