Co-authored-by: bashrusakh <bashrusakh@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
co-authored by
bashrusakh
parent
4e591503ce
commit
17af1f3369
@@ -29,7 +29,8 @@ const getWorker = (): Worker | undefined => {
|
|||||||
if (typeof window === 'undefined' || typeof Worker === 'undefined') return undefined;
|
if (typeof window === 'undefined' || typeof Worker === 'undefined') return undefined;
|
||||||
try {
|
try {
|
||||||
worker = new Worker(MarkdownShikiWorkerUrl, { type: 'module' });
|
worker = new Worker(MarkdownShikiWorkerUrl, { type: 'module' });
|
||||||
} catch {
|
} catch (err) {
|
||||||
|
console.error('Failed to create Shiki worker:', err);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
worker.onmessage = (event: MessageEvent<MarkdownWorkerResponse>) => {
|
worker.onmessage = (event: MessageEvent<MarkdownWorkerResponse>) => {
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ export function getWebviewHtml(options: WebviewHtmlOptions): string {
|
|||||||
const connectSrc = uniqueTokens(['*', 'ws:', 'wss:', 'http:', 'https:', devServerOrigin]);
|
const connectSrc = uniqueTokens(['*', 'ws:', 'wss:', 'http:', 'https:', devServerOrigin]);
|
||||||
const imgSrc = uniqueTokens([webview.cspSource, 'data:', 'https:', devServerOrigin]);
|
const imgSrc = uniqueTokens([webview.cspSource, 'data:', 'https:', devServerOrigin]);
|
||||||
const fontSrc = uniqueTokens([webview.cspSource, 'data:', devServerOrigin]);
|
const fontSrc = uniqueTokens([webview.cspSource, 'data:', devServerOrigin]);
|
||||||
|
const workerSrc = uniqueTokens([webview.cspSource, devServerOrigin]);
|
||||||
|
|
||||||
const themeKind = getThemeKindName(vscode.window.activeColorTheme.kind);
|
const themeKind = getThemeKindName(vscode.window.activeColorTheme.kind);
|
||||||
|
|
||||||
@@ -84,7 +85,7 @@ export function getWebviewHtml(options: WebviewHtmlOptions): string {
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src ${styleSrc}; script-src ${scriptSrc}; connect-src ${connectSrc}; img-src ${imgSrc}; font-src ${fontSrc};">
|
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src ${styleSrc}; script-src ${scriptSrc}; connect-src ${connectSrc}; img-src ${imgSrc}; font-src ${fontSrc}; worker-src ${workerSrc};">
|
||||||
<style>
|
<style>
|
||||||
html, body, #root { height: 100%; width: 100%; margin: 0; padding: 0; }
|
html, body, #root { height: 100%; width: 100%; margin: 0; padding: 0; }
|
||||||
body {
|
body {
|
||||||
|
|||||||
Reference in New Issue
Block a user