فهرست منبع

fix: excalidraw focus

Konstantinos Kaloutas 2 سال پیش
والد
کامیت
99865a5eef
1فایلهای تغییر یافته به همراه5 افزوده شده و 2 حذف شده
  1. 5 2
      src/main/frontend/extensions/excalidraw.cljs

+ 5 - 2
src/main/frontend/extensions/excalidraw.cljs

@@ -74,7 +74,8 @@
    :did-update update-draw-content-width
    :will-unmount (fn [state] (.disconnect @(::resize-observer state)))}
   [state data option]
-  (let [*draw-width (get state ::draw-width)
+  (let [ref (rum/create-ref)
+        *draw-width (get state ::draw-width)
         *zen-mode? (get state ::zen-mode?)
         *view-mode? (get state ::view-mode?)
         *grid-mode? (get state ::grid-mode?)
@@ -96,7 +97,8 @@
                                (editor-handler/edit-block! block :max block-uuid))}
          "Edit Block"]]
        [:div.draw-wrap
-        {:on-mouse-down (fn [e]
+        {:ref ref
+         :on-mouse-down (fn [e]
                           (util/stop e)
                           (state/set-block-component-editing-mode! true))
          :on-blur #(state/set-block-component-editing-mode! false)
@@ -121,6 +123,7 @@
            :zen-mode-enabled @*zen-mode?
            :view-mode-enabled @*view-mode?
            :grid-mode-enabled @*grid-mode?
+           :on-pointer-down #(.. (rum/deref ref) -firstChild focus)
            :initial-data data
            :theme (excalidraw-theme (state/sub :ui/theme))}))]])))