A ClojureScript wrapper for @logseq/libs
, making it friendly to work with Logseq Plugin API in ClojureScript.
Add to your deps.edn
:
{:deps {run.avelino/logseq-libs {:mvn/version "0.0.17.1"}}}
The @logseq/libs
npm package is included as a dependency and will be installed automatically.
Here's a simple example of creating a Logseq plugin:
(ns my-plugin.core
(:require [run.avelino.logseq-libs.core :as ls]
[run.avelino.logseq-libs.ui :as ls-ui]
[run.avelino.logseq-libs.editor :as ls-editor]))
;; Initialize plugin
(ls/ready!
(fn []
(ls-ui/show-msg! "Plugin ready!")
;; Register a command in Logseq's command palette
(ls/register-command-palette!
{:key "hello-world"
:label "Say Hello"
:keybinding "mod+shift+h"
:callback (fn []
(ls-ui/show-msg! "Hello from ClojureScript!"))})))
The library provides several modules to interact with different aspects of Logseq:
core
: Plugin initialization, settings, and command registrationui
: UI notifications and interactionseditor
: Block and page operationsdb
: Database queries and subscriptionsgit
: Git operationsassets
: File and asset managementtheme
: Theme managementFor detailed API documentation of each module, see the API Reference section below.
Most commonly used functions for plugin development:
;; Initialize plugin
(ls/ready! callback-fn)
;; Register command in command palette
(ls/register-command-palette!
{:key "command-key"
:label "Command Label"
:keybinding "mod+shift+k"
:callback fn})
;; Handle settings changes
(ls/on-settings-changed! handler-fn)
Functions for working with blocks and pages:
;; Create a new block
(ls-editor/insert-block!
{:page "Page Name"
:content "Block content"})
;; Get current page
(ls-editor/get-current-page!)
;; Update block content
(ls-editor/update-block!
block-uuid
"New content")
For the complete API reference, visit our API Documentation.
git clone https://github.com/avelino/logseq-libs.git
cd logseq-libs
npm install
# Watch for changes
bb watch
# Create production build
bb release
# Clean build artifacts
bb clean
We welcome contributions! Here's how you can help:
git checkout -b feature/amazing-feature
)git commit -m 'Add amazing feature'
)git push origin feature/amazing-feature
)MIT License - see LICENSE for details
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close