Tienson Qin 1 год назад
Родитель
Сommit
736e202460

+ 1 - 14
src/main/frontend/components/property/value.cljs

@@ -309,19 +309,6 @@
                                    (when on-chosen (on-chosen)))))]
     (select-page property opts')))
 
-;; (defn- move-cursor
-;;   [up? opts]
-;;   (let [f (if up? dec inc)
-;;         id (str (:parent-dom-id opts) "-" (f (:idx opts)))
-;;         editor-id (str (:parent-dom-id opts) "-editor" "-" (f (:idx opts)))
-;;         sibling (gdom/getElement id)
-;;         editor (gdom/getElement editor-id)]
-;;     (when sibling
-;;       (.click sibling)
-;;       (state/set-state! :editor/property-triggered-by-click? {editor-id true}))
-;;     (when editor
-;;       (.focus editor))))
-
 (defn- save-text!
   [repo block property value _editor-id e]
   (let [new-value (util/evalue e)]
@@ -701,7 +688,7 @@
                :style {:min-height 24}
                :on-click (fn []
                            (when (and (= type :default) (not (uuid? value)))
-                             (set-editing! property editor-id dom-id value {:ref @*ref})))}
+                             (set-editing! (assoc property :block/uuid (random-uuid)) editor-id dom-id value {:ref @*ref})))}
               (if (string/blank? value)
                 (if template?
                   (let [id (first (:classes schema))

+ 3 - 9
src/main/frontend/handler/editor/lifecycle.cljs

@@ -2,7 +2,6 @@
   (:require [frontend.handler.editor :as editor-handler]
             [frontend.state :as state]
             [frontend.util :as util]
-            [frontend.util.cursor :as cursor]
             [goog.dom :as gdom]
             [frontend.db :as db]
             [frontend.handler.block :as block-handler]
@@ -14,14 +13,9 @@
         content (state/get-edit-content)]
     (when block-parent-id
       (state/set-editing-block-dom-id! block-parent-id))
-    ;; FIXME: remove ugly :editor/property-triggered-by-click?
-    (if (get-in @state/state [:editor/property-triggered-by-click? id])
-      (do
-        (when-let [input (gdom/getElement (str id))]
-          (cursor/move-cursor-to-end input))
-        (state/set-state! :editor/property-triggered-by-click? {}))
-      (when content
-        (editor-handler/restore-cursor-pos! id content)))
+
+    (when content
+      (editor-handler/restore-cursor-pos! id content))
 
     (when-let [element (gdom/getElement id)]
       ;; TODO: check whether editor is visible, do less work