Skip to content

Commit

Permalink
fix: quick capture
Browse files Browse the repository at this point in the history
  • Loading branch information
tiensonqin committed Nov 23, 2022
1 parent 3440a3d commit bc0ebf1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/electron/listener.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,12 @@
insert-today? (get-in (state/get-config)
[:quick-capture-options :insert-today]
false)
page (if (true? insert-today?) (string/lower-case (date/journal-name)) (state/get-current-page))
today-page (string/lower-case (date/today))
page (if (true? insert-today?)
today-page
(or (state/get-current-page)
today-page
"Quick Capture"))
format (db/get-page-format page)
time (date/get-current-time)
text (or (and content (not-empty (string/trim content))) "")
Expand All @@ -171,9 +176,11 @@
content (-> template
(string/replace "{time}" time)
(string/replace "{url}" link)
(string/replace "{text}" text))]
(if (and (state/get-edit-block) (not state/editing?)) ; changed to not so that block is created at the end of the page
(editor-handler/insert content)
(string/replace "{text}" text))
edit-content (state/get-edit-content)
edit-content-include-capture? (and edit-content (string/includes? edit-content "[[quick capture]]"))]
(if (and (state/editing?) (not edit-content-include-capture?))
(editor-handler/insert (str "\n" content))
(editor-handler/api-insert-new-block! content {:page page
:edit-block? false
:replace-empty-target? true})))))
Expand Down

0 comments on commit bc0ebf1

Please sign in to comment.