Injected Libraries and Helpers
This document describes the libraries, CSS frameworks, and helper functions that are automatically available in the FDO iframe UI runtime. These are injected by the FDO application host for plugin UI code. They should not be assumed to exist in the plugin backend/runtime, bootstrap paths, or backend-side render-error fallbacks unless the current host/runtime explicitly proves that. For the full backend-vs-iframe runtime contract, see RENDER_RUNTIME_CONTRACT.md.Important Boundary: Third-Party Imports
In iframe UI runtime (render() / renderOnLoad() execution):
- arbitrary npm package
import/requireis not a supported contract - only host-injected globals and helpers are guaranteed
Teaching Boundary: Injected Libraries vs DOM Helpers
SDK DOM helpers are still a best practice for general SDK-native structured UI because they give authors a typed, reusable way to build consistent markup and styling. But this injected-libraries guide serves a different purpose:- teach iframe-only host-injected globals
- teach browser-only runtime behavior
- teach the
UI_MESSAGEbackend bridge pattern
renderOnLoad() wiring instead of DOM helpers, in order to keep the lesson focused.
Use this rule:
- general SDK-native structured UI: DOM helpers are preferred
- injected-library/runtime-boundary teaching: plain markup is acceptable when it keeps the example focused
render(), renderHTML(...) remains mandatory so the extracted goober CSS is emitted with the markup.
Important Boundary: JSX-Compatible Markup
Even when you use plain markup in injected-library examples, remember thatrender() output is consumed by the FDO host transform, not inserted as unconstrained raw HTML.
That means the safest mental model is:
- plain markup is acceptable here for teaching focus
- but it still needs to be JSX-compatible for the host render pipeline
<br />instead of<br>- inline element styles or DOM-helper styling instead of raw
<style>blocks inrender() - escaped code samples inside
<code>blocks, for example{and}
- raw
<style>tags inrender() - raw object/function braces inside code samples shown directly in JSX-visible markup
- if UI code wants to copy data outside the iframe sandbox, prefer a host-mediated clipboard path
- if UI code wants to read clipboard data, also prefer a host-mediated clipboard path
- in the SDK, use the clipboard privileged-action contract instead of assuming direct Electron clipboard access from plugin UI code
Table of Contents
CSS Libraries
The following CSS libraries are automatically loaded in the iframe UI runtime:Pure CSS (purecss.io)
A set of small, responsive CSS modules that you can use in every web project. Available Classes:.pure-g- Grid container.pure-u-*- Grid units (e.g.,.pure-u-1-2for 50% width).pure-button- Button styles.pure-form- Form layouts.pure-table- Table styles.pure-menu- Menu/navigation styles
Highlight.js
Syntax highlighting for code blocks with the “VS” theme. Usage:- CSS: Pre-loaded VS theme
- JS:
window.hljsobject
Notyf
Modern notification library for displaying toast messages. Available via:- CSS: Pre-loaded styles
- JS:
window.Notyfclass
JavaScript Libraries
FontAwesome
Complete icon library with all icon sets (solid, regular, brands). Available Sets:- FontAwesome Solid
- FontAwesome Regular
- FontAwesome Brands
Split Grid
Advanced grid splitter for creating resizable layouts. Available via:window.Split function
Example:
Goober
Lightweight CSS-in-JS library (already exposed via SDK’s DOM classes). Available via:window.goober
Note: While goober is loaded, the SDK’s DOM classes provide a more convenient interface for styling. Refer to the SDK documentation for usage.
ACE Editor
Powerful code editor component. Available via:window.ace
Example:
Window Helper Functions
These helper functions are injected into the iframe UI runtimewindow object.
createBackendReq(type, data)
Creates a request to your plugin’s backend transport.
Parameters:
type(string): The backend transport typedata(any, optional): The data to send to the backend
Promise<any> - The response from the backend
Example:
init() and call them through UI_MESSAGE. Do not assume arbitrary handler names are transport types.
If a UI_MESSAGE handler returns a privileged-action envelope for requestPrivilegedAction, extract the validated request object before sending it to the host bridge:
requestPrivilegedAction.
waitForElement(selector, callback, timeout)
Waits for an element to appear in the DOM.
Parameters:
selector(string): CSS selector for the elementcallback(function): Callback function called when element is foundtimeout(number, optional): Timeout in milliseconds (default: 5000)
executeInjectedScript(scriptContent)
Executes a script in the plugin context.
Parameters:
scriptContent(string): The JavaScript code to execute
addGlobalEventListener(eventType, callback)
Adds a global event listener to the window.
Parameters:
eventType(string): The event type (e.g., ‘click’, ‘keydown’)callback(function): The event handler function
removeGlobalEventListener(eventType, callback)
Removes a global event listener from the window.
Parameters:
eventType(string): The event typecallback(function): The event handler function to remove
applyClassToSelector(className, selector)
Applies a CSS class to an element matching the selector.
Parameters:
className(string): The CSS class name to addselector(string): CSS selector for the target element
Usage Examples
Example 1: Creating a Notification System
Example 2: Code Editor with Syntax Highlighting
Example 3: Responsive Grid Layout
Example 4: Backend Communication
Example 5: Split Panel Layout
Best Practices
- Use TypeScript types: The SDK provides TypeScript definitions for all window helper functions
- Error handling: Always wrap backend requests in try-catch blocks
- Element waiting: Use
waitForElementinstead ofsetTimeoutfor DOM-dependent code - Cleanup: Remove event listeners when they’re no longer needed
- CSP Compliance: Be aware of Content Security Policy restrictions in the plugin environment