Procházet zdrojové kódy

Fixes timeline webview not loading properly

main
Eric Amodio před 2 roky
rodič
revize
9101ed9747
3 změnil soubory, kde provedl 30 přidání a 38 odebrání
  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 Zobrazit soubor

@ -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 Zobrazit soubor

@ -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 Zobrazit soubor

@ -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;
}

Načítá se…
Zrušit
Uložit