Skip to content

Commit 5f65648

Browse files
committed
chore: update changelog and README for version 1.4.5; add remote mode check for image pasting
1 parent 469716f commit 5f65648

File tree

6 files changed

+35
-6
lines changed

6 files changed

+35
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 1.4.5 (2005/08/29)
4+
5+
- fix: Paste Image is disabled in SSH, and Dev Container remote modes.
6+
37
## 1.4.4 (2025/04/14)
48

59
- fix: timing issue when generating timestamps for imageRules

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Smartly paste for Markdown.
1818

1919
Smartly paste in Markdown by pressing 'Ctrl+Alt+V' ('Cmd+Alt+V' on Mac) or `Markdown Paste` command.
2020

21-
- If you paste an image, the extension will create an new file for the image and insert link code to Markdown.
21+
- If you paste an image, the extension will create an new file for the image and insert link code to Markdown (Disabled in SSH & Dev Container mode).
2222
- If you paste a text, it will test the text with customize regex, and replace matched content by regex.
2323
- If you paste a text contain HTML tag, it will try to convert the HTML content to Markdown.
2424
- If you paste a rich text, it will try to convert the rich text to Markdown.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-markdown-paste-image",
33
"displayName": "Markdown Paste",
44
"description": "A smartly paste for markdown.",
5-
"version": "1.4.4",
5+
"version": "1.4.5",
66
"publisher": "telesoho",
77
"author": {
88
"name": "telesoho",
@@ -55,6 +55,7 @@
5555
"dev:preinstall": "npx vsce package",
5656
"dev:install": "code --install-extension ./vscode-markdown-paste-image-*.vsix"
5757
},
58+
"extensionKind": ["ui"],
5859
"contributes": {
5960
"configuration": {
6061
"id": "MarkdownPaste",

src/paster.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
fetchAndSaveFile,
1010
newTemporaryFilename,
1111
base64Encode,
12+
isRemoteMode,
1213
} from "./utils";
1314
import { existsSync, rmSync, RmOptions } from "fs";
1415
import { LanguageDetection } from "./language_detection";
@@ -115,7 +116,15 @@ class Paster {
115116
}
116117
break;
117118
case xclip.ClipboardType.Image:
118-
Paster.pasteImage();
119+
if (false === isRemoteMode()) {
120+
Paster.pasteImage();
121+
} else {
122+
// show warring dialog
123+
Logger.showErrorMessage(
124+
"Paste Image is not available in Remote Mode (SSH, WSL, Dev Container). " +
125+
"Please paste the image locally, or use VS Code’s built-in paste feature instead."
126+
);
127+
}
119128
break;
120129
case xclip.ClipboardType.Unknown:
121130
Logger.log("Unknown type");

src/utils.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as path from "path";
55
import { mkdir } from "shelljs";
66
import * as fs from "fs";
77
import moment from "moment";
8-
import { Uri } from "vscode";
8+
import { Uri, env } from "vscode";
99
import * as os from "os";
1010
import Logger from "./Logger";
1111

@@ -120,9 +120,24 @@ function base64Encode(file) {
120120
return Buffer.from(bitmap).toString("base64");
121121
}
122122

123+
/**
124+
* Check if the current environment is remote (SSH, WSL, Dev Container)
125+
*/
126+
function isRemoteMode() {
127+
const remoteName = env.remoteName;
128+
if (remoteName) {
129+
// "wsl"?
130+
if (["ssh-remote", "dev-container"].includes(remoteName)) {
131+
return true;
132+
}
133+
}
134+
return false;
135+
}
136+
123137
export {
124138
prepareDirForFile,
125139
fetchAndSaveFile,
126140
base64Encode,
127141
newTemporaryFilename,
142+
isRemoteMode,
128143
};

0 commit comments

Comments
 (0)