fix: delete not auto-adjust the editor's height

pull/1819/head
Tienson Qin 2021-04-29 23:18:16 +08:00
parent 401ce9cf72
commit d8d5a5d486
2 changed files with 11 additions and 7 deletions

View File

@ -222,7 +222,8 @@
["Src" (->block "src" "")] ["Src" (->block "src" "")]
["Query" (->block "query")] ["Query" (->block "query")]
["Latex export" (->block "export" "latex")] ["Latex export" (->block "export" "latex")]
["Properties" (->properties)] (when-not (= :markdown (state/get-preferred-format))
["Properties" (->properties)])
["Note" (->block "note")] ["Note" (->block "note")]
["Tip" (->block "tip")] ["Tip" (->block "tip")]
["Important" (->block "important")] ["Important" (->block "important")]

View File

@ -2062,6 +2062,7 @@
(cond (cond
(not= selected-start selected-end) (not= selected-start selected-end)
(do (do
(util/stop e)
(when cut? (when cut?
(js/document.execCommand "copy")) (js/document.execCommand "copy"))
(.setRangeText input "" selected-start selected-end)) (.setRangeText input "" selected-start selected-end))
@ -2071,11 +2072,14 @@
(not (and page (not (and page
(util/uuid-string? page) (util/uuid-string? page)
(= (medley/uuid page) block-id)))) (= (medley/uuid page) block-id))))
(delete-block! repo e) (do
(util/stop e)
(delete-block! repo e))
(and (> current-pos 1) (and (> current-pos 1)
(= (util/nth-safe value (dec current-pos)) commands/slash)) (= (util/nth-safe value (dec current-pos)) commands/slash))
(do (do
(util/stop e)
(reset! *slash-caret-pos nil) (reset! *slash-caret-pos nil)
(reset! *show-commands false) (reset! *show-commands false)
(.setRangeText input "" (dec current-pos) current-pos)) (.setRangeText input "" (dec current-pos) current-pos))
@ -2083,6 +2087,7 @@
(and (> current-pos 1) (and (> current-pos 1)
(= (util/nth-safe value (dec current-pos)) commands/angle-bracket)) (= (util/nth-safe value (dec current-pos)) commands/angle-bracket))
(do (do
(util/stop e)
(reset! *angle-bracket-caret-pos nil) (reset! *angle-bracket-caret-pos nil)
(reset! *show-block-commands false) (reset! *show-block-commands false)
(.setRangeText input "" (dec current-pos) current-pos)) (.setRangeText input "" (dec current-pos) current-pos))
@ -2098,6 +2103,7 @@
(get delete-map deleted))) (get delete-map deleted)))
(do (do
(util/stop e)
(commands/delete-pair! id) (commands/delete-pair! id)
(cond (cond
(and (= deleted "[") (state/get-editor-show-page-search?)) (and (= deleted "[") (state/get-editor-show-page-search?))
@ -2111,13 +2117,11 @@
;; deleting hashtag ;; deleting hashtag
(and (= deleted "#") (state/get-editor-show-page-search-hashtag?)) (and (= deleted "#") (state/get-editor-show-page-search-hashtag?))
(do (state/set-editor-show-page-search-hashtag! false)
(state/set-editor-show-page-search-hashtag! false)
(.setRangeText input "" (dec current-pos) current-pos))
;; just delete ;; just delete
:else :else
(.setRangeText input "" (dec current-pos) current-pos)))) nil)))
;; TODO: merge indent-on-tab, outdent-on-shift-tab, on-tab ;; TODO: merge indent-on-tab, outdent-on-shift-tab, on-tab
(defn indent-on-tab (defn indent-on-tab
@ -2441,7 +2445,6 @@
(defn editor-delete (defn editor-delete
[_state e] [_state e]
(when (state/editing?) (when (state/editing?)
(util/stop e)
(keydown-backspace-handler false e))) (keydown-backspace-handler false e)))
(defn shortcut-up-down [direction] (defn shortcut-up-down [direction]