Browse Source

fix(editor): new block placeholder now accepts tab and enter key

Andelf 1 year ago
parent
commit
8c939a6cbd
2 changed files with 11 additions and 1 deletions
  1. 6 1
      src/main/frontend/components/page.cljs
  2. 5 0
      src/main/frontend/components/page.css

+ 6 - 1
src/main/frontend/components/page.cljs

@@ -151,7 +151,12 @@
 (rum/defc add-button
   [args]
   [:div.flex-1.flex-col.rounded-sm.add-button-link-wrap
-   {:on-click (fn [] (editor-handler/api-insert-new-block! "" args))}
+   {:on-click (fn [] (editor-handler/api-insert-new-block! "" args))
+    :on-key-down (fn [e]
+                    (when (= "Enter" (util/ekey e))
+                      (editor-handler/api-insert-new-block! "" args))
+                    (util/stop e))
+    :tab-index 0}
    [:div.flex.flex-row
     [:div.block {:style {:height      20
                          :width       20

+ 5 - 0
src/main/frontend/components/page.css

@@ -310,6 +310,11 @@ html.is-native-iphone-without-notch {
   }
 }
 
+.add-button-link-wrap:focus .add-button-link {
+  opacity: .8 !important;
+  transform: scale(.9);
+}
+
 .cp__right-sidebar .add-button-link {
   margin-left: 21px;
 }