vscode-colaview 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.vscode/launch.json +30 -0
  2. package/.vscode/settings.json +7 -0
  3. package/.vscode/tasks.json +18 -0
  4. package/.vscodeignore +23 -0
  5. package/CHANGELOG.md +112 -0
  6. package/LICENSE +21 -0
  7. package/README.md +264 -2
  8. package/README_CN.md +265 -0
  9. package/RELEASE_NOTES.md +201 -0
  10. package/esbuild.js +106 -0
  11. package/icon.png +0 -0
  12. package/package.json +186 -6
  13. package/src/commands/commands.ts +105 -0
  14. package/src/export/css-collector.ts +50 -0
  15. package/src/export/docx-exporter.ts +923 -0
  16. package/src/export/html-exporter.ts +18 -0
  17. package/src/export/pdf-exporter.ts +121 -0
  18. package/src/export/render-export-images.ts +206 -0
  19. package/src/export/theme-style.ts +135 -0
  20. package/src/extension.ts +59 -0
  21. package/src/preview/preview-manager.ts +499 -0
  22. package/src/preview/webview/app.ts +371 -0
  23. package/src/preview/webview/index.html +127 -0
  24. package/src/themes/built-in/bear.css +38 -0
  25. package/src/themes/built-in/dark.css +20 -0
  26. package/src/themes/built-in/dracula.css +38 -0
  27. package/src/themes/built-in/elegant.css +52 -0
  28. package/src/themes/built-in/gruvbox.css +42 -0
  29. package/src/themes/built-in/light.css +20 -0
  30. package/src/themes/built-in/midnight.css +31 -0
  31. package/src/themes/built-in/nord.css +38 -0
  32. package/src/themes/built-in/notion.css +48 -0
  33. package/src/themes/built-in/sepia.css +47 -0
  34. package/src/themes/built-in/solarized-dark.css +35 -0
  35. package/src/themes/built-in/writer.css +44 -0
  36. package/src/themes/theme-manager.ts +180 -0
  37. package/src/types/colamd-renderer.d.ts +47 -0
  38. package/src/types.ts +20 -0
  39. package/test/fixtures/basic.md +34 -0
  40. package/test/fixtures/math.md +20 -0
  41. package/test/fixtures/mermaid.md +19 -0
  42. package/test/runTest.ts +30 -0
  43. package/test/suite/html-exporter.test.ts +20 -0
  44. package/test/suite/markdown-parser.test.ts +8 -0
  45. package/test/suite/theme-manager.test.ts +31 -0
  46. package/tsconfig.json +19 -0
