Interface ILSPluginUser

Hierarchy

Implemented by

Properties

App: IAppProxy & Record<string, any>
Assets: IAssetsProxy
Editor: IEditorProxy & Record<string, any>
Experiments: LSPluginExperiments
FileStorage: LSPluginFileStorage
Request: LSPluginRequest

The plugin configurations from package.json

beforeunload: ((callback: (() => Promise<void>)) => void)

Type declaration

    • (callback: (() => Promise<void>)): void
    • Parameters

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

      Returns void

caller: LSPluginCaller

Duplex message caller

connected: boolean

Connection status with the main app

isMainUIVisible: boolean
settings?: {
    disabled: boolean;
    [key: string]: any;
}

The plugin user settings

Type declaration

  • [key: string]: any
  • disabled: boolean

Methods

  • Type Parameters

    Parameters

    • event: T
    • fn: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns ILSPluginUser

  • Calls each of the listeners registered for a given event.

    Type Parameters

    Parameters

    • event: T
    • Rest ...args: any[]

    Returns boolean

  • Return an array listing the events for which the emitter has registered listeners.

    Returns LSPluginUserEvents[]

  • hide the plugin's UI

    Parameters

    • Optional opts: {
          restoreEditingCursor: boolean;
      }
      • restoreEditingCursor: boolean

    Returns void

  • Return the number of listeners listening to a given event.

    Parameters

    Returns number

  • Return the listeners registered for a given event.

    Type Parameters

    Parameters

    • event: T

    Returns ((...args: any[]) => void)[]

  • Type Parameters

    Parameters

    • event: T
    • Optional fn: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns ILSPluginUser

  • Add a listener for a given event.

    Type Parameters

    Parameters

    • event: T
    • fn: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns ILSPluginUser

  • Type Parameters

    • T = any

    Parameters

    • cb: ((a: T, b: T) => void)
        • (a: T, b: T): void
        • Parameters

          • a: T
          • b: T

          Returns void

    Returns IUserOffHook

  • Add a one-time listener for a given event.

    Type Parameters

    Parameters

    • event: T
    • fn: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns ILSPluginUser

  • Create a object to hold the methods referenced in provideUI

    Example

    logseq.provideModel({
    openCalendar () {
    console.log('Open the calendar!')
    }
    })

    Parameters

    • model: Record<string, any>

    Returns ILSPluginUser

  • Inject custom css for the main Logseq app

    Example

    https://github.com/logseq/logseq-plugin-samples/tree/master/logseq-awesome-fonts
    

    Example

      logseq.provideStyle(`
    @import url("https://at.alicdn.com/t/font_2409735_r7em724douf.css");
    )

    Parameters

    Returns ILSPluginUser

  • Inject custom UI at specific DOM node. Event handlers can not be passed by string, so you need to create them in provideModel

    Example

    https://github.com/logseq/logseq-plugin-samples/tree/master/logseq-a-translator
    

    Example

    logseq.provideUI({
    key: 'open-calendar',
    path: '#search',
    template: `
    <a data-on-click="openCalendar" onclick="alert('abc')' style="opacity: .6; display: inline-flex; padding-left: 3px;'>
    <i class="iconfont icon-Calendaralt2"></i>
    </a>
    `
    })

    Parameters

    Returns ILSPluginUser

  • The main Logseq app is ready to run the plugin

    Parameters

    • Optional model: Record<string, any>

      same as the model in provideModel

    Returns Promise<any>

  • Parameters

    • Optional callback: ((e: any) => void | {})

      a function to run when the main Logseq app is ready

        • (e: any): void | {}
        • Parameters

          • e: any

          Returns void | {}

    Returns Promise<any>

  • Parameters

    • Optional model: Record<string, any>
    • Optional callback: ((e: any) => void | {})
        • (e: any): void | {}
        • Parameters

          • e: any

          Returns void | {}

    Returns Promise<any>

  • Remove the listeners of a given event.

    Type Parameters

    Parameters

    • event: T
    • Optional fn: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns ILSPluginUser

  • Parameters

    • filePath: string

    Returns string

  • Parameters

    • attrs: Record<string, any>

    Returns void

  • Set the style for the plugin's UI

    Example

    https://github.com/logseq/logseq-plugin-samples/tree/master/logseq-awesome-fonts
    

    Example

    logseq.setMainUIInlineStyle({
    position: 'fixed',
    zIndex: 11,
    })

    Parameters

    • style: Properties<0 | string & {}, string & {}>

    Returns void

  • show the plugin's UI

    Parameters

    • Optional opts: {
          autoFocus: boolean;
      }
      • autoFocus: boolean

    Returns void

  • Example

    https://github.com/logseq/logseq-plugin-samples/tree/master/logseq-awesome-fonts
    

    Parameters

    • attrs: Record<string, any>

    Returns void

Generated using TypeDoc