Merge branch 'feat/db' into refactor/db-properties-schema

This commit is contained in:
Tienson Qin
2024-04-29 15:55:23 +08:00
50 changed files with 942 additions and 723 deletions

View File

@@ -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)))