mirror of
https://github.com/logseq/logseq.git
synced 2026-04-28 08:04:40 +00:00
Merge branch 'feat/db' into refactor/db-properties-schema
This commit is contained in:
@@ -155,8 +155,8 @@
|
||||
(set! js/window -CodeMirror CodeMirror)
|
||||
|
||||
|
||||
(defn- all-tokens-by-cursur
|
||||
"All tokens from the beginning of the document to the cursur(inclusive)."
|
||||
(defn- all-tokens-by-cursor
|
||||
"All tokens from the beginning of the document to the cursor(inclusive)."
|
||||
[cm]
|
||||
(let [cur (.getCursor cm)
|
||||
line (.-line cur)
|
||||
@@ -236,7 +236,7 @@
|
||||
(defn- doc-state-at-cursor
|
||||
"Parse tokens into document state of last token."
|
||||
[cm]
|
||||
(let [tokens (all-tokens-by-cursur cm)
|
||||
(let [tokens (all-tokens-by-cursor cm)
|
||||
{:keys [current-config-path state-stack]} (tokens->doc-state tokens)
|
||||
doc-state (first state-stack)]
|
||||
[current-config-path doc-state]))
|
||||
@@ -448,14 +448,26 @@
|
||||
|
||||
(.addEventListener element "keydown" (fn [e]
|
||||
(let [key-code (.-code e)
|
||||
meta-or-ctrl-pressed? (or (.-ctrlKey e) (.-metaKey e))]
|
||||
(when meta-or-ctrl-pressed?
|
||||
meta-or-ctrl-pressed? (or (.-ctrlKey e) (.-metaKey e))
|
||||
shifted? (.-shiftKey e)]
|
||||
(cond
|
||||
meta-or-ctrl-pressed?
|
||||
;; prevent default behavior of browser
|
||||
;; Cmd + [ => Go back in browser, outdent in CodeMirror
|
||||
;; Cmd + ] => Go forward in browser, indent in CodeMirror
|
||||
(case key-code
|
||||
"BracketLeft" (util/stop e)
|
||||
"BracketRight" (util/stop e)
|
||||
nil)
|
||||
shifted?
|
||||
(case key-code
|
||||
"Enter"
|
||||
(when-let [blockid (some-> (.-target e) (.closest "[blockid]") (.getAttribute "blockid"))]
|
||||
(code-handler/save-code-editor!)
|
||||
(js/setTimeout
|
||||
#(editor-handler/api-insert-new-block! ""
|
||||
{:block-uuid (uuid blockid)
|
||||
:sibling? true}) 32))
|
||||
nil)))))
|
||||
(.addEventListener element "pointerdown"
|
||||
(fn [e]
|
||||
@@ -543,4 +555,4 @@
|
||||
textarea-ref (.querySelector block-node "textarea")]
|
||||
(when-let [codemirror-ref (gobj/get textarea-ref codemirror-ref-name)]
|
||||
(.focus codemirror-ref))))
|
||||
100)))
|
||||
256)))
|
||||
|
||||
Reference in New Issue
Block a user