Repository navigation
Plugin API Reference
When your plugin's main.js (written directly in JavaScript or compiled from TypeScript) is evaluated inside its isolated JSC.Context virtual machine, Imladris automatically exposes the global host namespace object imladris.
Tip
TypeScript Developers: Reference community-plugins/types/imladris.d.ts in your tsconfig.json for full type-checking and IntelliSense across every API below.
Displays a native non-blocking Libadwaita toast notification at the bottom of the main window.
-
Parameters:
message(string) — The notification text. -
Example:
imladris.ui.showToast("Export completed successfully!");
Registers a custom action button in the Ribbon bar.
-
Parameters:
options(Object) containing:-
id(string): Unique button identifier. -
label(string): Button display text. -
icon(string): Papirus symbolic icon name (e.g.,"applications-science-symbolic"). -
onClick(Function): Callback invoked when the button is clicked.
-
-
Example:
imladris.ui.addRibbonButton({ id: "my-custom-btn", label: "Run Lint", icon: "preferences-system-symbolic", onClick: () => { console.log("Linting clicked"); } });
Opens a hardware-accelerated WebKitGTK modal dialog (Adw.Dialog) rendering custom HTML5 Canvas or WebGL content.
-
Parameters:
options(Object) containing:-
title(string): Dialog window title. -
html(string): HTML content string to load. -
width(number, optional): Preferred window width (default950). -
height(number, optional): Preferred window height (default700).
-
-
IPC Messaging: JavaScript inside the webview can communicate with the host via:
window.webkit.messageHandlers.imladrisHost.postMessage({ action: "open_file", path: "notes/chapter1.md" });
Note
Requires the "editor" permission declared in your manifest.json.
Returns the full text content of the active editor buffer.
-
Returns:
string
Returns the currently highlighted text selection in the editor.
-
Returns:
string(or empty string if no selection).
Inserts text directly at the current cursor position in the active document.
-
Parameters:
text(string) — The string to insert. -
Example:
imladris.editor.insertAtCursor("# New Section Heading\n");
Note
Requires "repl_r" or "repl_python" permissions declared in your manifest.json.
Dispatches R code directly to the persistent interactive R session.
-
Parameters:
code(string) — Valid R expression or script. -
Example:
imladris.repl.runR("summary(mtcars); cat('Evaluated via plugin\\n')");
Dispatches Python code directly to the persistent interactive Python / IPython session.
-
Parameters:
code(string) — Valid Python statement or script. -
Example:
imladris.repl.runPython("import pandas as pd; print(pd.__version__)");
Note
Requires the "elrond_ai" permission declared in your manifest.json.
Sends a prompt directly to the Elrond Assistance (AI) panel using the active document narrative and dataframe context.
-
Parameters:
prompt(string) — Custom instructions or questions for Elrond. -
Returns:
void -
Example:
imladris.elrond.ask("Suggest a ggplot2 command for the active dataset.");
Important
Requires the "workspace" permission declared in your manifest.json.
Recursively enumerates all matching files within the currently active workspace directory.
-
Parameters:
pattern(string, optional) — Glob pattern (e.g.,"*.md","*.qmd"). Default is"*.md". -
Returns:
string[]— Array of relative file paths.
Reads the complete plain text contents of a file within the project directory.
-
Parameters:
relativePath(string) — Relative path to the project file. Path traversal (..) is strictly blocked. -
Returns:
string— File contents.
Opens the target project file in an editor tab in Imladris.
-
Parameters:
-
relativePath(string) — Relative path to the project file. -
line(number, optional) — Line number to scroll to (default1).
-
Returns the absolute path to the active workspace project root folder.
-
Returns:
string
Returns the path to the currently active open document.
-
Returns:
string
Reads an asset file bundled inside the plugin's own directory (e.g. templates, CSS, or JSON schemas).
-
Parameters:
relativePath(string) — Relative asset path within the plugin folder. -
Returns:
string— File contents.
Imladris IDE (v0.45.0) • Core licensed under Apache License 2.0 (Apache-2.0) (Hybrid Open-Core) • Built with Vala, GTK4, Libadwaita, WebKitGTK 6.0 & Papirus Icons (GPL-3.0-or-later).