Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file icon for webview #224858

Closed
ykawakamy opened this issue Aug 5, 2024 · 6 comments
Closed

file icon for webview #224858

ykawakamy opened this issue Aug 5, 2024 · 6 comments
Assignees
Labels
info-needed Issue requires more information from poster webview Webview issues

Comments

@ykawakamy
Copy link

Currently using FileIcon in extension webview requires a very complicated procedure.

  • Get the active IconTheme with vscode.workspace.getConfiguration("workbench").get<string>("iconTheme").

  • Scan vscode.extensions.all to find the active IconTheme extension.

  • Generate css rules from the active IconTheme.
    equivalent to processIconThemeDocument.
    It is necessary to set asWebViewUri of IconTheme as Uri of Font.

  • Set WebviewOptions#localResourceRoots to the on-disk URI of the active IconTheme extension.

  • Resolve Icon Class from Uri and ThemeIcon.
    equivalent to getIconClasses
    Currently, since the detectLanguageId is not public, it is possible to use vscode.workspace.openDocument as a substitute, but it is extremely slow.

I would like you to provide the functions corresponding to processIconThemeDocument, getIconClasses, and detectLanguageId.
Otherwise, add WebviewOptions#useFileIconStyleSheet. if set, FileIcon stylesheets to be automatically embedded in the webview like acquireVsCodeApi.

This issue is related to #191387, but there is no answer to Webview there.

--
Sorry, I'm not good at English.

This is off the topic but... , I'm somtimes confused Webview, WebviewView, WebviewPanel

@mjbvz
Copy link
Collaborator

mjbvz commented Aug 5, 2024

Sorry not sure I understand. Do you mean using the icon for the webview tab ( #90616)? Or using the icon inside the webview content?

@mjbvz mjbvz added info-needed Issue requires more information from poster webview Webview issues labels Aug 5, 2024
@ykawakamy
Copy link
Author

inside the webview content(in iframe).

@ykawakamy
Copy link
Author

I have created a demo of treeview with FileIcon on webview.
(tested it with the default seti icon theme.)
https://github.com/ykawakamy/treeview-demo-extension

image

I have reimplemented processIconThemeDocument(toStyleSheet) , getIconClasses(resolveTreeIconClasses), and detectLanguageId.

If these become public APIs, we think we can adapt the webview design to vscode.

@ArthurLobopro
Copy link

I think I have the same problem

I have a CodeSnap like extension with Windows window style. I wanted to add the file icon as a Window Icon, but there are no public APIs to do it in VSCode. I would like if there is a way to get file icons

image

Copy link

Hey @mjbvz, this issue might need further attention.

@ykawakamy, you can help us out by closing this issue if the problem no longer exists, or adding more information.

Copy link

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@vs-code-engineering vs-code-engineering bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2024
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jan 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster webview Webview issues
Projects
None yet
Development

No branches or pull requests

3 participants