Просмотр исходного кода

Merge branch 'feat/integration-plugins-core' of github.com:logseq/logseq into feat/integration-plugins-core

charlie 4 лет назад
Родитель
Сommit
601282a6c7
2 измененных файлов с 5 добавлено и 3 удалено
  1. 1 1
      libs/src/LSPlugin.d.ts
  2. 4 2
      src/main/logseq/api.cljs

+ 1 - 1
libs/src/LSPlugin.d.ts

@@ -170,7 +170,7 @@ interface IEditorProxy extends Record<string, any> {
   updateBlock: (srcBlock: BlockIdentity, content: string, opts?: Partial<{ props: {} }>) => Promise<void>
   removeBlock: (srcBlock: BlockIdentity, opts?: Partial<{ includeChildren: boolean }>) => Promise<void>
   getBlock: (srcBlock: BlockIdentity | BlockID, opts?: Partial<{ includeChildren: boolean }>) => Promise<BlockEntity | null>
-  getPage: (srcPage: PageIdentity, opts?: Partial<{ includeChildren: boolean }>) => Promise<PageEntity | null>
+  getPage: (srcPage: PageIdentity | BlockID, opts?: Partial<{ includeChildren: boolean }>) => Promise<PageEntity | null>
 
   getPreviousSiblingBlock: (srcBlock: BlockIdentity) => Promise<BlockEntity | null>
   getNextSiblingBlock: (srcBlock: BlockIdentity) => Promise<BlockEntity | null>

+ 4 - 2
src/main/logseq/api.cljs

@@ -210,8 +210,10 @@
         (bean/->js (normalize-keyword-for-json (db-utils/pull (:db/id page))))))))
 
 (def ^:export get_page
-  (fn [page-name]
-    (when-let [page (db-model/get-page page-name)]
+  (fn [id-or-page-name]
+    (when-let [page (cond
+                      (number? id-or-page-name) (db-utils/pull id-or-page-name)
+                      (string? id-or-page-name) (db-model/get-page id-or-page-name))]
       (if-not (contains? page :block/left)
         (bean/->js (normalize-keyword-for-json (db-utils/pull (:db/id page))))))))