A template Chrome extension (Manifest V3) that adds draw.io diagram editing to any web application. Based on a production integration with a real-world SaaS application.
.drawio.svg images| File | Purpose |
|---|---|
manifest.json |
Extension manifest - set your target domain here |
contentScript.js |
Main integration logic - diagram detection, editor lifecycle, save handler |
popup.html |
Extension popup UI |
popup.js |
Popup logic - sends messages to content script |
images/ |
Extension icons (16, 32, 48, 128px) - add your own |
manifest.json - Replace your-app.example.com with your target domain in host_permissions and content_scripts.matches
contentScript.js - Customize the configuration section at the top:
HOST_DOMAIN - your app’s domainDARK_MODE_CLASS - CSS class your app uses for dark modeEDITABLE_CONTENT_SELECTOR - selector for content-editable areascontentScript.js: saveDiagramToHost() - Implement your app’s upload/save API. This function receives the SVG data and metadata and should persist it.
contentScript.js: getScrollContainer() - Return your app’s main scrollable element so the editor iframe scrolls with the page.
contentScript.js: insertDiagram handler - Implement diagram insertion using your app’s content insertion mechanism (drag-and-drop, paste API, etc.)embedInline=1 URL parameterwindow.postMessage. See the protocol specificationcolor-scheme: light dark CSS and a @media (prefers-color-scheme: dark) inversion filter for automatic dark/light adaptationchrome://extensions/