Stop backspace when deleting a heading

pull/645/head
Tienson Qin 2020-05-01 16:18:01 +08:00
parent f22abff6d1
commit 6595945388
3 changed files with 35 additions and 33 deletions

View File

@ -49,6 +49,7 @@
(let [{:keys [id dummy? value on-hide pos]} (get-state state)
heading? (string/starts-with? id "edit-heading-")]
(when (and heading? (= value ""))
(util/stop e)
;; delete heading, edit previous heading
(let [heading-id (string/replace id "edit-heading-" "")
heading (db/entity [:heading/uuid (uuid heading-id)])
@ -59,7 +60,7 @@
id (gobj/get sibling-heading "id")]
(let [heading (db/entity [:heading/uuid (uuid heading-id)])]
(handler/delete-heading! heading))
(handler/delete-heading! heading dummy?))
(when id
(let [id (uuid (string/replace id "ls-heading-parent-" ""))]

View File

@ -120,7 +120,7 @@
(transact! (state/get-current-repo) tx-data))
([repo-url tx-data]
(when-let [conn (get-conn repo-url false)]
(d/transact! conn tx-data))))
(posh/transact! conn tx-data))))
;; (new TextEncoder().encode('foo')).length
;; (defn db-size
@ -315,7 +315,7 @@
(sub-key-value (state/get-current-repo) key))
([repo-url key]
(when-let [conn (get-conn repo-url false)]
(-> (posh/pull conn '[*] key)
(-> (posh/pull conn '[*] [:db/ident key])
(rum/react)
(get key)))))

View File

@ -714,7 +714,8 @@
(alter-file repo-url file-path new-content opts)))))
(defn delete-heading!
[{:heading/keys [uuid meta content file] :as heading}]
[{:heading/keys [uuid meta content file] :as heading} dummy?]
(when-not dummy?
(let [file-path (:file/path (db/entity (:db/id file)))
file-content (:file/content (db/entity (:db/id file)))
after-headings (db/get-file-after-headings (state/get-current-repo) (:db/id file) (:end-pos meta))
@ -742,7 +743,7 @@
:file/content new-content}])))
(save-heading-if-changed! heading ""
{:new-content new-content
:reset? false})))
:reset? false}))))
(defn clone-and-pull
[repo-url]