From 3a464eb487e79e6bceaa9cbd50c10f14ad3f1c76 Mon Sep 17 00:00:00 2001 From: charlie Date: Thu, 22 May 2025 20:25:05 +0800 Subject: [PATCH] enhance(capacitor): improve block editor --- src/main/capacitor/app.css | 2 +- src/main/capacitor/components/blocks.cljs | 12 +++++------- src/main/capacitor/components/editor.cljs | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/capacitor/app.css b/src/main/capacitor/app.css index f2d4f10c60..0326804329 100644 --- a/src/main/capacitor/app.css +++ b/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 { diff --git a/src/main/capacitor/components/blocks.cljs b/src/main/capacitor/components/blocks.cljs index d0d6333d3a..36097e1f8b 100644 --- a/src/main/capacitor/components/blocks.cljs +++ b/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)) )) }))) diff --git a/src/main/capacitor/components/editor.cljs b/src/main/capacitor/components/editor.cljs index 28aed98cc0..0a3a5f820f 100644 --- a/src/main/capacitor/components/editor.cljs +++ b/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]