Ver código fonte

Fixes timeline webview not loading properly

main
Eric Amodio 2 anos atrás
pai
commit
9101ed9747
3 arquivos alterados com 30 adições e 38 exclusões
  1. +6
    -10
      src/webviews/rebase/rebaseEditor.ts
  2. +12
    -14
      src/webviews/webviewBase.ts
  3. +12
    -14
      src/webviews/webviewViewBase.ts

+ 6
- 10
src/webviews/rebase/rebaseEditor.ts Ver arquivo

@ -503,21 +503,16 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
const root = context.panel.webview.asWebviewUri(this.container.context.extensionUri).toString();
const webRoot = context.panel.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)}/i,
(_substring, token) => {
switch (token) {
case 'endOfBody':
return `<script type="text/javascript" nonce="#{cspNonce}">window.bootstrap = ${JSON.stringify(
return `<script type="text/javascript" nonce="${cspNonce}">window.bootstrap=${JSON.stringify(
bootstrap,
)};</script>`;
case 'placement':
return 'editor';
default:
return '';
}
})
.replace(/#{(cspSource|cspNonce|root|webroot)}/g, (_substring, token) => {
switch (token) {
case 'cspSource':
return cspSource;
case 'cspNonce':
@ -529,7 +524,8 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
default:
return '';
}
});
},
);
return html;
}

+ 12
- 14
src/webviews/webviewBase.ts Ver arquivo

@ -203,27 +203,24 @@ export abstract class WebviewBase implements Disposable {
const root = webview.asWebviewUri(this.container.context.extensionUri).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) {
case 'head':
return head ?? '';
case 'body':
return body ?? '';
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':
return 'editor';
default:
return '';
}
})
.replace(/#{(cspSource|cspNonce|root|webroot)}/g, (_substring, token) => {
switch (token) {
case 'cspSource':
return cspSource;
case 'cspNonce':
@ -235,7 +232,8 @@ export abstract class WebviewBase implements Disposable {
default:
return '';
}
});
},
);
return html;
}

+ 12
- 14
src/webviews/webviewViewBase.ts Ver arquivo

@ -208,27 +208,24 @@ export abstract class WebviewViewBase implements WebviewViewProvider, Dis
const root = webview.asWebviewUri(this.container.context.extensionUri).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) {
case 'head':
return head ?? '';
case 'body':
return body ?? '';
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':
return 'view';
default:
return '';
}
})
.replace(/#{(cspSource|cspNonce|root|webroot)}/g, (_substring, token) => {
switch (token) {
case 'cspSource':
return cspSource;
case 'cspNonce':
@ -240,7 +237,8 @@ export abstract class WebviewViewBase implements WebviewViewProvider, Dis
default:
return '';
}
});
},
);
return html;
}

Carregando…
Cancelar
Salvar