@logseq/libs
    Preparing search index...

    Interface ILSPluginUser

    interface ILSPluginUser {
        App: IAppProxy;
        Assets: IAssetsProxy;
        baseInfo: LSPluginBaseInfo;
        beforeunload: (callback: () => Promise<void>) => void;
        caller: LSPluginCaller;
        connected: boolean;
        DB: IDBProxy;
        Editor: IEditorProxy;
        Experiments: LSPluginExperiments;
        FileStorage: LSPluginFileStorage;
        Git: IGitProxy;
        isMainUIVisible: boolean;
        Request: LSPluginRequest;
        settings?: { disabled: boolean } & Record<string, unknown>;
        UI: IUIProxy;
        addListener<T extends LSPluginUserEvents>(
            event: T,
            fn: (...args: any[]) => void,
            context?: any,
        ): this;
        emit<T extends LSPluginUserEvents>(event: T, ...args: any[]): boolean;
        eventNames(): LSPluginUserEvents[];
        hideMainUI(opts?: { restoreEditingCursor: boolean }): void;
        hideSettingsUI(): void;
        listenerCount(event: LSPluginUserEvents): number;
        listeners<T extends LSPluginUserEvents>(
            event: T,
        ): ((...args: any[]) => void)[];
        off<T extends LSPluginUserEvents>(
            event: T,
            fn?: (...args: any[]) => void,
            context?: any,
            once?: boolean,
        ): this;
        on<T extends LSPluginUserEvents>(
            event: T,
            fn: (...args: any[]) => void,
            context?: any,
        ): this;
        once<T extends LSPluginUserEvents>(
            event: T,
            fn: (...args: any[]) => void,
            context?: any,
        ): this;
        onSettingsChanged<T = any>(cb: (a: T, b: T) => void): IUserOffHook;
        provideModel(model: Record<string, any>): this;
        provideStyle(style: string | StyleOptions): this;
        provideTheme(theme: Theme): this;
        provideUI(ui: UIOptions): this;
        ready(model?: Record<string, any>): Promise<any>;
        ready(callback?: (e: any) => void | {}): Promise<any>;
        ready(
            model?: Record<string, any>,
            callback?: (e: any) => void | {},
        ): Promise<any>;
        removeAllListeners(event?: LSPluginUserEvents): this;
        removeListener<T extends LSPluginUserEvents>(
            event: T,
            fn?: (...args: any[]) => void,
            context?: any,
            once?: boolean,
        ): this;
        resolveResourceFullUrl(filePath: string): string;
        setMainUIAttrs(attrs: Record<string, any>): void;
        setMainUIInlineStyle(style: Properties): void;
        showMainUI(opts?: { autoFocus: boolean }): void;
        showSettingsUI(): void;
        toggleMainUI(): void;
        updateSettings(attrs: Record<string, any>): void;
        useSettingsSchema(schemas: SettingSchemaDesc[]): this;
    }

    Hierarchy

    Implemented by

    Index

    Properties

    Assets: IAssetsProxy

    The plugin configurations from package.json

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

    Duplex message caller

    connected: boolean

    Connection status with the main app

    Editor: IEditorProxy
    Experiments: LSPluginExperiments
    FileStorage: LSPluginFileStorage
    isMainUIVisible: boolean
    Request: LSPluginRequest
    settings?: { disabled: boolean } & Record<string, unknown>

    The plugin user settings

    Methods

    • Type Parameters

      Parameters

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

      Returns this

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

      Type Parameters

      Parameters

      • event: T
      • ...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

      • Optionalopts: { 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
      • Optionalfn: (...args: any[]) => void
      • Optionalcontext: any
      • Optionalonce: boolean

      Returns this

    • Add a listener for a given event.

      Type Parameters

      Parameters

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

      Returns this

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

      Type Parameters

      Parameters

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

      Returns this

    • Create a object to hold the methods referenced in provideUI

      Parameters

      • model: Record<string, any>

      Returns this

      logseq.provideModel({
      openCalendar () {
      console.log('Open the calendar!')
      }
      })
    • Inject custom css for the main Logseq app

      Parameters

      Returns this

      https://github.com/logseq/logseq-plugin-samples/tree/master/logseq-awesome-fonts
      
        logseq.provideStyle(`
      @import url("https://at.alicdn.com/t/font_2409735_r7em724douf.css");
      )
    • Inject custom UI at specific DOM node. Event handlers can not be passed by string, so you need to create them in provideModel

      Parameters

      Returns this

      https://github.com/logseq/logseq-plugin-samples/tree/master/logseq-a-translator
      
      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>
      `
      })
    • The main Logseq app is ready to run the plugin

      Parameters

      • Optionalmodel: Record<string, any>

        same as the model in provideModel

      Returns Promise<any>

    • Parameters

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

        a function to run when the main Logseq app is ready

      Returns Promise<any>

    • Parameters

      • Optionalmodel: Record<string, any>
      • Optionalcallback: (e: any) => void | {}

      Returns Promise<any>

    • Remove all listeners, or those of the specified event.

      Parameters

      Returns this

    • Remove the listeners of a given event.

      Type Parameters

      Parameters

      • event: T
      • Optionalfn: (...args: any[]) => void
      • Optionalcontext: any
      • Optionalonce: boolean

      Returns this

    • Parameters

      • filePath: string

      Returns string

    • Parameters

      • attrs: Record<string, any>

      Returns void

    • Set the style for the plugin's UI

      Parameters

      • style: Properties

      Returns void

      https://github.com/logseq/logseq-plugin-samples/tree/master/logseq-awesome-fonts
      
      logseq.setMainUIInlineStyle({
      position: 'fixed',
      zIndex: 11,
      })
    • show the plugin's UI

      Parameters

      • Optionalopts: { autoFocus: boolean }

      Returns void

    • Parameters

      • attrs: Record<string, any>

      Returns void

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