Connecting the WebView to an "Open New Tab" button
Up until now, we developed :
1. A hover panel that shows the image we are hovering over
2. A webview that shows an image, given the image URL.
So the next thing we wanted to do was to connect those two things:
create an "Open In A New Tab" button which opens the image in the WebView panel we already developed.
We knew that the Markdown string needs to execute the initialization of the panel and the HTML in the panel.
Then, We found this documantation:
and this code block, which looked a lot like ours:
But, the command we need to execute is longer than that and is not a vscode API command.
Luckily, we found the next code on the same page:
So, we followed those two code blocks and made a new command "newTabCommand" under our "previewHover" extension command.
**basically, all we did was to replace the:
(name: string = 'world') => {
console.log(`Hello ${name}!!!`); };
with the following:
Now we added the button according to the first code block:
Finally, we needed to add the new command to the package.json file:
This is how it looks now:
Comments
Post a Comment