1 Star 1 Fork 1

Sober / imgtogitee

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

🍤imgtogitee

  • 一个用于方便在 Markdown 中插入图片的扩展,支持将图片存放在第三方的图床或对象存储。
  • 一个用于方便在 Markdown 中插入随机表情的扩展,文档变得更好看了呢。
  • 一般截图软件会把图片放到剪切板中,imgtogitee原理是把剪切板中的图片存到临时文件夹,然后再上传到gitee,最后把返回的图片URL插入到markdown文本中,提高写作效率。

🍟命令|快捷键

名称 快捷键 描述
imgtogitee.getemo ctrl+numpad1 添加随机表情,如🍓
imgtogitee.paste ctrl+numpad2 上传剪切板图片到gitee
imgtogitee.pasteLocal ctrl+numpad3 上传本地板图片到gitee

🥙插件配置项

配置项名称 描述 默认值
imgtogitee.gitee_token gitee 的token
imgtogitee.gitee_url gitee 的仓库地址

🎇记录遇到的问题

1、🥃如何新建项目并打开?

npm install -g yo generator-code
yo code

2、🍁请求网络数据,为什么输出为空?

大多是异步的问题,用awite,等有返回值了再使用

3、🍫如何生成一个独立的控制台?

let log = vscode.window.createOutputChannel("sober-monkey/log");
log.show();
log.appendLine(data);

4、🍧如何获取前切板TXT?

vscode.env.clipboard.readText().then((text)=>{
    clipboard_content = text; 
    /* code */
});

或者

let clipboard_content = await vscode.env.clipboard.readText(); 
/* code */

5、🥣如何在插入文本

function insertToEnd(text: string, type?: number): Promise<boolean> {
    if (type === undefined) { type = InsertType.cursor; };
    return new Promise((resolve, reject) => {
        const editor = vscode.window.activeTextEditor;
        if (editor) {
            editor.edit(editBuilder => {
                switch (type) {
                    case InsertType.start:
                        editBuilder.insert(new vscode.Position(0, 0), text);
                        break;
                    case InsertType.end:
                        let linenumber = vscode.window.activeTextEditor?.document.lineCount || 1;
                        let pos = vscode.window.activeTextEditor?.document.lineAt(linenumber - 1).range.end || new vscode.Position(0, 0);
                        editBuilder.insert(pos, text);
                    break;
                    case InsertType.cursor:
                        editBuilder.insert(editor.selection.active, text);
                        break;
                    default:
                        break;
                }
                
            }).then(resolve);
        }
    });
}
enum InsertType {
    start = 1,
    end = 2,
    cursor=3
}

6、🐭PowerShell - 使用Windows截图并在cmd中草绘剪贴板临时图像

Add-Type -AssemblyName System.Windows.Forms
$clipboard = [System.Windows.Forms.Clipboard]::GetDataObject()
if ($clipboard.ContainsImage()) {
    $filename='c:\temp\test3.png'         
    [System.Drawing.Bitmap]$clipboard.getimage().Save($filename, [System.Drawing.Imaging.ImageFormat]::Png)
    Write-Output "clipboard content saved as $filename"
} else {
    Write-Output "clipboard does not contains image data"
}

##下面也可以
#get-clipboard -format image
#$img = get-clipboard -format image
#$img.save("c:\temp\temp.jpg")

7、🛷vscode 设置、读取配置

"contributes": {
	"configuration": {
		"type": "object",
		// 显示在配置页左侧
		"title": "Code插件demo",
		"properties": {
			// 全局唯一的配置ID
			"vscodePluginDemo.yourName": {
				"type": "string",
				"default": "guest",
				"description": "你的名字"
			},
			"vscodePluginDemo.showTip": {
				"type": "boolean",
				"default": true,
				"description": "启动时显示自定义欢迎页"
			}
		}
	}
}
// 如果没有设置,返回undefined
const result = vscode.workspace.getConfiguration().get('vscodePluginDemo.yourName');

🥈Enjoy!

MIT License Copyright (c) 2022  千山 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

一个用于方便在 Markdown 中插入图片的扩展,支持将图片存放在第三方的图床或对象存储。 展开 收起
TypeScript 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
TypeScript
1
https://gitee.com/kudsu/imgtogitee.git
git@gitee.com:kudsu/imgtogitee.git
kudsu
imgtogitee
imgtogitee
master

搜索帮助