@logseq/libs
    Preparing search index...

    Interface IEditorProxy

    Editor related APIs

    interface IEditorProxy {
        addBlockTag: (
            blockId: BlockIdentity,
            tagId: BlockIdentity,
        ) => Promise<void>;
        addTagExtends: (
            tagId: BlockIdentity,
            parentTagIdOrName: BlockIdentity,
        ) => Promise<void>;
        addTagProperty: (
            tagId: BlockIdentity,
            propertyIdOrName: BlockIdentity,
        ) => Promise<void>;
        appendBlockInPage: (
            page: PageIdentity,
            content: string,
            opts?: Partial<{ properties: {} }>,
        ) => Promise<BlockEntity>;
        checkEditing: () => Promise<string | boolean>;
        clearSelectedBlocks: () => Promise<void>;
        createJournalPage: (date: string | Date) => Promise<PageEntity>;
        createPage: (
            pageName: string,
            properties?: {},
            opts?: Partial<
                {
                    createFirstBlock: boolean;
                    customUUID: string;
                    format: BlockEntity["format"];
                    journal: boolean;
                    redirect: boolean;
                },
            >,
        ) => Promise<PageEntity>;
        createTag: (
            tagName: string,
            opts?: Partial<{ uuid: string }>,
        ) => Promise<PageEntity>;
        deletePage: (pageName: string) => Promise<void>;
        editBlock: (
            srcBlock: BlockIdentity,
            opts?: { pos: number },
        ) => Promise<void>;
        exitEditingMode: (selectBlock?: boolean) => Promise<void>;
        getAllPages: (repo?: string) => Promise<PageEntity[]>;
        getAllProperties: () => Promise<PageEntity[]>;
        getAllTags: () => Promise<PageEntity[]>;
        getBlock: (
            srcBlock: number | BlockIdentity,
            opts?: Partial<{ includeChildren: boolean }>,
        ) => Promise<BlockEntity>;
        getBlockProperties: (
            block: number | BlockIdentity,
        ) => Promise<Record<string, any>>;
        getBlockProperty: (
            block: number | BlockIdentity,
            key: string,
        ) => Promise<BlockEntity>;
        getCurrentBlock: () => Promise<BlockEntity>;
        getCurrentPage: () => Promise<BlockEntity | PageEntity>;
        getCurrentPageBlocksTree: () => Promise<BlockEntity[]>;
        getEditingBlockContent: () => Promise<string>;
        getEditingCursorPosition: () => Promise<BlockCursorPosition>;
        getNextSiblingBlock: (
            srcBlock: number | BlockIdentity,
        ) => Promise<BlockEntity>;
        getPage: (
            srcPage: number | PageIdentity,
            opts?: Partial<{ includeChildren: boolean }>,
        ) => Promise<PageEntity>;
        getPageBlocksTree: (srcPage: PageIdentity) => Promise<BlockEntity[]>;
        getPageLinkedReferences: (
            srcPage: PageIdentity,
        ) => Promise<[page: PageEntity, blocks: BlockEntity[]][]>;
        getPageProperties: (
            page: number | PageIdentity,
        ) => Promise<Record<string, any>>;
        getPagesFromNamespace: (namespace: string) => Promise<PageEntity[]>;
        getPagesTreeFromNamespace: (namespace: string) => Promise<PageEntity[]>;
        getPreviousSiblingBlock: (
            srcBlock: number | BlockIdentity,
        ) => Promise<BlockEntity>;
        getProperty: (key: string) => Promise<BlockEntity>;
        getSelectedBlocks: () => Promise<BlockEntity[]>;
        getTag: (nameOrIdent: string | number) => Promise<PageEntity>;
        getTagObjects: (nameOrIdent: string) => Promise<BlockEntity[]>;
        insertAtEditingCursor: (content: string) => Promise<void>;
        insertBatchBlock: (
            srcBlock: BlockIdentity,
            batch: IBatchBlock | IBatchBlock[],
            opts?: Partial<{ before: boolean; keepUUID: boolean; sibling: boolean }>,
        ) => Promise<BlockEntity[]>;
        insertBlock: (
            srcBlock: number | BlockIdentity,
            content: string,
            opts?: Partial<
                {
                    before: boolean;
                    customUUID: string;
                    end: boolean;
                    properties: {};
                    sibling: boolean;
                    start: boolean;
                },
            >,
        ) => Promise<BlockEntity>;
        isPageBlock: (block: BlockEntity | PageEntity) => Boolean;
        moveBlock: (
            srcBlock: BlockIdentity,
            targetBlock: BlockIdentity,
            opts?: Partial<{ before: boolean; children: boolean }>,
        ) => Promise<void>;
        newBlockUUID: () => Promise<string>;
        onInputSelectionEnd: IUserHook<
            {
                caret: any;
                end: number;
                point: { x: number; y: number };
                start: number;
                text: string;
            },
        >;
        openInRightSidebar: (id: string | number) => void;
        openPDFViewer: (assetBlockIdOrFileUrl: string | number) => Promise<void>;
        prependBlockInPage: (
            page: PageIdentity,
            content: string,
            opts?: Partial<{ properties: {} }>,
        ) => Promise<BlockEntity>;
        registerBlockContextMenuItem: (
            label: string,
            action: BlockCommandCallback,
        ) => unknown;
        registerHighlightContextMenuItem: (
            label: string,
            action: SimpleCommandCallback,
            opts?: { clearSelection: boolean },
        ) => unknown;
        registerSlashCommand: (
            tag: string,
            action:
                | BlockCommandCallback
                | [cmd: SlashCommandActionCmd, ...args: any[]][],
        ) => unknown;
        removeBlock: (srcBlock: number | BlockIdentity) => Promise<void>;
        removeBlockIcon: (blockId: BlockIdentity) => Promise<void>;
        removeBlockProperty: (
            block: number | BlockIdentity,
            key: string,
        ) => Promise<void>;
        removeBlockTag: (
            blockId: BlockIdentity,
            tagId: BlockIdentity,
        ) => Promise<void>;
        removeProperty: (key: string) => Promise<void>;
        removeTagExtends: (
            tagId: BlockIdentity,
            parentTagIdOrName: BlockIdentity,
        ) => Promise<void>;
        removeTagProperty: (
            tagId: BlockIdentity,
            propertyIdOrName: BlockIdentity,
        ) => Promise<void>;
        renamePage: (oldName: string, newName: string) => Promise<void>;
        restoreEditingCursor: () => Promise<void>;
        saveFocusedCodeEditorContent: () => Promise<void>;
        scrollToBlockInPage: (
            pageName: string,
            blockId: BlockIdentity,
            opts?: { replaceState: boolean },
        ) => void;
        selectBlock: (srcBlock: BlockIdentity) => Promise<void>;
        setBlockCollapsed: (
            srcBlock: number | BlockIdentity,
            opts: boolean | "toggle" | { flag: boolean | "toggle" },
        ) => Promise<void>;
        setBlockIcon: (
            blockId: BlockIdentity,
            iconType: "tabler-icon" | "emoji",
            iconName: string,
        ) => Promise<void>;
        updateBlock: (
            srcBlock: number | BlockIdentity,
            content: string,
            opts?: Partial<{ properties: {} }>,
        ) => Promise<void>;
        upsertBlockProperty: (
            block: number | BlockIdentity,
            key: string,
            value: any,
        ) => Promise<void>;
        upsertProperty: (
            key: string,
            schema?: Partial<
                {
                    cardinality: "many"
                    | "one";
                    hide: boolean;
                    public: boolean;
                    type:
                        | "default"
                        | "number"
                        | "node"
                        | "date"
                        | "checkbox"
                        | "url"
                        | string;
                },
            >,
            opts?: { name?: string },
        ) => Promise<IEntityID>;
        [key: string]: any;
    }

    Hierarchy

    • Record<string, any>
      • IEditorProxy

    Indexable

    • [key: string]: any
    Index

    Properties

    addBlockTag: (blockId: BlockIdentity, tagId: BlockIdentity) => Promise<void>
    addTagExtends: (
        tagId: BlockIdentity,
        parentTagIdOrName: BlockIdentity,
    ) => Promise<void>
    addTagProperty: (
        tagId: BlockIdentity,
        propertyIdOrName: BlockIdentity,
    ) => Promise<void>
    appendBlockInPage: (
        page: PageIdentity,
        content: string,
        opts?: Partial<{ properties: {} }>,
    ) => Promise<BlockEntity>
    checkEditing: () => Promise<string | boolean>
    clearSelectedBlocks: () => Promise<void>
    createJournalPage: (date: string | Date) => Promise<PageEntity>
    createPage: (
        pageName: string,
        properties?: {},
        opts?: Partial<
            {
                createFirstBlock: boolean;
                customUUID: string;
                format: BlockEntity["format"];
                journal: boolean;
                redirect: boolean;
            },
        >,
    ) => Promise<PageEntity>
    createTag: (
        tagName: string,
        opts?: Partial<{ uuid: string }>,
    ) => Promise<PageEntity>
    deletePage: (pageName: string) => Promise<void>
    editBlock: (srcBlock: BlockIdentity, opts?: { pos: number }) => Promise<void>
    exitEditingMode: (selectBlock?: boolean) => Promise<void>
    getAllPages: (repo?: string) => Promise<PageEntity[]>
    getAllProperties: () => Promise<PageEntity[]>
    getAllTags: () => Promise<PageEntity[]>
    getBlock: (
        srcBlock: number | BlockIdentity,
        opts?: Partial<{ includeChildren: boolean }>,
    ) => Promise<BlockEntity>
    getBlockProperties: (
        block: number | BlockIdentity,
    ) => Promise<Record<string, any>>
    getBlockProperty: (
        block: number | BlockIdentity,
        key: string,
    ) => Promise<BlockEntity>
    getCurrentBlock: () => Promise<BlockEntity>
    getCurrentPage: () => Promise<BlockEntity | PageEntity>
    getCurrentPageBlocksTree: () => Promise<BlockEntity[]>

    get all blocks of the current page as a tree structure

    const blocks = await logseq.Editor.getCurrentPageBlocksTree()
    initMindMap(blocks)
    getEditingBlockContent: () => Promise<string>
    getEditingCursorPosition: () => Promise<BlockCursorPosition>
    getNextSiblingBlock: (srcBlock: number | BlockIdentity) => Promise<BlockEntity>
    getPage: (
        srcPage: number | PageIdentity,
        opts?: Partial<{ includeChildren: boolean }>,
    ) => Promise<PageEntity>
    getPageBlocksTree: (srcPage: PageIdentity) => Promise<BlockEntity[]>

    get all blocks for the specified page

    Type Declaration

    getPageLinkedReferences: (
        srcPage: PageIdentity,
    ) => Promise<[page: PageEntity, blocks: BlockEntity[]][]>

    get all page/block linked references

    getPageProperties: (page: number | PageIdentity) => Promise<Record<string, any>>
    getPagesFromNamespace: (namespace: string) => Promise<PageEntity[]>

    get flatten pages from top namespace

    getPagesTreeFromNamespace: (namespace: string) => Promise<PageEntity[]>

    construct pages tree from namespace pages

    getPreviousSiblingBlock: (
        srcBlock: number | BlockIdentity,
    ) => Promise<BlockEntity>
    getProperty: (key: string) => Promise<BlockEntity>
    getSelectedBlocks: () => Promise<BlockEntity[]>
    getTag: (nameOrIdent: string | number) => Promise<PageEntity>
    getTagObjects: (nameOrIdent: string) => Promise<BlockEntity[]>
    insertAtEditingCursor: (content: string) => Promise<void>
    insertBatchBlock: (
        srcBlock: BlockIdentity,
        batch: IBatchBlock | IBatchBlock[],
        opts?: Partial<{ before: boolean; keepUUID: boolean; sibling: boolean }>,
    ) => Promise<BlockEntity[]>
    https://github.com/logseq/logseq-plugin-samples/tree/master/logseq-reddit-hot-news

    `keepUUID` will allow you to set a custom UUID for blocks by setting their properties.id
    insertBlock: (
        srcBlock: number | BlockIdentity,
        content: string,
        opts?: Partial<
            {
                before: boolean;
                customUUID: string;
                end: boolean;
                properties: {};
                sibling: boolean;
                start: boolean;
            },
        >,
    ) => Promise<BlockEntity>
    https://github.com/logseq/logseq-plugin-samples/tree/master/logseq-reddit-hot-news
    
    isPageBlock: (block: BlockEntity | PageEntity) => Boolean
    moveBlock: (
        srcBlock: BlockIdentity,
        targetBlock: BlockIdentity,
        opts?: Partial<{ before: boolean; children: boolean }>,
    ) => Promise<void>
    newBlockUUID: () => Promise<string>

    Create a unique UUID string which can then be assigned to a block.

    0.0.8

    onInputSelectionEnd: IUserHook<
        {
            caret: any;
            end: number;
            point: { x: number; y: number };
            start: number;
            text: string;
        },
    >
    https://github.com/logseq/logseq-plugin-samples/tree/master/logseq-a-translator
    
    openInRightSidebar: (id: string | number) => void
    openPDFViewer: (assetBlockIdOrFileUrl: string | number) => Promise<void>
    prependBlockInPage: (
        page: PageIdentity,
        content: string,
        opts?: Partial<{ properties: {} }>,
    ) => Promise<BlockEntity>
    registerBlockContextMenuItem: (
        label: string,
        action: BlockCommandCallback,
    ) => unknown

    register a custom command in the block context menu (triggered by right-clicking the block dot)

    Type Declaration

      • (label: string, action: BlockCommandCallback): unknown
      • Parameters

        • label: string

          displayed name of command

        • action: BlockCommandCallback

          can be a single callback function to run when the command is called

        Returns unknown

    registerHighlightContextMenuItem: (
        label: string,
        action: SimpleCommandCallback,
        opts?: { clearSelection: boolean },
    ) => unknown

    Current it's only available for pdf viewer

    Type Declaration

      • (
            label: string,
            action: SimpleCommandCallback,
            opts?: { clearSelection: boolean },
        ): unknown
      • Parameters

        • label: string

          displayed name of command

        • action: SimpleCommandCallback

          callback for the clickable item

        • Optionalopts: { clearSelection: boolean }

          clearSelection: clear highlight selection when callback invoked

        Returns unknown

    registerSlashCommand: (
        tag: string,
        action:
            | BlockCommandCallback
            | [cmd: SlashCommandActionCmd, ...args: any[]][],
    ) => unknown

    register a custom command which will be added to the Logseq slash command list

    Type Declaration

    https://github.com/logseq/logseq-plugin-samples/tree/master/logseq-slash-commands
    
    logseq.Editor.registerSlashCommand("Say Hi", () => {
    console.log('Hi!')
    })
    logseq.Editor.registerSlashCommand("💥 Big Bang", [
    ["editor/hook", "customCallback"],
    ["editor/clear-current-slash"],
    ]);
    removeBlock: (srcBlock: number | BlockIdentity) => Promise<void>
    removeBlockIcon: (blockId: BlockIdentity) => Promise<void>
    removeBlockProperty: (
        block: number | BlockIdentity,
        key: string,
    ) => Promise<void>
    removeBlockTag: (blockId: BlockIdentity, tagId: BlockIdentity) => Promise<void>
    removeProperty: (key: string) => Promise<void>
    removeTagExtends: (
        tagId: BlockIdentity,
        parentTagIdOrName: BlockIdentity,
    ) => Promise<void>
    removeTagProperty: (
        tagId: BlockIdentity,
        propertyIdOrName: BlockIdentity,
    ) => Promise<void>
    renamePage: (oldName: string, newName: string) => Promise<void>
    restoreEditingCursor: () => Promise<void>
    saveFocusedCodeEditorContent: () => Promise<void>
    scrollToBlockInPage: (
        pageName: string,
        blockId: BlockIdentity,
        opts?: { replaceState: boolean },
    ) => void
    selectBlock: (srcBlock: BlockIdentity) => Promise<void>
    setBlockCollapsed: (
        srcBlock: number | BlockIdentity,
        opts: boolean | "toggle" | { flag: boolean | "toggle" },
    ) => Promise<void>
    setBlockIcon: (
        blockId: BlockIdentity,
        iconType: "tabler-icon" | "emoji",
        iconName: string,
    ) => Promise<void>
    updateBlock: (
        srcBlock: number | BlockIdentity,
        content: string,
        opts?: Partial<{ properties: {} }>,
    ) => Promise<void>
    upsertBlockProperty: (
        block: number | BlockIdentity,
        key: string,
        value: any,
    ) => Promise<void>
    upsertProperty: (
        key: string,
        schema?: Partial<
            {
                cardinality: "many"
                | "one";
                hide: boolean;
                public: boolean;
                type:
                    | "default"
                    | "number"
                    | "node"
                    | "date"
                    | "checkbox"
                    | "url"
                    | string;
            },
        >,
        opts?: { name?: string },
    ) => Promise<IEntityID>