|
@ -208,27 +208,24 @@ export abstract class WebviewViewBase implements WebviewViewProvider, Dis |
|
|
const root = webview.asWebviewUri(this.container.context.extensionUri).toString(); |
|
|
const root = webview.asWebviewUri(this.container.context.extensionUri).toString(); |
|
|
const webRoot = webview.asWebviewUri(webRootUri).toString(); |
|
|
const webRoot = webview.asWebviewUri(webRootUri).toString(); |
|
|
|
|
|
|
|
|
const html = content |
|
|
|
|
|
.replace(/#{(head|body|endOfBody|placement)}/i, (_substring, token) => { |
|
|
|
|
|
|
|
|
const html = content.replace( |
|
|
|
|
|
/#{(head|body|endOfBody|placement|cspSource|cspNonce|root|webroot)}/g, |
|
|
|
|
|
(_substring, token) => { |
|
|
switch (token) { |
|
|
switch (token) { |
|
|
case 'head': |
|
|
case 'head': |
|
|
return head ?? ''; |
|
|
return head ?? ''; |
|
|
case 'body': |
|
|
case 'body': |
|
|
return body ?? ''; |
|
|
return body ?? ''; |
|
|
case 'endOfBody': |
|
|
case 'endOfBody': |
|
|
return bootstrap != null |
|
|
|
|
|
? `<script type="text/javascript" nonce="#{cspNonce}">window.bootstrap = ${JSON.stringify( |
|
|
|
|
|
bootstrap, |
|
|
|
|
|
)};</script>${endOfBody ?? ''}`
|
|
|
|
|
|
: endOfBody ?? ''; |
|
|
|
|
|
|
|
|
return `${ |
|
|
|
|
|
bootstrap != null |
|
|
|
|
|
? `<script type="text/javascript" nonce="${cspNonce}">window.bootstrap=${JSON.stringify( |
|
|
|
|
|
bootstrap, |
|
|
|
|
|
)};</script>`
|
|
|
|
|
|
: '' |
|
|
|
|
|
}${endOfBody ?? ''}`;
|
|
|
case 'placement': |
|
|
case 'placement': |
|
|
return 'view'; |
|
|
return 'view'; |
|
|
default: |
|
|
|
|
|
return ''; |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.replace(/#{(cspSource|cspNonce|root|webroot)}/g, (_substring, token) => { |
|
|
|
|
|
switch (token) { |
|
|
|
|
|
case 'cspSource': |
|
|
case 'cspSource': |
|
|
return cspSource; |
|
|
return cspSource; |
|
|
case 'cspNonce': |
|
|
case 'cspNonce': |
|
@ -240,7 +237,8 @@ export abstract class WebviewViewBase implements WebviewViewProvider, Dis |
|
|
default: |
|
|
default: |
|
|
return ''; |
|
|
return ''; |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
return html; |
|
|
return html; |
|
|
} |
|
|
} |
|
|