Skip to content

Commit fb5fae9

Browse files
committed
Merge branch 'dev' of github.com:estruyf/vscode-demo-time into dev
2 parents 5cda6e8 + 9b69fa9 commit fb5fae9

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## [0.0.90] - 2025-03-31
4+
5+
- [#83](https://github.com/estruyf/vscode-demo-time/issues/83): Added support for custom web components in the slide view
6+
37
## [0.0.89] - 2025-03-29
48

59
- Small title theme fix in `quantum`

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@
158158
"type": "boolean",
159159
"default": false,
160160
"description": "Hide the editor actions"
161+
},
162+
"demoTime.customWebComponents": {
163+
"type": "array",
164+
"items": {
165+
"type": "string"
166+
},
167+
"default": [],
168+
"description": "Provide paths to scripts for loading your custom web components. Each path should point to a JavaScript file."
161169
}
162170
}
163171
},

src/constants/Config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ export const Config = {
2222
enabled: "api.enabled",
2323
port: "api.port",
2424
},
25+
webcomponents: {
26+
scripts: "customWebComponents",
27+
},
2528
};

src/preview/Preview.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ export class Preview {
175175
const localServerUrl = "http://localhost:9001";
176176

177177
let scriptUrl = [];
178+
let moduleUrl = [];
178179

179180
const extension = Extension.getInstance();
180181
const extPath = Uri.file(extension.extensionPath);
@@ -196,6 +197,18 @@ export class Preview {
196197

197198
scriptUrl.push(webview.asWebviewUri(Uri.joinPath(extPath, "assets", "slides", "tailwind.js")).toString());
198199

200+
const webComponents = extension.getSetting<string[]>(Config.webcomponents.scripts);
201+
if (webComponents) {
202+
const workspaceFolder = extension.workspaceFolder;
203+
for (const webComponent of webComponents) {
204+
if (webComponent.startsWith("http")) {
205+
moduleUrl.push(webComponent);
206+
} else if (workspaceFolder) {
207+
moduleUrl.push(webview.asWebviewUri(Uri.joinPath(workspaceFolder.uri, webComponent)).toString());
208+
}
209+
}
210+
}
211+
199212
const webviewUrl = getWebviewUrl(webview, "");
200213

201214
return `<!DOCTYPE html>
@@ -208,6 +221,7 @@ export class Preview {
208221
<div id="root" data-webview-url="${webviewUrl}"></div>
209222
210223
${scriptUrl.map((url) => `<script src="${url}"></script>`).join("\n")}
224+
${moduleUrl.map((url) => `<script src="${url}" type="module"></script>`).join("\n")}
211225
212226
<img style="display:none" src="https://api.visitorbadge.io/api/combined?path=https:%2f%2fgithub.com%2festruyf%2fvscode-demo-time&labelColor=%23202736&countColor=%23FFD23F&slug=preview" alt="Preview usage" />
213227
</body>

0 commit comments

Comments
 (0)