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

enhance(apis): add tag related apis

charlie пре 1 недеља
родитељ
комит
e5903e1c21
2 измењених фајлова са 8 додато и 4 уклоњено
  1. 4 0
      libs/src/LSPlugin.ts
  2. 4 4
      src/main/logseq/api/db_based.cljs

+ 4 - 0
libs/src/LSPlugin.ts

@@ -785,8 +785,12 @@ export interface IEditorProxy extends Record<string, any> {
   getTag: (nameOrIdent: string) => Promise<PageEntity | null>
   getTag: (nameOrIdent: string) => Promise<PageEntity | null>
   addTagProperty: (tagId: BlockIdentity, propertyIdOrName: BlockIdentity) => Promise<void>
   addTagProperty: (tagId: BlockIdentity, propertyIdOrName: BlockIdentity) => Promise<void>
   removeTagProperty: (tagId: BlockIdentity, propertyIdOrName: BlockIdentity) => Promise<void>
   removeTagProperty: (tagId: BlockIdentity, propertyIdOrName: BlockIdentity) => Promise<void>
+  addTagExtends: (tagId: BlockIdentity, parentTagIdOrName: BlockIdentity) => Promise<void>
+  removeTagExtends: (tagId: BlockIdentity, parentTagIdOrName: BlockIdentity) => Promise<void>
   addBlockTag: (blockId: BlockIdentity, tagId: BlockIdentity) => Promise<void>
   addBlockTag: (blockId: BlockIdentity, tagId: BlockIdentity) => Promise<void>
   removeBlockTag: (blockId: BlockIdentity, tagId: BlockIdentity) => Promise<void>
   removeBlockTag: (blockId: BlockIdentity, tagId: BlockIdentity) => Promise<void>
+  setBlockIcon: (blockId: BlockIdentity, iconType: 'tabler-icon' | 'emoji', iconName: string) => Promise<void>
+  removeBlockIcon: (blockId: BlockIdentity) => Promise<void>
 
 
   prependBlockInPage: (
   prependBlockInPage: (
     page: PageIdentity,
     page: PageIdentity,

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

@@ -233,8 +233,8 @@
                     {:tag tag}))))
                     {:tag tag}))))
 
 
 (defn add-tag-extends [tag-id extend-id]
 (defn add-tag-extends [tag-id extend-id]
-  (let [tag (db-async/<get-block (state/get-current-repo) tag-id)
-        extend (db-async/<get-block (state/get-current-repo) extend-id)]
+  (p/let [tag (db-async/<get-block (state/get-current-repo) tag-id)
+          extend (db-async/<get-block (state/get-current-repo) extend-id)]
     (throw-error-if-not-tag! tag tag-id)
     (throw-error-if-not-tag! tag tag-id)
     (throw-error-if-not-tag! extend extend-id)
     (throw-error-if-not-tag! extend extend-id)
     (when (ldb/built-in? tag)
     (when (ldb/built-in? tag)
@@ -244,8 +244,8 @@
                                              (:db/id extend))))
                                              (:db/id extend))))
 
 
 (defn remove-tag-extends [tag-id extend-id]
 (defn remove-tag-extends [tag-id extend-id]
-  (let [tag (db-async/<get-block (state/get-current-repo) tag-id)
-        extend (db-async/<get-block (state/get-current-repo) extend-id)]
+  (p/let [tag (db-async/<get-block (state/get-current-repo) tag-id)
+          extend (db-async/<get-block (state/get-current-repo) extend-id)]
     (throw-error-if-not-tag! tag tag-id)
     (throw-error-if-not-tag! tag tag-id)
     (throw-error-if-not-tag! extend extend-id)
     (throw-error-if-not-tag! extend extend-id)
     (when (ldb/built-in? tag)
     (when (ldb/built-in? tag)