Explorar o código

improve(plugin): api of select single block

charlie %!s(int64=3) %!d(string=hai) anos
pai
achega
af49427ef1
Modificáronse 2 ficheiros con 6 adicións e 0 borrados
  1. 1 0
      libs/src/LSPlugin.ts
  2. 5 0
      src/main/logseq/api.cljs

+ 1 - 0
libs/src/LSPlugin.ts

@@ -650,6 +650,7 @@ export interface IEditorProxy extends Record<string, any> {
   ) => Promise<void>
 
   editBlock: (srcBlock: BlockIdentity, opts?: { pos: number }) => Promise<void>
+  selectBlock: (srcBlock: BlockIdentity) => Promise<void>
 
   upsertBlockProperty: (
     block: BlockIdentity,

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

@@ -442,6 +442,11 @@
   [block-uuid]
   (editor-handler/open-block-in-sidebar! (uuid block-uuid)))
 
+(def ^:export select_block
+  (fn [block-uuid]
+    (when-let [block (db-model/get-block-by-uuid block-uuid)]
+      (editor-handler/select-block! (:block/uuid block)) nil)))
+
 (def ^:export edit_block
   (fn [block-uuid ^js opts]
     (when-let [block-uuid (and block-uuid (uuid block-uuid))]