我可以在悬停者中显示图像吗?
我是VSCODE扩展开发的新手,因此不确定最好的帮助场所。我想悬停在一个单词上,如果该单词与我们的图标目录中的名称匹配,请与该图像显示悬停。我的第一次尝试是使用Markdown显示网络上的SVG图像,但我认为,可以执行代码的安全性。我可以在vscode.hover中的降价中显示SVG吗?我可以在扩展名中包括SVG,或者期望开发人员已经将NPM软件包安装到工作区中。
I am new to vscode extension development so not sure best places to look for help. I want to hover over a word, and if that word matches the name in our icon directory, show a hover with that image. My first try was to use markdown to show the svg image from the web, but I believe that is not allowed for security that code could be executed. Can I show an svg in the markdown in a vscode.Hover? I can either include the svgs in the extension, or expect that the developer has already installed the npm package with the files into the workspace.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,在徘徊的
markdownstring
中,对内容和样式有很丰富的支持。您可以直接使用
SVG的
:baseuri
属性至关重要。在这里,它从images
文件夹中获取SVG。在下面,我将
png
图像添加到扩展名图像
文件夹中。您可以检测到悬停的单词并加载相应的图标。以下是在明文文件中进行测试:
There is actually quite rich support for content and styling in
MarkdownString
in hovers.You can use
svg's
directly this way:The
baseUri
property is crucial. Here it gets the svgs from animages
folder.In the below I added the
png
images to an extensionimages
folder. You can detect what word is hovered and load the corresponding icon.Below is testing in a plaintext file:
据我所知,在悬停项目中只有非常有限的降价支持。
There's only very limited Markdown support in hover items and images are not supported there at all, as far as I know.