Pārlūkot izejas kodu

improve(plugin): update api

charlie 4 gadi atpakaļ
vecāks
revīzija
db85eac095
3 mainītis faili ar 6 papildinājumiem un 7 dzēšanām
  1. 1 1
      libs/package.json
  2. 1 1
      libs/src/LSPlugin.d.ts
  3. 4 5
      src/main/logseq/api.cljs

+ 1 - 1
libs/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@logseq/libs",
-  "version": "0.0.1-alpha.14",
+  "version": "0.0.1-alpha.15",
   "description": "Logseq SDK libraries",
   "main": "dist/lsplugin.user.js",
   "typings": "index.d.ts",

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

@@ -160,9 +160,9 @@ interface IEditorProxy extends Record<string, any> {
   restoreEditingCursor: () => Promise<void>
   exitEditingMode: (selectBlock?: boolean) => Promise<void>
   getEditingCursorPosition: () => Promise<BlockCursorPosition | null>
+  getEditingBlockContent: () => Promise<string>
   getCurrentPage: () => Promise<PageEntity | BlockEntity | null>
   getCurrentBlock: () => Promise<BlockEntity | null>
-  getCurrentBlockContent: () => Promise<[string, BlockUUID] | null>
   getCurrentPageBlocksTree: () => Promise<Array<BlockEntity>>
   getPageBlocksTree: (srcPage: PageIdentity) => Promise<Array<BlockEntity>>
 

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

@@ -192,6 +192,10 @@
     (when-let [input-id (state/get-edit-input-id)]
       (bean/->js (normalize-keyword-for-json (util/get-caret-pos (gdom/getElement input-id)))))))
 
+(def ^:export get_editing_block_content
+  (fn []
+    (state/get-edit-content)))
+
 (def ^:export get_current_block
   (fn []
     (let [block (state/get-edit-block)
@@ -199,11 +203,6 @@
           block (and block (db-utils/pull (:db/id block)))]
       (bean/->js (normalize-keyword-for-json block)))))
 
-(def ^:export get_current_block_content
-  (fn []
-    (when-let [block (state/get-edit-block)]
-      (bean/->js [(state/get-edit-content) (str (:block/uuid block))]))))
-
 (def ^:export get_current_page
   (fn []
     (when-let [page (state/get-current-page)]