A clean, modern starter template for building Adobe InDesign UXP plugins with WebView support. This template demonstrates how to create rich, animated UIs using modern web technologies that aren't possible with standard UXP components.
- π¨ Full-Screen WebView Panel: Seamless integration with InDesign's panel system
- π Two-Way Communication: Message passing between WebView and UXP
- π InDesign API Integration: Examples of creating text frames and accessing document properties
- β‘ Modern UI: Dark theme with glassmorphism effects and smooth animations
- π± Responsive Design: Adapts to different panel sizes
- π‘ Well-Documented: Clear comments and examples throughout the code
- Adobe InDesign 2020 or later (version 20.4.0+)
- Node.js installed on your system
-
Start the local server:
node server.js
You should see:
π InDesign WebView Starter - Local Server π Server running at http://127.0.0.1:7724/ -
Load the plugin in InDesign:
- Open Adobe InDesign
- Go to
Plugins > Developer > Load Plugin... - Select this plugin folder
- The "WebView Panel" will appear
-
Start building:
- The webview will automatically load and display the starter UI
- Try the demo buttons to see UXP β WebView communication
- Open an InDesign document to test the API examples
indesign-webview-starter/
βββ Receiver/ # WebView content (served by local server)
β βββ index.html # Main UI structure
β βββ style.css # Modern styling with animations
β βββ script.js # WebView logic and communication
βββ images/ # Plugin icons
β βββ icon@1x.png
β βββ icon@2x.png
βββ server.js # Local HTTP server (port 7724)
βββ index.html # UXP panel (full-screen webview)
βββ index.js # UXP plugin logic & InDesign API
βββ manifest.json # Plugin configuration
βββ README.md # This file
βββββββββββββββββββββββββββββββββββββββββββ
β InDesign Application β
β βββββββββββββββββββββββββββββββββββββ β
β β UXP Plugin (index.js) β β
β β - Loads webview β β
β β - Handles messages β β
β β - Calls InDesign API β β
β β β β
β β βββββββββββββββββββββββββββββββ β β
β β β WebView (Receiver/) β β β
β β β - Modern UI β β β
β β β - User interactions β β β
β β β - Sends messages to UXP β β β
β β βββββββββββββββββββββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββ
β HTTP (port 7724)
βββββββββββββββββββββββββββββββββββββββββββ
β Local Server (server.js) β
β - Serves webview content β
β - Runs on http://127.0.0.1:7724 β
βββββββββββββββββββββββββββββββββββββββββββ
WebView β UXP:
// In Receiver/script.js
window.uxpHost.postMessage({
type: 'createTextFrame',
text: 'Hello!'
});UXP β WebView:
// In index.js
panelWebview.postMessage({
type: 'success',
message: 'Text frame created!'
});Edit Receiver/index.html to change the structure:
<div class="card">
<h2>Your Custom Content</h2>
<button id="myButton">Click Me</button>
</div>Edit Receiver/style.css - use CSS variables for consistency:
:root {
--primary: #6366f1; /* Change primary color */
--bg-dark: #0f172a; /* Change background */
}Edit Receiver/script.js to add your logic:
document.getElementById('myButton').addEventListener('click', () => {
sendMessageToUXP({
type: 'myCustomAction',
data: { /* your data */ }
});
});Edit index.js to process messages from the webview:
window.addEventListener("message", (e) => {
if (e.data.type === 'myCustomAction') {
// Call InDesign API
const doc = app.activeDocument;
// Your InDesign logic here
}
});const page = app.activeWindow.activePage;
const textFrame = page.textFrames.add({
geometricBounds: [y1, x1, y2, x2]
});
textFrame.contents = 'Your text here';const doc = app.activeDocument;
console.log(doc.name); // Document name
console.log(doc.pages.length); // Number of pages
console.log(doc.modified); // Is modified?const rect = page.rectangles.add({
geometricBounds: [y1, x1, y2, x2]
});
rect.place(imageFile);
rect.fit(1718580851); // FitOptions.FILL_PROPORTIONALLYWebView won't load:
- β
Make sure the server is running (
node server.js) - β Check that port 7724 is not in use by another application
- β
Verify the URL in
manifest.jsonmatches the server (http://127.0.0.1:7724)
Messages not working:
- β
Ensure
enableMessageBridgeis set to"localAndRemote"inmanifest.json - β Check browser console for errors (right-click webview β Inspect)
- β
Verify you're using
window.uxpHost.postMessage()in the webview
InDesign API errors:
- β Make sure a document is open before calling document-related APIs
- β Check the UXP Developer Console for error messages
- β Verify you're using the correct InDesign API version (20.4.0+)
Server errors:
- β Make sure Node.js is installed
- β
Check that all files in the
Receiver/folder exist - β Try restarting the server
- Customize the branding: Update plugin name in
manifest.json - Design your UI: Modify
Receiver/index.htmlandstyle.css - Add your features: Implement your logic in
Receiver/script.js - Integrate with InDesign: Use the API examples in
index.js - Test thoroughly: Try different panel sizes and document states
- Package for distribution: Follow Adobe's UXP plugin packaging guidelines
This is a starter template - feel free to use it for your own projects!
- Use the browser console: Right-click the webview and select "Inspect" to debug
- Hot reload: Edit files in
Receiver/and refresh the panel to see changes - Keep it simple: Start with small features and build up gradually
- Test early: Test your plugin frequently during development
Happy coding! π
