Kaynağa Gözat

enhance: remove some icons from mobile bar

Tienson Qin 3 yıl önce
ebeveyn
işleme
e3fece74c8
1 değiştirilmiş dosya ile 11 ekleme ve 45 silme
  1. 11 45
      src/main/frontend/mobile/mobile_bar.cljs

+ 11 - 45
src/main/frontend/mobile/mobile_bar.cljs

@@ -14,23 +14,6 @@
             [goog.dom :as gdom]
             [rum.core :as rum]))
 
-(def ^:private icons-keywords
-  [:checkbox :camera :brackets :parentheses :command :tag :a-b :list
-   :brand-youtube :link :rotate :rotate-clockwise :calendar :code :bold :italic :strikethrough :paint])
-
-(def ^:private commands-stats
-  (atom (into {}
-              (mapv (fn [name] [name {:counts 0}])
-                    icons-keywords))))
-
-(defn set-command-stats [icon]
-  (let [key (keyword icon)
-        counts (get-in @commands-stats [key :counts])]
-    (swap! commands-stats
-           assoc-in [key :counts] (inc counts))
-    (config-handler/set-config!
-     :mobile/toolbar-stats @commands-stats)))
-
 (rum/defc indent-outdent [indent? icon]
   [:div
    [:button.bottom-action
@@ -45,8 +28,6 @@
    [:button.bottom-action
     {:on-mouse-down (fn [e]
                       (util/stop e)
-                      (when count?
-                        (set-command-stats icon))
                       (if event?
                         (command-handler e)
                         (command-handler)))}
@@ -68,7 +49,6 @@
      [:button.bottom-action
       {:on-mouse-down (fn [event]
                         (util/stop event)
-                        (set-command-stats :calendar)
                         (let [target (gdom/getNextElementSibling (.-target event))]
                           (dom/add-class! target "show-submenu")))}
       (ui/icon "calendar" {:size ui/icon-size})
@@ -92,36 +72,17 @@
   (let [viewport-fn (fn [] (when-let [input (gdom/getElement parent-id)]
                              (util/scroll-editor-cursor input :to-vw-one-quarter? true)
                              (.focus input)))]
-    (zipmap icons-keywords
-            [(command editor-handler/cycle-todo! "checkbox" true)
-             (command #(mobile-camera/embed-photo parent-id) "camera" true)
-             (command #(do (viewport-fn) (editor-handler/toggle-page-reference-embed parent-id)) "brackets" true)
-             (command #(do (viewport-fn) (editor-handler/toggle-block-reference-embed parent-id)) "parentheses" true)
-             (command #(do (viewport-fn) (commands/simple-insert! parent-id "/" {})) "command" true)
-             (command #(do (viewport-fn) (commands/simple-insert! parent-id "#" {})) "tag" true)
-             (command editor-handler/cycle-priority! "a-b" true)
-             (command editor-handler/toggle-list! "list" true)
-             (command commands/insert-youtube-timestamp "brand-youtube" true)
-             (command editor-handler/html-link-format! "link" true)
-             (command history/undo! "rotate" true true)
-             (command history/redo! "rotate-clockwise" true true)
-             (timestamp-submenu parent-id)
-             (command #(commands/simple-insert! parent-id "<" {}) "code" true)
-             (command editor-handler/bold-format! "bold" true)
-             (command editor-handler/italics-format! "italic" true)
-             (command editor-handler/strike-through-format! "strikethrough" true)
-             (command editor-handler/highlight-format! "paint" true)])))
+    [(command #(do (viewport-fn) (editor-handler/toggle-page-reference-embed parent-id)) "brackets" true)
+     (command #(do (viewport-fn) (editor-handler/toggle-block-reference-embed parent-id)) "parentheses" true)
+     (command #(do (viewport-fn) (commands/simple-insert! parent-id "/" {})) "command" true)]))
 
 (rum/defc mobile-bar < rum/reactive
   []
   (when (and (state/sub :editor/editing?)
              (or (state/sub :mobile/show-toolbar?)
                  (mobile-util/native-ipad?)))
-    (when-let [config-toolbar-stats (:mobile/toolbar-stats (state/get-config))]
-      (reset! commands-stats config-toolbar-stats))
     (let [parent-id (state/get-edit-input-id)
-          commands (commands parent-id)
-          sorted-commands (sort-by (comp :counts second) > @commands-stats)]
+          commands (commands parent-id)]
       [:div#mobile-editor-toolbar.bg-base-2
        [:div.toolbar-commands
         (indent-outdent false "indent-decrease")
@@ -131,7 +92,12 @@
         (command #(if (state/sub :document/mode?)
                     (editor-handler/insert-new-block! nil)
                     (commands/simple-insert! parent-id "\n" {})) "arrow-back")
-        (for [command sorted-commands]
-          ((first command) commands))]
+        (command editor-handler/cycle-todo! "checkbox" true)
+        (command #(mobile-camera/embed-photo parent-id) "camera" true)
+        (command history/undo! "rotate" true true)
+        (command history/redo! "rotate-clockwise" true true)
+        (timestamp-submenu parent-id)
+        (for [command commands]
+          command)]
        [:div.toolbar-hide-keyboard
         (command #(state/clear-edit!) "keyboard-show")]])))