Skip to content

Commit db68ab6

Browse files
authored
feat: add options to disable webview patch (#35)
* add options * add FAQ
1 parent 06f31c2 commit db68ab6

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ VSCode extension that custom ui css style in both editor and webview
1515
> This extension works by editting the VSCode's css and js files.
1616
>
1717
> ~~So, a warning appears while the first time to install or VSCode update. You can click the [never show again] to avoid it.~~
18-
> From V0.4.0, the warning will no longer prompt after fully restart. #11
18+
> From V0.4.0, the warning will no longer prompt after fully restart. [#11](https://github.com/subframe7536/vscode-custom-ui-style/issues/11)
1919
2020
## Features
2121

@@ -207,6 +207,10 @@ sudo chown -R $(whoami) "/usr/local/code"
207207

208208
See in [#6](https://github.com/subframe7536/vscode-custom-ui-style/issues/6)
209209

210+
### Fail to render panel
211+
212+
According to [#34](https://github.com/subframe7536/vscode-custom-ui-style/issues/34), in Cursor (close source VSCode's fork), the extension detail panel will not show by default due to the violation of iframe's CSP. Currently the way to fix it is just skip patch on webview, so please set `"custom-ui-style.webview.enable": false`
213+
210214
## Configurations
211215

212216
<!-- configs -->
@@ -227,6 +231,7 @@ See in [#6](https://github.com/subframe7536/vscode-custom-ui-style/issues/6)
227231
| `custom-ui-style.external.loadStrategy` | Load strategy for external CSS or JS resources | `string` | `"refetch"` |
228232
| `custom-ui-style.external.imports` | External CSS or JS resources, support variable: [${userHome}, ${env:your_env_name:optional_fallback_value}], support protocol: 'https://', 'file://' | `array` | `` |
229233
| `custom-ui-style.stylesheet` | Custom css for editor, support nest selectors | `object` | `{}` |
234+
| `custom-ui-style.webview.enable` | Enable style patch in webview | `boolean` | `true` |
230235
| `custom-ui-style.webview.monospaceSelector` | Custom monospace selector in webview | `array` | `` |
231236
| `custom-ui-style.webview.sansSerifSelector` | Custom sans-serif selector in webview | `array` | `` |
232237
| `custom-ui-style.webview.stylesheet` | Custom css for webview, support nest selectors | `object` | `{}` |

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@
170170
"type": "object",
171171
"description": "Custom css for editor, support nest selectors"
172172
},
173+
"custom-ui-style.webview.enable": {
174+
"scope": "application",
175+
"type": "boolean",
176+
"default": true,
177+
"description": "Enable style patch in webview"
178+
},
173179
"custom-ui-style.webview.monospaceSelector": {
174180
"scope": "application",
175181
"type": "array",

src/manager/webview.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export class WebViewFileManager extends BaseFileManager {
4343
}
4444

4545
patch(content: string): string {
46+
if (!config['webview.enable']) {
47+
return content
48+
}
4649
return fixSha256(
4750
content.replace(
4851
entry,

src/path.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ function getWebviewHTML(ext: string) {
4646
'webview',
4747
'browser',
4848
'pre',
49-
`index${ext}`,
49+
`index.${ext}`,
5050
)
5151
}
5252

53-
export const webviewHTMLPath = getWebviewHTML('.html')
54-
export const webviewHTMLBakPath = getWebviewHTML(`.${bakExt}.html`)
53+
export const webviewHTMLPath = getWebviewHTML('html')
54+
export const webviewHTMLBakPath = getWebviewHTML(`${bakExt}.html`)
5555
/**
5656
* See https://code.visualstudio.com/api/references/vscode-api#env
5757
*/

0 commit comments

Comments
 (0)