This Visual Studio Code extension named "paste-smms" enables users to upload images from their clipboard directly to the image hosting service sm.ms and insert the resulting image URL markdown into the active editor. Key behaviors include:
-
Activation and Command Registration: The extension activates on the first execution of the command extension.paste2smms.
-
Configuration Reading: Reads a socks5proxy setting from the user's VSCode configuration under the paste namespace to optionally route network requests through a SOCKS5 proxy.
-
Platform-Specific Clipboard Handling:
- On Windows, it spawns a batch script
res/pasteFromClip.bat passing proxy options.
- On Linux, it spawns a shell script
res/pasteFromClip.sh with temporary file path and proxy options.
-
Child Process Management: Uses Node.js child_process.spawn to execute these scripts, capturing their standard output and error streams.
-
JSON Response Parsing: Parses JSON output from the scripts to determine success or failure of the upload.
-
Editor Modification: On successful upload, inserts markdown image syntax with the uploaded image URL at the current cursor position.
-
User Notifications: Shows information messages to the user about upload status and errors.
-
Logging: Outputs diagnostic information and errors to the console.
No direct network communication is performed by the extension code itself; network activity is delegated to the external scripts. The extension does not perform any Windows Registry operations, user creation, clipboard access directly (delegated to scripts), or persistence mechanisms. It does execute shell and batch scripts as child processes, which handle the actual clipboard image extraction and upload.