Skip to content

Commit

Permalink
fix local image preview which missing file scheme, and add support fo…
Browse files Browse the repository at this point in the history
…r http/https link image
  • Loading branch information
Sean10 committed Sep 22, 2021
1 parent e449a77 commit 6853ab3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,18 @@ function bootstrap(context) {
["link", ["image", (start, end, node) => {
const text = state.text.slice(start, end);
const match = /!\[(.*)\]\(.+?\)/.exec(text);
console.log("text: "+ JSON.stringify(text));
if (!match) return;
addDecoration(hideDecoration, start, start + 2);
addDecoration(getUrlDecoration(true), start + match[1].length + 2, end);
console.log(JSON.stringify(node));
if (node.url.startsWith("http")) {
state.imageList.push([posToRange(start, end), node.url, node.alt || " "]);
return;
}
const editor = vscode.window.activeTextEditor;
const mdFilePath = editor.document.uri.fsPath;
const imgPath =path.resolve(path.dirname(mdFilePath), node.url);
const imgPath = path.resolve("file://", path.dirname(mdFilePath), node.url);
state.imageList.push([posToRange(start, end), imgPath, node.alt || " "]);
}]],
["emphasis", ["delete", (() => {
Expand Down

0 comments on commit 6853ab3

Please sign in to comment.