Преглед изворни кода

enhance(libs): add get_file_content function for retrieving file content

charlie пре 1 недеља
родитељ
комит
23c6f81010
3 измењених фајлова са 7 додато и 0 уклоњено
  1. 1 0
      libs/src/LSPlugin.ts
  2. 1 0
      src/main/logseq/api.cljs
  3. 5 0
      src/main/logseq/api/db.cljs

+ 1 - 0
libs/src/LSPlugin.ts

@@ -924,6 +924,7 @@ export interface IDBProxy {
    * @param content
    */
   setFileContent: (path: string, content: string) => Promise<void>
+  getFileContent: (path: string) => Promise<string | null>
 }
 
 /**

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

@@ -89,6 +89,7 @@
 (def ^:export datascript_query api-db/datascript_query)
 (def ^:export custom_query api-db/custom_query)
 (def ^:export set_file_content api-db/set_file_content)
+(def ^:export get_file_content api-db/get_file_content)
 
 ;; editor
 (def ^:export prepend_block_in_page api-editor/prepend_block_in_page)

+ 5 - 0
src/main/logseq/api/db.cljs

@@ -3,6 +3,7 @@
   (:require [cljs-bean.core :as bean]
             [cljs.reader]
             [frontend.db :as db]
+            [frontend.db.model :as db-model]
             [frontend.db.async :as db-async]
             [frontend.db.query-custom :as query-custom]
             [frontend.db.query-dsl :as query-dsl]
@@ -67,3 +68,7 @@
        (db/transact! [{:file/path path
                        :file/content content}])
        true))))
+
+(defn get_file_content
+  [path]
+  (db-model/get-file path))