diff --git a/src/main/frontend/components/editor.cljs b/src/main/frontend/components/editor.cljs index 1736c9f5cf..5b7d704437 100644 --- a/src/main/frontend/components/editor.cljs +++ b/src/main/frontend/components/editor.cljs @@ -714,6 +714,7 @@ :on-click (editor-handler/editor-on-click! id) :on-change (editor-handler/editor-on-change! block id search-timeout) :on-paste (editor-handler/editor-on-paste! id) + :on-height-change (editor-handler/editor-on-height-change! id) :auto-focus false :class heading-class}) diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index b83e402594..9081e1bd09 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -3116,6 +3116,20 @@ (let [input (gdom/getElement id)] (close-autocomplete-if-outside input)))) +(defn editor-on-height-change! + [id] + (fn [row-height] + (let [input (gdom/getElement id) + top (gobj/get (.getBoundingClientRect input) "top") + cursor-y (+ top row-height) + vw-height (.-height js/window.visualViewport)] + ;; 40 is mobile toolbar height + (when (< vw-height (+ cursor-y 40)) + (let [main-node (gdom/getElement "main-content-container") + scroll-top (.-scrollTop main-node)] + ;; 24 is default line height + (set! (.-scrollTop main-node) (+ scroll-top 24))))))) + (defn editor-on-change! [block id search-timeout] (fn [e]