Browse Source

fix: lint warnings

Tienson Qin 3 years ago
parent
commit
ecb2024c14

+ 2 - 2
src/main/frontend/commands.cljs

@@ -313,7 +313,7 @@
   (reset! *matched-block-commands (block-commands-map)))
 
 (defn restore-state
-  [restore-slash-caret-pos?]
+  []
   (state/clear-editor-action!)
   (reinit-matched-commands!)
   (reinit-matched-block-commands!))
@@ -639,7 +639,7 @@
          (string/blank? value)))
     (do
       (notification/show! [:div "Please add some content first."] :warning)
-      (restore-state false))
+      (restore-state))
     (state/set-editor-show-date-picker! true)))
 
 (defmethod handle-step :editor/click-hidden-file-input [[_ _input-id]]

+ 1 - 1
src/main/frontend/components/datetime.cljs

@@ -106,7 +106,7 @@
       (reset! show? false)))
   (clear-timestamp!)
   (state/set-editor-show-date-picker! false)
-  (commands/restore-state false))
+  (commands/restore-state))
 
 (rum/defc time-repeater < rum/reactive
   (mixins/event-mixin

+ 3 - 7
src/main/frontend/components/editor.cljs

@@ -232,12 +232,9 @@
 (rum/defc property-search < rum/reactive
   {:will-unmount (fn [state] (reset! editor-handler/*selected-text nil) state)}
   [id]
-  (let [pos (:pos (:pos (state/get-editor-action-data)))
-        input (gdom/getElement id)]
+  (let [input (gdom/getElement id)]
     (when input
-      (let [current-pos (cursor/pos input)
-            edit-content (state/sub [:editor/content id])
-            q (:searching-property (editor-handler/get-searching-property input))
+      (let [q (:searching-property (editor-handler/get-searching-property input))
             matched-properties (editor-handler/get-matched-properties q)
             q-property (string/replace (string/lower-case q) #"\s+" "-")
             non-exist-handler (fn [_state]
@@ -254,8 +251,7 @@
 (rum/defc property-value-search < rum/reactive
   {:will-unmount (fn [state] (reset! editor-handler/*selected-text nil) state)}
   [id]
-  (let [pos (:pos (:pos (state/get-editor-action-data)))
-        property (:property (state/get-editor-action-data))
+  (let [property (:property (state/get-editor-action-data))
         input (gdom/getElement id)]
     (when (and input
                (not (string/blank? property)))

+ 6 - 14
src/main/frontend/handler/editor.cljs

@@ -522,8 +522,7 @@
 
 (defn clear-when-saved!
   []
-  (state/clear-editor-action!)
-  (commands/restore-state true))
+  (commands/restore-state))
 
 (defn get-state
   []
@@ -1347,13 +1346,7 @@
     nil)
 
   (when restore?
-    (let [restore-slash-caret-pos? (if (and
-                                        (seq? command-output)
-                                        (= :editor/click-hidden-file-input
-                                           (ffirst command-output)))
-                                     false
-                                     true)]
-      (commands/restore-state restore-slash-caret-pos?))))
+    (commands/restore-state)))
 
 (defn get-asset-file-link
   [format url file-name image?]
@@ -2096,9 +2089,8 @@
 (defn property-value-on-chosen-handler
   [element-id q]
   (fn [property-value]
-    (when-let [input (gdom/getElement element-id)]
-      (commands/insert! element-id (or property-value q)
-                        {:last-pattern q}))
+    (commands/insert! element-id (or property-value q)
+                      {:last-pattern q})
     (state/clear-editor-action!)))
 
 (defn parent-is-page?
@@ -2616,14 +2608,14 @@
            (= (util/nth-safe value (dec current-pos)) (state/get-editor-command-trigger)))
       (do
         (util/stop e)
-        (commands/restore-state true)
+        (commands/restore-state)
         (delete-and-update input (dec current-pos) current-pos))
 
       (and (> current-pos 1)
            (= (util/nth-safe value (dec current-pos)) commands/angle-bracket))
       (do
         (util/stop e)
-        (commands/restore-state true)
+        (commands/restore-state)
         (delete-and-update input (dec current-pos) current-pos))
 
       ;; pair

+ 0 - 9
src/main/frontend/state.cljs

@@ -626,21 +626,12 @@
 (defn set-editor-show-template-search!
   [value]
   (set-editor-action! (when value :template-search)))
-(defn get-editor-show-template-search?
-  []
-  (= (get-editor-action) :template-search))
 (defn set-editor-show-property-search!
   [value]
   (set-editor-action! (when value :property-search)))
-(defn get-editor-show-property-search?
-  []
-  (= (get-editor-action) :property-search))
 (defn set-editor-show-date-picker!
   [value]
   (set-editor-action! (when value :datepicker)))
-(defn get-editor-show-date-picker?
-  []
-  (= (get-editor-action) :datepicker))
 (defn set-editor-show-input!
   [value]
   (if value

+ 3 - 3
src/test/frontend/util/text_test.cljs

@@ -23,11 +23,11 @@
 (deftest get-string-all-indexes
   []
   (are [x y] (= x y)
-    (text-util/get-string-all-indexes "[[hello]] [[world]]" "[[")
+    (text-util/get-string-all-indexes "[[hello]] [[world]]" "[[" true)
     [0 10]
 
-    (text-util/get-string-all-indexes "abc abc ab" "ab")
+    (text-util/get-string-all-indexes "abc abc ab" "ab" true)
     [0 4 8]
 
-    (text-util/get-string-all-indexes "a.c a.c ab" "a.")
+    (text-util/get-string-all-indexes "a.c a.c ab" "a." true)
     [0 4]))