enhance: ;; to set block property

This commit is contained in:
Tienson Qin
2024-06-01 21:07:48 +08:00
parent f5bcf69c6c
commit 0d6c810b65
2 changed files with 43 additions and 24 deletions

View File

@@ -2869,6 +2869,16 @@
(on-tab direction)))
nil))
(defn- double-chars-typed?
[value pos key sym]
(and (= key sym)
(>= (count value) 1)
(> pos 0)
(= (nth value (dec pos)) sym)
(if (> (count value) pos)
(not= (nth value pos) sym)
true)))
(defn ^:large-vars/cleanup-todo keydown-not-matched-handler
"NOTE: Keydown cannot be used on Android platform"
[format]
@@ -2941,8 +2951,8 @@
(do (util/stop e)
(autopair input-id "(" format nil))
;; If you type `xyz`, the last backtick should close the first and not add another autopair
;; If you type several backticks in a row, each one should autopair to accommodate multiline code (```)
;; If you type `xyz`, the last backtick should close the first and not add another autopair
;; If you type several backticks in a row, each one should autopair to accommodate multiline code (```)
(-> (keys autopair-map)
set
(disj "(")
@@ -2955,24 +2965,17 @@
(cursor/move-cursor-forward input)
(autopair input-id key format nil)))
; `;;` to add or change property for db graphs
(let [sym ";"]
(and (config/db-based-graph? (state/get-current-repo)) (double-chars-typed? value pos key sym)))
(state/pub-event! [:editor/new-property])
(let [sym "$"]
(and (= key sym)
(>= (count value) 1)
(> pos 0)
(= (nth value (dec pos)) sym)
(if (> (count value) pos)
(not= (nth value pos) sym)
true)))
(double-chars-typed? value pos key sym))
(commands/simple-insert! input-id "$$" {:backward-pos 2})
(let [sym "^"]
(and (= key sym)
(>= (count value) 1)
(> pos 0)
(= (nth value (dec pos)) sym)
(if (> (count value) pos)
(not= (nth value pos) sym)
true)))
(double-chars-typed? value pos key sym))
(commands/simple-insert! input-id "^^" {:backward-pos 2})
:else