Skip to content

Commit b08e7cd

Browse files
committed
fix: enable Lucide icon rendering in component palette dialog
Fixed two critical issues preventing Lucide icons from rendering in the palette dialog: 1. Added CommonJS exports shim to allow lucide.js to load in browser context (matching pattern used in component-dialog.html) 2. Updated Content Security Policy to allow inline scripts by adding 'unsafe-inline' to script-src directive Changes: - palette.html: Added lucide.min.js, exports shim, and lucide.js scripts - palette.html: Updated CSP from "script-src 'self'" to include 'unsafe-inline' - palette.ts: Removed direct import of initializeLucideIconsFromGlobal - palette.ts: Added LucideHelperWindow type to access window.lucideHelpers - palette.ts: Updated all icon hydration calls to use window.lucideHelpers - palette.ts: Added global icon initialization on DOMContentLoaded This resolves the issue where component icons and status badge icons (pin, check) were displaying as empty blue squares instead of SVG icons.
1 parent 1488405 commit b08e7cd

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

src/ui/palette/palette.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22
<html>
33
<head>
44
<meta charset="UTF-8" />
5-
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:">
5+
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:">
66
<title>Component Palette</title>
77
<link rel="stylesheet" href="palette.css" />
8+
<script src="../../../dist/webui/static/lucide.min.js"></script>
9+
<script>
10+
if (typeof exports === 'undefined') {
11+
var exports = {};
12+
}
13+
</script>
14+
<script src="../../../lib/ui/shared/lucide.js"></script>
815
</head>
916
<body>
1017
<div class="palette-window">

src/ui/palette/palette.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
* availability and dispatching add requests.
88
*/
99

10-
import { initializeLucideIconsFromGlobal } from '../shared/lucide';
10+
type LucideHelperWindow = Window & {
11+
lucideHelpers?: {
12+
initializeLucideIconsFromGlobal?(
13+
iconNames: string[],
14+
root?: Document | Element | DocumentFragment
15+
): void;
16+
};
17+
};
1118

1219
interface PaletteAPI {
1320
close: () => void;
@@ -31,7 +38,7 @@ type PaletteWindow = Window & {
3138
debugPaletteManager?: unknown;
3239
};
3340

34-
const paletteWindow = window as unknown as PaletteWindow;
41+
const paletteWindow = window as unknown as PaletteWindow & LucideHelperWindow;
3542

3643
interface PaletteState {
3744
componentsInUse: Set<string>;
@@ -182,7 +189,7 @@ class PaletteManager {
182189
item.appendChild(actionButton);
183190

184191
if (iconsToHydrate.length > 0) {
185-
initializeLucideIconsFromGlobal(iconsToHydrate, item);
192+
paletteWindow.lucideHelpers?.initializeLucideIconsFromGlobal?.(iconsToHydrate, item);
186193
}
187194

188195
return item;
@@ -247,6 +254,7 @@ paletteWindow.debugPaletteManager = paletteManager;
247254

248255
document.addEventListener('DOMContentLoaded', async () => {
249256
await paletteManager.initialize();
257+
paletteWindow.lucideHelpers?.initializeLucideIconsFromGlobal?.(['x', 'pin', 'check']);
250258
});
251259

252260
window.addEventListener('beforeunload', () => {

0 commit comments

Comments
 (0)