Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
}
}
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
}
}
8 changes: 0 additions & 8 deletions .gitignore

This file was deleted.

16 changes: 8 additions & 8 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
MIT License

Copyright (c) <year> <copyright holders>

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.

MIT License
Copyright (c) <year> <copyright holders>
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.
140 changes: 70 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
# Obsidian Image Uploader

![](https://i.loli.net/2021/07/16/fxWBeLAESNc6tK9.gif)

This plugin could resize(optional) and upload the image in your clipboard to any image hosting automatically when pasting.

## Getting started

### Settings

1. Api Endpoint: the Endpoint of the image hosting api.
2. Upload Header: the header of upload request in **json** format.
3. Upload Body: the body of upload request in **json** format. Don't change it unless you know what you are doing.
4. Image Url Path: the path to the image url in http response.
5. Enable Resize: whether resizing images before uploading.
6. Max Width: images that wider than this will be resized resized by the natural aspect ratio.

### Examples

Take Imgur as an example. The upload request is something like this:

```shell
curl --location --request POST 'https://api.imgur.com/3/image' \
--header 'Authorization: Client-ID {{clientId}}' \
--form 'image="R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'
```

So, `Api Endpoint` should be `https://api.imgur.com/3/image` and `Upload Header` should be `{"Authorization": "Client-ID {{clientId}}"}`.

The response of the upload request is:
```json
{
"data": {
"id": "orunSTu",
"title": null,
"description": null,
"datetime": 1495556889,
"type": "image/gif",
"animated": false,
"width": 1,
"height": 1,
"size": 42,
"views": 0,
"bandwidth": 0,
"vote": null,
"favorite": false,
"nsfw": null,
"section": null,
"account_url": null,
"account_id": 0,
"is_ad": false,
"in_most_viral": false,
"tags": [],
"ad_type": 0,
"ad_url": "",
"in_gallery": false,
"deletehash": "x70po4w7BVvSUzZ",
"name": "",
"link": "http://i.imgur.com/orunSTu.gif"
},
"success": true,
"status": 200
}
```

All you need is the image url `http://i.imgur.com/orunSTu.gif`, so `Image Url Path` should be `data.link`.

## Thanks
1. [obsidian-imgur-plugin](https://github.com/gavvvr/obsidian-imgur-plugin)
2. [create-obsidian-plugin](https://www.npmjs.com/package/create-obsidian-plugin)
# Obsidian Image Uploader
![](https://i.loli.net/2021/07/16/fxWBeLAESNc6tK9.gif)
This plugin could resize(optional) and upload the image in your clipboard to any image hosting automatically when pasting.
## Getting started
### Settings
1. Api Endpoint: the Endpoint of the image hosting api.
2. Upload Header: the header of upload request in **json** format.
3. Upload Body: the body of upload request in **json** format. Don't change it unless you know what you are doing.
4. Image Url Path: the path to the image url in http response.
5. Enable Resize: whether resizing images before uploading.
6. Max Width: images that wider than this will be resized resized by the natural aspect ratio.
### Examples
Take Imgur as an example. The upload request is something like this:
```shell
curl --location --request POST 'https://api.imgur.com/3/image' \
--header 'Authorization: Client-ID {{clientId}}' \
--form 'image="R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'
```
So, `Api Endpoint` should be `https://api.imgur.com/3/image` and `Upload Header` should be `{"Authorization": "Client-ID {{clientId}}"}`.
The response of the upload request is:
```json
{
"data": {
"id": "orunSTu",
"title": null,
"description": null,
"datetime": 1495556889,
"type": "image/gif",
"animated": false,
"width": 1,
"height": 1,
"size": 42,
"views": 0,
"bandwidth": 0,
"vote": null,
"favorite": false,
"nsfw": null,
"section": null,
"account_url": null,
"account_id": 0,
"is_ad": false,
"in_most_viral": false,
"tags": [],
"ad_type": 0,
"ad_url": "",
"in_gallery": false,
"deletehash": "x70po4w7BVvSUzZ",
"name": "",
"link": "http://i.imgur.com/orunSTu.gif"
},
"success": true,
"status": 200
}
```
All you need is the image url `http://i.imgur.com/orunSTu.gif`, so `Image Url Path` should be `data.link`.
## Thanks
1. [obsidian-imgur-plugin](https://github.com/gavvvr/obsidian-imgur-plugin)
2. [create-obsidian-plugin](https://www.npmjs.com/package/create-obsidian-plugin)
18 changes: 9 additions & 9 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "obsidian-image-uploader",
"name": "Image Uploader",
"description": "This plugin uploads the image in your clipboard to any image hosting automatically when pasting.",
"author": "Creling",
"isDesktopOnly": true,
"minAppVersion": "0.15",
"version": "0.2"
}
{
"id": "obsidian-image-uploader",
"name": "Image Uploader",
"description": "This plugin uploads the image in your clipboard to any image hosting automatically when pasting.",
"author": "Creling",
"isDesktopOnly": true,
"minAppVersion": "0.15",
"version": "0.2"
}
48 changes: 24 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"name": "obsidian-image-uploader",
"version": "0.0.1",
"description": "This plugin uploads images in your clipboard to any image bed you like.",
"main": "lib/main.js",
"license": "MIT",
"scripts": {
"build": "obsidian-plugin build src/main.ts",
"dev": "obsidian-plugin dev src/main.ts"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"eslint": "^7.32.0",
"obsidian": "^0.15.9",
"obsidian-plugin-cli": "^0.4.5",
"typescript": "^4.7.4"
},
"dependencies": {
"axios": "^0.21.4",
"compressorjs": "^1.1.1",
"object-path": "^0.11.8"
}
}
{
"name": "obsidian-image-uploader",
"version": "0.0.1",
"description": "This plugin uploads images in your clipboard to any image bed you like.",
"main": "lib/main.js",
"license": "MIT",
"scripts": {
"build": "obsidian-plugin build src/main.ts",
"dev": "obsidian-plugin dev src/main.ts"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"eslint": "^7.32.0",
"obsidian": "^0.15.9",
"obsidian-plugin-cli": "^0.4.5",
"typescript": "^4.7.4"
},
"dependencies": {
"axios": "^0.21.4",
"compressorjs": "^1.1.1",
"object-path": "^0.11.8"
}
}
34 changes: 17 additions & 17 deletions src/custom-events.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
* @Author: Creling
* @Date: 2022-08-26 09:52:01
* @LastEditors: Creling
* @LastEditTime: 2022-08-26 09:52:45
* @Description: file content
*/

export class PasteEventCopy extends ClipboardEvent {
constructor(originalEvent: ClipboardEvent) {
const { files } = originalEvent.clipboardData;
const dt = new DataTransfer();
for (let i = 0; i < files.length; i += 1) {
dt.items.add(files.item(i));
}
super("paste", { clipboardData: dt });
}
/*
* @Author: Creling
* @Date: 2022-08-26 09:52:01
* @LastEditors: Creling
* @LastEditTime: 2022-08-26 09:52:45
* @Description: file content
*/
export class PasteEventCopy extends ClipboardEvent {
constructor(originalEvent: ClipboardEvent) {
const { files } = originalEvent.clipboardData;
const dt = new DataTransfer();
for (let i = 0; i < files.length; i += 1) {
dt.items.add(files.item(i));
}
super("paste", { clipboardData: dt });
}
}
Loading