Merge pull request #1072 from logseq/enhance/undo-redo

Enhance/undo redo
This commit is contained in:
Tienson Qin
2021-01-12 07:16:50 -08:00
committed by GitHub
22 changed files with 447 additions and 235 deletions

View File

@@ -183,10 +183,19 @@
(not (false? (:feature/enable-journals?
(get (sub-config) repo)))))
(defn enable-git-auto-push?
[repo]
(not (false? (:git-auto-push
(get (sub-config) repo)))))
(defn enable-block-time?
[]
(true? (:feature/enable-block-time?
(get (sub-config) (get-current-repo)))))
;; (true? (:feature/enable-block-time?
;; (get (sub-config) (get-current-repo))))
;; Disable block timestamps for now, because it doesn't work with undo/redo
false
)
;; Enable by default
(defn show-brackets?
@@ -631,7 +640,14 @@
(defn set-editing!
[edit-input-id content block cursor-range]
(when edit-input-id
(let [content (or content "")]
(let [block-element (gdom/getElement (string/replace edit-input-id "edit-block" "ls-block"))
{:keys [idx container]} (util/get-block-idx-inside-container block-element)
block (if (and idx container)
(assoc block
:block/idx idx
:block/container (gobj/get container "id"))
block)
content (or content "")]
(swap! state
(fn [state]
(-> state
@@ -990,7 +1006,7 @@
(or
(when-let [last-time (get-in @state [:editor/last-input-time repo])]
(let [now (util/time-ms)]
(>= (- now last-time) 3000)))
(>= (- now last-time) 1000)))
;; not in editing mode
(not (get-edit-input-id)))))