mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 14:14:55 +00:00
enhance(api): block related types
This commit is contained in:
@@ -180,14 +180,17 @@ export interface AppGraphInfo {
|
||||
export interface BlockEntity {
|
||||
id: EntityID // db id
|
||||
uuid: BlockUUID
|
||||
left: IEntityID
|
||||
order: string
|
||||
format: 'markdown' | 'org'
|
||||
parent: IEntityID
|
||||
content: string
|
||||
page: IEntityID
|
||||
createdAt: number
|
||||
updatedAt: number
|
||||
properties?: Record<string, any>
|
||||
|
||||
// optional fields in dummy page
|
||||
left?: IEntityID
|
||||
anchor?: string
|
||||
body?: any
|
||||
children?: Array<BlockEntity | BlockUUIDTuple>
|
||||
@@ -770,7 +773,9 @@ export interface IEditorProxy extends Record<string, any> {
|
||||
srcBlock: BlockIdentity
|
||||
) => Promise<BlockEntity | null>
|
||||
|
||||
getNextSiblingBlock: (srcBlock: BlockIdentity) => Promise<BlockEntity | null>
|
||||
getNextSiblingBlock: (
|
||||
srcBlock: BlockIdentity
|
||||
) => Promise<BlockEntity | null>
|
||||
|
||||
moveBlock: (
|
||||
srcBlock: BlockIdentity,
|
||||
@@ -791,9 +796,9 @@ export interface IEditorProxy extends Record<string, any> {
|
||||
|
||||
removeBlockProperty: (block: BlockIdentity, key: string) => Promise<void>
|
||||
|
||||
getBlockProperty: (block: BlockIdentity, key: string) => Promise<any>
|
||||
getBlockProperty: (block: BlockIdentity, key: string) => Promise<BlockEntity | string| null>
|
||||
|
||||
getBlockProperties: (block: BlockIdentity) => Promise<any>
|
||||
getBlockProperties: (block: BlockIdentity) => Promise<Record<string, any> | null>
|
||||
|
||||
scrollToBlockInPage: (
|
||||
pageName: BlockPageName,
|
||||
|
||||
@@ -755,24 +755,24 @@
|
||||
(get_block (:block/uuid block) opts))))
|
||||
|
||||
(def ^:export get_previous_sibling_block
|
||||
(fn [block-uuid]
|
||||
(fn [block-uuid ^js opts]
|
||||
(p/let [id (sdk-utils/uuid-or-throw-error block-uuid)
|
||||
block (<pull-block id)
|
||||
;; Load all children blocks
|
||||
_ (db-async/<get-block (state/get-current-repo) (:block/uuid (:block/parent block)) {:children? true})]
|
||||
(when block
|
||||
(when-let [left-sibling (ldb/get-left-sibling (db/entity (:db/id block)))]
|
||||
(let [block (db/pull (:db/id left-sibling))]
|
||||
(bean/->js (sdk-utils/normalize-keyword-for-json block))))))))
|
||||
(when-let [sibling (ldb/get-left-sibling (db/entity (:db/id block)))]
|
||||
(get_block (:block/uuid sibling) opts))))))
|
||||
|
||||
(def ^:export get_next_sibling_block
|
||||
(fn [block-uuid]
|
||||
(fn [block-uuid ^js opts]
|
||||
(p/let [id (sdk-utils/uuid-or-throw-error block-uuid)
|
||||
block (<pull-block id)]
|
||||
block (<pull-block id)
|
||||
;; Load all children blocks
|
||||
_ (db-async/<get-block (state/get-current-repo) (:block/uuid (:block/parent block)) {:children? true})]
|
||||
(when block
|
||||
(p/let [sibling (db-async/<get-right-sibling (state/get-current-repo) (:db/id block))]
|
||||
(when sibling
|
||||
(bean/->js (sdk-utils/normalize-keyword-for-json sibling))))))))
|
||||
(p/let [sibling (ldb/get-right-sibling (db/entity (:db/id block)))]
|
||||
(get_block (:block/uuid sibling) opts))))))
|
||||
|
||||
(def ^:export set_block_collapsed
|
||||
(fn [block-uuid ^js opts]
|
||||
|
||||
Reference in New Issue
Block a user