Browse Source

enhance(apis): add today page

charlie 1 month ago
parent
commit
110084e4ba
3 changed files with 8 additions and 0 deletions
  1. 1 0
      libs/src/LSPlugin.ts
  2. 1 0
      src/main/logseq/api.cljs
  3. 6 0
      src/main/logseq/api/editor.cljs

+ 1 - 0
libs/src/LSPlugin.ts

@@ -639,6 +639,7 @@ export interface IEditorProxy extends Record<string, any> {
   getEditingBlockContent: () => Promise<string>
 
   getCurrentPage: () => Promise<PageEntity | BlockEntity | null>
+  getTodayPage: () => Promise<PageEntity | null>
 
   getCurrentBlock: () => Promise<BlockEntity | null>
 

+ 1 - 0
src/main/logseq/api.cljs

@@ -116,6 +116,7 @@
 (def ^:export get_editing_cursor_position api-editor/get_editing_cursor_position)
 (def ^:export get_next_sibling_block api-editor/get_next_sibling_block)
 (def ^:export get_page api-editor/get_page)
+(def ^:export get_today_page api-editor/get_today_page)
 (def ^:export get_page_blocks_tree api-editor/get_page_blocks_tree)
 (def ^:export get_page_linked_references api-editor/get_page_linked_references)
 (def ^:export get_page_properties api-editor/get_page_properties)

+ 6 - 0
src/main/logseq/api/editor.cljs

@@ -102,6 +102,12 @@
     (when page
       (sdk-utils/result->js page))))
 
+(defn get_today_page
+  []
+  (p/let [today-name (date/today)
+          page (<get-block today-name {:children? false})]
+    (some-> page (sdk-utils/result->js))))
+
 (defn get_all_pages
   []
   (p/let [result (db-async/<q