>
```
--------------------------------
### Get a specific block
Source: https://github.com/logseq/plugins/blob/master/interfaces/IEditorProxy.html
Retrieves a block by its identifier. Optionally, include its children in the returned data.
```typescript
getBlock: (
srcBlock: number | [BlockIdentity](../types/BlockIdentity.html),
opts?: Partial<{ includeChildren: boolean }>,
) => Promise<[BlockEntity](BlockEntity.html)>
```
--------------------------------
### showSettingsUI
Source: https://github.com/logseq/plugins/blob/master/interfaces/ILSPluginUser.html
Displays the plugin's settings UI.
```APIDOC
## showSettingsUI
### Description
Displays the plugin's settings UI.
### Method
Overloaded
### Returns
void
```
--------------------------------
### setupPluginUserInstance Function
Source: https://github.com/logseq/plugins/blob/master/functions/setupPluginUserInstance.html
The setupPluginUserInstance function is used internally to set up a plugin's user instance. It takes plugin base information and a caller object, returning an array of LSPluginUser objects.
```APIDOC
## Function: setupPluginUserInstance
### Description
Internal function to set up a plugin user instance.
### Parameters
* **pluginBaseInfo** (LSPluginBaseInfo) - Information about the plugin's base setup.
* **pluginCaller** (LSPluginCaller) - The caller object for the plugin.
### Returns
* [LSPluginUser[]] - An array of LSPluginUser objects.
```
--------------------------------
### Get all tags
Source: https://github.com/logseq/plugins/blob/master/interfaces/IEditorProxy.html
Retrieves a list of all tags present in the Logseq graph. Tags are typically represented as pages.
```typescript
getAllTags: () => Promise<[PageEntity](PageEntity.html)[]>
```
--------------------------------
### showSettingsUI
Source: https://github.com/logseq/plugins/blob/master/classes/LSPluginUser.html
Displays the plugin's settings UI. This method is part of the ILSPluginUser interface.
```APIDOC
## showSettingsUI
### Description
Displays the plugin's settings UI.
### Method
void
### Endpoint
N/A (SDK method)
### Parameters
None
### Request Example
```javascript
logseq.showSettingsUI();
```
### Response
#### Success Response (void)
Returns void.
### Response Example
N/A
```
--------------------------------
### Get the current page
Source: https://github.com/logseq/plugins/blob/master/interfaces/IEditorProxy.html
Retrieves the page entity that is currently active or being viewed. This could be a regular page or a journal page.
```typescript
getCurrentPage: () => Promise<[BlockEntity](BlockEntity.html) | [PageEntity](PageEntity.html)>
```
--------------------------------
### Math Rendering with Remark and Rehype Plugins
Source: https://github.com/logseq/plugins/blob/master/docs/pages/_index.md
Enable math rendering in markdown by using `remark-math` and `rehype-katex` plugins. Ensure `katex` CSS is imported.
```jsx
import React from 'react'
import ReactDom from 'react-dom'
import ReactMarkdown from 'react-markdown'
import remarkMath from 'remark-math'
import rehypeKatex from 'rehype-katex'
import 'katex/dist/katex.min.css' // `rehype-katex` does not import the CSS for you
ReactDom.render(
,
document.body
)
```
```jsx
The lift coefficient (
{/* β¦ */}
) is a dimensionless coefficient.
```
--------------------------------
### Get Active Page Entity
Source: https://context7.com/logseq/plugins/llms.txt
Retrieves the `PageEntity` for the currently open page in the main view. Returns `null` if on the home screen.
```typescript
const page = await logseq.Editor.getCurrentPage()
if (page) {
console.log("Page name:", page.name)
console.log("Page UUID:", page.uuid)
console.log("Is journal:", page["journal?"])
}
```
--------------------------------
### Get Current Focused Block
Source: https://context7.com/logseq/plugins/llms.txt
Returns the `BlockEntity` of the block currently in focus (where the editor cursor is). Returns `null` if no block is being edited.
```typescript
const block = await logseq.Editor.getCurrentBlock()
if (block) {
console.log("Editing block:", block.uuid)
console.log("Content:", block.content)
console.log("On page:", block.page)
}
```
--------------------------------
### provideTheme
Source: https://github.com/logseq/plugins/blob/master/interfaces/ILSPluginUser.html
Sets the theme for the main Logseq application.
```APIDOC
## provideTheme
### Description
Set the theme for the main Logseq app.
### Method Signature
provideTheme(theme: [Theme](Theme.html)): this[]
### Parameters
#### theme
- **theme**: [Theme](Theme.html) - The theme object to apply.
### Returns
- this[] - Returns the emitter instance for chaining.
```
--------------------------------
### provideTheme
Source: https://github.com/logseq/plugins/blob/master/classes/LSPluginUser.html
Sets the theme for the main Logseq application.
```APIDOC
## provideTheme
### Description
Sets the theme for the main Logseq application. This allows plugins to customize the overall look and feel.
### Method Signature
provideTheme(theme: [Theme](../interfaces/Theme.html)): LSPluginUser
### Parameters
#### Theme
- **theme** ([Theme](../interfaces/Theme.html)) - An object conforming to the Theme interface, defining the theme properties.
### Returns
- LSPluginUser - The LSPluginUser instance for chaining.
```
--------------------------------
### Get Block Tree for a Named Page
Source: https://context7.com/logseq/plugins/llms.txt
Fetches all blocks for a specified page, identified by its name or UUID. The result is a nested tree structure.
```typescript
const blocks = await logseq.Editor.getPageBlocksTree("My Project Notes")
blocks.forEach(block => {
console.log(block.content)
if (block.children?.length) {
console.log(" Children:", block.children.length)
}
})
```
--------------------------------
### Get all pages
Source: https://github.com/logseq/plugins/blob/master/interfaces/IEditorProxy.html
Retrieves a list of all pages present in the Logseq graph. An optional repository string can be provided, though its specific use case is not detailed here.
```typescript
getAllPages: (repo?: string) => Promise<[PageEntity](PageEntity.html)[]>
```
--------------------------------
### provideModel
Source: https://github.com/logseq/plugins/blob/master/interfaces/ILSPluginUser.html
Creates an object to hold methods that can be referenced in `provideUI`.
```APIDOC
## provideModel
### Description
Create an object to hold the methods referenced in `provideUI`.
### Method Signature
provideModel(model: Record): this[]
### Parameters
#### model
- **model**: Record - An object containing methods to be exposed.
### Returns
- this[] - Returns the emitter instance for chaining.
### Example
```javascript
logseq.provideModel({ openCalendar () { console.log('Open the calendar!') }})
```
```
--------------------------------
### Get SDK version with logseq.version
Source: https://context7.com/logseq/plugins/llms.txt
A getter that returns the current version string of the `@logseq/libs` SDK as reported at runtime. Useful for debugging or compatibility checks.
```typescript
logseq.ready(() => {
console.log("SDK version:", logseq.version)
// β e.g. "0.0.16"
})
```
--------------------------------
### provideModel
Source: https://github.com/logseq/plugins/blob/master/classes/LSPluginUser.html
Creates an object to hold methods that can be referenced in `provideUI`.
```APIDOC
## provideModel
### Description
Creates an object to hold methods that can be referenced in `provideUI`. This allows for modularity and separation of concerns in UI interactions.
### Method Signature
provideModel(model: Record): LSPluginUser
### Parameters
#### Model
- **model** (Record) - An object containing methods to be exposed.
### Returns
- LSPluginUser - The LSPluginUser instance for chaining.
### Example
```javascript
logseq.provideModel({ openCalendar () { console.log('Open the calendar!') }})
```
```
--------------------------------
### Get cursor position in editing block
Source: https://github.com/logseq/plugins/blob/master/interfaces/IEditorProxy.html
Retrieves the current cursor position within the block that is being edited. This includes the block's UUID and the character offset.
```typescript
getEditingCursorPosition: () => Promise<[BlockCursorPosition](../types/BlockCursorPosition.html)>
```
--------------------------------
### logseq.App.getUserConfigs()
Source: https://context7.com/logseq/plugins/llms.txt
Returns the current user's app configuration, such as preferred date format, preferred workflow, and language.
```APIDOC
## `logseq.App.getUserConfigs()` β Read user configuration
Returns the current user's app configuration, such as preferred date format, preferred workflow, and language.
```ts
const configs = await logseq.App.getUserConfigs()
// configs.preferredDateFormat β "MMM do, yyyy"
// configs.preferredWorkflow β ":now" | ":later"
// configs.currentGraph β "/Users/alice/notes"
console.log("Date format:", configs.preferredDateFormat)
```
```
--------------------------------
### Get Active Graph with logseq.App.getCurrentGraph()
Source: https://context7.com/logseq/plugins/llms.txt
Retrieve metadata about the currently active Logseq graph, including its name, path, and URL. Returns null if no graph is open.
```typescript
const graph = await logseq.App.getCurrentGraph()
// graph: { name: "my-notes", path: "/Users/alice/notes", url: "logseq://graph/my-notes" }
if (graph) {
console.log("Active graph:", graph.name)
console.log("Graph path:", graph.path)
}
```
--------------------------------
### Register a Logseq Theme with provideTheme()
Source: https://context7.com/logseq/plugins/llms.txt
Registers a theme that appears in Logseq's built-in theme picker. Requires a `name`, `url` to the theme CSS file, and optional `mode` (`"light"` | `"dark"`).
```typescript
logseq.provideTheme({
name: "My Awesome Theme",
url: "lsp://logseq.io/my-plugin/dist/theme.css",
description: "A clean, minimal dark theme",
mode: "dark",
pid: logseq.baseInfo.id,
})
```
--------------------------------
### Syntax Highlighting with Custom Code Component
Source: https://github.com/logseq/plugins/blob/master/docs/pages/_index.md
Overwrite the default code handling to apply syntax highlighting using `react-syntax-highlighter`. Ensure `react-syntax-highlighter` is installed and imported.
```jsx
import React from 'react'
import ReactDom from 'react-dom'
import ReactMarkdown from 'react-markdown'
import {Prism as SyntaxHighlighter} from 'react-syntax-highlighter'
import {dark} from 'react-syntax-highlighter/dist/esm/styles/prism'
// Did you know you can use tildes instead of backticks for code in markdown? β¨
const markdown = `Here is some JavaScript code:
~~~js
console.log('It works!')
~~~
`
ReactDom.render(
) : (
{children}
)
}
}}
/>,
document.body
)
```
```jsx
<>
Here is some JavaScript code:
>
```
--------------------------------
### provideStyle
Source: https://github.com/logseq/plugins/blob/master/interfaces/ILSPluginUser.html
Injects custom CSS into the main Logseq application.
```APIDOC
## provideStyle
### Description
Inject custom css for the main Logseq app.
### Method Signature
provideStyle(style: string | [StyleOptions](../types/StyleOptions.html)): this[]
### Parameters
#### style
- **style**: string | [StyleOptions](../types/StyleOptions.html) - The CSS style to inject, either as a string or a StyleOptions object.
### Returns
- this[] - Returns the emitter instance for chaining.
### Example
```javascript
logseq.provideStyle(` @import url("https://at.alicdn.com/t/font_2409735_r7em724douf.css");`)
```
```
--------------------------------
### Get a specific property of a block
Source: https://github.com/logseq/plugins/blob/master/interfaces/IEditorProxy.html
Retrieves the value of a specific property for a given block. Note: The return type is BlockEntity, which might be a typo and should perhaps be the property value itself.
```typescript
getBlockProperty: (
block: number | [BlockIdentity](../types/BlockIdentity.html),
key: string,
) => Promise<[BlockEntity](BlockEntity.html)>
```
--------------------------------
### provideStyle
Source: https://github.com/logseq/plugins/blob/master/classes/LSPluginUser.html
Injects custom CSS into the main Logseq application.
```APIDOC
## provideStyle
### Description
Injects custom CSS styles into the main Logseq application, allowing for UI customization.
### Method Signature
provideStyle(style: string): LSPluginUser
### Parameters
#### Style
- **style** (string) - A string containing the CSS rules to inject.
### Returns
- LSPluginUser - The LSPluginUser instance for chaining.
### Example
```css
logseq.provideStyle(` @import url("https://at.alicdn.com/t/font_2409735_r7em724douf.css"); `)
```
```
--------------------------------
### loadIgnoreFile
Source: https://github.com/logseq/plugins/blob/master/interfaces/IGitProxy.html
Loads the content of the .gitignore file.
```APIDOC
## loadIgnoreFile
### Description
Loads the content of the .gitignore file.
### Method
() => Promise
### Response
#### Success Response (Promise)
- **content** (string) - The content of the .gitignore file.
```
--------------------------------
### Get State from App Store
Source: https://github.com/logseq/plugins/blob/master/interfaces/IAppProxy.html
Retrieve a specific piece of state from the Logseq app store. The state path corresponds to keys in the application's state management.
```typescript
const isDocMode = await logseq.App.getStateFromStore('document/mode?')
```
--------------------------------
### Insert Text at Cursor with logseq.Editor
Source: https://context7.com/logseq/plugins/llms.txt
Use `insertAtEditingCursor` to insert text at the current cursor position within the active block editor. This example is triggered by a keyboard shortcut.
```typescript
logseq.App.registerCommandShortcut(
{ binding: "ctrl+shift+t" },
async () => {
const now = new Date()
const timestamp = `[[${now.getFullYear()}-${String(now.getMonth()+1).padStart(2,"0")}-${String(now.getDate()).padStart(2,"0")}
]]`
await logseq.Editor.insertAtEditingCursor(timestamp)
}
)
```
--------------------------------
### Create a New Page
Source: https://context7.com/logseq/plugins/llms.txt
Creates a new page with specified properties and options. Use `redirect: true` to navigate to the new page and `createFirstBlock: true` to add an initial empty block.
```typescript
const newPage = await logseq.Editor.createPage(
"2024 Goals",
{ author: "Alice", status: "active" },
{
redirect: true,
createFirstBlock: true,
journal: false,
}
)
console.log("Created page:", newPage?.uuid)
```
--------------------------------
### logseq.provideModel() - Register UI interaction handlers
Source: https://context7.com/logseq/plugins/llms.txt
Creates an object holding handler methods that can be called from HTML templates injected via `provideUI`. The method names become callable via `data-on-click` attributes on injected elements.
```APIDOC
## logseq.provideModel()
### Description
Creates an object holding handler methods that can be called from HTML templates injected via `provideUI`. The method names become callable via `data-on-click` attributes on injected elements.
### Usage
```typescript
logseq.provideModel({
openCalendar() {
console.log("Opening calendarβ¦")
logseq.App.pushState("page", { name: "Journal" })
},
async insertDate() {
const block = await logseq.Editor.getCurrentBlock()
if (block) {
await logseq.Editor.insertAtEditingCursor(
new Date().toISOString().split("T")[0]
)
}
},
})
```
```
--------------------------------
### Add Block Context Menu Item with logseq.Editor
Source: https://context7.com/logseq/plugins/llms.txt
Add custom items to the right-click context menu for blocks. This example copies the block's UUID to the clipboard.
```typescript
logseq.Editor.registerBlockContextMenuItem(
"Copy block UUID",
async ({ uuid }) => {
await navigator.clipboard.writeText(uuid)
await logseq.App.showMsg("UUID copied to clipboard!", "success")
}
)
```
--------------------------------
### getInfo
Source: https://github.com/logseq/plugins/blob/master/interfaces/IAppProxy.html
Retrieves application information.
```APIDOC
## getInfo
### Description
Retrieves application information.
### Method
(key?: keyof AppInfo) => Promise
### Parameters
- **key** (keyof AppInfo) - Optional. The specific key of the application information to retrieve.
```
--------------------------------
### Get all properties
Source: https://github.com/logseq/plugins/blob/master/interfaces/IEditorProxy.html
Retrieves all properties defined across pages in the Logseq graph. The return type suggests it might return page entities, implying properties are associated with pages.
```typescript
getAllProperties: () => Promise<[PageEntity](PageEntity.html)[]>
```
--------------------------------
### Get Backlinks for a Page
Source: https://context7.com/logseq/plugins/llms.txt
Retrieves all blocks across the graph that reference a given page. Returns an array of tuples, where each tuple contains the referenced page and an array of its referencing blocks.
```typescript
const refs = await logseq.Editor.getPageLinkedReferences("Project Alpha")
// refs is an array of [PageEntity, BlockEntity[]] tuples
refs?.forEach(([page, blocks]) => {
console.log(`Page: ${page.name}, ${blocks.length} reference(s)`)
blocks.forEach(b => console.log(" β", b.content))
})
```
--------------------------------
### showMainUI
Source: https://github.com/logseq/plugins/blob/master/classes/LSPluginUser.html
Makes the plugin's main UI visible. Optionally, it can automatically focus the UI.
```APIDOC
## showMainUI
### Description
Show the plugin's UI.
### Method
showMainUI(opts?: { autoFocus: boolean }): void
### Parameters
#### Optional Parameters
- **opts** ({ autoFocus: boolean }) - Configuration options for showing the UI.
- **autoFocus** (boolean) - Whether to automatically focus the UI when shown.
### Returns
void
```
--------------------------------
### Get Full Block Tree of Current Page
Source: https://context7.com/logseq/plugins/llms.txt
Fetches all blocks on the current page as a nested tree structure. Useful for visualizing page content or processing hierarchical data.
```typescript
const blocks = await logseq.Editor.getCurrentPageBlocksTree()
// Flatten and print all block contents
function flatten(nodes: typeof blocks): string[] {
return nodes.flatMap(b => [b.content, ...flatten(b.children ?? [])])
}
console.log("All blocks:", flatten(blocks))
// Example: initialize a mind-map visualization
initMindMap(blocks)
```
--------------------------------
### q
Source: https://github.com/logseq/plugins/blob/master/interfaces/IDBProxy.html
Run a DSL (Domain Specific Language) query. This method is useful for simpler queries defined in Logseq's DSL.
```APIDOC
## q
### Description
Run a DSL query.
### Method
`q`
### Parameters
* **dsl** (string) - Required - The DSL query string.
### Returns
Promise - A promise that resolves with an array of results.
```
--------------------------------
### makeSandboxStorage
Source: https://github.com/logseq/plugins/blob/master/interfaces/IAssetsProxy.html
Creates and returns an asynchronous storage instance for use within a sandbox environment. This allows for isolated data storage.
```APIDOC
## makeSandboxStorage
### Description
Creates a sandbox storage.
### Method
makeSandboxStorage
### Returns
IAsyncStorage
### Example
```typescript
const storage = logseq.Assets.makeSandboxStorage();
await storage.setItem("key", "value");
const value = await storage.getItem("key");
```
```
--------------------------------
### Provide Logseq Plugin Styles
Source: https://github.com/logseq/plugins/blob/master/interfaces/ILSPluginUser.html
Inject custom CSS for the main Logseq application. This can be a CSS string or a StyleOptions object. Example shows importing an external CSS file.
```typescript
logseq.provideStyle(` @import url("https://at.alicdn.com/t/font_2409735_r7em724douf.css"); )
```
--------------------------------
### Customize ReactMarkdown Components
Source: https://github.com/logseq/plugins/blob/master/docs/pages/_index.md
Map markdown elements to custom React components to alter their rendering. For example, `h1` can be rendered as `h2`, and `em` can be styled with a red foreground color.
```jsx
}}
/>
```
--------------------------------
### Import Logseq Plugin SDK
Source: https://github.com/logseq/plugins/blob/master/index.html
Imports the logseq plugin SDK to be available as a global namespace in your project.
```javascript
import "@logseq/libs"
```
--------------------------------
### logseq.provideTheme() - Register a Logseq theme
Source: https://context7.com/logseq/plugins/llms.txt
Registers a theme that appears in Logseq's built-in theme picker. Requires a `name`, `url` pointing to the theme CSS file, and optional `mode` (`"light"` | `"dark"`).
```APIDOC
## logseq.provideTheme()
### Description
Registers a theme that appears in Logseq's built-in theme picker. Requires a `name`, `url` pointing to the theme CSS file, and optional `mode` (`"light"` | `"dark"`).
### Usage
```typescript
logseq.provideTheme({
name: "My Awesome Theme",
url: "lsp://logseq.io/my-plugin/dist/theme.css",
description: "A clean, minimal dark theme",
mode: "dark",
pid: logseq.baseInfo.id,
})
```
```
--------------------------------
### React Markdown with remark-gfm Plugin
Source: https://github.com/logseq/plugins/blob/master/docs/pages/_index.md
Example of using the remark-gfm plugin to enable GitHub Flavored Markdown features like links, tables, and tasklists. The markdown content is passed as a string.
```jsx
import React from 'react'
import ReactDom from 'react-dom'
import ReactMarkdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
const markdown = `Just a link: https://reactjs.com.`
ReactDom.render(
,
document.body
)
```
--------------------------------
### execCommand
Source: https://github.com/logseq/plugins/blob/master/interfaces/IGitProxy.html
Executes a Git command with the provided arguments and returns the result.
```APIDOC
## execCommand
### Description
Executes a Git command with the provided arguments and returns the result.
### Method
(args: string[]) => Promise
### Parameters
#### Path Parameters
- **args** (string[]) - Required - The arguments to pass to the Git command.
### Response
#### Success Response (Promise)
- **result** (IGitResult) - The result of the Git command execution.
```
--------------------------------
### logseq.DB.q()
Source: https://context7.com/logseq/plugins/llms.txt
Runs a Logseq query DSL query (the same syntax used in `{{query ...}}` blocks in the editor). See https://docs.logseq.com/#/page/queries for syntax.
```APIDOC
## `logseq.DB.q()` β Run a Logseq DSL query
Runs a Logseq query DSL query (the same syntax used in `{{query ...}}` blocks in the editor). See https://docs.logseq.com/#/page/queries for syntax.
```ts
// Find all blocks tagged #meeting from the last 7 days
const results = await logseq.DB.q(
`(and (page-tags #meeting) (between -7d today))`
)
results?.forEach((block: any) => {
console.log("Meeting note:", block.content)
})
```
```
--------------------------------
### getAllProperties
Source: https://github.com/logseq/plugins/blob/master/interfaces/IEditorProxy.html
Retrieves all properties available in the system.
```APIDOC
## getAllProperties
### Description
Retrieves all properties available in the system.
### Method
getAllProperties
### Response
#### Success Response (PageEntity[])
An array of PageEntity objects representing all properties.
```
--------------------------------
### logseq.beforeunload()
Source: https://context7.com/logseq/plugins/llms.txt
Registers a callback that runs just before the plugin is unloaded, allowing for cleanup of resources, data flushing, or cancellation of subscriptions.
```APIDOC
## `logseq.beforeunload()` β Cleanup before plugin unload
Registers a callback that runs just before the plugin is unloaded (e.g., when the user disables it or Logseq closes). Use this to clean up resources, flush data, or cancel subscriptions.
```ts
logseq.beforeunload(async (e) => {
console.log("Plugin unloadingβ¦", e)
// Save unsaved state
await logseq.FileStorage.setItem("dirty-buffer", pendingContent)
// Cancel any ongoing polling
clearInterval(syncTimer)
})
```
```
--------------------------------
### beforeunload(callback: (e: any) => Promise)
Source: https://github.com/logseq/plugins/blob/master/classes/LSPluginUser.html
Registers a callback function to be executed before the plugin is unloaded.
```APIDOC
## beforeunload(callback: (e: any) => Promise)
### Description
Registers a callback function to be executed before the plugin is unloaded.
### Parameters
- callback: (e: any) => Promise
### Returns
- void
```
--------------------------------
### Run a git command with logseq.Git.execCommand()
Source: https://context7.com/logseq/plugins/llms.txt
Executes a git command on the current graph's repository. Available only for file-based graphs. Handles command execution and provides results including exit code and standard error.
```typescript
// Commit all changes with a timestamped message
const result = await logseq.Git.execCommand([
"commit",
"--all",
"--message",
`Auto-commit: ${new Date().toISOString()}`,
])
if (result.exitCode === 0) {
await logseq.App.showMsg("Graph committed to git!", "success")
} else {
await logseq.App.showMsg(`Git error: ${result.stderr}`, "error")
}
```
--------------------------------
### Import React Markdown in Browser
Source: https://github.com/logseq/plugins/blob/master/docs/pages/_index.md
Import ReactMarkdown from esm.sh for use in browser projects. The ?bundle flag is used for bundling.
```html
```
--------------------------------
### builtInOpen
Source: https://github.com/logseq/plugins/blob/master/interfaces/IAssetsProxy.html
Attempts to open a specified asset file within the Logseq application. Returns a promise that resolves to a boolean indicating success or failure.
```APIDOC
## builtInOpen
### Description
Try to open asset type file in Logseq app.
### Method
builtInOpen
### Parameters
#### Path Parameters
- **path** (string) - Description of the path parameter
### Returns
Promise
### Example
```typescript
await logseq.Assets.builtInOpen("path/to/asset.png");
```
```
--------------------------------
### Provide Plugin Model
Source: https://github.com/logseq/plugins/blob/master/classes/LSPluginUser.html
Define methods that can be referenced in `provideUI`. This allows for creating interactive UI components.
```typescript
provideModel(model: Record): LSPluginUser
```
--------------------------------
### showMainUI
Source: https://github.com/logseq/plugins/blob/master/interfaces/ILSPluginUser.html
Shows the plugin's main UI element.
```APIDOC
## showMainUI
### Description
Show the plugin's UI.
### Method
Overloaded
### Parameters
#### Optional Parameters
- **opts** ({ autoFocus: boolean }) - Options for showing the UI, such as whether to auto-focus.
### Returns
void
```
--------------------------------
### Read User Configurations with logseq.App.getUserConfigs()
Source: https://context7.com/logseq/plugins/llms.txt
Fetch the current user's application configuration settings, such as date format, workflow preference, and current graph.
```typescript
const configs = await logseq.App.getUserConfigs()
// configs.preferredDateFormat β "MMM do, yyyy"
// configs.preferredWorkflow β ":now" | ":later"
// configs.currentGraph β "/Users/alice/notes"
console.log("Date format:", configs.preferredDateFormat)
```
--------------------------------
### logseq.App.registerCommandPalette()
Source: https://context7.com/logseq/plugins/llms.txt
Registers a named action directly in the command palette without a keyboard shortcut.
```APIDOC
## `logseq.App.registerCommandPalette()` β Add a palette entry
Registers a named action directly in the command palette without a keyboard shortcut.
```ts
logseq.App.registerCommandPalette(
{ key: "open-dashboard", label: "Open Plugin Dashboard" },
() => logseq.showMainUI()
)
```
```
--------------------------------
### createTemplate
Source: https://github.com/logseq/plugins/blob/master/interfaces/IAppProxy.html
Creates a new template.
```APIDOC
## createTemplate
### Description
Creates a new template.
### Signature
`createTemplate(target: string, name: string, opts?: { overwrite: boolean }) => Promise`
```
--------------------------------
### LSPluginUser Methods
Source: https://github.com/logseq/plugins/blob/master/interfaces/ILSPluginUser.html
This section details the methods available on the LSPluginUser interface, allowing plugins to perform actions and interact with Logseq.
```APIDOC
## Methods
### `addListener(eventName: string, listener: (...args: any[]) => void): void`
Adds an event listener.
### `emit(eventName: string, ...args: any[]): void`
Emits an event.
### `eventNames(): string[]`
Returns an array of all event names.
### `hideMainUI(): void`
Hides the main UI.
### `hideSettingsUI(): void`
Hides the settings UI.
### `listenerCount(eventName: string): number`
Returns the number of listeners for a given event.
### `listeners(eventName: string): Function[]`
Returns an array of listeners for a given event.
### `off(eventName: string, listener: (...args: any[]) => void): void`
Removes an event listener.
### `on(eventName: string, listener: (...args: any[]) => void): void`
Registers an event listener.
### `once(eventName: string, listener: (...args: any[]) => void): void`
Registers a one-time event listener.
### `onSettingsChanged(callback: (newSettings: Record) => void): void`
Registers a callback to be invoked when plugin settings change.
### `provideModel(model: any): void`
Provides a model to the plugin system.
### `provideStyle(css: string): void`
Provides custom CSS styles to the plugin.
### `provideTheme(theme: Record): void`
Provides theme variables to the plugin.
### `provideUI(element: HTMLElement): void`
Provides a UI element to be rendered in Logseq.
### `ready(): Promise`
Returns a promise that resolves when the plugin is ready.
### `removeAllListeners(eventName?: string): void`
Removes all event listeners, or all listeners for a specific event.
### `removeListener(eventName: string, listener: (...args: any[]) => void): void`
Removes a specific event listener.
### `resolveResourceFullUrl(url: string): string`
Resolves a resource URL to its full, absolute path.
### `setMainUIAttrs(attrs: Record): void`
Sets attributes for the main UI.
### `setMainUIInlineStyle(style: Record): void`
Sets inline styles for the main UI.
### `showMainUI(): void`
Shows the main UI.
### `showSettingsUI(): void`
Shows the settings UI.
### `toggleMainUI(): void`
Toggles the visibility of the main UI.
### `updateSettings(newSettings: Record): void`
Updates the plugin's settings.
### `useSettingsSchema(schema: Record): void`
Defines the schema for the plugin's settings.
```
--------------------------------
### _execCallableAPI(method: string, ...args: any[])
Source: https://github.com/logseq/plugins/blob/master/classes/LSPluginUser.html
Internal method to execute a callable API method.
```APIDOC
## _execCallableAPI(method: string, ...args: any[])
### Description
Internal method to execute a callable API method.
### Parameters
- method: string
- ...args: any[]
### Returns
- void
```
--------------------------------
### logseq.Git.execCommand()
Source: https://context7.com/logseq/plugins/llms.txt
Executes a git command on the graph repository using dugite. Available only for file-based graphs.
```APIDOC
## `logseq.Git.execCommand()` β Run a git command on the graph repository
Executes a git command (via [dugite](https://github.com/desktop/dugite/blob/master/docs/api/exec.md)) in the directory of the current graph. Available only for file-based graphs.
```ts
// Commit all changes with a timestamped message
const result = await logseq.Git.execCommand([
"commit",
"--all",
"--message",
`Auto-commit: ${new Date().toISOString()}`,
])
if (result.exitCode === 0) {
await logseq.App.showMsg("Graph committed to git!", "success")
} else {
await logseq.App.showMsg(`Git error: ${result.stderr}`, "error")
}
```
```
--------------------------------
### logseq.Editor.createPage()
Source: https://context7.com/logseq/plugins/llms.txt
Creates a new page with optional initial properties. Returns the new `PageEntity`.
```APIDOC
## `logseq.Editor.createPage()` β Create a new page
Creates a new page with optional initial properties. Returns the new `PageEntity`.
```ts
const newPage = await logseq.Editor.createPage(
"2024 Goals",
{ author: "Alice", status: "active" },
{
redirect: true,
createFirstBlock: true,
journal: false,
}
)
console.log("Created page:", newPage?.uuid)
```
```
--------------------------------
### Provide Logseq Plugin Theme
Source: https://github.com/logseq/plugins/blob/master/interfaces/ILSPluginUser.html
Set the theme for the main Logseq application. Accepts a `Theme` object.
```typescript
provideTheme(theme: Theme): this
```
--------------------------------
### Command and Event Registration
Source: https://github.com/logseq/plugins/blob/master/interfaces/IEditorProxy.html
Functions for registering custom commands and context menu items.
```APIDOC
## registerBlockContextMenuItem
### Description
Registers a custom context menu item for blocks.
### Method
Not specified (assumed SDK method)
### Endpoint
Not applicable
## registerHighlightContextMenuItem
### Description
Registers a custom context menu item for highlights.
### Method
Not specified (assumed SDK method)
### Endpoint
Not applicable
## registerSlashCommand
### Description
Registers a new slash command.
### Method
Not specified (assumed SDK method)
### Endpoint
Not applicable
```
--------------------------------
### Provide Logseq Plugin Model
Source: https://github.com/logseq/plugins/blob/master/interfaces/ILSPluginUser.html
Create an object to hold methods referenced in `provideUI`. This is used to define actions that can be triggered by UI elements.
```typescript
logseq.provideModel({ openCalendar () { console.log('Open the calendar!') }})
```