@@ -0,0 +1,499 @@
1
+ // 预览面板管理器 — WebView 面板生命周期管理 + Milkdown 编辑器同步
2
+ import * as vscode from 'vscode';
3
+ import * as path from 'path';
4
+ import * as fs from 'fs';
5
+ import { ThemeManager } from '../themes/theme-manager';
6
+ import { exportHTML } from '../export/html-exporter';
7
+ import { exportPDF } from '../export/pdf-exporter';
8
+ import { exportWord } from '../export/docx-exporter';
9
+ import { translateThemeCssForExport } from '../export/theme-style';
10
+
11
+ function getNonce(): string {
12
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
13
+ let result = '';
14
+ for (let i = 0; i < 32; i++) {
15
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
16
+ }
17
+ return result;
18
+ }
19
+
20
+ function getTopVisibleLine(editor: vscode.TextEditor): number | undefined {
21
+ if (!editor.visibleRanges.length) {
22
+ return undefined;
23
+ }
24
+ return editor.visibleRanges[0].start.line;
25
+ }
26
+
27
+ function getBottomVisibleLine(editor: vscode.TextEditor): number | undefined {
28
+ if (!editor.visibleRanges.length) {
29
+ return undefined;
30
+ }
31
+ const lastRange = editor.visibleRanges[editor.visibleRanges.length - 1];
32
+ return lastRange.end.line;
33
+ }
34
+
35
+ export class PreviewManager {
36
+ private panel: vscode.WebviewPanel | null = null;
37
+ private currentUri: vscode.Uri | null = null;
38
+ private debounceTimer: NodeJS.Timeout | null = null;
39
+ private disposables: vscode.Disposable[] = [];
40
+ private pendingDocument: vscode.TextDocument | null = null;
41
+ private exportResolve: ((html: string) => void) | null = null;
42
+ private editorScrollDelay = Date.now();
43
+
44
+ constructor(private context: vscode.ExtensionContext) {
45
+ this.registerActiveEditorListener();
46
+ this.registerScrollSyncListeners();
47
+ this.registerConfigurationListener();
48
+ }
49
+
50
+ private registerActiveEditorListener(): void {
51
+ try {
52
+ vscode.window.onDidChangeActiveTextEditor(editor => {
53
+ try {
54
+ if (editor && editor.document.languageId === 'markdown' && this.panel) {
55
+ if (this.currentUri?.toString() !== editor.document.uri.toString()) {
56
+ this.currentUri = editor.document.uri;
57
+ this.updatePreview(editor.document);
58
+ }
59
+ }
60
+ } catch (e) {
61
+ console.error('[ColaView] onDidChangeActiveTextEditor error:', e);
62
+ }
63
+ }, null, this.disposables);
64
+ } catch (e) {
65
+ console.error('[ColaView] registerActiveEditorListener failed:', e);
66
+ }
67
+ }
68
+
69
+ private registerScrollSyncListeners(): void {
70
+ try {
71
+ vscode.window.onDidChangeTextEditorSelection((event) => {
72
+ try {
73
+ if (!this.isScrollSyncEnabled()) { return; }
74
+ const editor = event.textEditor;
75
+ if (Date.now() < this.editorScrollDelay) { return; }
76
+ if (editor.document.languageId !== 'markdown') { return; }
77
+ if (editor.document.uri.toString() !== this.currentUri?.toString()) { return; }
78
+
79
+ const topLine = getTopVisibleLine(editor);
80
+ const bottomLine = getBottomVisibleLine(editor);
81
+ if (typeof topLine === 'undefined' || typeof bottomLine === 'undefined') { return; }
82
+
83
+ const cursorLine = event.selections[0].active.line;
84
+ const topRatio = (bottomLine > topLine)
85
+ ? (cursorLine - topLine) / (bottomLine - topLine)
86
+ : 0.3;
87
+
88
+ this.panel?.webview.postMessage({
89
+ type: 'editorScroll',
90
+ line: cursorLine,
91
+ totalLines: editor.document.lineCount,
92
+ topRatio: Math.max(0, Math.min(1, topRatio)),
93
+ });
94
+ } catch (e) {
95
+ // silently ignore errors in scroll sync handler
96
+ }
97
+ }, null, this.disposables);
98
+
99
+ vscode.window.onDidChangeTextEditorVisibleRanges((event) => {
100
+ try {
101
+ if (!this.isScrollSyncEnabled()) { return; }
102
+ const editor = event.textEditor;
103
+ if (Date.now() < this.editorScrollDelay) { return; }
104
+ if (editor.document.languageId !== 'markdown') { return; }
105
+ if (editor.document.uri.toString() !== this.currentUri?.toString()) { return; }
106
+
107
+ const totalLines = editor.document.lineCount;
108
+ if (totalLines <= 1) { return; }
109
+
110
+ const topLine = getTopVisibleLine(editor);
111
+ const bottomLine = getBottomVisibleLine(editor);
112
+ if (typeof topLine === 'undefined' || typeof bottomLine === 'undefined') { return; }
113
+
114
+ let midLine: number;
115
+ if (topLine === 0) {
116
+ midLine = 0;
117
+ } else if (Math.floor(bottomLine) === totalLines - 1) {
118
+ midLine = bottomLine;
119
+ } else {
120
+ midLine = Math.floor((topLine + bottomLine) / 2);
121
+ }
122
+
123
+ const scrollPercent = midLine / (totalLines - 1);
124
+
125
+ this.panel?.webview.postMessage({
126
+ type: 'editorScroll',
127
+ scrollPercent: Math.max(0, Math.min(1, scrollPercent)),
128
+ });
129
+ } catch (e) {
130
+ // silently ignore errors in scroll sync handler
131
+ }
132
+ }, null, this.disposables);
133
+ } catch (e) {
134
+ console.error('[ColaView] registerScrollSyncListeners failed:', e);
135
+ }
136
+ }
137
+
138
+ private registerConfigurationListener(): void {
139
+ try {
140
+ vscode.workspace.onDidChangeConfiguration((event) => {
141
+ if (event.affectsConfiguration('colaview.scrollSync')) {
142
+ // config changed, no action needed — will be checked on next scroll event
143
+ }
144
+ }, null, this.disposables);
145
+ } catch (e) {
146
+ console.error('[ColaView] registerConfigurationListener failed:', e);
147
+ }
148
+ }
149
+
150
+ private isScrollSyncEnabled(): boolean {
151
+ try {
152
+ return vscode.workspace.getConfiguration('colaview').get<boolean>('scrollSync', false);
153
+ } catch {
154
+ return false;
155
+ }
156
+ }
157
+
158
+ showPreview(): void {
159
+ const editor = vscode.window.activeTextEditor;
160
+ if (!editor || editor.document.languageId !== 'markdown') {
161
+ vscode.window.showWarningMessage('No Markdown file is open');
162
+ return;
163
+ }
164
+
165
+ this.currentUri = editor.document.uri;
166
+
167
+ if (this.panel) {
168
+ this.panel.reveal(vscode.ViewColumn.Two);
169
+ this.updatePreview(editor.document);
170
+ } else {
171
+ this.panel = vscode.window.createWebviewPanel(
172
+ 'colaview',
173
+ `Preview: ${path.basename(editor.document.fileName)}`,
174
+ vscode.ViewColumn.Two,
175
+ {
176
+ enableScripts: true,
177
+ localResourceRoots: [
178
+ vscode.Uri.joinPath(this.context.extensionUri, 'out', 'preview', 'webview'),
179
+ vscode.Uri.joinPath(this.context.extensionUri, 'src', 'preview', 'webview'),
180
+ vscode.Uri.file(path.dirname(editor.document.fileName)),
181
+ ],
182
+ retainContextWhenHidden: true,
183
+ }
184
+ );
185
+
186
+ this.panel.webview.html = this.buildWebViewHTML();
187
+ this.panel.onDidDispose(() => { this.panel = null; }, null, this.disposables);
188
+
189
+ this.panel.webview.onDidReceiveMessage((msg: { type: string; html?: string; message?: string; name?: string; scrollPercent?: number }) => {
190
+ switch (msg.type) {
191
+ case 'ready': {
192
+ const theme = ThemeManager.getCurrentTheme();
193
+ const markdown = this.pendingDocument?.getText() || '';
194
+ const builtins = ThemeManager.getBuiltinThemes();
195
+ const isCustom = !builtins.includes(theme);
196
+ const customCSS = isCustom ? ThemeManager.loadThemeCSS(theme) : undefined;
197
+ const themeCSS = ThemeManager.loadThemeCSS(theme);
198
+ this.panel?.webview.postMessage({
199
+ type: 'init',
200
+ markdown,
201
+ theme,
202
+ customCSS,
203
+ themeCSS,
204
+ });
205
+ this.pendingDocument = null;
206
+ const list = ThemeManager.getThemeList();
207
+ this.panel?.webview.postMessage({ type: 'themeList', ...list });
208
+ break;
209
+ }
210
+ case 'exportHTMLResult': {
211
+ if (this.exportResolve) {
212
+ this.exportResolve(msg.html || '');
213
+ this.exportResolve = null;
214
+ }
215
+ break;
216
+ }
217
+ case 'error': {
218
+ console.error('[ColaView] WebView error:', msg.message);
219
+ break;
220
+ }
221
+ case 'requestExportHTML': {
222
+ this.handleExportHTML();
223
+ break;
224
+ }
225
+ case 'requestExportPDF': {
226
+ this.handleExportPDF();
227
+ break;
228
+ }
229
+ case 'requestExportWord': {
230
+ this.handleExportWord();
231
+ break;
232
+ }
233
+ case 'requestImportTheme': {
234
+ vscode.commands.executeCommand('colaview.importTheme');
235
+ break;
236
+ }
237
+ case 'requestThemeList': {
238
+ const list = ThemeManager.getThemeList();
239
+ this.panel?.webview.postMessage({ type: 'themeList', ...list });
240
+ break;
241
+ }
242
+ case 'switchTheme': {
243
+ if (msg.name) {
244
+ this.handleSwitchTheme(msg.name);
245
+ }
246
+ break;
247
+ }
248
+ case 'scrollSync': {
249
+ if (msg.scrollPercent !== undefined) {
250
+ this.handleScrollSync({ scrollPercent: msg.scrollPercent });
251
+ }
252
+ break;
253
+ }
254
+ }
255
+ }, null, this.disposables);
256
+
257
+ this.pendingDocument = editor.document;
258
+
259
+ vscode.workspace.onDidChangeTextDocument(e => {
260
+ if (e.document.uri.toString() === this.currentUri?.toString()) {
261
+ if (this.debounceTimer) clearTimeout(this.debounceTimer);
262
+ this.debounceTimer = setTimeout(() => {
263
+ this.updatePreview(e.document);
264
+ }, 150);
265
+ }
266
+ }, null, this.disposables);
267
+ }
268
+ }
269
+
270
+ private async handleExportHTML(): Promise<void> {
271
+ if (!this.currentUri) {
272
+ vscode.window.showWarningMessage('No Markdown file is open');
273
+ return;
274
+ }
275
+ try {
276
+ const document = await vscode.workspace.openTextDocument(this.currentUri);
277
+ const fullHTML = await this.getExportHTML();
278
+ if (!fullHTML) {
279
+ vscode.window.showWarningMessage('Could not get rendered HTML from preview');
280
+ return;
281
+ }
282
+ await exportHTML(document, fullHTML);
283
+ } catch (e) {
284
+ vscode.window.showErrorMessage(`HTML export failed: ${e instanceof Error ? e.message : String(e)}`);
285
+ }
286
+ }
287
+
288
+ private async handleExportPDF(): Promise<void> {
289
+ if (!this.currentUri) {
290
+ vscode.window.showWarningMessage('No Markdown file is open');
291
+ return;
292
+ }
293
+ try {
294
+ const document = await vscode.workspace.openTextDocument(this.currentUri);
295
+ const fullHTML = await this.getExportHTML();
296
+ if (!fullHTML) {
297
+ vscode.window.showWarningMessage('Could not get rendered HTML from preview');
298
+ return;
299
+ }
300
+ await exportPDF(document, fullHTML);
301
+ } catch (e) {
302
+ vscode.window.showErrorMessage(`PDF export failed: ${e instanceof Error ? e.message : String(e)}`);
303
+ }
304
+ }
305
+
306
+ private async handleExportWord(): Promise<void> {
307
+ if (!this.currentUri) {
308
+ vscode.window.showWarningMessage('No Markdown file is open');
309
+ return;
310
+ }
311
+ try {
312
+ const document = await vscode.workspace.openTextDocument(this.currentUri);
313
+ await exportWord(document);
314
+ } catch (e) {
315
+ vscode.window.showErrorMessage(`Word export failed: ${e instanceof Error ? e.message : String(e)}`);
316
+ }
317
+ }
318
+
319
+ private async handleSwitchTheme(name: string): Promise<void> {
320
+ await ThemeManager.switchTheme(name);
321
+ const builtins = ThemeManager.getBuiltinThemes();
322
+ const isCustom = !builtins.includes(name);
323
+ const customCSS = isCustom ? ThemeManager.loadThemeCSS(name) : undefined;
324
+ const themeCSS = ThemeManager.loadThemeCSS(name);
325
+ this.panel?.webview.postMessage({ type: 'updateTheme', theme: name, customCSS, themeCSS });
326
+ const list = ThemeManager.getThemeList();
327
+ this.panel?.webview.postMessage({ type: 'themeList', ...list });
328
+ }
329
+
330
+ private updatePreview(document: vscode.TextDocument): void {
331
+ if (!this.panel) return;
332
+ const markdown = document.getText();
333
+ const theme = ThemeManager.getCurrentTheme();
334
+ const builtins = ThemeManager.getBuiltinThemes();
335
+ const isCustom = !builtins.includes(theme);
336
+ const customCSS = isCustom ? ThemeManager.loadThemeCSS(theme) : undefined;
337
+ const themeCSS = ThemeManager.loadThemeCSS(theme);
338
+ this.panel.webview.postMessage({
339
+ type: 'update',
340
+ markdown,
341
+ theme,
342
+ customCSS,
343
+ themeCSS,
344
+ });
345
+ }
346
+
347
+ async getExportHTML(): Promise<string> {
348
+ if (!this.panel) {
349
+ throw new Error('No preview panel is open. Please open a preview first.');
350
+ }
351
+ const html = await new Promise<string>((resolve) => {
352
+ this.exportResolve = resolve;
353
+ const title = this.currentUri
354
+ ? path.basename(this.currentUri.fsPath, '.md')
355
+ : undefined;
356
+ this.panel!.webview.postMessage({ type: 'exportHTML', title });
357
+ setTimeout(() => {
358
+ if (this.exportResolve) {
359
+ this.exportResolve('');
360
+ this.exportResolve = null;
361
+ }
362
+ }, 30000);
363
+ });
364
+ return this.patchExportHTML(html);
365
+ }
366
+
367
+ /**
368
+ * 导出 HTML 后处理:
369
+ * colamd.css 末尾带一条 Electron 桌面版专用的打印规则
370
+ * `@media print { body > :not(#editor-region), ... { display: none !important } }`
371
+ * 它假定打印时 body 下只保留 #editor-region(ColaMD 桌面版结构),而我们的导出
372
+ * HTML 是 <body><article class="colamd-document">,没有 #editor-region ——
373
+ * article 会被整体隐藏,PDF/浏览器打印全部空白(仅剩一页空纸)。
374
+ *
375
+ * 覆盖规则用 :not(#_) 抬高特异性:原规则含 ID(:not(#editor-region) = 1,0,1),
376
+ * 普通 class 选择器(0,1,2)同带 !important 时也输给它;:not(#_) 恒真但贡献
377
+ * ID 特异性,得到 (1,1,2),稳定压制原规则。
378
+ * HTML 导出在浏览器中 Ctrl+P 同样受益。
379
+ */
380
+ private patchExportHTML(html: string): string {
381
+ if (!html) return html;
382
+
383
+ // colamd 导出器把 document.body 的 class 原样复制到导出 HTML 的 <body> 上,
384
+ // 而它收集的主题规则(colamd.css 内置的 body.theme-X 字体/强调色/变量)全部
385
+ // 以 body.theme-X 为作用域 —— body 缺主题类时这些规则整体失配,导出就只剩
386
+ // 浅色默认样式。这里兜底把主题类补到导出 body 上。
387
+ const theme = ThemeManager.getCurrentTheme();
388
+ const isBuiltin = ThemeManager.getBuiltinThemes().includes(theme);
389
+ const themeClass = isBuiltin ? ThemeManager.getThemeClass(theme) : 'theme-custom';
390
+ let patched = html;
391
+ const bodyTagMatch = /<body[^>]*>/i.exec(patched);
392
+ if (bodyTagMatch) {
393
+ const bodyTag = bodyTagMatch[0];
394
+ if (/\sclass="/.test(bodyTag)) {
395
+ if (!new RegExp(`\\s${themeClass}[\\s"]`).test(bodyTag)) {
396
+ patched = patched.replace(bodyTag, bodyTag.replace(/\sclass="/, ` class="${themeClass} `));
397
+ }
398
+ } else {
399
+ patched = patched.replace(bodyTag, bodyTag.replace(/<body/i, `<body class="${themeClass}"`));
400
+ }
401
+ }
402
+
403
+ // 自定义主题的规则不在 colamd.css 里(内置主题的翻译规则是冗余兜底),
404
+ // 翻译成语义选择器后注入到 </head> 前,保证优先级最高。
405
+ const themeOverrideCss = translateThemeCssForExport(ThemeManager.loadThemeCSS(theme));
406
+ const THEME_FIX = themeOverrideCss ? `<style>${themeOverrideCss}</style>` : '';
407
+ const PRINT_FIX = `<style>@media print { body > article.colamd-document:not(#_) { display: block !important; } }</style>`;
408
+ return patched.replace('</head>', PRINT_FIX + '\n' + THEME_FIX + '\n</head>');
409
+ }
410
+
411
+ sendTheme(theme: string): void {
412
+ if (!this.panel) return;
413
+ this.panel.webview.postMessage({ type: 'updateTheme', theme });
414
+ }
415
+
416
+ switchThemeFromCommand(name: string): void {
417
+ if (!this.panel) return;
418
+ const builtins = ThemeManager.getBuiltinThemes();
419
+ const isCustom = !builtins.includes(name);
420
+ const customCSS = isCustom ? ThemeManager.loadThemeCSS(name) : undefined;
421
+ const themeCSS = ThemeManager.loadThemeCSS(name);
422
+ this.panel.webview.postMessage({ type: 'updateTheme', theme: name, customCSS, themeCSS });
423
+ const list = ThemeManager.getThemeList();
424
+ this.panel.webview.postMessage({ type: 'themeList', ...list });
425
+ }
426
+
427
+ refreshThemeList(): void {
428
+ if (!this.panel) return;
429
+ const list = ThemeManager.getThemeList();
430
+ this.panel.webview.postMessage({ type: 'themeList', ...list });
431
+ }
432
+
433
+ togglePlugin(id: string, enabled: boolean): void {
434
+ if (!this.panel) return;
435
+ this.panel.webview.postMessage({ type: 'togglePlugin', id, enabled });
436
+ }
437
+
438
+ private handleScrollSync(msg: { scrollPercent: number }): void {
439
+ if (!this.isScrollSyncEnabled()) { return; }
440
+
441
+ const scrollPercent = msg.scrollPercent;
442
+ const editor = vscode.window.activeTextEditor;
443
+ if (!editor || editor.document.uri.toString() !== this.currentUri?.toString()) {
444
+ return;
445
+ }
446
+
447
+ const totalLines = editor.document.lineCount;
448
+ const targetLine = Math.floor(scrollPercent * (totalLines - 1));
449
+
450
+ this.editorScrollDelay = Date.now() + 500;
451
+
452
+ const range = new vscode.Range(targetLine, 0, targetLine + 1, 0);
453
+ editor.revealRange(range, vscode.TextEditorRevealType.AtTop);
454
+ }
455
+
456
+ private buildWebViewHTML(): string {
457
+ const outDir = path.join(this.context.extensionPath, 'out', 'preview', 'webview');
458
+ const srcDir = path.join(this.context.extensionPath, 'src', 'preview', 'webview');
459
+ const webviewDir = fs.existsSync(outDir) ? outDir : srcDir;
460
+
461
+ const appJsPath = vscode.Uri.file(path.join(webviewDir, 'app.js'));
462
+ const appJsUri = this.panel!.webview.asWebviewUri(appJsPath);
463
+
464
+ const nonce = getNonce();
465
+
466
+ const indexPath = path.join(webviewDir, 'index.html');
467
+ let html = fs.readFileSync(indexPath, 'utf-8');
468
+
469
+ html = html.replace(
470
+ /<meta http-equiv="Content-Security-Policy"[^>]*>/,
471
+ `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline' vscode-webview-resource:; script-src 'nonce-${nonce}' vscode-webview-resource:; font-src vscode-webview-resource: data:; img-src file: data: https: vscode-webview-resource:; connect-src https: vscode-webview-resource:;">`
472
+ );
473
+
474
+ // colamd.css 必须内联为 <style>,不能用 <link>:
475
+ // 跨源 <link> 的 cssRules 对 CSSOM 不可访问(SecurityError),buildExportHTML 的
476
+ // collectExportStyles() 会静默丢掉全部渲染样式(1.43MB → 15KB),导出的 HTML/PDF
477
+ // 就没有排版和 KaTeX 字体了。内联样式对 CSSOM 完全可读,导出管线才能完整带走样式。
478
+ const colamdCss = fs.readFileSync(path.join(webviewDir, 'colamd.css'), 'utf-8')
479
+ .replace(/<\/style/gi, '<\\/style') // 防 css 内容意外闭合 style 标签
480
+ // 剥离 ColaMD 桌面版打印隐藏规则,从源头避免导出 HTML/PDF 里 article 被 display:none
481
+ .replace(/@media\s*print\s*\{[^}]*\}/gi, (m) => m.includes('#editor-region') ? '' : m);
482
+ html = html.replace(
483
+ /<link rel="stylesheet" href="colamd\.css" id="colamd-css">/,
484
+ `<style id="colamd-css">${colamdCss}</style>`
485
+ );
486
+
487
+ html = html.replace(
488
+ '<script src="app.js"></script>',
489
+ `<script nonce="${nonce}" src="${appJsUri}"></script>`
490
+ );
491
+
492
+ return html;
493
+ }
494
+
495
+ dispose(): void {
496
+ this.panel?.dispose();
497
+ this.disposables.forEach(d => d.dispose());
498
+ }
499
+ }