mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
enhance: backspace moves cursor to the above item
This commit is contained in:
@@ -262,6 +262,9 @@
|
||||
(db/sub-block (:db/id block))))
|
||||
|
||||
(rum/defcs properties-area < rum/reactive
|
||||
{:init (fn [state]
|
||||
(assoc state ::blocks-container-id (or (:blocks-container-id (last (:rum/args state)))
|
||||
(state/next-blocks-container-id))))}
|
||||
[state target-block edit-input-id opts]
|
||||
(let [block (resolve-instance-page-if-exists target-block)
|
||||
properties (if (and (:class-schema? opts) (:block/schema block))
|
||||
@@ -293,9 +296,7 @@
|
||||
@(:*configure-show? opts)
|
||||
(empty? properties))
|
||||
(= edit-input-id (state/sub :ui/new-property-input-id)))
|
||||
opts (if (:blocks-container-id opts)
|
||||
opts
|
||||
(assoc opts :blocks-container-id (state/next-blocks-container-id)))]
|
||||
opts (assoc opts :blocks-container-id (::blocks-container-id state))]
|
||||
(when-not (and (empty? properties)
|
||||
(not new-property?)
|
||||
(not (:page-configure? opts)))
|
||||
|
||||
@@ -197,11 +197,12 @@
|
||||
meta? (util/meta-key? e)
|
||||
create-another-one? (and meta? enter?)
|
||||
down? (= (util/ekey e) "ArrowDown")
|
||||
up? (= (util/ekey e) "ArrowUp")]
|
||||
(when (and (or enter? esc? create-another-one? down? up?)
|
||||
up? (= (util/ekey e) "ArrowUp")
|
||||
backspace? (= (util/ekey e) "Backspace")]
|
||||
(when (and (or enter? esc? create-another-one? down? up? backspace?)
|
||||
(not (state/get-editor-action)))
|
||||
(util/stop e)
|
||||
(when-not blank?
|
||||
(when-not (or down? up? backspace?) (util/stop e))
|
||||
(when (and (not blank?) (or enter? esc?))
|
||||
(when (not= (string/trim new-value) (string/trim value))
|
||||
(property-handler/set-block-property! repo (:block/uuid block)
|
||||
(:block/original-name property)
|
||||
@@ -211,6 +212,19 @@
|
||||
(exit-edit-property)
|
||||
|
||||
(cond
|
||||
(and backspace? (= new-value "") (not @*add-new-item?)) ; delete item
|
||||
(do
|
||||
(move-cursor true opts)
|
||||
(property-handler/delete-property-value! repo block (:block/uuid property) value))
|
||||
|
||||
(and backspace? (= new-value "") @*add-new-item?)
|
||||
(do
|
||||
(move-cursor true opts)
|
||||
(reset! *add-new-item? false))
|
||||
|
||||
backspace?
|
||||
nil
|
||||
|
||||
down?
|
||||
(move-cursor false opts)
|
||||
|
||||
@@ -396,6 +410,7 @@
|
||||
opts
|
||||
{:editor-args editor-args
|
||||
:editor-id editor-id
|
||||
:idx (count items)
|
||||
:dom-id dom-id
|
||||
:editing? true
|
||||
:*add-new-item? *add-new-item?}))
|
||||
|
||||
@@ -265,8 +265,7 @@
|
||||
{:block/uuid (:block/uuid block)
|
||||
:block/properties properties'
|
||||
:block/refs refs}]
|
||||
{:outliner-op :save-block}))))
|
||||
(state/clear-edit!))))))
|
||||
{:outliner-op :save-block})))))))))
|
||||
|
||||
(defn class-add-property!
|
||||
[repo class k-name]
|
||||
|
||||
Reference in New Issue
Block a user