Interface IEditorProxy

Editor related APIs

Hierarchy

  • Record<string, any>
    • IEditorProxy

Properties

appendBlockInPage: ((page: PageIdentity, content: string, opts?: Partial<{
    properties: {};
}>) => Promise<BlockEntity>)

Type declaration

    • (page: PageIdentity, content: string, opts?: Partial<{
          properties: {};
      }>): Promise<BlockEntity>
    • Parameters

      • page: PageIdentity
      • content: string
      • Optional opts: Partial<{
            properties: {};
        }>

      Returns Promise<BlockEntity>

checkEditing: (() => Promise<string | boolean>)

Type declaration

    • (): Promise<string | boolean>
    • Returns Promise<string | boolean>

createPage: ((pageName: string, properties?: {}, opts?: Partial<{
    createFirstBlock: boolean;
    format: "markdown" | "org";
    journal: boolean;
    redirect: boolean;
}>) => Promise<PageEntity>)

Type declaration

    • (pageName: string, properties?: {}, opts?: Partial<{
          createFirstBlock: boolean;
          format: "markdown" | "org";
          journal: boolean;
          redirect: boolean;
      }>): Promise<PageEntity>
    • Parameters

      • pageName: string
      • Optional properties: {}
        • Optional opts: Partial<{
              createFirstBlock: boolean;
              format: "markdown" | "org";
              journal: boolean;
              redirect: boolean;
          }>

        Returns Promise<PageEntity>

    deletePage: ((pageName: string) => Promise<void>)

    Type declaration

      • (pageName: string): Promise<void>
      • Parameters

        • pageName: string

        Returns Promise<void>

    editBlock: ((srcBlock: BlockIdentity, opts?: {
        pos: number;
    }) => Promise<void>)

    Type declaration

      • (srcBlock: BlockIdentity, opts?: {
            pos: number;
        }): Promise<void>
      • Parameters

        • srcBlock: BlockIdentity
        • Optional opts: {
              pos: number;
          }
          • pos: number

        Returns Promise<void>

    exitEditingMode: ((selectBlock?: boolean) => Promise<void>)

    Type declaration

      • (selectBlock?: boolean): Promise<void>
      • Parameters

        • Optional selectBlock: boolean

        Returns Promise<void>

    getAllPages: ((repo?: string) => Promise<PageEntity[]>)

    Type declaration

      • (repo?: string): Promise<PageEntity[]>
      • Parameters

        • Optional repo: string

        Returns Promise<PageEntity[]>

    getBlock: ((srcBlock: number | BlockIdentity, opts?: Partial<{
        includeChildren: boolean;
    }>) => Promise<BlockEntity>)

    Type declaration

      • (srcBlock: number | BlockIdentity, opts?: Partial<{
            includeChildren: boolean;
        }>): Promise<BlockEntity>
      • Parameters

        • srcBlock: number | BlockIdentity
        • Optional opts: Partial<{
              includeChildren: boolean;
          }>

        Returns Promise<BlockEntity>

    getBlockProperties: ((block: BlockIdentity) => Promise<any>)

    Type declaration

    getBlockProperty: ((block: BlockIdentity, key: string) => Promise<any>)

    Type declaration

    getCurrentBlock: (() => Promise<BlockEntity>)

    Type declaration

    getCurrentPage: (() => Promise<BlockEntity | PageEntity>)

    Type declaration

    getCurrentPageBlocksTree: (() => Promise<BlockEntity[]>)

    Type declaration

      • (): Promise<BlockEntity[]>
      • get all blocks of the current page as a tree structure

        Example

        const blocks = await logseq.Editor.getCurrentPageBlocksTree()
        initMindMap(blocks)

        Returns Promise<BlockEntity[]>

    getEditingBlockContent: (() => Promise<string>)

    Type declaration

      • (): Promise<string>
      • Returns Promise<string>

    getEditingCursorPosition: (() => Promise<BlockCursorPosition>)

    Type declaration

    getNextSiblingBlock: ((srcBlock: BlockIdentity) => Promise<BlockEntity>)

    Type declaration

    getPage: ((srcPage: number | PageIdentity, opts?: Partial<{
        includeChildren: boolean;
    }>) => Promise<PageEntity>)

    Type declaration

      • (srcPage: number | PageIdentity, opts?: Partial<{
            includeChildren: boolean;
        }>): Promise<PageEntity>
      • Parameters

        • srcPage: number | PageIdentity
        • Optional opts: Partial<{
              includeChildren: boolean;
          }>

        Returns Promise<PageEntity>

    getPageBlocksTree: ((srcPage: PageIdentity) => Promise<BlockEntity[]>)

    Type declaration

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

    Type declaration

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

    Type declaration

      • (namespace: string): Promise<PageEntity[]>
      • get flatten pages from top namespace

        Parameters

        • namespace: string

        Returns Promise<PageEntity[]>

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

    Type declaration

      • (namespace: string): Promise<PageEntity[]>
      • construct pages tree from namespace pages

        Parameters

        • namespace: string

        Returns Promise<PageEntity[]>

    getPreviousSiblingBlock: ((srcBlock: BlockIdentity) => Promise<BlockEntity>)

    Type declaration

    getSelectedBlocks: (() => Promise<BlockEntity[]>)

    Type declaration

    insertAtEditingCursor: ((content: string) => Promise<void>)

    Type declaration

      • (content: string): Promise<void>
      • Parameters

        • content: string

        Returns Promise<void>

    insertBatchBlock: ((srcBlock: BlockIdentity, batch: IBatchBlock | IBatchBlock[], opts?: Partial<{
        before: boolean;
        keepUUID: boolean;
        sibling: boolean;
    }>) => Promise<BlockEntity[]>)

    Type declaration

    insertBlock: ((srcBlock: BlockIdentity, content: string, opts?: Partial<{
        before: boolean;
        customUUID: string;
        focus: boolean;
        isPageBlock: boolean;
        properties: {};
        sibling: boolean;
    }>) => Promise<BlockEntity>)

    Type declaration

      • (srcBlock: BlockIdentity, content: string, opts?: Partial<{
            before: boolean;
            customUUID: string;
            focus: boolean;
            isPageBlock: boolean;
            properties: {};
            sibling: boolean;
        }>): Promise<BlockEntity>
      • Example

        https://github.com/logseq/logseq-plugin-samples/tree/master/logseq-reddit-hot-news
        

        Parameters

        • srcBlock: BlockIdentity
        • content: string
        • Optional opts: Partial<{
              before: boolean;
              customUUID: string;
              focus: boolean;
              isPageBlock: boolean;
              properties: {};
              sibling: boolean;
          }>

        Returns Promise<BlockEntity>

    moveBlock: ((srcBlock: BlockIdentity, targetBlock: BlockIdentity, opts?: Partial<{
        before: boolean;
        children: boolean;
    }>) => Promise<void>)

    Type declaration

      • (srcBlock: BlockIdentity, targetBlock: BlockIdentity, opts?: Partial<{
            before: boolean;
            children: boolean;
        }>): Promise<void>
      • Parameters

        • srcBlock: BlockIdentity
        • targetBlock: BlockIdentity
        • Optional opts: Partial<{
              before: boolean;
              children: boolean;
          }>

        Returns Promise<void>

    newBlockUUID: (() => Promise<string>)

    Type declaration

      • (): Promise<string>
      • Create a unique UUID string which can then be assigned to a block.

        Added

        0.0.8

        Returns Promise<string>

    onInputSelectionEnd: IUserHook<{
        caret: any;
        end: number;
        point: {
            x: number;
            y: number;
        };
        start: number;
        text: string;
    }, IUserOffHook>

    Example

    https://github.com/logseq/logseq-plugin-samples/tree/master/logseq-a-translator
    
    openInRightSidebar: ((uuid: string) => void)

    Type declaration

      • (uuid: string): void
      • Parameters

        • uuid: string

        Returns void

    prependBlockInPage: ((page: PageIdentity, content: string, opts?: Partial<{
        properties: {};
    }>) => Promise<BlockEntity>)

    Type declaration

      • (page: PageIdentity, content: string, opts?: Partial<{
            properties: {};
        }>): Promise<BlockEntity>
      • Parameters

        • page: PageIdentity
        • content: string
        • Optional opts: Partial<{
              properties: {};
          }>

        Returns Promise<BlockEntity>

    registerBlockContextMenuItem: ((label: string, action: BlockCommandCallback) => unknown)

    Type declaration

      • (label: string, action: BlockCommandCallback): unknown
      • register a custom command in the block context menu (triggered by right-clicking the block dot)

        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<any>, opts?: {
        clearSelection: boolean;
    }) => unknown)

    Type declaration

      • (label: string, action: SimpleCommandCallback<any>, opts?: {
            clearSelection: boolean;
        }): unknown
      • Current it's only available for pdf viewer

        Parameters

        • label: string

          displayed name of command

        • action: SimpleCommandCallback<any>

          callback for the clickable item

        • Optional opts: {
              clearSelection: boolean;
          }

          clearSelection: clear highlight selection when callback invoked

          • clearSelection: boolean

        Returns unknown

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

    Type declaration

      • (tag: string, action: BlockCommandCallback | [cmd: SlashCommandActionCmd, ...args: any[]][]): unknown
      • register a custom command which will be added to the Logseq slash command list

        Example

        https://github.com/logseq/logseq-plugin-samples/tree/master/logseq-slash-commands
        

        Example

        logseq.Editor.registerSlashCommand("Say Hi", () => {
        console.log('Hi!')
        })

        Example

        logseq.Editor.registerSlashCommand("💥 Big Bang", [
        ["editor/hook", "customCallback"],
        ["editor/clear-current-slash"],
        ]);

        Parameters

        • tag: string

          displayed name of command

        • action: BlockCommandCallback | [cmd: SlashCommandActionCmd, ...args: any[]][]

          can be a single callback function to run when the command is called, or an array of fixed commands with arguments

        Returns unknown

    removeBlock: ((srcBlock: BlockIdentity) => Promise<void>)

    Type declaration

    removeBlockProperty: ((block: BlockIdentity, key: string) => Promise<void>)

    Type declaration

    renamePage: ((oldName: string, newName: string) => Promise<void>)

    Type declaration

      • (oldName: string, newName: string): Promise<void>
      • Parameters

        • oldName: string
        • newName: string

        Returns Promise<void>

    restoreEditingCursor: (() => Promise<void>)

    Type declaration

      • (): Promise<void>
      • Returns Promise<void>

    saveFocusedCodeEditorContent: (() => Promise<void>)

    Type declaration

      • (): Promise<void>
      • Returns Promise<void>

    scrollToBlockInPage: ((pageName: string, blockId: BlockIdentity, opts?: {
        replaceState: boolean;
    }) => void)

    Type declaration

      • (pageName: string, blockId: BlockIdentity, opts?: {
            replaceState: boolean;
        }): void
      • Parameters

        • pageName: string
        • blockId: BlockIdentity
        • Optional opts: {
              replaceState: boolean;
          }
          • replaceState: boolean

        Returns void

    selectBlock: ((srcBlock: BlockIdentity) => Promise<void>)

    Type declaration

    setBlockCollapsed: ((uuid: string, opts: boolean | "toggle" | {
        flag: boolean | "toggle";
    }) => Promise<void>)

    Type declaration

      • (uuid: string, opts: boolean | "toggle" | {
            flag: boolean | "toggle";
        }): Promise<void>
      • Example

         logseq.Editor.setBlockCollapsed('uuid', true)
        logseq.Editor.setBlockCollapsed('uuid', 'toggle')

        Parameters

        • uuid: string
        • opts: boolean | "toggle" | {
              flag: boolean | "toggle";
          }

        Returns Promise<void>

    updateBlock: ((srcBlock: BlockIdentity, content: string, opts?: Partial<{
        properties: {};
    }>) => Promise<void>)

    Type declaration

      • (srcBlock: BlockIdentity, content: string, opts?: Partial<{
            properties: {};
        }>): Promise<void>
      • Parameters

        • srcBlock: BlockIdentity
        • content: string
        • Optional opts: Partial<{
              properties: {};
          }>

        Returns Promise<void>

    upsertBlockProperty: ((block: BlockIdentity, key: string, value: any) => Promise<void>)

    Type declaration

      • (block: BlockIdentity, key: string, value: any): Promise<void>
      • Parameters

        Returns Promise<void>

    Generated using TypeDoc