-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2a3d8ec
Showing
20 changed files
with
1,251 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
tab_width = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
npm node_modules | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"root": true, | ||
"parser": "@typescript-eslint/parser", | ||
"env": { "node": true }, | ||
"plugins": ["@typescript-eslint"], | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"parserOptions": { | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"no-unused-vars": "off", | ||
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], | ||
"@typescript-eslint/ban-ts-comment": "off", | ||
"no-prototype-builtins": "off", | ||
"@typescript-eslint/no-empty-function": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# vscode | ||
.vscode | ||
|
||
# Intellij | ||
*.iml | ||
.idea | ||
|
||
# npm | ||
node_modules | ||
|
||
# Don't include the compiled main.js file in the repo. | ||
# They should be uploaded to GitHub releases instead. | ||
main.js | ||
|
||
# Exclude sourcemaps | ||
*.map | ||
|
||
# obsidian | ||
data.json | ||
|
||
# Exclude macOS Finder (System Explorer) View States | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tag-version-prefix="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Cloud uploader | ||
|
||
This plugins is under development. Cloudinary is the only provider at the moment | ||
|
||
## TODO / Ideas | ||
|
||
- [ ] Multiple Providers | ||
- Maybe activate several providers and have rules per provider, e.g use a specific provider per folder (maybe private notes on paid provider and public ones in free server). | ||
- [ ] Offline first | ||
- Save images localy and upload them. | ||
- `Plugin#.app.vault.configDir` has the .obsidian folder | ||
- `Plugin#.app.vault.writeBinary` for writing a binary file | ||
- `Plugin#.app.vault.config.attachmentFolderPath` has the attachment folder path | ||
- [More info](https://github.com/aleksey-rezvov/obsidian-local-images/blob/master/src/contentProcessor.ts) | ||
- Parse offline images to be previewed if exists, download if not | ||
- There should be a render-hook for all images 🤔 | ||
- [Maybe this?](https://github.com/bicarlsen/obsidian_image_caption/blob/main/src/view_observer.ts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import esbuild from "esbuild"; | ||
import process from "process"; | ||
import builtins from "builtin-modules"; | ||
|
||
const banner = `/* | ||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD | ||
if you want to view the source, please visit the github repository of this plugin | ||
*/ | ||
`; | ||
|
||
const prod = process.argv[2] === "production"; | ||
|
||
esbuild | ||
.build({ | ||
banner: { | ||
js: banner, | ||
}, | ||
entryPoints: ["src/main.ts"], | ||
bundle: true, | ||
external: [ | ||
"obsidian", | ||
"electron", | ||
"@codemirror/autocomplete", | ||
"@codemirror/collab", | ||
"@codemirror/commands", | ||
"@codemirror/language", | ||
"@codemirror/lint", | ||
"@codemirror/search", | ||
"@codemirror/state", | ||
"@codemirror/view", | ||
"@lezer/common", | ||
"@lezer/highlight", | ||
"@lezer/lr", | ||
...builtins, | ||
], | ||
format: "cjs", | ||
watch: !prod, | ||
target: "es2018", | ||
logLevel: "info", | ||
sourcemap: prod ? false : "inline", | ||
treeShaking: true, | ||
outfile: "main.js", | ||
}) | ||
.catch(() => process.exit(1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"id": "cloud-uploader", | ||
"name": "Cloud Uploader", | ||
"version": "0.0.1", | ||
"minAppVersion": "0.15.0", | ||
"description": "Upload drop/paste images directly to the cloud", | ||
"author": "Algus Dark", | ||
"authorUrl": "https://algus.ninja", | ||
"isDesktopOnly": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "obsidian-cloud-uploader", | ||
"version": "0.0.1", | ||
"description": "Upload drop/paste images directly to a cloud provider", | ||
"scripts": { | ||
"dev": "node esbuild.config.mjs", | ||
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", | ||
"version": "node version-bump.mjs && git add manifest.json versions.json" | ||
}, | ||
"keywords": [], | ||
"author": "Algus Dark", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@types/node": "^16.11.6", | ||
"@typescript-eslint/eslint-plugin": "5.29.0", | ||
"@typescript-eslint/parser": "5.29.0", | ||
"builtin-modules": "3.3.0", | ||
"esbuild": "0.14.47", | ||
"obsidian": "latest", | ||
"tslib": "2.4.0", | ||
"typescript": "4.7.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export class CustomClipboardEvent extends ClipboardEvent { | ||
constructor(type: string, eventInitDict: ClipboardEventInit) { | ||
super(type, eventInitDict); | ||
} | ||
} | ||
|
||
export class CustomDragEvent extends DragEvent { | ||
constructor(type: string, eventInitDict: DragEventInit) { | ||
super(type, eventInitDict); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { Plugin } from "obsidian"; | ||
|
||
import { CustomClipboardEvent, CustomDragEvent } from "@app/events"; | ||
import { CloudUploaderSettings, DEFAULT_SETTINGS } from "@app/settings"; | ||
import { handleUploadEvent } from "@app/utils"; | ||
import { CloudinaryProvider } from "@app/providers/cloudinary"; | ||
|
||
import type { IProvider } from "@app/providers/manager"; | ||
|
||
declare module "obsidian" { | ||
interface MarkdownSubView { | ||
clipboardManager: { | ||
handlePaste(e: ClipboardEvent): void; | ||
handleDrop(e: DragEvent): void; | ||
}; | ||
} | ||
} | ||
|
||
export default class CloudUploader extends Plugin { | ||
settings: typeof DEFAULT_SETTINGS; | ||
provider: IProvider; | ||
|
||
async onload() { | ||
await this.loadSettings(); | ||
|
||
this.registerEvent( | ||
this.app.workspace.on("editor-paste", (event, editor, markdownView) => { | ||
handleUploadEvent({ | ||
event, | ||
editor, | ||
provider: this.provider, | ||
eventAllowDefault: (dataTransfer) => { | ||
markdownView.currentMode.clipboardManager.handlePaste( | ||
new CustomClipboardEvent(event.type, { | ||
clipboardData: dataTransfer, | ||
}) | ||
); | ||
}, | ||
}); | ||
}) | ||
); | ||
|
||
this.registerEvent( | ||
this.app.workspace.on("editor-drop", (event, editor, markdownView) => { | ||
handleUploadEvent({ | ||
event, | ||
editor, | ||
provider: this.provider, | ||
eventAllowDefault: (dataTransfer) => { | ||
markdownView.currentMode.clipboardManager.handleDrop( | ||
new CustomDragEvent(event.type, { | ||
clientX: event.clientX, | ||
clientY: event.clientY, | ||
dataTransfer, | ||
}) | ||
); | ||
}, | ||
}); | ||
}) | ||
); | ||
|
||
this.addSettingTab(new CloudUploaderSettings(this.app, this)); | ||
} | ||
|
||
private setProvider() { | ||
switch (this.settings.provider) { | ||
case "cloudinary": | ||
this.provider = new CloudinaryProvider(this.settings.cloudinary); | ||
} | ||
} | ||
|
||
private async loadSettings() { | ||
this.settings = await Object.assign( | ||
{}, | ||
DEFAULT_SETTINGS, | ||
await this.loadData() | ||
); | ||
|
||
this.setProvider(); | ||
} | ||
|
||
async saveSettings() { | ||
await this.saveData(this.settings); | ||
|
||
this.setProvider(); | ||
} | ||
|
||
onunload() {} | ||
} |
Oops, something went wrong.