Browse Source

enhance: skip property inner text when navigating properties

Tienson Qin 1 year ago
parent
commit
56e3136103

+ 9 - 1
src/main/frontend/handler/editor.cljs

@@ -2720,7 +2720,15 @@
 
       (= input element)
       (cond
-        (and property? right? (cursor/end? input) (not= (get-in block [:block/schema :type]) :default))
+        (and property? right? (not (cursor/end? input)))
+        (cursor/move-cursor-to-end input)
+
+        (and property? left? (not (cursor/start? input)))
+        (cursor/move-cursor-to-start input)
+
+        (and property? right? (cursor/end? input)
+             (or (not= (get-in block [:block/schema :type]) :default)
+                 (seq (:property/closed-values block))))
         (let [pair (util/rec-get-node input "property-pair")
               jtrigger (when pair (dom/sel1 pair ".property-value-container .jtrigger"))]
           (when jtrigger

+ 4 - 8
src/main/frontend/state.cljs

@@ -1169,21 +1169,17 @@ Similar to re-frame subscriptions"
     (dom/remove-class! node "selected")))
 
 (defn mark-dom-blocks-as-selected
-  ([]
-   (mark-dom-blocks-as-selected (get-selection-block-ids)))
-  ([ids]
-   (doseq [id ids]
-     (doseq [node (array-seq (gdom/getElementsByClass (str "id" id)))]
-       (dom/add-class! node "selected")))))
+  [nodes]
+  (doseq [node nodes]
+    (dom/add-class! node "selected")))
 
 (defn- set-selection-blocks-aux!
   [blocks]
   (let [selected-ids (set (get-selected-block-ids @(:selection/blocks @state)))
         _ (set-state! :selection/blocks blocks)
         new-ids (set (get-selection-block-ids))
-        added (set/difference new-ids selected-ids)
         removed (set/difference selected-ids new-ids)]
-    (mark-dom-blocks-as-selected added)
+    (mark-dom-blocks-as-selected blocks)
     (doseq [id removed]
       (doseq [node (array-seq (gdom/getElementsByClass (str "id" id)))]
         (dom/remove-class! node "selected")))))

+ 3 - 4
src/main/frontend/util/cursor.cljs

@@ -130,10 +130,9 @@
     [input]
     (move-cursor-to input (line-beginning-pos input))))
 
-(comment
-  (defn move-cursor-to-start
-    [input]
-    (move-cursor-to input 0)))
+(defn move-cursor-to-start
+  [input]
+  (move-cursor-to input 0))
 
 (defn move-cursor-to-end
   [input]