From 180151567bca7e5af81b8ac2d39ebbdf6e4b4f0d Mon Sep 17 00:00:00 2001 From: sean10 Date: Thu, 17 Jun 2021 23:16:24 +0800 Subject: [PATCH 1/2] support preview image whose path is relative to the markdown file --- src/extension.js | 7 +++++-- src/util.js | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/extension.js b/src/extension.js index 8f64f0b..367b55c 100644 --- a/src/extension.js +++ b/src/extension.js @@ -1,7 +1,7 @@ const vscode = require('vscode'); const { hideDecoration, transparentDecoration, getUrlDecoration, getSvgDecoration } = require('./common-decorations'); const { state } = require('./state'); -const { memoize, nodeToHtml, svgToUri, htmlToSvg, DefaultMap, texToSvg, enableHoverImage } = require('./util'); +const { memoize, nodeToHtml, svgToUri, htmlToSvg, DefaultMap, texToSvg, enableHoverImage, path } = require('./util'); const { triggerUpdateDecorations, addDecoration, posToRange } = require('./runner'); const cheerio = require('cheerio'); @@ -325,7 +325,10 @@ function bootstrap(context) { if (!match) return; addDecoration(hideDecoration, start, start + 2); addDecoration(getUrlDecoration(true), start + match[1].length + 2, end); - state.imageList.push([posToRange(start, end), node.url, node.alt || " "]); + const editor = vscode.window.activeTextEditor; + const mdFilePath = editor.document.uri.fsPath; + const imgPath =path.resolve(path.dirname(mdFilePath), node.url); + state.imageList.push([posToRange(start, end), imgPath, node.alt || " "]); }]], ["emphasis", ["delete", (() => { const strikeDecoration = vscode.window.createTextEditorDecorationType({ diff --git a/src/util.js b/src/util.js index fed3a2a..1f07cea 100644 --- a/src/util.js +++ b/src/util.js @@ -137,4 +137,6 @@ const nodeToHtml = (() => { return (/** @type {import("unist").Node} */ node) => toHtml(toHast(node)); })(); -module.exports = { DefaultMap, memoize, urlToUri, svgToUri, htmlToSvg, parser, nodeToHtml, texToSvg, enableHoverImage }; \ No newline at end of file +const path = require('path'); + +module.exports = { DefaultMap, memoize, urlToUri, svgToUri, htmlToSvg, parser, nodeToHtml, texToSvg, enableHoverImage, path }; \ No newline at end of file From f282e99cd46a817a6309856108e38b7defafb131 Mon Sep 17 00:00:00 2001 From: sean10 Date: Fri, 18 Jun 2021 00:26:35 +0800 Subject: [PATCH 2/2] add FAQ How to make Images Preview always maximized --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 9dbbbf3..fa5694a 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,11 @@ Bracket pair colorizers interfere with the rendering. If you use one, install th --- +# FAQ +## Q: How to make Images Preview always maximized +Set vscode settings `Workbench › Panel: Opens Maximized` as `always`. + + # **Differences** | | Markless | Typora |