vscode-markdown icon indicating copy to clipboard operation
vscode-markdown copied to clipboard

Image preview doesn't show in completion info

Open ronggang opened this issue 3 years ago • 4 comments

What is the problem?

还是用中文描述吧; 当插入一张图片时,在列表右边的预览框无法显示图片内容。 但是图片路径是正确的,我选择完之后,可以正常显示。

How can I reproduce it?

VSCode 里新建一个 Markdown 文件,然后输入 ![]() ,在弹出的列表中选择图片。

2020-08-28_09-18-27

Is there any error message in the console?

no.


是参数设置问题吗?记得以前显示是正常的。😂

VSCode 版本

Version: 1.48.2 (system setup)
Commit: a0479759d6e9ea56afa657e454193f72aef85bd0
Date: 2020-08-25T10:13:11.295Z
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.17134

Markdown All in One 版本: v3.2.0

ronggang avatar Aug 28 '20 01:08 ronggang

我好像也注意到过这个问题

yzhang-gh avatar Aug 28 '20 02:08 yzhang-gh

我好像也注意到过这个问题

不知是否可定位到问题所在?路径问题?

ronggang avatar Aug 31 '20 11:08 ronggang

我的第一感觉是可能 VSCode 出于安全原因禁用掉了(仅仅是猜测,没有验证),毕竟以前没问题,后来也没有改动相关的代码。 也正因为不清楚原因,需要专门花一段时间来看,优先级就变低了😥

yzhang-gh avatar Aug 31 '20 14:08 yzhang-gh

Got the solution:

Use <img> and control the image size via the style attribute.


This problem involves many aspects.

VS Code has a strict CSP for security reasons. However, its markdownRenderer cannot transform image URLs correctly on some code paths. The bug will be fixed in VS Code 1.63: https://github.com/microsoft/vscode/issues/136027.

When creating CompletionItem.documentation, we currently take some extended syntax of VS Code to limit the image size. IIRC, this is not robust, and some versions of VS Code occasionally interpreted it incorrectly. Now we'll have a reliable way: MarkdownString.supportHtml, which was proposed in VS Code 1.61 and has become stable since VS Code 1.62.

Lemmingh avatar Nov 16 '21 13:11 Lemmingh