Răsfoiți Sursa

enhance(capacitor): improve block editor

charlie 8 luni în urmă
părinte
comite
3a464eb487

+ 1 - 1
src/main/capacitor/app.css

@@ -92,7 +92,7 @@ ion-textarea {
   }
 
   .block-item {
-    @apply flex list-none active:opacity-70 py-1;
+    @apply flex list-none py-1;
   }
 
   .block-bullet-marker {

+ 5 - 7
src/main/capacitor/components/blocks.cljs

@@ -113,7 +113,6 @@
                              (if (dom/has-class? node "block-item")
                                node
                                (recur node)))))]
-    (prn :debug next-node)
     (let [uuid' (.-blockid (.-dataset next-node))]
       (db-model/get-block-by-uuid (uuid uuid')))))
 
@@ -184,18 +183,17 @@
 
              :else
              (let [has-children? (seq (:block/_parent block))]
-               (when-not has-children?
+               (when (and (not has-children?) prev-block)
                  (p/do!
+                   (when prev-block (cc-common/keep-keyboard-open nil))
                    (editor-handler/delete-block-aux! block)
                    (state/set-state! [:modified-blocks (:block/uuid block)] (js/Date.now))
                    (when (and (false? (some-> content (string/trim) (string/blank?))) prev-block)
                      (editor-handler/save-block! current-repo prev-block
                        (str (:block/title prev-block) content)))
-                   (when prev-block
-                     (cc-common/keep-keyboard-open nil)
-                     (state/set-state! [:modified-blocks (:block/uuid prev-block)] (js/Date.now))
-                     (js/requestAnimationFrame #(state/edit-block! prev-block
-                                                  {:cursor-at (count (:block/title prev-block))})))))))
+                   (state/set-state! [:modified-blocks (:block/uuid prev-block)] (js/Date.now))
+                   (js/requestAnimationFrame #(state/edit-block! prev-block
+                                                {:cursor-at (count (:block/title prev-block))}))))))
            (prn :debug "delete node:" (:db/id block) (:block/title prev-block))
            ))
        })))

+ 1 - 1
src/main/capacitor/components/editor.cljs

@@ -47,7 +47,7 @@
                                (on-delete! content opts))))
           debounce-save-handle! (util/debounce save-handle! 500)]
       (ui/textarea
-        {:class "editor-aux-input bg-gray-200 border-none"
+        {:class "editor-aux-input bg-gray-200 border-none resize-none"
          :ref *input
          :on-change (fn [] (debounce-save-handle!))
          :on-key-down (fn [^js e]