enhance(capacitor): improve block editor

This commit is contained in:
charlie
2025-05-22 20:25:05 +08:00
parent 42eaabed4e
commit 3a464eb487
3 changed files with 7 additions and 9 deletions

View File

@@ -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 {

View File

@@ -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))
))
})))

View File

@@ -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]