diff --git a/manifest.json b/manifest.json index 721b221..91f6a25 100755 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "id": "alx-folder-note", "name": "AidenLx's Folder Note", "version": "0.16.3", - "minAppVersion": "0.13.24", + "minAppVersion": "0.14.8", "description": "Add description, summary and more info to folders with folder notes.", "author": "AidenLx", "authorUrl": "https://github.com/aidenlx", diff --git a/package.json b/package.json index f64d58d..480d9ed 100755 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "fast-deep-equal": "^3.1.3", "gray-matter": "^4.0.3", "monkey-around": "^2.3.0", - "obsidian": "github:obsidianmd/obsidian-api", + "obsidian": "^0.14.8", "path-browserify": "^1.0.1", "prettier": "^2.6.1", "release-it": "^14.13.1", diff --git a/src/drag-patch.ts b/src/drag-patch.ts index 53d57c9..4afb775 100644 --- a/src/drag-patch.ts +++ b/src/drag-patch.ts @@ -3,6 +3,7 @@ import "obsidian"; import { around } from "monkey-around"; import { ClipboardManager, + DragManager, MarkdownView, Platform, TFolder, @@ -17,6 +18,7 @@ declare global { declare module "obsidian" { interface App { dragManager: DragManager; + getObsidianUrl(file: TFile): string; } interface DragInfo { source?: string; @@ -106,6 +108,20 @@ const PatchDragManager = (plugin: ALxFolderNote) => { if (!editMode) throw new Error("Failed to patch clipboard manager: no edit view found"); + plugin.register( + around(app.dragManager.constructor.prototype as DragManager, { + dragFolder: (next) => + function (this: DragManager, evt, folder, source, ...args) { + let note; + if ((note = getFolderNote(folder))) { + const url = app.getObsidianUrl(note); + evt.dataTransfer!.setData("text/plain", url); + evt.dataTransfer!.setData("text/uri-list", url); + } + return next.call(this, evt, folder, source, ...args); + }, + }), + ); plugin.register( around( editMode.clipboardManager.constructor.prototype as ClipboardManager, @@ -119,7 +135,7 @@ const PatchDragManager = (plugin: ALxFolderNote) => { draggable.file instanceof TFolder && getFolderNote(draggable.file) ) { - evt.preventDefault(); + // evt.preventDefault(); VD(evt, "link"); this.app.dragManager.setAction( i18next.t("interface.drag-and-drop.insert-link-here"), diff --git a/yarn.lock b/yarn.lock index 34a9a4d..5b990a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -78,7 +78,7 @@ __metadata: fast-deep-equal: ^3.1.3 gray-matter: ^4.0.3 monkey-around: ^2.3.0 - obsidian: "github:obsidianmd/obsidian-api" + obsidian: ^0.14.8 path-browserify: ^1.0.1 prettier: ^2.6.1 release-it: ^14.13.1 @@ -4395,6 +4395,13 @@ __metadata: languageName: node linkType: hard +"moment@npm:2.29.2": + version: 2.29.2 + resolution: "moment@npm:2.29.2" + checksum: ee850b5776485e2af0775ceb3cfebaa7d7638f0a750fe0678fcae24c310749f96c1938808384bd422a55e5703834a71fcb09c8a1d36d9cf847f6ed0205d7a3e5 + languageName: node + linkType: hard + "monkey-around@npm:^2.3.0": version: 2.3.0 resolution: "monkey-around@npm:2.3.0" @@ -4595,6 +4602,18 @@ __metadata: languageName: node linkType: hard +"obsidian@npm:^0.14.8": + version: 0.14.8 + resolution: "obsidian@npm:0.14.8" + dependencies: + "@codemirror/state": ^0.19.6 + "@codemirror/view": ^0.19.31 + "@types/codemirror": 0.0.108 + moment: 2.29.2 + checksum: 8bbaf676e7c9d4cd33d3fef76518a0bbe395e6cc5bae522d1b0c8d9cadd38a501caa940f41cd76da0e97efd704cfd0124c85c9cfa79bedb6f63dae829b5183c0 + languageName: node + linkType: hard + "once@npm:^1.3.0, once@npm:^1.3.1, once@npm:^1.4.0": version: 1.4.0 resolution: "once@npm:1.4.0::__archiveUrl=https%3A%2F%2Fregistry.npmmirror.com%2Fonce%2F-%2Fonce-1.4.0.tgz"