Browse Source

fix(api): compatible block content/title for the classic APIs

charlie 1 year ago
parent
commit
7209540fe2
2 changed files with 8 additions and 3 deletions
  1. 2 2
      libs/src/LSPlugin.ts
  2. 6 1
      src/main/logseq/sdk/utils.cljs

+ 2 - 2
libs/src/LSPlugin.ts

@@ -183,7 +183,8 @@ export interface BlockEntity {
   order: string
   format: 'markdown' | 'org'
   parent: IEntityID
-  content: string
+  title: string
+  content?: string // @deprecated. Use :title instead!
   page: IEntityID
   createdAt: number
   updatedAt: number
@@ -198,7 +199,6 @@ export interface BlockEntity {
   file?: IEntityID
   level?: number
   meta?: { timestamps: any; properties: any; startPos: number; endPos: number }
-  title?: Array<any>
   marker?: string
 
   [key: string]: unknown

+ 6 - 1
src/main/logseq/sdk/utils.cljs

@@ -22,7 +22,7 @@
                                                (entity->map %)
                                                %) input)
                    :else input)]
-       (walk/postwalk
+       (walk/prewalk
         (fn [a]
           (cond
             (keyword? a)
@@ -31,6 +31,11 @@
               (csk/->camelCase))
 
             (uuid? a) (str a)
+
+            ;; @FIXME compatible layer for classic APIs
+            (and (map? a) (:block/uuid a))
+            (some->> (:block/title a) (assoc a :block/content))
+
             :else a)) input)))))
 
 (defn uuid-or-throw-error