Browse Source

improve(plugin): insert block api & type & bump libs version

charlie 4 years ago
parent
commit
6535e2068d
4 changed files with 7 additions and 5 deletions
  1. 1 1
      libs/package.json
  2. 1 1
      libs/src/LSPlugin.ts
  3. 2 1
      src/main/frontend/handler/editor.cljs
  4. 3 2
      src/main/logseq/api.cljs

+ 1 - 1
libs/package.json

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

+ 1 - 1
libs/src/LSPlugin.ts

@@ -280,7 +280,7 @@ export interface IEditorProxy extends Record<string, any> {
     srcBlock: BlockIdentity,
     batch: IBatchBlock | Array<IBatchBlock>,
     opts?: Partial<{ before: boolean, sibling: boolean }>
-  ) => Promise<null>
+  ) => Promise<Array<BlockEntity> | null>
 
   updateBlock: (
     srcBlock: BlockIdentity,

+ 2 - 1
src/main/frontend/handler/editor.cljs

@@ -683,7 +683,8 @@
                                      nil)]
             (when block-m
               (outliner-insert-block! {:skip-save-current-block? true} block-m new-block sibling?)
-              (ui-handler/re-render-root!))))))))
+              (ui-handler/re-render-root!)
+              new-block)))))))
 
 (defn insert-first-page-block-if-not-exists!
   [page-name]

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

@@ -241,8 +241,9 @@
           new-block (editor-handler/api-insert-new-block!
                      content
                      {:block-uuid block-uuid
-                      :sibling? sibling
-                      :page page-name
+                      :sibling?   sibling
+                      :before?    before
+                      :page       page-name
                       :properties properties})]
       (bean/->js (normalize-keyword-for-json new-block)))))